-- MySQL dump 10.13  Distrib 5.7.29, for Linux (x86_64)
--
-- Host: localhost    Database: aerion
-- ------------------------------------------------------
-- Server version	5.7.29-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `all_attration`
--

DROP TABLE IF EXISTS `all_attration`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `all_attration` (
  `idall_attration` int(11) NOT NULL AUTO_INCREMENT,
  `att_dt` date DEFAULT NULL,
  `att_for` varchar(45) DEFAULT NULL COMMENT 'IT reqs, IT tickets, emp, comp, contract, etc',
  `att_start` int(3) DEFAULT NULL,
  `att_end` int(3) DEFAULT NULL,
  `att_open_total` int(5) DEFAULT NULL,
  `att_percent` decimal(5,2) DEFAULT NULL,
  `att_test` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idall_attration`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `all_users`
--

DROP TABLE IF EXISTS `all_users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `all_users` (
  `uid_id` int(9) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `user_name` varchar(40) DEFAULT NULL,
  `password` varbinary(40) DEFAULT NULL,
  `status` varchar(10) DEFAULT 'Active' COMMENT 'Active, Deactive, Locked',
  `expire_tm` int(5) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(5) DEFAULT NULL,
  PRIMARY KEY (`uid_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 MAX_ROWS=999999999 COMMENT='Used to store Apex User details';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `all_users_login`
--

DROP TABLE IF EXISTS `all_users_login`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `all_users_login` (
  `login_id` int(10) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `lastlogin` datetime DEFAULT NULL,
  `login_IP_add` varchar(105) DEFAULT NULL,
  `domain_name` text,
  `idlook_menu_pvt_lvl1` int(11) DEFAULT NULL,
  `idlook_menu_pvt_lvl2` int(11) DEFAULT NULL,
  `browser` varchar(45) DEFAULT NULL,
  `isp` varchar(45) DEFAULT NULL,
  `continent` varchar(105) DEFAULT NULL,
  `country` varchar(45) DEFAULT NULL,
  `state` varchar(45) DEFAULT NULL,
  `city` varchar(45) DEFAULT NULL,
  `postal_code` varchar(45) DEFAULT NULL,
  `lastlogout` datetime DEFAULT NULL,
  `logouttype` char(1) DEFAULT NULL,
  `logged_in` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`login_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `allusr_pref`
--

DROP TABLE IF EXISTS `allusr_pref`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `allusr_pref` (
  `idallusr_pref` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `idlook_menu_pvt` int(5) DEFAULT NULL COMMENT 'Status, ',
  `hide_col` text,
  `sort_col` text,
  PRIMARY KEY (`idallusr_pref`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `asset_lk`
--

DROP TABLE IF EXISTS `asset_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `asset_lk` (
  `idasset_look` int(11) NOT NULL AUTO_INCREMENT,
  `asset_name` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `asset_desc` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`idasset_look`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `asset_lk_val`
--

DROP TABLE IF EXISTS `asset_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `asset_lk_val` (
  `idasset_look_value` int(11) NOT NULL AUTO_INCREMENT,
  `idasset_look` int(11) DEFAULT NULL,
  `asset_value` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idasset_look_value`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `asset_mgmt`
--

DROP TABLE IF EXISTS `asset_mgmt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `asset_mgmt` (
  `idasset_mgmt` int(11) NOT NULL AUTO_INCREMENT,
  `comp_id` int(11) DEFAULT NULL COMMENT 'Selection, eg, ibm, apple, Microsoft ',
  `asset_serial_no` varchar(45) DEFAULT NULL,
  `tangible` char(1) DEFAULT NULL COMMENT 'Y or N',
  `category` int(5) DEFAULT NULL COMMENT 'Hardware, Software, Furniture (asset_lk)',
  `category_type` int(5) DEFAULT NULL COMMENT 'Table, printer, chair, Computer, PC (asset_lk)',
  `prchse_dt` date DEFAULT NULL,
  `prchse_pr` varchar(45) DEFAULT NULL,
  `prchse_type` int(5) DEFAULT NULL COMMENT 'Lease, Purchase',
  `prchse_expy` date DEFAULT NULL COMMENT 'If purchase type lease, then mandatory',
  `depriciate_pcnt` int(2) DEFAULT NULL,
  `depriciate_calc` char(1) DEFAULT NULL COMMENT 'Y or N',
  `warranty` date DEFAULT NULL COMMENT 'User inputs year or date',
  `asset_desc` varchar(100) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idasset_mgmt`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `asset_mgmt_attach`
--

DROP TABLE IF EXISTS `asset_mgmt_attach`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `asset_mgmt_attach` (
  `idasset_mgmt_attach` int(11) NOT NULL AUTO_INCREMENT,
  `idasset_mgmt` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idasset_mgmt_attach`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `asset_mgmt_decpt`
--

DROP TABLE IF EXISTS `asset_mgmt_decpt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `asset_mgmt_decpt` (
  `idasset_mgmt_decpt` int(11) NOT NULL AUTO_INCREMENT,
  `idasset_mgmt` int(11) DEFAULT NULL,
  `as_of_dt` datetime DEFAULT NULL,
  `decpt_val` float DEFAULT NULL,
  `as_of_val` float DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idasset_mgmt_decpt`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_acc`
--

DROP TABLE IF EXISTS `bank_acc`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_acc` (
  `idbank_acc` int(11) NOT NULL AUTO_INCREMENT,
  `acc_owner` int(11) DEFAULT NULL,
  `acc_owner_table` varchar(45) DEFAULT NULL COMMENT 'company id or emp_id',
  `comp_id` int(11) DEFAULT NULL COMMENT 'emp directly with company, company with comp_engage',
  `crncy` varchar(45) DEFAULT NULL,
  `acc_no` varchar(95) DEFAULT NULL,
  `acc_open_dt` date DEFAULT NULL,
  `acc_close_dt` date DEFAULT NULL,
  `acc_type` varchar(45) DEFAULT NULL COMMENT 'Credit, Credit & Debit, Checking, Saving,',
  `acc_limit` decimal(7,2) DEFAULT NULL,
  `contact_info` varchar(200) DEFAULT NULL,
  `open_bal_amt` decimal(13,2) DEFAULT NULL,
  `open_bal_dt` date DEFAULT NULL,
  `bk_bal_amt` float DEFAULT NULL COMMENT 'Display only ',
  `bk_bal_dt` datetime DEFAULT NULL,
  `isu_bal_amt` float DEFAULT NULL COMMENT 'non editable',
  `isu_bal_dt` datetime DEFAULT NULL,
  `clr_bal_amt` float DEFAULT NULL COMMENT 'non editable',
  `clr_bal_dt` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idbank_acc`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_accounts`
--

DROP TABLE IF EXISTS `bank_accounts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_accounts` (
  `account_id` int(11) NOT NULL AUTO_INCREMENT,
  `account_name` varchar(45) DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `maturity_date` date DEFAULT NULL,
  `term_days` int(11) DEFAULT NULL,
  `ex_rate` float DEFAULT NULL,
  `principal_amount` int(11) DEFAULT NULL,
  `extra_amt` int(11) DEFAULT NULL,
  `interest_rate` float DEFAULT NULL,
  `payout_type` varchar(45) DEFAULT NULL,
  `int_to_dt` int(11) DEFAULT NULL,
  `total_value` int(11) DEFAULT NULL,
  `to_ex_rate` float DEFAULT NULL,
  `infla_defla` float DEFAULT NULL,
  `app_dep` float DEFAULT NULL,
  `pl_per` float DEFAULT NULL,
  `pl` float DEFAULT NULL,
  PRIMARY KEY (`account_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_bk_bal`
--

DROP TABLE IF EXISTS `bank_bk_bal`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_bk_bal` (
  `idbk_bk_bal` int(11) NOT NULL AUTO_INCREMENT,
  `idbank_acc` int(11) DEFAULT NULL,
  `consolidate_dt` date DEFAULT NULL,
  `bank_depo` decimal(9,2) DEFAULT NULL,
  `bank_draw` decimal(9,2) DEFAULT NULL,
  `bank_balance` decimal(9,2) DEFAULT NULL,
  PRIMARY KEY (`idbk_bk_bal`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_bk_bal_ln`
--

DROP TABLE IF EXISTS `bank_bk_bal_ln`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_bk_bal_ln` (
  `idbank_bk_bal_ln` int(11) NOT NULL AUTO_INCREMENT,
  `idbank_rec` int(11) DEFAULT NULL,
  `idbk_bal` int(11) DEFAULT NULL,
  PRIMARY KEY (`idbank_bk_bal_ln`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_clr_bal`
--

DROP TABLE IF EXISTS `bank_clr_bal`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_clr_bal` (
  `idbk_clr_bal` int(11) NOT NULL AUTO_INCREMENT,
  `idbank_acc` int(11) DEFAULT NULL,
  `consolidate_dt` date DEFAULT NULL,
  `bank_depo` decimal(9,2) DEFAULT NULL,
  `bank_draw` decimal(9,2) DEFAULT NULL,
  `bank_balance` decimal(9,2) DEFAULT NULL,
  PRIMARY KEY (`idbk_clr_bal`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_clr_bal_ln`
--

DROP TABLE IF EXISTS `bank_clr_bal_ln`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_clr_bal_ln` (
  `idbank_clr_bal_ln` int(11) NOT NULL AUTO_INCREMENT,
  `idbank_rec` int(11) DEFAULT NULL,
  `idbk_bal` int(11) DEFAULT NULL,
  PRIMARY KEY (`idbank_clr_bal_ln`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_isu_bal`
--

DROP TABLE IF EXISTS `bank_isu_bal`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_isu_bal` (
  `idbk_isu_bal` int(11) NOT NULL AUTO_INCREMENT,
  `idbank_acc` int(11) DEFAULT NULL,
  `consolidate_dt` date DEFAULT NULL,
  `bank_depo` decimal(9,2) DEFAULT NULL,
  `bank_draw` decimal(9,2) DEFAULT NULL,
  `bank_balance` decimal(9,2) DEFAULT NULL,
  PRIMARY KEY (`idbk_isu_bal`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_isu_bal_ln`
--

DROP TABLE IF EXISTS `bank_isu_bal_ln`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_isu_bal_ln` (
  `idbank_bk_bal_ln` int(11) NOT NULL AUTO_INCREMENT,
  `idbank_rec` int(11) DEFAULT NULL,
  `idbk_bal` int(11) DEFAULT NULL,
  PRIMARY KEY (`idbank_bk_bal_ln`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_lk`
--

DROP TABLE IF EXISTS `bank_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_lk` (
  `idbank_lk` int(11) NOT NULL AUTO_INCREMENT,
  `bank_name` varchar(45) DEFAULT NULL,
  `disp_order` int(11) DEFAULT NULL,
  PRIMARY KEY (`idbank_lk`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_lk_val`
--

DROP TABLE IF EXISTS `bank_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_lk_val` (
  `idbank_lk_val` int(11) NOT NULL,
  `idbank_lk` int(11) DEFAULT NULL,
  `bank_value` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idbank_lk_val`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_record`
--

DROP TABLE IF EXISTS `bank_record`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_record` (
  `idbank_rec` int(11) NOT NULL AUTO_INCREMENT,
  `hist` int(3) DEFAULT NULL,
  `idbank_acc` int(11) DEFAULT NULL,
  `books_dt` date DEFAULT NULL,
  `issue_dt` date DEFAULT NULL,
  `clear_dt` date DEFAULT NULL,
  `check_no` varchar(45) DEFAULT NULL,
  `check_amt` float DEFAULT NULL,
  `rec_type` varchar(45) DEFAULT NULL COMMENT 'D = Deposit,W = Withdrawal',
  `check_type` varchar(45) DEFAULT NULL,
  `issue_to_ref_id` int(11) DEFAULT NULL,
  `issue_to_ref_table` varchar(45) DEFAULT NULL,
  `issue_for_level1` int(11) DEFAULT NULL,
  `issue_for_level2` int(11) DEFAULT NULL,
  `issue_for_level3` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_upated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idbank_rec`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_record_hist`
--

DROP TABLE IF EXISTS `bank_record_hist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_record_hist` (
  `idbank_record_hist` int(11) NOT NULL AUTO_INCREMENT,
  `idbank_acc` int(11) DEFAULT NULL,
  `trans_by` int(11) DEFAULT NULL,
  `book_dt` date DEFAULT NULL,
  `issue_dt` date DEFAULT NULL,
  `clear_dt` date DEFAULT NULL,
  `check_amt` float DEFAULT NULL,
  `rec_type` varchar(45) DEFAULT NULL COMMENT 'D = Deposit,B = Bounce,C = Correction',
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idbank_record_hist`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_active`
--

DROP TABLE IF EXISTS `comp_active`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_active` (
  `idcomp_active` int(11) NOT NULL AUTO_INCREMENT,
  `comp_id` int(10) DEFAULT NULL,
  `comp_background` text,
  `active_type` char(1) DEFAULT NULL COMMENT 'dispute or alliance',
  `publish` char(1) DEFAULT NULL,
  `manage_by` int(11) DEFAULT NULL,
  `client_since` date DEFAULT NULL,
  `last_updated` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idcomp_active`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_address`
--

DROP TABLE IF EXISTS `comp_address`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_address` (
  `comp_add_id` int(11) NOT NULL AUTO_INCREMENT,
  `comp_id` int(10) DEFAULT NULL,
  `look_street_no_id` int(11) DEFAULT NULL,
  `suite_no` varchar(45) DEFAULT NULL,
  `add_type` varchar(45) DEFAULT NULL COMMENT 'Primary, Branch',
  `add_type2` varchar(50) DEFAULT NULL,
  `from_dt` date DEFAULT NULL,
  `to_dt` date DEFAULT NULL,
  `no_days` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`comp_add_id`),
  KEY `fk_comp_add_id` (`comp_id`),
  KEY `fk_look_street_comp_branch_idx` (`look_street_no_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_audit`
--

DROP TABLE IF EXISTS `comp_audit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_audit` (
  `idcomp_audit` int(19) NOT NULL AUTO_INCREMENT,
  `last_update` datetime DEFAULT NULL,
  `updater` varchar(90) DEFAULT NULL,
  `table_update` varchar(90) DEFAULT NULL,
  `trans_type` char(1) DEFAULT NULL,
  `table_id` text,
  `col1` text,
  `col2` text,
  `col3` text,
  `col4` text,
  `col5` text,
  `col6` text,
  `col7` text,
  `col8` text,
  `col9` text,
  `col10` text,
  `col11` text,
  `col12` text,
  `col13` text,
  `col14` text,
  `col15` text,
  PRIMARY KEY (`idcomp_audit`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_contact`
--

DROP TABLE IF EXISTS `comp_contact`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_contact` (
  `comp_contact_id` int(11) NOT NULL AUTO_INCREMENT,
  `comp_id` int(10) DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL,
  `title` varchar(45) DEFAULT NULL COMMENT 'Sales, HR, etc',
  `description` varchar(100) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`comp_contact_id`),
  KEY `fk_emp_comp_contact_idx` (`emp_id`),
  CONSTRAINT `fk_emp_comp_contact` FOREIGN KEY (`emp_id`) REFERENCES `emp` (`emp_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_contact_no`
--

DROP TABLE IF EXISTS `comp_contact_no`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_contact_no` (
  `comp_contact_no_id` int(11) NOT NULL AUTO_INCREMENT,
  `comp_contact_id` int(11) DEFAULT NULL,
  `emp_contact_id` int(11) DEFAULT NULL COMMENT 'Phone, Cell, email',
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`comp_contact_no_id`),
  KEY `fk_com_con_comp_con_no_idx` (`comp_contact_id`),
  CONSTRAINT `fk_com_con_comp_con_no` FOREIGN KEY (`comp_contact_id`) REFERENCES `comp_contact` (`comp_contact_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_lk`
--

DROP TABLE IF EXISTS `comp_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_lk` (
  `idcomp_lk` int(11) NOT NULL AUTO_INCREMENT,
  `comp_name` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  PRIMARY KEY (`idcomp_lk`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_lk_val`
--

DROP TABLE IF EXISTS `comp_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_lk_val` (
  `idcomp_lk_val` int(11) NOT NULL AUTO_INCREMENT,
  `idcomp_lk` int(11) DEFAULT NULL,
  `comp_value` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idcomp_lk_val`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_prdt`
--

DROP TABLE IF EXISTS `comp_prdt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_prdt` (
  `idcomp_prdt` int(11) NOT NULL AUTO_INCREMENT,
  `comp_id` int(11) DEFAULT NULL,
  `prdt_nm` varchar(45) DEFAULT NULL COMMENT 'Ipad, mac, maruti',
  `prod_num` varchar(45) DEFAULT NULL,
  `prod_ver` varchar(45) DEFAULT NULL,
  `prdt_family` varchar(45) DEFAULT NULL,
  `idasset_look` int(11) DEFAULT NULL,
  `idasset_look_value` int(11) DEFAULT NULL,
  `stocking` char(1) DEFAULT NULL COMMENT 'Y or N, to show in inventory',
  `dscont_dt` date DEFAULT NULL COMMENT 'Date stopped manufacturing',
  `idinvn` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idcomp_prdt`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_reg`
--

DROP TABLE IF EXISTS `comp_reg`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_reg` (
  `comp_reg_id` int(11) NOT NULL AUTO_INCREMENT,
  `comp_id` int(10) DEFAULT NULL,
  `state_id` int(11) DEFAULT NULL,
  `dept_id` int(11) DEFAULT NULL,
  `reg_number` varchar(45) DEFAULT NULL,
  `login_smry` varchar(100) DEFAULT NULL,
  `login_link` varchar(100) DEFAULT NULL,
  `comp_open_dt` date DEFAULT NULL,
  `comp_close_dt` date DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(5) DEFAULT NULL,
  PRIMARY KEY (`comp_reg_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_reg_dept`
--

DROP TABLE IF EXISTS `comp_reg_dept`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_reg_dept` (
  `comp_reg_dept_id` int(11) NOT NULL AUTO_INCREMENT,
  `comp_reg_id` int(11) DEFAULT NULL,
  `dept_id` int(11) DEFAULT NULL,
  `reg_number` varchar(45) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `login_smry` varchar(100) DEFAULT NULL,
  `login_link` varchar(500) DEFAULT NULL,
  `comp_open_dt` date DEFAULT NULL,
  `comp_close_dt` date DEFAULT NULL,
  PRIMARY KEY (`comp_reg_dept_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_reg_dept_dt`
--

DROP TABLE IF EXISTS `comp_reg_dept_dt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_reg_dept_dt` (
  `comp_reg_dept_dt_id` int(11) NOT NULL AUTO_INCREMENT,
  `comp_reg_dept_id` int(11) DEFAULT NULL,
  `reg_number` varchar(45) DEFAULT NULL,
  `comp_open_dt` date DEFAULT NULL,
  `comp_close_dt` date DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`comp_reg_dept_dt_id`),
  KEY `comp_reg_dept_dt_id` (`comp_reg_dept_dt_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_reg_dept_hist`
--

DROP TABLE IF EXISTS `comp_reg_dept_hist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_reg_dept_hist` (
  `idcomp_reg_dept_hist` int(11) NOT NULL AUTO_INCREMENT,
  `comp_reg_dept_id` int(11) DEFAULT NULL,
  `login_link` varchar(500) DEFAULT NULL,
  `login_smry` varchar(100) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  PRIMARY KEY (`idcomp_reg_dept_hist`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `comp_type`
--

DROP TABLE IF EXISTS `comp_type`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comp_type` (
  `idcomp_type` int(11) NOT NULL AUTO_INCREMENT,
  `comp_id` int(10) DEFAULT NULL,
  `comp_type` int(5) DEFAULT NULL,
  `on_dt` date DEFAULT NULL,
  PRIMARY KEY (`idcomp_type`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `company`
--

DROP TABLE IF EXISTS `company`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `company` (
  `comp_id` int(10) NOT NULL AUTO_INCREMENT,
  `idstorage` int(11) DEFAULT NULL COMMENT 'company logo',
  `companyname` varchar(65) NOT NULL,
  `comp_tax_id` varchar(100) DEFAULT NULL,
  `company_info` varchar(500) DEFAULT NULL,
  `comp_website` varchar(95) DEFAULT NULL,
  `comp_phone` varchar(15) DEFAULT NULL,
  `comp_email` varchar(45) DEFAULT NULL,
  `comp_merge_id` int(10) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`comp_id`),
  UNIQUE KEY `comp_tax_id` (`comp_tax_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 MAX_ROWS=999999999;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `company_owners`
--

DROP TABLE IF EXISTS `company_owners`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `company_owners` (
  `comp_own_id` int(9) NOT NULL AUTO_INCREMENT,
  `comp_id` int(10) DEFAULT NULL,
  `emp_id` int(9) DEFAULT NULL,
  `owner_share` int(9) DEFAULT NULL,
  `share_dt_from` date DEFAULT NULL,
  `share_dt_to` date DEFAULT NULL,
  PRIMARY KEY (`comp_own_id`),
  KEY `fk_comp_own_id` (`comp_id`),
  KEY `fk_empid_comp_owner` (`emp_id`),
  CONSTRAINT `fk_comp_own_id` FOREIGN KEY (`comp_id`) REFERENCES `company` (`comp_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_empid_comp_owner` FOREIGN KEY (`emp_id`) REFERENCES `emp` (`emp_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `contact_no`
--

DROP TABLE IF EXISTS `contact_no`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `contact_no` (
  `contact_id` int(11) NOT NULL AUTO_INCREMENT,
  `contact_detail` varchar(95) DEFAULT NULL,
  PRIMARY KEY (`contact_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `currency_ex`
--

DROP TABLE IF EXISTS `currency_ex`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `currency_ex` (
  `idcurrency_ex` int(11) NOT NULL AUTO_INCREMENT,
  `open_dt` date DEFAULT NULL,
  `term_days` int(5) DEFAULT NULL,
  `maturity_dt` date DEFAULT NULL,
  `wd_dt` date DEFAULT NULL,
  `ex_rate` varchar(45) DEFAULT NULL,
  `principal_amt` varchar(45) DEFAULT NULL,
  `int_amt` varchar(45) DEFAULT NULL,
  `total_amt` varchar(45) DEFAULT NULL,
  `int_rate` varchar(45) DEFAULT NULL,
  `pay_out_type` varchar(45) DEFAULT NULL COMMENT 'M, Q, P',
  PRIMARY KEY (`idcurrency_ex`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Temporary table structure for view `del_no_days`
--

DROP TABLE IF EXISTS `del_no_days`;
/*!50001 DROP VIEW IF EXISTS `del_no_days`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `del_no_days` AS SELECT 
 1 AS `emp_id`,
 1 AS `gender`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `Fullname`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `org_start_dt`,
 1 AS `org_end_dt`,
 1 AS `BillableType`,
 1 AS `Employment`,
 1 AS `difference`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `del_temp_data`
--

DROP TABLE IF EXISTS `del_temp_data`;
/*!50001 DROP VIEW IF EXISTS `del_temp_data`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `del_temp_data` AS SELECT 
 1 AS `engage_calc`,
 1 AS `engage_amt`,
 1 AS `engage_st_dt`,
 1 AS `engage_end_st`,
 1 AS `limit_amt`,
 1 AS `engage_ref_id`,
 1 AS `companyname`*/;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `dev_apps`
--

DROP TABLE IF EXISTS `dev_apps`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_apps` (
  `iddev_apps` int(11) NOT NULL AUTO_INCREMENT,
  `disp_order` int(3) DEFAULT NULL,
  `app_name` varchar(30) DEFAULT NULL,
  `start_dt` datetime DEFAULT NULL,
  `comp_id` int(10) DEFAULT NULL,
  `app_description` varchar(150) DEFAULT NULL,
  `end_dt` datetime DEFAULT NULL,
  `dev_est_cnt` varchar(45) DEFAULT NULL,
  `dev_est_pcnt` varchar(10) DEFAULT NULL,
  `dev_est_req_cnt` varchar(45) DEFAULT NULL,
  `dev_est_req_pcnt` varchar(10) DEFAULT NULL,
  `dev_est_req_stat_cnt` varchar(45) DEFAULT NULL,
  `dev_est_req_stat_pcnt` varchar(10) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `arch_dt` datetime DEFAULT NULL,
  `arch_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_apps`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_apps_attach`
--

DROP TABLE IF EXISTS `dev_apps_attach`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_apps_attach` (
  `iddev_app_attach` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_apps` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_app_attach`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_audit`
--

DROP TABLE IF EXISTS `dev_audit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_audit` (
  `iddev_audit` int(19) NOT NULL AUTO_INCREMENT,
  `last_update` datetime DEFAULT NULL,
  `updater` varchar(90) DEFAULT NULL,
  `table_update` varchar(90) DEFAULT NULL,
  `trans_type` char(1) DEFAULT NULL,
  `table_id` text,
  `col1` text,
  `col2` text,
  `col3` text,
  `col4` text,
  `col5` text,
  `col6` text,
  `col7` text,
  `col8` text,
  `col9` text,
  `col10` text,
  `col11` text,
  `col12` text,
  `col13` text,
  `col14` text,
  `col15` text,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_audit`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est`
--

DROP TABLE IF EXISTS `dev_est`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est` (
  `iddev_est` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_apps` int(11) DEFAULT NULL,
  `dev_est_smry` varchar(100) DEFAULT NULL,
  `dev_st_dt` datetime DEFAULT NULL,
  `dev_en_dt` datetime DEFAULT NULL,
  `est_time` int(11) DEFAULT NULL,
  `owner_ref_tab` varchar(45) DEFAULT NULL COMMENT 'Required',
  `owner_ref_id` int(11) DEFAULT NULL COMMENT 'Required',
  `est_ref_tab` varchar(45) DEFAULT NULL COMMENT 'Required',
  `est_ref_id` int(11) DEFAULT NULL COMMENT 'Required',
  `priority` int(5) DEFAULT NULL COMMENT 'Required (Value 1 thru 5)',
  `category` int(5) DEFAULT NULL COMMENT 'IT, Support, Hybrid',
  `est_skill` varchar(5) DEFAULT NULL COMMENT 'Not needed',
  `est_gap_lvl` varchar(5) DEFAULT NULL COMMENT 'Not Needed',
  `est_reqs` int(5) DEFAULT NULL,
  `est_type` varchar(11) DEFAULT NULL,
  `est_amt` float DEFAULT NULL COMMENT 'Exists',
  `cnt_actual` int(5) DEFAULT NULL,
  `cnt_est` int(5) DEFAULT NULL,
  `cnt_actual_est` varchar(20) DEFAULT NULL,
  `cnt_pcnt` varchar(10) DEFAULT NULL,
  `cnt_req_actual` int(5) DEFAULT NULL,
  `cnt_req_est` int(5) DEFAULT NULL,
  `cnt_req_actual_est` varchar(20) DEFAULT NULL,
  `cnt_req_pcnt` varchar(10) DEFAULT NULL,
  `est_amt_pay` float DEFAULT NULL COMMENT 'Exists',
  `est_amt_bal` float DEFAULT NULL COMMENT 'Exists',
  `updater` int(11) DEFAULT NULL COMMENT 'Not Needed',
  `last_updated` datetime DEFAULT NULL COMMENT 'Not Needed',
  `attach` char(1) DEFAULT NULL COMMENT 'Y or Null',
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(5) DEFAULT NULL,
  PRIMARY KEY (`iddev_est`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_access`
--

DROP TABLE IF EXISTS `dev_est_access`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_access` (
  `iddev_est_access` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est` int(11) DEFAULT NULL,
  `dev_est_emp_id` int(11) DEFAULT NULL,
  `dev_est_access` varchar(15) DEFAULT NULL COMMENT '1 = View / 2 = edit ',
  `dev_est_req_access` varchar(15) DEFAULT NULL,
  `dev_est_reqs_case_access` varchar(15) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_est_access`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_attach`
--

DROP TABLE IF EXISTS `dev_est_attach`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_attach` (
  `iddev_est_attach` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(5) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_attach`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_attr`
--

DROP TABLE IF EXISTS `dev_est_attr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_attr` (
  `iddev_est_attr` int(11) NOT NULL AUTO_INCREMENT,
  `dev_est_dt` date DEFAULT NULL,
  `new` int(11) DEFAULT NULL,
  `close` int(11) DEFAULT NULL,
  `total` int(11) DEFAULT NULL,
  `added` varchar(45) DEFAULT NULL,
  `completion` varchar(45) DEFAULT NULL,
  `growth` varchar(45) DEFAULT NULL,
  `iddev_apps` int(11) DEFAULT NULL,
  `dev_app_nm` varchar(45) DEFAULT NULL,
  `owner_id` int(11) DEFAULT NULL,
  `owner_type` varchar(45) DEFAULT NULL COMMENT 'Emp or company',
  `owner_nm` varchar(90) DEFAULT NULL,
  `est_id` int(11) DEFAULT NULL,
  `est_type` varchar(45) DEFAULT NULL COMMENT 'Emp or company',
  `est_nm` varchar(90) DEFAULT NULL,
  `priority_id` int(11) DEFAULT NULL,
  `priority_nm` varchar(45) DEFAULT NULL,
  `category_id` int(11) DEFAULT NULL,
  `category_nm` varchar(45) DEFAULT NULL,
  `est_skill_nm` varchar(45) DEFAULT NULL,
  `est_skill_gap_lvl` varchar(45) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updater_nm` varchar(45) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `parent_iddev_est_attr` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_attr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_attr_list`
--

DROP TABLE IF EXISTS `dev_est_attr_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_attr_list` (
  `iddev_est_attr_list` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_attr` int(11) DEFAULT NULL,
  `dev_est_dt` date DEFAULT NULL,
  `iddev_est` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_attr_list`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_attr_set`
--

DROP TABLE IF EXISTS `dev_est_attr_set`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_attr_set` (
  `iddev_est_attr_set` int(11) NOT NULL AUTO_INCREMENT,
  `dev_est_dt` date DEFAULT NULL,
  `iddev_est_attr` text,
  `new` text,
  `close` text,
  `total` text,
  `added` text,
  `completion` text,
  `growth` text,
  `iddev_apps` text,
  `dev_app_nm` longtext,
  `owner_id` text,
  `owner_type` longtext,
  `owner_nm` longtext,
  `est_id` text,
  `est_type` longtext,
  `est_nm` longtext,
  `priority_id` text,
  `priority_nm` text,
  `category_id` text,
  `category_nm` longtext,
  `est_skill_nm` text,
  `est_skill_gap_lvl` text,
  PRIMARY KEY (`iddev_est_attr_set`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_audit`
--

DROP TABLE IF EXISTS `dev_est_audit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_audit` (
  `iddev_est_audit` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_atrr` int(11) DEFAULT NULL,
  `dev_est_dt` date DEFAULT NULL,
  `new_est` int(5) DEFAULT NULL,
  `close_est` int(5) DEFAULT NULL,
  `total` int(5) DEFAULT NULL,
  `added` varchar(45) DEFAULT NULL,
  `completion` varchar(45) DEFAULT NULL,
  `growth` varchar(45) DEFAULT NULL,
  `updater` varchar(45) DEFAULT NULL,
  `updater_nm` varchar(45) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_est_audit`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs`
--

DROP TABLE IF EXISTS `dev_est_reqs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs` (
  `iddev_est_reqs` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est` int(11) DEFAULT NULL,
  `open_dt_time` datetime DEFAULT NULL,
  `close_dt_time` datetime DEFAULT NULL,
  `req_time` int(11) DEFAULT NULL,
  `disp_order` int(3) DEFAULT NULL,
  `req_desc` varchar(300) DEFAULT NULL,
  `skill_lvl` int(5) DEFAULT NULL,
  `req_type` int(5) DEFAULT NULL COMMENT 'Db, JS, web design, content, Analysis, presentation, document, programming, hybrid, network, server',
  `req_status` int(5) DEFAULT NULL,
  `idlook_stat_order` int(5) DEFAULT NULL,
  `gap_lvl` int(2) DEFAULT NULL COMMENT '1=redo, 5 = perfect',
  `st_dt_time` datetime DEFAULT NULL,
  `e_dt_time` datetime DEFAULT NULL,
  `stat_time` int(11) DEFAULT NULL,
  `assigned_to` int(11) DEFAULT NULL,
  `cnt_actual` int(2) DEFAULT NULL COMMENT 'Count from dev_est_status',
  `cnt_est` int(2) DEFAULT NULL COMMENT 'Count from dev_est_status_forcast',
  `cnt_actual_est` varchar(20) DEFAULT NULL,
  `cnt_pcnt` varchar(10) DEFAULT NULL,
  `case` varchar(45) DEFAULT NULL COMMENT 'None, Open, Close',
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_attach`
--

DROP TABLE IF EXISTS `dev_est_reqs_attach`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_attach` (
  `iddev_est_reqs_attach` int(11) NOT NULL AUTO_INCREMENT,
  `idstorage` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_attach`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_attr`
--

DROP TABLE IF EXISTS `dev_est_reqs_attr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_attr` (
  `iddev_est_reqs_attr` int(11) NOT NULL AUTO_INCREMENT,
  `dev_est_reqs_dt` date DEFAULT NULL,
  `new_req` int(5) DEFAULT NULL,
  `close_req` int(5) DEFAULT NULL,
  `total` int(5) DEFAULT NULL,
  `added` varchar(45) DEFAULT NULL,
  `completion` varchar(45) DEFAULT NULL COMMENT '= close_req / total',
  `growth` varchar(45) DEFAULT NULL,
  `phase` int(5) DEFAULT NULL,
  `phase_nm` varchar(95) DEFAULT NULL,
  `assignee` int(11) DEFAULT NULL,
  `assignee_nm` varchar(95) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updater_nm` varchar(95) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `req_type` int(5) DEFAULT NULL,
  `req_type_val` varchar(95) DEFAULT NULL,
  `skill_lvl` int(5) DEFAULT NULL,
  `skill_lvl_val` varchar(95) DEFAULT NULL,
  `req_status` int(5) DEFAULT NULL,
  `req_status_val` varchar(95) DEFAULT NULL,
  `parent_iddev_est_reqs_attr` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_attr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_attr_audit`
--

DROP TABLE IF EXISTS `dev_est_reqs_attr_audit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_attr_audit` (
  `iddev_est_reqs_attr_audit` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs_attr` int(11) DEFAULT NULL,
  `new_req` int(5) DEFAULT NULL,
  `close_req` int(5) DEFAULT NULL,
  `total` int(5) DEFAULT NULL,
  `added` varchar(45) DEFAULT NULL,
  `completion` varchar(45) DEFAULT NULL,
  `growth` varchar(45) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updater_nm` varchar(95) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_attr_audit`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_attr_list`
--

DROP TABLE IF EXISTS `dev_est_reqs_attr_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_attr_list` (
  `iddev_est_reqs_attr_list` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs_attr` int(11) DEFAULT NULL,
  `req_dt` date DEFAULT NULL,
  `req_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_attr_list`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_case`
--

DROP TABLE IF EXISTS `dev_est_reqs_case`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_case` (
  `iddev_est_reqs_case` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs` int(11) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `create_dt` date DEFAULT NULL,
  `create_end_dt` date DEFAULT NULL,
  `disp_order` int(2) DEFAULT NULL,
  `reqs_cases` varchar(200) DEFAULT NULL,
  `case_data` varchar(200) DEFAULT NULL,
  `case_result_desc` varchar(200) DEFAULT NULL,
  `case_status` int(5) DEFAULT NULL,
  `executed_by` int(11) DEFAULT NULL,
  `execute_dt` date DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(30) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_case`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_case_result`
--

DROP TABLE IF EXISTS `dev_est_reqs_case_result`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_case_result` (
  `iddev_est_reqs_case_result` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs_case` int(11) DEFAULT NULL,
  `case_data` varchar(200) DEFAULT NULL,
  `case_result_desc` varchar(200) DEFAULT NULL,
  `case_status` int(11) DEFAULT NULL,
  `executed_by` int(11) DEFAULT NULL,
  `execute_dt` date DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` varchar(45) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_case_result`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_stat_amt`
--

DROP TABLE IF EXISTS `dev_est_reqs_stat_amt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_stat_amt` (
  `iddev_est_reqs_stat_amt` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs_status` int(11) DEFAULT NULL,
  `hist_cnt` int(5) DEFAULT NULL,
  `reqs_status_by` int(11) DEFAULT NULL,
  `req_amt` float DEFAULT NULL,
  `req_action_by` int(11) DEFAULT NULL,
  `req_action` int(5) DEFAULT NULL,
  `req_paid` float DEFAULT NULL,
  `req_bal` float DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_stat_amt`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_stat_amt_hist`
--

DROP TABLE IF EXISTS `dev_est_reqs_stat_amt_hist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_stat_amt_hist` (
  `iddev_est_reqs_stat_amt_hist` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs_stat_amt` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_stat_amt_hist`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_status`
--

DROP TABLE IF EXISTS `dev_est_reqs_status`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_status` (
  `iddev_est_reqs_status` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs` int(11) DEFAULT NULL,
  `req_status` int(5) DEFAULT NULL,
  `idlook_stat_order` int(5) DEFAULT NULL,
  `stat_st_dt` datetime DEFAULT NULL,
  `stat_e_dt` datetime DEFAULT NULL,
  `stat_time` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `lag_time` int(11) DEFAULT NULL,
  `assigned_to` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_status`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_status_forcast`
--

DROP TABLE IF EXISTS `dev_est_reqs_status_forcast`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_status_forcast` (
  `iddev_est_reqs_status_forcast` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs` int(11) DEFAULT NULL,
  `req_status` int(5) DEFAULT NULL,
  `idlook_stat_order` int(5) DEFAULT NULL,
  `lag_time` int(11) DEFAULT NULL,
  `stat_st_dt` datetime DEFAULT NULL,
  `stat_e_dt` datetime DEFAULT NULL,
  `stat_time` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `assigned_to` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_status_forcast`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_status_forcast_steps`
--

DROP TABLE IF EXISTS `dev_est_reqs_status_forcast_steps`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_status_forcast_steps` (
  `iddev_est_reqs_status_forcast_steps` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs_status_forcast` int(11) DEFAULT NULL,
  `dev_steps_details` varchar(100) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_est_reqs_status_forcast_steps`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_est_reqs_status_steps`
--

DROP TABLE IF EXISTS `dev_est_reqs_status_steps`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_est_reqs_status_steps` (
  `iddev_est_req_status_steps` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs_status` int(11) DEFAULT NULL,
  `dev_steps_details` varchar(100) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_est_req_status_steps`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_lk_label`
--

DROP TABLE IF EXISTS `dev_lk_label`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_lk_label` (
  `iddev_lk_label` int(5) NOT NULL AUTO_INCREMENT,
  `display_nm` varchar(45) DEFAULT NULL,
  `dev_label_nm` varchar(45) DEFAULT NULL,
  `hover_fields` varchar(255) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `lk_parent_val_id` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_lk_label`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_lk_wrk_flow`
--

DROP TABLE IF EXISTS `dev_lk_wrk_flow`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_lk_wrk_flow` (
  `iddev_lk_wrk_flow` int(11) NOT NULL AUTO_INCREMENT,
  `wrk_flow_nm` varchar(45) DEFAULT NULL,
  `id_wrk_flow` int(11) DEFAULT NULL,
  `wrk_flow_desc` varchar(100) DEFAULT NULL,
  `id_wrk_flow_parent` int(11) DEFAULT NULL,
  `look_initial` varchar(5) DEFAULT NULL,
  `look_restart` varchar(5) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_lk_wrk_flow`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_look`
--

DROP TABLE IF EXISTS `dev_look`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_look` (
  `iddev_look` int(11) NOT NULL AUTO_INCREMENT,
  `look_name` varchar(45) DEFAULT NULL,
  `look_name_desc` varchar(100) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_look`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_look_value`
--

DROP TABLE IF EXISTS `dev_look_value`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_look_value` (
  `iddev_look_value` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_look` int(11) DEFAULT NULL,
  `look_value` varchar(45) DEFAULT NULL,
  `look_value_desc` varchar(100) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_look_value`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_policy`
--

DROP TABLE IF EXISTS `dev_policy`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_policy` (
  `iddev_policy` int(11) NOT NULL AUTO_INCREMENT,
  `owner_id` int(11) DEFAULT NULL,
  `lk_tag` varchar(200) DEFAULT NULL,
  `lk_tag_desc` varchar(200) DEFAULT NULL,
  `lk_disp_id` int(5) DEFAULT NULL,
  `lk_paren_tag_id` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(5) DEFAULT NULL,
  PRIMARY KEY (`iddev_policy`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_rel`
--

DROP TABLE IF EXISTS `dev_rel`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_rel` (
  `iddev_rel` int(11) NOT NULL AUTO_INCREMENT,
  `rel_nm` varchar(45) DEFAULT NULL,
  `rel_desc` varchar(100) DEFAULT NULL,
  `reqs_cnt` int(5) DEFAULT NULL COMMENT 'Total reqs',
  `team_cnt` int(5) DEFAULT NULL COMMENT 'total unique assignee',
  `aprox_flow` int(5) DEFAULT NULL,
  `ten_st_dt` date DEFAULT NULL,
  `ten_e_dt` date DEFAULT NULL,
  `actual_st_dt` date DEFAULT NULL,
  `actaul_en_dt` date DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_rel`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_rel_reqs`
--

DROP TABLE IF EXISTS `dev_rel_reqs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_rel_reqs` (
  `iddev_rel_reqs` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_est_reqs` int(11) DEFAULT NULL,
  `iddev_est_reqs_parent` int(11) DEFAULT NULL,
  `dev_est_req_brief` varchar(150) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_rel_reqs`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_res`
--

DROP TABLE IF EXISTS `dev_res`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_res` (
  `iddev_res` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `status_id` int(5) DEFAULT NULL,
  `status_name` varchar(45) DEFAULT NULL,
  `from_dt` date DEFAULT NULL,
  `to_dt` date DEFAULT NULL,
  `max_limit` int(3) DEFAULT NULL COMMENT 'User input (max 100)',
  `wkly_limit` int(5) DEFAULT NULL,
  `mon_limit` int(5) DEFAULT NULL,
  `qtr_limit` int(5) DEFAULT NULL,
  `semi_yr_limit` int(5) DEFAULT NULL,
  `yr_limit` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_res`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_res_hist`
--

DROP TABLE IF EXISTS `dev_res_hist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_res_hist` (
  `iddev_res_hist` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_res` int(11) DEFAULT NULL,
  `from_dt` date DEFAULT NULL,
  `to_dt` date DEFAULT NULL,
  `max_limit` int(5) DEFAULT NULL,
  `wkly_limit` int(5) DEFAULT NULL,
  `mon_limit` int(5) DEFAULT NULL,
  `qtr_limit` int(5) DEFAULT NULL,
  `semi_yr_limit` int(5) DEFAULT NULL,
  `yr_limit` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_res_hist`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_rpt`
--

DROP TABLE IF EXISTS `dev_rpt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_rpt` (
  `iddev_rpt` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_apps` varchar(10) DEFAULT NULL,
  `app_name` varchar(45) DEFAULT NULL,
  `iddev_est` varchar(10) DEFAULT NULL,
  `dev_est_smry` varchar(100) DEFAULT NULL COMMENT 'Same as dev.est.smry column',
  `category` int(11) DEFAULT NULL,
  `category_nm` varchar(45) DEFAULT NULL,
  `priority_id` int(11) DEFAULT NULL,
  `priority_value` int(11) DEFAULT NULL,
  `iddev_est_reqs` int(11) DEFAULT NULL,
  `req_desc` varchar(300) DEFAULT NULL,
  `skill_level` int(11) DEFAULT NULL,
  `skll_level_avg` varchar(45) DEFAULT NULL,
  `req_type_value` varchar(45) DEFAULT NULL,
  `req_type` int(11) DEFAULT NULL,
  `req_gap` int(11) DEFAULT NULL,
  `req_gap_avg` varchar(10) DEFAULT NULL,
  `owner_ref_tab` varchar(45) DEFAULT NULL,
  `owner_ref_id` int(11) DEFAULT NULL,
  `owner_ref_nm` varchar(100) DEFAULT NULL COMMENT 'get emp name from emp table',
  `est_ref_tab` varchar(45) DEFAULT NULL,
  `est_ref_id` int(11) DEFAULT NULL,
  `est_ref_nm` varchar(100) DEFAULT NULL,
  `pha_cnt` int(11) DEFAULT NULL,
  `pha_curr_id` int(11) DEFAULT NULL,
  `pha_curr_value` varchar(45) DEFAULT NULL,
  `pha_cur_st_dt` datetime DEFAULT NULL,
  `pha_cur_end_dt` datetime DEFAULT NULL,
  `pha_cur_by_id` int(11) DEFAULT NULL,
  `pha_cur_by_nm` varchar(45) DEFAULT NULL,
  `pha_cur_prior_st_en_dt` datetime DEFAULT NULL,
  `pha_cur_lag` text,
  `pha_cur_duration` int(11) DEFAULT NULL,
  `tot_duration` varchar(45) DEFAULT NULL,
  `tot_lag` varchar(45) DEFAULT NULL,
  `pha_smry` text,
  `acpt_cnt` int(11) DEFAULT NULL,
  `acpt_attmpt_cnt` int(11) DEFAULT NULL,
  `wrk_or_gap` varchar(10) DEFAULT NULL,
  `w_or_opned` datetime DEFAULT NULL,
  `w_or_closed` datetime DEFAULT NULL,
  `w_or_duration` int(11) DEFAULT NULL COMMENT 'w.or.closed - w.or.opened (round up decimal, i.e 6.6 = 7, 6.4 = 6)',
  `w_or_cnvr` varchar(100) DEFAULT NULL,
  `req_disp_ord` int(5) DEFAULT NULL,
  `req_open` datetime DEFAULT NULL,
  `req_close` datetime DEFAULT NULL,
  `req_tm` int(11) DEFAULT NULL,
  `pha1_id` int(11) DEFAULT NULL,
  `pha1_nm` varchar(100) DEFAULT NULL,
  `pha1_by_id` int(11) DEFAULT NULL,
  `pha1_by_nm` varchar(100) DEFAULT NULL,
  `pha1_lag` int(11) DEFAULT NULL,
  `pha1_duration` int(11) DEFAULT NULL,
  `pha2_id` int(11) DEFAULT NULL,
  `pha2_nm` varchar(100) DEFAULT NULL,
  `pha2_by_id` int(11) DEFAULT NULL,
  `pha2_by_nm` varchar(100) DEFAULT NULL,
  `pha2_lag` int(11) DEFAULT NULL,
  `pha2_duration` int(11) DEFAULT NULL,
  `pha3_id` int(11) DEFAULT NULL,
  `pha3_nm` varchar(100) DEFAULT NULL,
  `pha3_by_id` int(11) DEFAULT NULL,
  `pha3_by_nm` varchar(100) DEFAULT NULL,
  `pha3_lag` int(11) DEFAULT NULL,
  `pha3_duration` int(11) DEFAULT NULL,
  `pha4_id` int(11) DEFAULT NULL,
  `pha4_nm` varchar(100) DEFAULT NULL,
  `pha4_by_id` int(11) DEFAULT NULL,
  `pha4_by_nm` varchar(100) DEFAULT NULL,
  `pha4_lag` int(11) DEFAULT NULL,
  `pha4_duration` int(11) DEFAULT NULL,
  `pha5_id` int(11) DEFAULT NULL,
  `pha5_nm` varchar(100) DEFAULT NULL,
  `pha5_by_id` int(11) DEFAULT NULL,
  `pha5_by_nm` varchar(100) DEFAULT NULL,
  `pha5_lag` int(11) DEFAULT NULL,
  `pha5_duration` int(11) DEFAULT NULL,
  `pha6_plus` text,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updater_nm` varchar(45) DEFAULT NULL,
  `pha_last_id` int(11) DEFAULT NULL,
  `pha_last_name` varchar(100) DEFAULT NULL,
  `pha_last_by_id` int(11) DEFAULT NULL,
  `pha_last_by_name` varchar(100) DEFAULT NULL,
  `pha_last_lag` int(11) DEFAULT NULL,
  `pha_last_duration` int(11) DEFAULT NULL,
  `assigned_to_ids` text,
  `dev_app_attach_id` text,
  `dev_app_attach_nm` text,
  `dev_est_attach_id` text,
  `phase_id` text,
  `phase_nm` longtext,
  `phase_by_id` longtext,
  `phase_by_nm` longtext,
  `phase_stat_dt` longtext,
  `phase_end_dt` longtext,
  `phase_lag` longtext,
  `phase_duration` longtext,
  `est_type` varchar(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_rpt`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_stat_attr`
--

DROP TABLE IF EXISTS `dev_stat_attr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_stat_attr` (
  `iddev_rpt_stat_attr` int(11) NOT NULL AUTO_INCREMENT,
  `dev_phase_dt` date DEFAULT NULL,
  `phase_num` int(2) DEFAULT NULL,
  `new_stat` int(11) DEFAULT NULL,
  `close_stat` int(11) DEFAULT NULL,
  `total` int(11) DEFAULT NULL,
  `added` varchar(45) DEFAULT NULL,
  `completion` varchar(45) DEFAULT NULL,
  `growth` varchar(45) DEFAULT NULL,
  `ph_nm` varchar(45) DEFAULT NULL,
  `ph_owner` varchar(45) DEFAULT NULL,
  `parent_iddev_rpt_status` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updater_nm` varchar(95) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`iddev_rpt_stat_attr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_stat_attr_audit`
--

DROP TABLE IF EXISTS `dev_stat_attr_audit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_stat_attr_audit` (
  `iddev_stat_attr_audit` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_stat_attr` int(11) DEFAULT NULL,
  `dev_phase_dt` date DEFAULT NULL,
  `new_status` int(11) DEFAULT NULL,
  `close_stat` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_stat_attr_audit`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_stat_attr_list`
--

DROP TABLE IF EXISTS `dev_stat_attr_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_stat_attr_list` (
  `iddev_stat_attr_list` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_stat_attr` int(11) DEFAULT NULL,
  `dev_phase_dt` date DEFAULT NULL,
  `req_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_stat_attr_list`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_trng`
--

DROP TABLE IF EXISTS `dev_trng`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_trng` (
  `iddev_trng` int(11) NOT NULL AUTO_INCREMENT,
  `disp_order` int(3) DEFAULT NULL,
  `train_nm` varchar(45) DEFAULT NULL,
  `train_desc` varchar(200) DEFAULT NULL,
  `duration` int(5) DEFAULT NULL,
  `cnt` int(5) DEFAULT NULL,
  `practical` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`iddev_trng`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `dev_trng_attach`
--

DROP TABLE IF EXISTS `dev_trng_attach`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dev_trng_attach` (
  `iddev_trng_attach` int(11) NOT NULL AUTO_INCREMENT,
  `iddev_trng` int(11) DEFAULT NULL,
  `disp_order` int(3) DEFAULT NULL,
  `trng_desc` varchar(100) DEFAULT NULL,
  `duration` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `cloud_link` varchar(100) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(5) DEFAULT NULL,
  PRIMARY KEY (`iddev_trng_attach`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp`
--

DROP TABLE IF EXISTS `emp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp` (
  `emp_id` int(9) NOT NULL AUTO_INCREMENT,
  `firstname` varchar(45) DEFAULT NULL,
  `lastname` varchar(45) DEFAULT NULL,
  `nickname` varchar(5) DEFAULT NULL,
  `unique_id_type` int(5) DEFAULT NULL COMMENT 'SSN, PAN, etc',
  `ssn` varchar(20) DEFAULT NULL,
  `dob` date DEFAULT NULL,
  `gender` int(5) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `sto_limit` bigint(45) DEFAULT '5368709120',
  `taxid` varchar(45) DEFAULT NULL,
  `login_id` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updater` int(9) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`emp_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 MAX_ROWS=999999999 COMMENT='Used to store details of Apex employee details';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_access`
--

DROP TABLE IF EXISTS `emp_access`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_access` (
  `access_id` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(9) NOT NULL,
  `feature_id` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`access_id`),
  KEY `feature_id_fk1` (`feature_id`),
  KEY `uid_fk3` (`emp_id`),
  KEY `fk_emp_id_allusr_acc_idx` (`emp_id`),
  KEY `fk_fea_allusr_acc_idx` (`feature_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 MAX_ROWS=999999999 COMMENT='Used to store access details of employees';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_access_old`
--

DROP TABLE IF EXISTS `emp_access_old`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_access_old` (
  `access_id` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(9) NOT NULL,
  `feature_id` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`access_id`),
  KEY `feature_id_fk1` (`feature_id`),
  KEY `uid_fk3` (`emp_id`),
  KEY `fk_emp_id_allusr_acc_idx` (`emp_id`),
  KEY `fk_fea_allusr_acc_idx` (`feature_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 MAX_ROWS=999999999 COMMENT='Used to store access details of employees';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_activity`
--

DROP TABLE IF EXISTS `emp_activity`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_activity` (
  `idemp_activity` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `call_recv_dt` date DEFAULT NULL,
  `next_call_dt` date DEFAULT NULL,
  `call_note` text,
  `last_updated` datetime DEFAULT NULL,
  `emp_id_updated` int(11) DEFAULT NULL,
  PRIMARY KEY (`idemp_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_address`
--

DROP TABLE IF EXISTS `emp_address`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_address` (
  `emp_add_id` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(9) DEFAULT NULL,
  `look_street_no_id` int(10) DEFAULT NULL,
  `house_apt_no` varchar(45) DEFAULT NULL,
  `house_apt_type` int(5) DEFAULT NULL,
  `from_dt` date DEFAULT NULL,
  `to_dt` date DEFAULT NULL,
  `add_type` varchar(45) DEFAULT NULL COMMENT 'Mailing or Physical',
  `last_updated` datetime DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  PRIMARY KEY (`emp_add_id`),
  KEY `fk_emp_id_emp_address_idx` (`emp_id`),
  CONSTRAINT `fk_emp_id_emp_address` FOREIGN KEY (`emp_id`) REFERENCES `emp` (`emp_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_attach`
--

DROP TABLE IF EXISTS `emp_attach`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_attach` (
  `idemp_attach` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idemp_attach`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_contact`
--

DROP TABLE IF EXISTS `emp_contact`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_contact` (
  `emp_contact_id` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(9) DEFAULT NULL,
  `contact_id` int(11) DEFAULT NULL COMMENT 'email, cell, work, home',
  `emp_contact_type` int(11) DEFAULT NULL,
  `summary` varchar(100) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  PRIMARY KEY (`emp_contact_id`),
  UNIQUE KEY `emp_contact_id` (`emp_contact_id`),
  KEY `fk_emp_id_emp_contact_idx` (`emp_id`),
  CONSTRAINT `fk_emp_id_emp_contact` FOREIGN KEY (`emp_id`) REFERENCES `emp` (`emp_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_hrs`
--

DROP TABLE IF EXISTS `emp_hrs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_hrs` (
  `idemp_hrs` int(11) NOT NULL AUTO_INCREMENT,
  `emp_org_id` int(11) DEFAULT NULL,
  `from_dt` date DEFAULT NULL,
  `to_dt` date DEFAULT NULL,
  `tentative_en_dt` date DEFAULT NULL,
  `emp_hrs_title` varchar(45) DEFAULT NULL COMMENT 'Probation, Jr, Sr, etc',
  `time_zone` int(5) DEFAULT NULL COMMENT 'EST, IST, ect',
  `idstorage` int(11) DEFAULT NULL,
  `max_withdraw` char(1) DEFAULT NULL COMMENT 'y = withdrawal all from bank_acc',
  `cycle_run` char(1) DEFAULT NULL COMMENT 'Y or N',
  `updated_by` varchar(100) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `approx_day` int(11) DEFAULT NULL,
  `approx_wk` int(11) DEFAULT NULL,
  `approx_mon` int(11) DEFAULT NULL,
  `approx_yr` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idemp_hrs`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_hrs_days`
--

DROP TABLE IF EXISTS `emp_hrs_days`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_hrs_days` (
  `idemp_hrs_days` int(11) NOT NULL AUTO_INCREMENT,
  `idemp_hrs` int(11) DEFAULT NULL,
  `start_tm` time DEFAULT NULL,
  `end_tm` time DEFAULT NULL,
  `hrs_tm` float DEFAULT NULL,
  `off_time` varchar(2) DEFAULT NULL,
  `days` int(1) DEFAULT NULL COMMENT '0 = Monday to Friday\n1 = Monday to Saturday\n2 = All Seven\n3 = Monday only\n4 = Tuesdays, etc',
  `pay_amt` float DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idemp_hrs_days`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_legal`
--

DROP TABLE IF EXISTS `emp_legal`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_legal` (
  `emp_legal_id` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `doc_type` int(5) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `expire_dt` date DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` date DEFAULT NULL,
  PRIMARY KEY (`emp_legal_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_legal_hist`
--

DROP TABLE IF EXISTS `emp_legal_hist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_legal_hist` (
  `idemp_legal_hist` int(11) NOT NULL AUTO_INCREMENT,
  `emp_legal_id` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `expire_dt` date DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idemp_legal_hist`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_lk`
--

DROP TABLE IF EXISTS `emp_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_lk` (
  `idemp_lk` int(11) NOT NULL AUTO_INCREMENT,
  `emp_name` varchar(45) DEFAULT NULL,
  `disp_order` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idemp_lk`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_lk_tag`
--

DROP TABLE IF EXISTS `emp_lk_tag`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_lk_tag` (
  `idemp_lk_tag` int(11) NOT NULL AUTO_INCREMENT,
  `owner_id` int(11) DEFAULT NULL,
  `lk_tag` varchar(200) DEFAULT NULL,
  `lk_tag_desc` varchar(200) DEFAULT NULL,
  `lk_disp_id` int(5) DEFAULT NULL,
  `lk_parent_val_id` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idemp_lk_tag`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_lk_val`
--

DROP TABLE IF EXISTS `emp_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_lk_val` (
  `idemp_lk_value` int(11) NOT NULL AUTO_INCREMENT,
  `idemp_lk` int(11) DEFAULT NULL,
  `emp_value` varchar(45) DEFAULT NULL,
  `emp_value_desc` varchar(100) DEFAULT NULL,
  `disp_order` int(1) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idemp_lk_value`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_load`
--

DROP TABLE IF EXISTS `emp_load`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_load` (
  `idload_emp_details` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `file_name` varchar(100) DEFAULT NULL,
  `first_name` varchar(45) DEFAULT NULL,
  `last_name` varchar(45) DEFAULT NULL,
  `nick_name` varchar(45) DEFAULT NULL,
  `unique_id_type` int(5) DEFAULT NULL,
  `ssn` varchar(45) DEFAULT NULL,
  `contacts` text,
  `addresses` text,
  `companies` text CHARACTER SET utf8,
  `emp_day_end` char(1) DEFAULT NULL,
  `emp_day_chk` date DEFAULT NULL,
  `emp_days` int(5) DEFAULT NULL,
  `consulting_companies` text CHARACTER SET utf8,
  `consult_day_end` char(1) DEFAULT NULL,
  `consult_day_chk` date DEFAULT NULL,
  `consulting_days` int(5) DEFAULT NULL,
  `gender` int(5) DEFAULT NULL,
  `dob` date DEFAULT NULL,
  `login_id` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idload_emp_details`),
  UNIQUE KEY `emp_id_UNIQUE` (`emp_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_org`
--

DROP TABLE IF EXISTS `emp_org`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_org` (
  `emp_org_id` int(11) NOT NULL AUTO_INCREMENT,
  `comp_id` int(10) DEFAULT NULL,
  `emp_id` int(9) DEFAULT NULL,
  `org_start_dt` date DEFAULT NULL,
  `org_end_dt` date DEFAULT NULL,
  `days` int(11) DEFAULT NULL,
  `emp_type` int(5) DEFAULT NULL COMMENT '1099, w2, freelancer',
  `run_script` char(1) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`emp_org_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_org_access`
--

DROP TABLE IF EXISTS `emp_org_access`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_org_access` (
  `idemp_org_access` int(11) NOT NULL AUTO_INCREMENT,
  `emp_org_id` int(11) DEFAULT NULL,
  `emp_access` int(11) DEFAULT NULL COMMENT 'This emp will have access to emp_org_id record',
  `emp_access_type` varchar(45) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idemp_org_access`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_org_attr`
--

DROP TABLE IF EXISTS `emp_org_attr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_org_attr` (
  `idemp_org_attr` int(11) NOT NULL AUTO_INCREMENT,
  `emp_org_dt` date DEFAULT NULL,
  `new_emp` int(11) DEFAULT NULL,
  `close_emp` int(11) DEFAULT NULL,
  `total` int(11) DEFAULT NULL,
  `added` varchar(45) DEFAULT NULL,
  `completion` varchar(45) DEFAULT NULL,
  `growth` varchar(45) DEFAULT NULL,
  `comp_id` int(11) DEFAULT NULL,
  `comp_nm` varchar(95) DEFAULT NULL,
  `emp_type_id` int(11) DEFAULT NULL,
  `emp_type_nm` varchar(45) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updater_nm` varchar(95) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `parent_idemp_org_attr` int(11) DEFAULT NULL,
  PRIMARY KEY (`idemp_org_attr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_org_attr_audit`
--

DROP TABLE IF EXISTS `emp_org_attr_audit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_org_attr_audit` (
  `idemp_org_attr_audit` int(11) NOT NULL AUTO_INCREMENT,
  `idemp_org_attr` int(11) DEFAULT NULL,
  `emp_org_dt` date DEFAULT NULL,
  `new_emp` int(5) DEFAULT NULL,
  `close_emp` int(5) DEFAULT NULL,
  `total` int(5) DEFAULT NULL,
  `added` varchar(45) DEFAULT NULL,
  `completion` varchar(45) DEFAULT NULL,
  `growth` varchar(45) DEFAULT NULL,
  `updater` varchar(45) DEFAULT NULL,
  `updater_nm` varchar(45) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idemp_org_attr_audit`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_org_attr_list`
--

DROP TABLE IF EXISTS `emp_org_attr_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_org_attr_list` (
  `idemp_org_attr_list` int(11) NOT NULL AUTO_INCREMENT,
  `idemp_org_attr` int(11) DEFAULT NULL,
  `emp_org_dt` date DEFAULT NULL,
  `emp_org_id` int(11) DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL,
  `emp_nm` varchar(95) DEFAULT NULL COMMENT 'Take “full name, i.e concat first and last name',
  PRIMARY KEY (`idemp_org_attr_list`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_org_attr_list_comp`
--

DROP TABLE IF EXISTS `emp_org_attr_list_comp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_org_attr_list_comp` (
  `idemp_org_attr_list_comp` int(11) NOT NULL AUTO_INCREMENT,
  `idemp_org_attr` int(11) DEFAULT NULL,
  `emp_org_dt` date DEFAULT NULL,
  `emp_org_id` int(11) DEFAULT NULL,
  `comp_id` int(11) DEFAULT NULL,
  `comp_nm` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`idemp_org_attr_list_comp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_org_attr_list_type`
--

DROP TABLE IF EXISTS `emp_org_attr_list_type`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_org_attr_list_type` (
  `idemp_org_attr_list_type` int(11) NOT NULL AUTO_INCREMENT,
  `idemp_org_attr` int(11) DEFAULT NULL,
  `emp_org_dt` date DEFAULT NULL,
  `emp_org_id` int(11) DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL,
  `emp_nm` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`idemp_org_attr_list_type`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_org_attr_list_type_set`
--

DROP TABLE IF EXISTS `emp_org_attr_list_type_set`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_org_attr_list_type_set` (
  `idemp_org_attr_list_type_set` int(11) NOT NULL AUTO_INCREMENT,
  `idemp_org_attr` varchar(45) DEFAULT NULL,
  `emp_org_id` varchar(45) DEFAULT NULL,
  `emp_org_id_set` text,
  `emp_org_id_nm` text,
  PRIMARY KEY (`idemp_org_attr_list_type_set`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_org_attr_set`
--

DROP TABLE IF EXISTS `emp_org_attr_set`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_org_attr_set` (
  `idemp_org_attr_set` int(11) NOT NULL AUTO_INCREMENT,
  `idemp_org_attr` int(11) DEFAULT NULL,
  `emp_org_dt` date DEFAULT NULL,
  `emp_org_id` text,
  `emp_id` text,
  `emp_nm` text COMMENT '“Jiten Patel”, etc',
  `comp_id` text,
  `comp_nm` text,
  `emp_type` text,
  `emp_type_nm` text,
  PRIMARY KEY (`idemp_org_attr_set`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_sales`
--

DROP TABLE IF EXISTS `emp_sales`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_sales` (
  `idemp_sales` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `emp_level` int(5) DEFAULT NULL,
  `emp_tag` text,
  `call_recv_dt` date DEFAULT NULL,
  `next_recv_dt` date DEFAULT NULL,
  `call_note` varchar(95) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` varchar(45) DEFAULT NULL,
  `attachment` char(1) DEFAULT NULL,
  PRIMARY KEY (`idemp_sales`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_tag`
--

DROP TABLE IF EXISTS `emp_tag`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_tag` (
  `idemp_tag` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `emp_tags` int(5) DEFAULT NULL,
  PRIMARY KEY (`idemp_tag`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_tag_merger`
--

DROP TABLE IF EXISTS `emp_tag_merger`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_tag_merger` (
  `emp_id` int(9) NOT NULL DEFAULT '0',
  `firstname` varchar(45) DEFAULT NULL,
  `lastname` varchar(45) DEFAULT NULL,
  `nickname` varchar(5) DEFAULT NULL,
  `gender` int(5) DEFAULT NULL,
  `emp_assigned_id` int(1) NOT NULL DEFAULT '0',
  `mod_call_recv_dt` varchar(8) CHARACTER SET utf8 DEFAULT NULL,
  `call_recv_dt` datetime DEFAULT NULL,
  `mod_next_call_dt` varchar(8) CHARACTER SET utf8 DEFAULT NULL,
  `next_call_dt` datetime DEFAULT NULL,
  `call_note` text,
  `emp_smry` varchar(200) DEFAULT NULL,
  `last_updated_sale` datetime DEFAULT NULL,
  `mod_last_updated` varchar(116) DEFAULT NULL,
  `emp_level` int(5) DEFAULT NULL,
  `emp_lvl_desc` varchar(200) DEFAULT NULL,
  `contacts` longtext,
  `emp_tag` longtext,
  `file_group` longtext,
  `258` decimal(23,0) DEFAULT NULL,
  `1358` decimal(23,0) DEFAULT NULL,
  `1369` decimal(23,0) DEFAULT NULL,
  `1666` decimal(23,0) DEFAULT NULL,
  `259` decimal(23,0) DEFAULT NULL,
  `67` decimal(23,0) DEFAULT NULL,
  `1707` decimal(23,0) DEFAULT NULL,
  `262` decimal(23,0) DEFAULT NULL,
  `263` decimal(23,0) DEFAULT NULL,
  `1022` decimal(23,0) DEFAULT NULL,
  `260` decimal(23,0) DEFAULT NULL,
  `261` decimal(23,0) DEFAULT NULL,
  `289` decimal(23,0) DEFAULT NULL,
  `290` decimal(23,0) DEFAULT NULL,
  `291` decimal(23,0) DEFAULT NULL,
  `293` decimal(23,0) DEFAULT NULL,
  `297` decimal(23,0) DEFAULT NULL,
  `1405` decimal(23,0) DEFAULT NULL,
  `255` decimal(23,0) DEFAULT NULL,
  `256` decimal(23,0) DEFAULT NULL,
  `295` decimal(23,0) DEFAULT NULL,
  `296` decimal(23,0) DEFAULT NULL,
  `975` decimal(23,0) DEFAULT NULL,
  `974` decimal(23,0) DEFAULT NULL,
  `973` decimal(23,0) DEFAULT NULL,
  `1417` decimal(23,0) DEFAULT NULL,
  `1418` decimal(23,0) DEFAULT NULL,
  `1678` decimal(23,0) DEFAULT NULL,
  `1680` decimal(23,0) DEFAULT NULL,
  `1706` decimal(23,0) DEFAULT NULL,
  `1682` decimal(23,0) DEFAULT NULL,
  `1684` decimal(23,0) DEFAULT NULL,
  `1686` decimal(23,0) DEFAULT NULL,
  `1687` decimal(23,0) DEFAULT NULL,
  `1688` decimal(23,0) DEFAULT NULL,
  `121` int(1) NOT NULL DEFAULT '0',
  `3` int(1) NOT NULL DEFAULT '0',
  `32` int(1) NOT NULL DEFAULT '0',
  `33` int(1) NOT NULL DEFAULT '0',
  `288` int(1) NOT NULL DEFAULT '0',
  `253` int(1) NOT NULL DEFAULT '0',
  `294` int(1) NOT NULL DEFAULT '0',
  `972` int(1) NOT NULL DEFAULT '0',
  `1416` int(1) NOT NULL DEFAULT '0',
  `1677` int(1) NOT NULL DEFAULT '0',
  `1681` int(1) NOT NULL DEFAULT '0',
  `1685` int(1) NOT NULL DEFAULT '0',
  `Total_Missing` int(1) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_vac`
--

DROP TABLE IF EXISTS `emp_vac`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_vac` (
  `idemp_vac` int(11) NOT NULL AUTO_INCREMENT,
  `emp_org_id` int(11) DEFAULT NULL,
  `from_dt` date DEFAULT NULL,
  `to_dt` date DEFAULT NULL,
  `brought_fwd` int(2) DEFAULT NULL,
  `vac_type` int(5) DEFAULT NULL COMMENT 'H = Holiday, V = vacation, Sick, Maternity, Compensate ',
  `hrs` varchar(5) DEFAULT NULL,
  `run_script` char(1) DEFAULT NULL COMMENT 'Y then do not run',
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idemp_vac`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `emp_vac_trace`
--

DROP TABLE IF EXISTS `emp_vac_trace`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp_vac_trace` (
  `idemp_vac_trace` int(11) NOT NULL AUTO_INCREMENT,
  `idemp_vac` int(11) DEFAULT NULL,
  `emp_org_id` int(11) DEFAULT NULL,
  `trace_dt` date DEFAULT NULL,
  `vac_type` int(5) DEFAULT NULL,
  `trace_hrs` varchar(5) DEFAULT NULL COMMENT 'Hrs, I.e 1, 2, 4 8',
  `approver` int(5) DEFAULT NULL,
  `app_date` datetime DEFAULT NULL,
  `hrs_ytd` varchar(5) DEFAULT NULL,
  `updater` int(5) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idemp_vac_trace`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage`
--

DROP TABLE IF EXISTS `engage`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage` (
  `engage_id` int(11) NOT NULL AUTO_INCREMENT,
  `srv_st_dt` date DEFAULT NULL,
  `srv_e_dt` date DEFAULT NULL,
  `eng_tentive_en_dt` date DEFAULT NULL,
  `sr_frequency` varchar(45) DEFAULT NULL,
  `srv_paytype` char(5) DEFAULT NULL COMMENT 'credit, invoice, email',
  `srv_amt` float DEFAULT NULL,
  `eg_sumry` varchar(45) DEFAULT NULL,
  `cloud_drive` text,
  `srv_client` int(10) DEFAULT NULL,
  `srv_vendor` int(10) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `en_prv_smry` text,
  `access_name` varchar(45) DEFAULT NULL,
  `remind` int(3) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`engage_id`),
  UNIQUE KEY `access_name_UNIQUE` (`access_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_add`
--

DROP TABLE IF EXISTS `engage_add`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_add` (
  `idengage_add` int(11) NOT NULL AUTO_INCREMENT,
  `idengage_comp` int(11) DEFAULT NULL,
  `comp_add_id` int(11) DEFAULT NULL,
  `add_type` int(5) DEFAULT NULL COMMENT 'Primary',
  PRIMARY KEY (`idengage_add`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_add_con`
--

DROP TABLE IF EXISTS `engage_add_con`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_add_con` (
  `idengage_add_con` int(11) NOT NULL AUTO_INCREMENT,
  `idengage_add` int(11) DEFAULT NULL,
  `idengage_comp` int(11) DEFAULT NULL,
  `comp_add_id` int(11) DEFAULT NULL,
  `comp_contact_no_id` int(11) DEFAULT NULL,
  `contact_notes` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idengage_add_con`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_budget`
--

DROP TABLE IF EXISTS `engage_budget`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_budget` (
  `idengage_budget` int(11) NOT NULL AUTO_INCREMENT,
  `idengage_entity_po` int(11) NOT NULL,
  `engage_ref_id` int(11) DEFAULT NULL,
  `engage_ref_table` varchar(45) DEFAULT NULL,
  `engage_calc` varchar(5) DEFAULT NULL COMMENT '.70 %,  $,',
  `engage_amt` varchar(45) DEFAULT NULL,
  `show_emp` int(5) DEFAULT NULL COMMENT 'Y or N',
  `engage_st_dt` date DEFAULT NULL,
  `engage_end_st` date DEFAULT NULL,
  `limit_amt` varchar(45) DEFAULT NULL,
  `engage_summary` varchar(45) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idengage_budget`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='																																																												';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_comp`
--

DROP TABLE IF EXISTS `engage_comp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_comp` (
  `idengage_comp` int(11) NOT NULL AUTO_INCREMENT,
  `engage_id` int(11) DEFAULT NULL,
  `comp_id` int(10) DEFAULT NULL,
  `temp_id` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`idengage_comp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_doc`
--

DROP TABLE IF EXISTS `engage_doc`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_doc` (
  `engage_doc_id` int(11) NOT NULL AUTO_INCREMENT,
  `engage_id` int(11) DEFAULT NULL,
  `doc_type` int(5) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `expire_dt` date DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`engage_doc_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_doc_hist`
--

DROP TABLE IF EXISTS `engage_doc_hist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_doc_hist` (
  `idengage_doc_hist` int(11) NOT NULL AUTO_INCREMENT,
  `engage_doc_id` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `expire_dt` date DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idengage_doc_hist`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_entity`
--

DROP TABLE IF EXISTS `engage_entity`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_entity` (
  `idengage_entity` int(11) NOT NULL AUTO_INCREMENT,
  `engage_id` int(11) DEFAULT NULL,
  `engage_ref_tab` varchar(45) DEFAULT NULL,
  `engage_ref_id` int(11) DEFAULT NULL,
  `entity_parent` int(11) DEFAULT NULL,
  PRIMARY KEY (`idengage_entity`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_entity_po`
--

DROP TABLE IF EXISTS `engage_entity_po`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_entity_po` (
  `idengage_entity_po` int(11) NOT NULL AUTO_INCREMENT,
  `engage_id` int(11) DEFAULT NULL,
  `idengage_entity` int(11) DEFAULT NULL,
  `engage_ref_tab` varchar(45) DEFAULT NULL,
  `engage_ref_id` int(11) DEFAULT NULL,
  `bill_start_dt` date DEFAULT NULL,
  `bill_cycle` int(5) DEFAULT NULL,
  `bill_end_dt` date DEFAULT NULL,
  `bill_fst_dt` date DEFAULT NULL,
  `bill_day` varchar(45) DEFAULT NULL,
  `bill_pay_type` varchar(11) DEFAULT NULL,
  `bill_pay_rate` decimal(6,2) DEFAULT NULL,
  `ts_cycle` int(5) DEFAULT NULL,
  `ts_fst_dt` date DEFAULT NULL,
  `netpay` int(5) DEFAULT NULL,
  `tentative_end_dt` date DEFAULT NULL,
  `access_name` varchar(20) DEFAULT NULL,
  `remind` int(3) DEFAULT NULL,
  `summary` varchar(100) DEFAULT NULL,
  `cloud_drive` text,
  `idstorage` int(11) DEFAULT NULL,
  `actions` char(1) DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `last_update` datetime DEFAULT NULL,
  `allow_inv` int(5) DEFAULT NULL COMMENT 'Y or N',
  `show_emp` varchar(5) DEFAULT NULL COMMENT 'Y or N',
  `bill_cyle_run` char(1) DEFAULT NULL COMMENT 'Y or N',
  `bill_last_run` date DEFAULT NULL,
  `ts_cycle_run` char(1) DEFAULT NULL,
  `ts_last_run` date DEFAULT NULL,
  `mon_cycle_run` char(1) DEFAULT NULL,
  `mon_last_run` date DEFAULT NULL,
  `bill_pay_rate_xtra` float DEFAULT NULL,
  `bill_hrs_min` int(5) DEFAULT NULL,
  `bill_title` int(5) DEFAULT NULL COMMENT 'Req type look value',
  PRIMARY KEY (`idengage_entity_po`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_entity_po_doc`
--

DROP TABLE IF EXISTS `engage_entity_po_doc`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_entity_po_doc` (
  `idengage_entity_po_doc` int(11) NOT NULL AUTO_INCREMENT,
  `idengage_entity` int(11) DEFAULT NULL,
  `idengage_entity_po` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `doc_type` int(11) DEFAULT NULL,
  `expire_dt` date DEFAULT NULL,
  `last_updated` date DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idengage_entity_po_doc`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_entity_po_doc_hist`
--

DROP TABLE IF EXISTS `engage_entity_po_doc_hist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_entity_po_doc_hist` (
  `idengage_entity_po_doc_hist` int(11) NOT NULL AUTO_INCREMENT,
  `idengage_entity_po_doc` int(11) DEFAULT NULL,
  `doc_type` int(5) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `expire_dt` date DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `last_updated` date DEFAULT NULL,
  PRIMARY KEY (`idengage_entity_po_doc_hist`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_inv`
--

DROP TABLE IF EXISTS `engage_inv`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_inv` (
  `idengage_inv` int(11) NOT NULL AUTO_INCREMENT,
  `idengage_entity_po` int(11) DEFAULT NULL,
  `idengage_add_con` int(11) DEFAULT NULL,
  `display` char(1) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idengage_inv`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_temp`
--

DROP TABLE IF EXISTS `engage_temp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_temp` (
  `idengage_temp` int(11) NOT NULL AUTO_INCREMENT,
  `session_id` int(11) DEFAULT NULL,
  `engage_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`idengage_temp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `engage_tree`
--

DROP TABLE IF EXISTS `engage_tree`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `engage_tree` (
  `engage_tree_id` int(11) NOT NULL AUTO_INCREMENT,
  `idengage_entity_po` int(11) DEFAULT NULL,
  `comp_id` int(10) DEFAULT NULL,
  `engage_parent_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`engage_tree_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `exchange_rate`
--

DROP TABLE IF EXISTS `exchange_rate`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `exchange_rate` (
  `ExRateID` int(11) NOT NULL AUTO_INCREMENT,
  `curr_date` date NOT NULL,
  `currency` varchar(45) NOT NULL,
  `open_rate` float NOT NULL,
  `close_rate` float NOT NULL,
  `Average_rate` float NOT NULL,
  `daily_difference` float DEFAULT '0',
  `half_monthly_difference` float DEFAULT '0',
  `monthly_difference` float DEFAULT '0',
  `two_month_difference` float DEFAULT '0',
  `four_month_difference` float DEFAULT '0',
  `six_month_difference` float DEFAULT '0',
  `difference_against_six_month` float DEFAULT '0',
  `yearly_difference` float DEFAULT '0',
  `difference_against_year` float DEFAULT '0',
  `two_year_difference` float DEFAULT '0',
  `difference_against_two_year` float DEFAULT '0',
  `five_year_difference` float DEFAULT '0',
  `difference_against_five_year` float DEFAULT '0',
  PRIMARY KEY (`ExRateID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `exchange_rate_cny`
--

DROP TABLE IF EXISTS `exchange_rate_cny`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `exchange_rate_cny` (
  `ExRateID` int(11) NOT NULL AUTO_INCREMENT,
  `curr_date` date NOT NULL,
  `currency` varchar(45) NOT NULL,
  `open_rate` float NOT NULL,
  `close_rate` float NOT NULL,
  `Average_rate` float NOT NULL,
  `daily_difference` float DEFAULT '0',
  `half_monthly_difference` float DEFAULT '0',
  `monthly_difference` float DEFAULT '0',
  `two_month_difference` float DEFAULT '0',
  `four_month_difference` float DEFAULT '0',
  `six_month_difference` float DEFAULT '0',
  `difference_against_six_month` float DEFAULT '0',
  `yearly_difference` float DEFAULT '0',
  `difference_against_year` float DEFAULT '0',
  `two_year_difference` float DEFAULT '0',
  `difference_against_two_year` float DEFAULT '0',
  `five_year_difference` float DEFAULT '0',
  `difference_against_five_year` float DEFAULT '0',
  PRIMARY KEY (`ExRateID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `exchange_rate_eur`
--

DROP TABLE IF EXISTS `exchange_rate_eur`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `exchange_rate_eur` (
  `ExRateID` int(11) NOT NULL AUTO_INCREMENT,
  `curr_date` date NOT NULL,
  `currency` varchar(45) NOT NULL,
  `open_rate` float NOT NULL,
  `close_rate` float NOT NULL,
  `Average_rate` float NOT NULL,
  `daily_difference` float DEFAULT '0',
  `half_monthly_difference` float DEFAULT '0',
  `monthly_difference` float DEFAULT '0',
  `two_month_difference` float DEFAULT '0',
  `four_month_difference` float DEFAULT '0',
  `six_month_difference` float DEFAULT '0',
  `difference_against_six_month` float DEFAULT '0',
  `yearly_difference` float DEFAULT '0',
  `difference_against_year` float DEFAULT '0',
  `two_year_difference` float DEFAULT '0',
  `difference_against_two_year` float DEFAULT '0',
  `five_year_difference` float DEFAULT '0',
  `difference_against_five_year` float DEFAULT '0',
  PRIMARY KEY (`ExRateID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `expense_comp`
--

DROP TABLE IF EXISTS `expense_comp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `expense_comp` (
  `expense_id` int(11) NOT NULL AUTO_INCREMENT,
  `bank_rec_id` int(11) DEFAULT NULL,
  `exp_amt` varchar(45) DEFAULT NULL,
  `exp_look_id` int(11) DEFAULT NULL,
  `exp_summary` varchar(95) DEFAULT NULL,
  `exp_by` int(10) DEFAULT NULL COMMENT 'company id only',
  `paid_to` int(11) DEFAULT NULL,
  `paid_ref_table` varchar(45) DEFAULT NULL,
  `exp_dt` date DEFAULT NULL,
  `enter_by` int(11) DEFAULT NULL,
  `enter_dt` date DEFAULT NULL,
  `approve_by` int(11) DEFAULT NULL,
  `approve_dt` date DEFAULT NULL,
  PRIMARY KEY (`expense_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `expense_hist`
--

DROP TABLE IF EXISTS `expense_hist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `expense_hist` (
  `expense_hist_id` int(11) NOT NULL AUTO_INCREMENT,
  `expense_id` int(11) DEFAULT NULL,
  `bank_rec_id` int(11) DEFAULT NULL,
  `exp_amt` varchar(45) DEFAULT NULL,
  `exp_look_id` int(11) DEFAULT NULL,
  `exp_summary` varchar(95) DEFAULT NULL,
  `exp_by_ref_id` int(11) DEFAULT NULL,
  `exp_ref_table` varchar(45) DEFAULT NULL,
  `exp_for_ref_id` int(11) DEFAULT NULL,
  `exp_for_ref_table` varchar(45) DEFAULT NULL,
  `exp_dt` date DEFAULT NULL,
  `exp_clam_dt` date DEFAULT NULL,
  `approve_by` int(11) DEFAULT NULL,
  `approve_dt` date DEFAULT NULL,
  PRIMARY KEY (`expense_hist_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature`
--

DROP TABLE IF EXISTS `feature`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature` (
  `feature_no` int(11) NOT NULL AUTO_INCREMENT,
  `feature_id` int(11) DEFAULT NULL,
  `feature_name` varchar(45) DEFAULT NULL,
  `feature_desc` varchar(200) DEFAULT NULL,
  `disp_order` int(11) DEFAULT NULL,
  PRIMARY KEY (`feature_no`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_access`
--

DROP TABLE IF EXISTS `feature_access`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_access` (
  `idfeature_access` int(11) NOT NULL AUTO_INCREMENT,
  `feature_id` int(11) DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL COMMENT 'Employee assignee limitation',
  `updater` int(11) DEFAULT NULL,
  `last_updater` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idfeature_access`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_audit`
--

DROP TABLE IF EXISTS `feature_audit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_audit` (
  `idfeature_audit` int(19) NOT NULL AUTO_INCREMENT,
  `last_update` datetime DEFAULT NULL,
  `updater` varchar(90) DEFAULT NULL,
  `table_update` varchar(90) DEFAULT NULL,
  `trans_type` char(1) DEFAULT NULL,
  `table_id` text,
  `col1` text,
  `col2` text,
  `col3` text,
  `col4` text,
  `col5` text,
  `col6` text,
  `col7` text,
  `col8` text,
  `col9` text,
  `col10` text,
  `col11` text,
  `col12` text,
  `col13` text,
  `col14` text,
  `col15` text,
  PRIMARY KEY (`idfeature_audit`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_grp`
--

DROP TABLE IF EXISTS `feature_grp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_grp` (
  `idfeature_grp` int(11) NOT NULL AUTO_INCREMENT,
  `group_name` varchar(45) DEFAULT NULL,
  `group_desc` varchar(200) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  PRIMARY KEY (`idfeature_grp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_grp_list`
--

DROP TABLE IF EXISTS `feature_grp_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_grp_list` (
  `idfeature_grp_list` int(11) NOT NULL AUTO_INCREMENT,
  `idfeature_grp` int(11) NOT NULL,
  `feature_id` int(11) NOT NULL,
  `disp_order` int(5) DEFAULT NULL,
  PRIMARY KEY (`idfeature_grp_list`),
  KEY `fk_feture_grp_name_feture_grp_id` (`idfeature_grp`),
  KEY `fk_feture_id_feture_grping_idx` (`feature_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_grp_load`
--

DROP TABLE IF EXISTS `feature_grp_load`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_grp_load` (
  `idfeature_grp_load` int(11) NOT NULL AUTO_INCREMENT,
  `idfeature_grp` int(11) DEFAULT NULL,
  `disp_order` int(11) DEFAULT NULL,
  `group_name` varchar(45) DEFAULT NULL,
  `group_desc` varchar(200) DEFAULT NULL,
  `idfeature_grp_list` text,
  `feature_id` text,
  `feature_nm` text,
  `updater` int(11) DEFAULT NULL,
  `updater_nm` varchar(100) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` varchar(45) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  PRIMARY KEY (`idfeature_grp_load`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_grp_log`
--

DROP TABLE IF EXISTS `feature_grp_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_grp_log` (
  `idfeature_grp_log` int(11) NOT NULL AUTO_INCREMENT,
  `trans_type` char(1) DEFAULT NULL,
  `table_id` int(11) DEFAULT NULL,
  `idfeature_grp` int(11) DEFAULT NULL,
  `group_name` varchar(45) DEFAULT NULL,
  `group_desc` varchar(200) DEFAULT NULL,
  `idfeature_grp_list` text,
  `feature_id` text,
  `feature_nm` longtext,
  `updater` int(11) DEFAULT NULL,
  `updater_nm` varchar(95) DEFAULT NULL,
  `last_update` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idfeature_grp_log`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_lk`
--

DROP TABLE IF EXISTS `feature_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_lk` (
  `idfeature_lk` int(11) NOT NULL AUTO_INCREMENT,
  `feature_name` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  PRIMARY KEY (`idfeature_lk`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_lk_val`
--

DROP TABLE IF EXISTS `feature_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_lk_val` (
  `idfeature_lk_val` int(11) NOT NULL AUTO_INCREMENT,
  `idfeature_lk` int(11) DEFAULT NULL,
  `feature_value` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idfeature_lk_val`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_menu`
--

DROP TABLE IF EXISTS `feature_menu`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_menu` (
  `idfeature_menu` int(11) NOT NULL AUTO_INCREMENT,
  `feature_id` int(11) DEFAULT NULL,
  `idlook_menu_pvt` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idfeature_menu`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_menu_old`
--

DROP TABLE IF EXISTS `feature_menu_old`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_menu_old` (
  `idfeature_menu` int(11) NOT NULL AUTO_INCREMENT,
  `feature_id` int(11) DEFAULT NULL,
  `idlook_menu_pvt` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idfeature_menu`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `feature_old`
--

DROP TABLE IF EXISTS `feature_old`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `feature_old` (
  `feature_no` int(11) NOT NULL AUTO_INCREMENT,
  `feature_id` int(11) DEFAULT NULL,
  `feature_name` varchar(45) DEFAULT NULL,
  `feature_desc` varchar(200) DEFAULT NULL,
  `disp_order` int(11) DEFAULT NULL,
  PRIMARY KEY (`feature_no`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `festival`
--

DROP TABLE IF EXISTS `festival`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `festival` (
  `idfestival` int(11) NOT NULL AUTO_INCREMENT,
  `look_values_id` int(5) DEFAULT NULL,
  `comp_id` int(11) DEFAULT NULL,
  `festival_yr` int(5) DEFAULT NULL,
  `festival_day` date DEFAULT NULL,
  `festival_name` varchar(50) DEFAULT NULL,
  `festival_type` char(5) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idfestival`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hours`
--

DROP TABLE IF EXISTS `hours`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hours` (
  `hour_id` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(9) NOT NULL,
  `comp_id` int(11) DEFAULT NULL,
  `inv_num` int(11) DEFAULT NULL,
  `hoursdate` date DEFAULT NULL,
  `hoursday` varchar(45) DEFAULT NULL,
  `starttime` datetime DEFAULT NULL,
  `endtime` datetime DEFAULT NULL,
  `off_time` float DEFAULT NULL,
  `totaltime` decimal(4,2) DEFAULT NULL,
  `iddev_apps` int(11) DEFAULT NULL,
  `dev_est` int(11) DEFAULT NULL,
  `dev_est_reqs` int(11) DEFAULT NULL,
  `expected_hrs` decimal(4,2) DEFAULT NULL,
  `enterby` int(9) DEFAULT NULL,
  `hrs_type` varchar(5) DEFAULT NULL COMMENT 'B = Billable, N = Non Billable',
  `enter_dt` date DEFAULT NULL,
  `approver` int(11) DEFAULT NULL,
  `approve_by` int(9) DEFAULT NULL,
  `approve_dt` date DEFAULT NULL,
  `timecard_id` int(11) DEFAULT NULL,
  `process_dt` date DEFAULT NULL,
  `process_by` int(9) DEFAULT NULL,
  `summary` varchar(45) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`hour_id`),
  KEY `fkemp_hrs` (`emp_id`),
  KEY `fk_company_hrs` (`comp_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hours_attr`
--

DROP TABLE IF EXISTS `hours_attr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hours_attr` (
  `idhours_attr` int(11) NOT NULL AUTO_INCREMENT,
  `hoursdate` date DEFAULT NULL,
  `hoursday` varchar(45) DEFAULT NULL,
  `new` int(11) DEFAULT NULL,
  `close` int(11) DEFAULT NULL,
  `total` int(11) DEFAULT NULL,
  `added` varchar(45) DEFAULT NULL,
  `completion` varchar(45) DEFAULT NULL,
  `growth` varchar(45) DEFAULT NULL,
  `tol_hr` varchar(45) DEFAULT NULL,
  `comp_id` int(11) DEFAULT NULL,
  `comp_nm` varchar(95) DEFAULT NULL,
  `invoiced` int(11) DEFAULT NULL,
  `iddev_apps` int(11) DEFAULT NULL,
  `app_nm` varchar(45) DEFAULT NULL,
  `dev_est` int(11) DEFAULT NULL,
  `dev_est_nm` varchar(200) DEFAULT NULL,
  `dev_est_reqs` int(11) DEFAULT NULL,
  `dev_est_reqs_nm` varchar(500) DEFAULT NULL,
  `hrs_type` int(11) DEFAULT NULL,
  `enter_by` int(11) DEFAULT NULL,
  `enter_by_nm` varchar(45) DEFAULT NULL,
  `approver` int(11) DEFAULT NULL,
  `approver_nm` varchar(45) DEFAULT NULL,
  `approved_by` int(11) DEFAULT NULL,
  `approved_by_nm` varchar(45) DEFAULT NULL,
  `proccess_by` int(11) DEFAULT NULL,
  `process_by_nm` varchar(45) DEFAULT NULL,
  `parent_idhour_attr` int(11) DEFAULT NULL,
  PRIMARY KEY (`idhours_attr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hours_attr_set`
--

DROP TABLE IF EXISTS `hours_attr_set`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hours_attr_set` (
  `idhours_attr_set` int(11) NOT NULL AUTO_INCREMENT,
  `hoursdate` date DEFAULT NULL,
  `hoursday` varchar(45) DEFAULT NULL,
  `idhours_attr` text,
  `tol_hr` longtext,
  `comp_id` text,
  `comp_nm` longtext,
  `invoiced` longtext,
  `iddev_apps` text,
  `app_nm` longtext,
  `dev_est` text,
  `dev_est_nm` longtext,
  `dev_est_reqs` text,
  `dev_est_reqs_nm` longtext,
  `hrs_type` text,
  `enter_by` text,
  `enter_by_nm` longtext,
  `approver` text,
  `approver_nm` longtext,
  `approved_by` text,
  `approved_by_nm` longtext,
  `proccess_by` text,
  `process_by_nm` longtext,
  PRIMARY KEY (`idhours_attr_set`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hours_card_audit`
--

DROP TABLE IF EXISTS `hours_card_audit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hours_card_audit` (
  `timecard_audit_id` int(11) NOT NULL AUTO_INCREMENT,
  `timcard_id` int(11) DEFAULT NULL,
  `emp_id` int(9) NOT NULL,
  `timefrom_dt` date DEFAULT NULL,
  `timeto_dt` date DEFAULT NULL,
  `timesheet` longblob,
  `total_hrs` varchar(10) DEFAULT NULL,
  `bill_hrs` char(1) DEFAULT NULL,
  `validate_date` date DEFAULT NULL,
  `validate_by` date DEFAULT NULL,
  `summary` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`timecard_audit_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hours_hist`
--

DROP TABLE IF EXISTS `hours_hist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hours_hist` (
  `hour_hist_id` int(11) NOT NULL AUTO_INCREMENT,
  `hour_id` int(11) DEFAULT NULL,
  `comp_id` int(11) DEFAULT NULL,
  `hoursdate` date DEFAULT NULL,
  `hoursday` varchar(45) DEFAULT NULL,
  `starttime` datetime DEFAULT NULL,
  `endtime` datetime DEFAULT NULL,
  `off_time` float DEFAULT NULL,
  `totaltime` decimal(4,2) DEFAULT NULL,
  `enterby` int(9) DEFAULT NULL,
  `hrs_type` char(1) DEFAULT NULL COMMENT 'B = Billable, N = Non Billable',
  `enter_dt` date DEFAULT NULL,
  `approve_by` int(9) DEFAULT NULL,
  `approve_dt` datetime DEFAULT NULL,
  `process_dt` date DEFAULT NULL,
  `process_by` int(9) DEFAULT NULL,
  `summary` varchar(45) DEFAULT NULL,
  `iddev_apps` int(11) DEFAULT NULL,
  `dev_est` int(11) DEFAULT NULL,
  `dev_est_reqs` int(11) DEFAULT NULL,
  PRIMARY KEY (`hour_hist_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hours_lk`
--

DROP TABLE IF EXISTS `hours_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hours_lk` (
  `idhours_lk` int(11) NOT NULL AUTO_INCREMENT,
  `look_name` varchar(45) DEFAULT NULL,
  `look_name_desc` varchar(100) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  PRIMARY KEY (`idhours_lk`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hours_lk_val`
--

DROP TABLE IF EXISTS `hours_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hours_lk_val` (
  `idhours_lk_val` int(11) NOT NULL AUTO_INCREMENT,
  `idhours_lk` int(11) DEFAULT NULL,
  `lk_value` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `lk_value_desc` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idhours_lk_val`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hours_time`
--

DROP TABLE IF EXISTS `hours_time`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hours_time` (
  `timecard_id` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(9) NOT NULL,
  `comp_id` int(10) DEFAULT NULL,
  `timefrom_dt` date DEFAULT NULL,
  `timeto_dt` date DEFAULT NULL,
  `bill_hrs` decimal(5,2) DEFAULT NULL,
  `unbill_hrs` decimal(5,2) DEFAULT NULL,
  `total_hrs` decimal(5,2) DEFAULT NULL,
  `validate_dt` date DEFAULT NULL,
  `validate_by` varchar(10) DEFAULT NULL,
  `summary` varchar(45) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `last_updated` date DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`timecard_id`),
  KEY `fkempid_ts_valid` (`emp_id`),
  KEY `fk_ts_val_comp_engage` (`comp_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hr_meeting`
--

DROP TABLE IF EXISTS `hr_meeting`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hr_meeting` (
  `idhr_meeting` int(5) NOT NULL AUTO_INCREMENT,
  `st_tm_est` time DEFAULT NULL,
  `e_tm_est` time DEFAULT NULL,
  `st_tm_ist` time DEFAULT NULL,
  `e_tm_ist` time DEFAULT NULL,
  `description` varchar(200) DEFAULT NULL,
  `attendances` varchar(200) DEFAULT NULL,
  `scrum_master` varchar(100) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  PRIMARY KEY (`idhr_meeting`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hr_policy`
--

DROP TABLE IF EXISTS `hr_policy`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hr_policy` (
  `idhr_policy` int(11) NOT NULL AUTO_INCREMENT,
  `lk_tag` varchar(30) DEFAULT NULL,
  `lk_tag_desc` varchar(500) DEFAULT NULL,
  `lk_disp_id` int(5) DEFAULT NULL,
  `lk_paren_tag_id` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idhr_policy`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hr_recruite`
--

DROP TABLE IF EXISTS `hr_recruite`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hr_recruite` (
  `idhr_recruite` int(11) NOT NULL AUTO_INCREMENT,
  `recruite_fst_nm` varchar(45) DEFAULT NULL,
  `recruite_last_nm` varchar(45) DEFAULT NULL,
  `recruite_open` date DEFAULT NULL,
  `recruite_close` date DEFAULT NULL,
  `recruite_lvl` int(5) DEFAULT NULL COMMENT '1 ,2, 3, ',
  `recruite_smry` varchar(500) DEFAULT NULL,
  `dob` date DEFAULT NULL,
  `gender` char(1) DEFAULT NULL,
  `call_recv_dt` datetime DEFAULT NULL,
  `nxt_call_dt` datetime DEFAULT NULL,
  `call_note` varchar(100) DEFAULT NULL,
  `attempts` int(5) DEFAULT NULL,
  `attachment` char(1) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idhr_recruite`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hr_recruite_lk`
--

DROP TABLE IF EXISTS `hr_recruite_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hr_recruite_lk` (
  `idhr_recruite_lk` int(11) NOT NULL AUTO_INCREMENT,
  `recruite_name` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  PRIMARY KEY (`idhr_recruite_lk`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hr_recruite_lk_tag`
--

DROP TABLE IF EXISTS `hr_recruite_lk_tag`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hr_recruite_lk_tag` (
  `idhr_recruite_lk_tag` int(11) NOT NULL AUTO_INCREMENT,
  `owner_id` int(11) DEFAULT NULL,
  `lk_tag` varchar(200) DEFAULT NULL,
  `lk_tag_desc` varchar(200) DEFAULT NULL,
  `lk_disp_id` int(5) DEFAULT NULL,
  `lk_parent_tag_id` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idhr_recruite_lk_tag`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hr_recruite_lk_val`
--

DROP TABLE IF EXISTS `hr_recruite_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hr_recruite_lk_val` (
  `idhr_recruite_lk_val` int(11) NOT NULL AUTO_INCREMENT,
  `idhr_recruite_lk` int(11) DEFAULT NULL,
  `hr_value` varchar(45) DEFAULT NULL,
  `hr_value_desc` varchar(100) DEFAULT NULL,
  `disp_order` int(1) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idhr_recruite_lk_val`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hrs_connect`
--

DROP TABLE IF EXISTS `hrs_connect`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hrs_connect` (
  `idhrs_connect` bigint(20) NOT NULL AUTO_INCREMENT,
  `hour_id` int(11) DEFAULT NULL,
  `idhrs_cycle2` int(11) DEFAULT NULL,
  PRIMARY KEY (`idhrs_connect`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hrs_cycle`
--

DROP TABLE IF EXISTS `hrs_cycle`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hrs_cycle` (
  `idhrs_cycle` int(11) NOT NULL AUTO_INCREMENT,
  `comp_id` int(11) DEFAULT NULL,
  `idengage_entity` int(11) DEFAULT NULL,
  `idengage_entity_po` int(11) DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL,
  `hrs_from_dt` date DEFAULT NULL,
  `hrs_to_dt` date DEFAULT NULL,
  `bill_pay_rate` float DEFAULT NULL,
  `hrs_cycle` varchar(10) DEFAULT NULL,
  `cycle` varchar(15) DEFAULT NULL COMMENT 'Timesheet or Billing',
  `expected_hrs` float DEFAULT NULL COMMENT '8 default (Override with approved hrs)',
  `total_hrs` float DEFAULT NULL,
  PRIMARY KEY (`idhrs_cycle`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `hrs_cycle2`
--

DROP TABLE IF EXISTS `hrs_cycle2`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hrs_cycle2` (
  `idhrs_cycle2` bigint(20) NOT NULL AUTO_INCREMENT,
  `idhrs_cycle` int(11) DEFAULT NULL,
  `expected_hrs` int(11) DEFAULT NULL,
  `bill_hrs` float DEFAULT NULL,
  `unbill_hrs` float DEFAULT NULL,
  `total_hrs` float DEFAULT NULL,
  `hrs_date` date DEFAULT NULL,
  PRIMARY KEY (`idhrs_cycle2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_attach`
--

DROP TABLE IF EXISTS `immi_attach`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_attach` (
  `idimmi_attach` int(11) NOT NULL AUTO_INCREMENT,
  `status_id` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idimmi_attach`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_lk`
--

DROP TABLE IF EXISTS `immi_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_lk` (
  `idimmi_lk` int(11) NOT NULL AUTO_INCREMENT,
  `immi_name` varchar(45) DEFAULT NULL,
  `disp_order` int(11) DEFAULT NULL,
  PRIMARY KEY (`idimmi_lk`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_lk_val`
--

DROP TABLE IF EXISTS `immi_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_lk_val` (
  `idimmi_lk_val` int(11) NOT NULL AUTO_INCREMENT,
  `idimmi_look` int(11) DEFAULT NULL,
  `immi_value` varchar(100) DEFAULT NULL,
  `immi_form` char(1) DEFAULT NULL,
  `updater` varchar(100) DEFAULT NULL,
  `disp_order` int(11) DEFAULT NULL,
  `lk_parent_val_id` int(11) DEFAULT NULL,
  `last_updated` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`idimmi_lk_val`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_lk_wrk_flow`
--

DROP TABLE IF EXISTS `immi_lk_wrk_flow`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_lk_wrk_flow` (
  `idimmi_lk_wrk_flow` int(11) NOT NULL AUTO_INCREMENT,
  `id_wrk_flow` int(11) DEFAULT NULL,
  `id_wrk_flow_parent` int(11) DEFAULT NULL,
  `updater` varchar(100) DEFAULT NULL,
  `last_updated` varchar(100) DEFAULT NULL,
  `look_restart` varchar(5) DEFAULT NULL,
  PRIMARY KEY (`idimmi_lk_wrk_flow`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_qry`
--

DROP TABLE IF EXISTS `immi_qry`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_qry` (
  `idimmi_qry` int(11) NOT NULL AUTO_INCREMENT,
  `immi_desc` varchar(150) DEFAULT NULL,
  `immi_desc_detail` text,
  `last_updated` datetime NOT NULL,
  `updated_by` int(11) NOT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  PRIMARY KEY (`idimmi_qry`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_receipt_qry`
--

DROP TABLE IF EXISTS `immi_receipt_qry`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_receipt_qry` (
  `idimmi_receipt_qry` int(11) NOT NULL AUTO_INCREMENT,
  `immi_receipts` int(11) DEFAULT NULL,
  `due_dt` date DEFAULT NULL,
  `qry_stat` char(1) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idimmi_receipt_qry`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_receipt_qry_list`
--

DROP TABLE IF EXISTS `immi_receipt_qry_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_receipt_qry_list` (
  `idimmi_receipt_qry_list` int(11) NOT NULL AUTO_INCREMENT,
  `idimmi_receipt_qry` int(11) DEFAULT NULL,
  `immi_receipts` int(11) DEFAULT NULL,
  `idimmi_qry` int(11) DEFAULT NULL,
  `start_dt` date DEFAULT NULL,
  `end_dt` date DEFAULT NULL,
  `due_dt` date DEFAULT NULL,
  `no_days` int(5) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idimmi_receipt_qry_list`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_receipts`
--

DROP TABLE IF EXISTS `immi_receipts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_receipts` (
  `receipt_id` int(11) NOT NULL AUTO_INCREMENT,
  `comp_id` int(10) DEFAULT NULL,
  `receipt_type` varchar(45) DEFAULT NULL COMMENT 'AD, h1, L1, I-140, 1-485',
  `receipt_no` varchar(45) DEFAULT NULL,
  `immi_ref_id` int(11) DEFAULT NULL,
  `immi_ref_tab` varchar(45) DEFAULT NULL,
  `filed_dt` date DEFAULT NULL,
  `ad_title` int(5) DEFAULT NULL,
  `immi_source` int(5) DEFAULT NULL,
  `occ_code` int(5) DEFAULT NULL,
  `skill_level` int(5) DEFAULT NULL,
  `from_dt` date DEFAULT NULL,
  `to_dt` date DEFAULT NULL,
  `valid_days` int(5) DEFAULT NULL,
  `expire_dt` date DEFAULT NULL,
  `education` int(5) DEFAULT NULL,
  `exp_years` int(5) DEFAULT NULL,
  `salary_type` int(5) DEFAULT NULL,
  `salary_amt` int(10) DEFAULT NULL,
  `look_street_no_id` int(11) DEFAULT NULL,
  `suite_no` varchar(45) DEFAULT NULL,
  `rec_status` int(5) DEFAULT NULL,
  `stat_st_dt` date DEFAULT NULL,
  `stat_e_dt` date DEFAULT NULL,
  `no_days` int(5) DEFAULT NULL,
  `immi_summary` varchar(200) DEFAULT NULL,
  `idlook_stat_order` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` varchar(45) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`receipt_id`),
  UNIQUE KEY `myin` (`receipt_no`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_recpt_parent`
--

DROP TABLE IF EXISTS `immi_recpt_parent`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_recpt_parent` (
  `immi_recpt_parent_id` int(11) NOT NULL AUTO_INCREMENT,
  `receipt_parent_id` int(11) DEFAULT NULL,
  `receipt_child_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`immi_recpt_parent_id`),
  KEY `fk_immi_rcpt_child_id` (`receipt_child_id`),
  KEY `fk_immi_rcpt_parent_id` (`receipt_parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_recpt_qry_list_attach`
--

DROP TABLE IF EXISTS `immi_recpt_qry_list_attach`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_recpt_qry_list_attach` (
  `idimmi_recpt_qry_list_attach` int(11) NOT NULL AUTO_INCREMENT,
  `idimmi_receipt_qry_list` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `updater` int(11) NOT NULL,
  `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`idimmi_recpt_qry_list_attach`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_stat_list`
--

DROP TABLE IF EXISTS `immi_stat_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_stat_list` (
  `status_list_id` int(11) NOT NULL AUTO_INCREMENT,
  `status_id` int(11) DEFAULT NULL,
  `qry_id` int(5) DEFAULT NULL,
  `qry_file_name` int(11) DEFAULT NULL,
  `qry_show` char(1) DEFAULT NULL COMMENT 'Hide or Unhide for employees',
  `target_dt` date DEFAULT NULL,
  `sent_dt` date DEFAULT NULL,
  PRIMARY KEY (`status_list_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_status`
--

DROP TABLE IF EXISTS `immi_status`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_status` (
  `status_id` int(11) NOT NULL AUTO_INCREMENT,
  `receipt_id` int(11) DEFAULT NULL,
  `rec_status` varchar(45) DEFAULT NULL COMMENT 'reg, ins, app, rvk, q, qs, den, wd',
  `stat_dt_dt` date DEFAULT NULL,
  `stat_e_dt` date DEFAULT NULL,
  `no_days` int(5) DEFAULT NULL,
  `idlook_stat_order` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`status_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `immi_status_steps`
--

DROP TABLE IF EXISTS `immi_status_steps`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `immi_status_steps` (
  `idimmi_status_steps` int(11) NOT NULL AUTO_INCREMENT,
  `immi_status_id` int(11) DEFAULT NULL,
  `receipt_id` int(11) DEFAULT NULL,
  `immi_steps_detail` varchar(100) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updater` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idimmi_status_steps`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `inv`
--

DROP TABLE IF EXISTS `inv`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `inv` (
  `inv_num` int(10) NOT NULL AUTO_INCREMENT,
  `comp_id` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `inv_from_ref_tab` varchar(45) DEFAULT NULL,
  `inv_from_ref_id` int(11) DEFAULT NULL,
  `comp_add_ref_id` int(11) DEFAULT NULL,
  `inv_phone` int(15) DEFAULT NULL,
  `comp_add_suite_no` int(15) DEFAULT NULL,
  `inv_email` varchar(45) DEFAULT NULL,
  `invoice_no` int(11) DEFAULT NULL,
  `inv_to_ref_table` varchar(45) DEFAULT NULL,
  `inv_to_ref_id` int(11) DEFAULT NULL COMMENT 'emp or comp or prosp_consult',
  `inv_add_ref_id` int(11) DEFAULT NULL,
  `inv_add_suite_no` int(11) DEFAULT NULL,
  `from_dt` date DEFAULT NULL,
  `to_dt` date DEFAULT NULL,
  `billed_dt` date DEFAULT NULL,
  `due_dt` date DEFAULT NULL,
  `summary` varchar(500) DEFAULT NULL,
  `amt_sub` decimal(9,2) DEFAULT NULL,
  `amt_tax` decimal(9,2) DEFAULT NULL,
  `amt_tol` decimal(9,2) DEFAULT NULL,
  `amt_paid` decimal(9,2) DEFAULT NULL,
  `updatedby` int(10) DEFAULT NULL,
  `lastupdated` datetime NOT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`inv_num`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `inv_atten`
--

DROP TABLE IF EXISTS `inv_atten`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `inv_atten` (
  `idinv_atten` int(11) NOT NULL AUTO_INCREMENT,
  `inv_num` int(11) DEFAULT NULL,
  `inv_attn_name` varchar(45) DEFAULT NULL,
  `inv_attn_contact_type` varchar(45) DEFAULT NULL,
  `inv_attn_contact` varchar(45) DEFAULT NULL,
  `inv__attn_display` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idinv_atten`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `inv_listing`
--

DROP TABLE IF EXISTS `inv_listing`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `inv_listing` (
  `inv_list_id` int(10) NOT NULL AUTO_INCREMENT,
  `inv_num` int(10) DEFAULT NULL,
  `inv_ref_id` varchar(45) DEFAULT NULL,
  `inv_for_ref_id` int(11) DEFAULT NULL,
  `item` int(5) DEFAULT NULL,
  `description` varchar(100) DEFAULT NULL,
  `qty` int(11) DEFAULT NULL,
  `rate` float DEFAULT NULL,
  `amount` decimal(9,2) DEFAULT NULL,
  `tax_rate` float DEFAULT NULL,
  `tax_amount` decimal(9,2) DEFAULT NULL,
  PRIMARY KEY (`inv_list_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `inv_pay`
--

DROP TABLE IF EXISTS `inv_pay`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `inv_pay` (
  `inv_pay_id` int(11) NOT NULL AUTO_INCREMENT,
  `pay_frm_ref_tab` varchar(45) DEFAULT NULL,
  `pay_frm_ref_id` int(11) DEFAULT NULL,
  `pay_frm_acc_code` varchar(45) DEFAULT NULL,
  `pay_type` varchar(45) DEFAULT NULL,
  `pay_type_detail` varchar(45) DEFAULT NULL,
  `pay_net` float DEFAULT NULL COMMENT 'pay_amt - pay_fees\n',
  `pay_fee_percent` float DEFAULT NULL,
  `pay_fees_amt` float DEFAULT '0' COMMENT 'Default = 0 ',
  `pay_amt` float DEFAULT NULL,
  `pay_bal` float DEFAULT NULL COMMENT 'pay_net = pay_bal - inv_pay_apply.inv_amt_split',
  `visible` char(1) DEFAULT NULL,
  `smry` varchar(100) DEFAULT NULL,
  `pay_to_ref_tab` varchar(45) DEFAULT NULL,
  `pay_to_ref_id` int(11) DEFAULT NULL,
  `pay_to_acc_code` varchar(45) DEFAULT NULL,
  `pay_dt` date DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`inv_pay_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `inv_pay_apply`
--

DROP TABLE IF EXISTS `inv_pay_apply`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `inv_pay_apply` (
  `idinv_pay_apply` int(11) NOT NULL AUTO_INCREMENT,
  `inv_pay_id` int(11) DEFAULT NULL,
  `inv_num` int(11) DEFAULT NULL,
  `inv_net` float DEFAULT NULL,
  `inv_fee_percent` float DEFAULT NULL,
  `inv_fee_amt` float DEFAULT NULL,
  `inv_amt_split` decimal(9,2) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idinv_pay_apply`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `inv_pay_apply_amt`
--

DROP TABLE IF EXISTS `inv_pay_apply_amt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `inv_pay_apply_amt` (
  `idinv_pay_apply_amt` int(11) NOT NULL AUTO_INCREMENT,
  `status_ref_id` int(11) DEFAULT NULL,
  `status_amt_ref_id` int(11) DEFAULT NULL,
  `status_ref_tab` varchar(45) DEFAULT NULL,
  `idinv_pay_apply` int(11) DEFAULT NULL,
  `req_paid_amt` float DEFAULT NULL,
  `req_pay_dt` date DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idinv_pay_apply_amt`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invn`
--

DROP TABLE IF EXISTS `invn`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invn` (
  `idinvn` int(11) NOT NULL AUTO_INCREMENT,
  `idcomp_prdt` varchar(45) DEFAULT NULL,
  `prdt_desc` varchar(200) DEFAULT NULL,
  `prdt_invn` char(1) DEFAULT NULL COMMENT 'Do not take input',
  `updater` int(11) DEFAULT NULL COMMENT 'Do not take input',
  `last_updated` datetime DEFAULT NULL COMMENT 'Do not take input',
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idinvn`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invn_lk_val`
--

DROP TABLE IF EXISTS `invn_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invn_lk_val` (
  `idinvn_lk_val` int(11) NOT NULL AUTO_INCREMENT,
  `owner_id` int(11) DEFAULT NULL,
  `lk_val` varchar(200) DEFAULT NULL,
  `lk_val_desc` varchar(250) DEFAULT NULL,
  `lk_disp_id` int(5) DEFAULT NULL,
  `lk_parent_val_id` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idinvn_lk_val`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invn_lk_val_col`
--

DROP TABLE IF EXISTS `invn_lk_val_col`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invn_lk_val_col` (
  `idinvn_lk_val_col` int(11) NOT NULL AUTO_INCREMENT,
  `idcomp_prdt` varchar(45) DEFAULT NULL,
  `comp_id` varchar(45) DEFAULT NULL,
  `companyname` varchar(45) DEFAULT NULL,
  `pdt_nm` varchar(45) DEFAULT NULL,
  `prod_num` varchar(45) DEFAULT NULL,
  `prod_ver` varchar(45) DEFAULT NULL,
  `prdt_family` varchar(45) DEFAULT NULL,
  `asset_look_nm` varchar(45) DEFAULT NULL,
  `asset_look_value_nm` varchar(45) DEFAULT NULL,
  `prdt_invn` varchar(45) DEFAULT NULL,
  `idasset_look` varchar(45) DEFAULT NULL,
  `updater` varchar(45) DEFAULT NULL,
  `updater_name` varchar(45) DEFAULT NULL,
  `idasset_look_value` varchar(45) DEFAULT NULL,
  `last_updated` varchar(45) DEFAULT NULL,
  `1` varchar(45) DEFAULT NULL,
  `2` varchar(45) DEFAULT NULL,
  `4` varchar(45) DEFAULT NULL,
  `3` varchar(45) DEFAULT NULL,
  `5` varchar(45) DEFAULT NULL,
  `6` varchar(45) DEFAULT NULL,
  `7` varchar(45) DEFAULT NULL,
  `8` varchar(45) DEFAULT NULL,
  `9` varchar(45) DEFAULT NULL,
  `10` varchar(45) DEFAULT NULL,
  `11` varchar(45) DEFAULT NULL,
  `12` varchar(45) DEFAULT NULL,
  `13` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idinvn_lk_val_col`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invn_tags`
--

DROP TABLE IF EXISTS `invn_tags`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invn_tags` (
  `idinvn_tags` int(11) NOT NULL AUTO_INCREMENT,
  `idcomp_prdt` int(11) DEFAULT NULL,
  `invn_tags` int(11) DEFAULT NULL,
  `invn_tag_ids` text,
  `invn_tag_list` text,
  PRIMARY KEY (`idinvn_tags`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `lk_prdt_dscnt`
--

DROP TABLE IF EXISTS `lk_prdt_dscnt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `lk_prdt_dscnt` (
  `idlk_prdt_dscnt` int(11) NOT NULL AUTO_INCREMENT,
  `dscnt_name` varchar(45) DEFAULT NULL,
  `dscnt_smry` varchar(200) DEFAULT NULL,
  `updater` int(5) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idlk_prdt_dscnt`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `lk_prdt_dscnt_list`
--

DROP TABLE IF EXISTS `lk_prdt_dscnt_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `lk_prdt_dscnt_list` (
  `idget_prdt_dscnt_list` int(11) NOT NULL AUTO_INCREMENT,
  `idget_prdt_dscnt` varchar(45) DEFAULT NULL,
  `prdt_st_qty` int(11) DEFAULT NULL,
  `prdt_end_qty` varchar(45) DEFAULT NULL,
  `prdt_dscnt` varchar(45) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idget_prdt_dscnt_list`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `load_contracts`
--

DROP TABLE IF EXISTS `load_contracts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `load_contracts` (
  `idload_contracts` int(11) NOT NULL AUTO_INCREMENT,
  `engage_id` int(11) DEFAULT NULL,
  `srv_st_dt` date DEFAULT NULL,
  `srv_e_dt` date DEFAULT NULL,
  `eng_tentitive_en_dt` date DEFAULT NULL,
  `sr_frequency` varchar(45) DEFAULT NULL,
  `srv_paytype` char(5) DEFAULT NULL COMMENT 'credit, invoice, email',
  `srv_amount` float DEFAULT NULL,
  `eg_sumry` varchar(45) DEFAULT NULL,
  `cloud_drive` text,
  `srv_client` int(10) DEFAULT NULL,
  `access_name` varchar(45) DEFAULT NULL,
  `remind` int(5) DEFAULT NULL,
  `comp_id` int(10) DEFAULT NULL,
  `mod_srv_st_dt` varchar(8) DEFAULT NULL,
  `mod_srv_st_dt1` varchar(8) DEFAULT NULL,
  `mod_srv_e_dt` varchar(8) DEFAULT NULL,
  `mod_srv_e_dt1` varchar(8) DEFAULT NULL,
  `mod_eng_tentitive_en_dt` varchar(8) DEFAULT NULL,
  `mod_eng_tentitive_en_dt1` varchar(8) DEFAULT NULL,
  `eng_tentitive_en_dt_filter` varchar(45) DEFAULT NULL,
  `frequency` varchar(200) DEFAULT NULL,
  `paytype` varchar(200) DEFAULT NULL,
  `engage_doc_id` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `srv_client_name` varchar(65) DEFAULT NULL,
  `companyname` varchar(65) DEFAULT NULL,
  `updated_by` varchar(91) DEFAULT NULL,
  `freqypaytype` varchar(401) DEFAULT NULL,
  `last_updter` varchar(114) DEFAULT NULL,
  `last_updter1` varchar(114) DEFAULT NULL,
  `idengage_comp` bigint(11) DEFAULT NULL,
  `client_address` longtext,
  `vendor_address` longtext,
  PRIMARY KEY (`idload_contracts`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `log_global`
--

DROP TABLE IF EXISTS `log_global`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `log_global` (
  `last_update` datetime DEFAULT NULL,
  `updater` varchar(45) DEFAULT NULL,
  `table_update` varchar(200) DEFAULT NULL,
  `actions` varchar(10) DEFAULT NULL,
  `table_id` varchar(500) DEFAULT NULL,
  `col1` varchar(200) DEFAULT NULL,
  `col2` varchar(200) DEFAULT NULL,
  `col3` varchar(200) DEFAULT NULL,
  `col4` varchar(200) DEFAULT NULL,
  `col5` varchar(200) DEFAULT NULL,
  `col6` varchar(200) DEFAULT NULL,
  `idglb_log` bigint(20) NOT NULL AUTO_INCREMENT,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idglb_log`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_city`
--

DROP TABLE IF EXISTS `look_city`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_city` (
  `city_id` int(11) NOT NULL AUTO_INCREMENT,
  `state_id` int(11) DEFAULT NULL,
  `city_name` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`city_id`),
  KEY `fk_look_state_city_idx` (`state_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_country`
--

DROP TABLE IF EXISTS `look_country`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_country` (
  `country_id` int(11) NOT NULL AUTO_INCREMENT,
  `con_name` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`country_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_ip`
--

DROP TABLE IF EXISTS `look_ip`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_ip` (
  `look_ip_id` int(11) NOT NULL AUTO_INCREMENT,
  `ip_add` varchar(150) NOT NULL,
  `ip_country` varchar(150) NOT NULL,
  `ip_state` varchar(150) NOT NULL,
  `ip_city` varchar(150) NOT NULL,
  `ip_latitude` decimal(11,8) NOT NULL,
  `ip_longitude` decimal(11,8) NOT NULL,
  `allow_access` varchar(3) NOT NULL DEFAULT 'Yes',
  PRIMARY KEY (`look_ip_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_menu_ln`
--

DROP TABLE IF EXISTS `look_menu_ln`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_menu_ln` (
  `idlook_menu_ln` int(11) NOT NULL AUTO_INCREMENT,
  `idlk_menu_pub` int(11) DEFAULT NULL,
  `idlook_menu_ln_text` int(11) DEFAULT NULL,
  PRIMARY KEY (`idlook_menu_ln`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_menu_ln_text`
--

DROP TABLE IF EXISTS `look_menu_ln_text`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_menu_ln_text` (
  `idlook_menu_ln_text` int(11) NOT NULL AUTO_INCREMENT,
  `text_name` varchar(50) DEFAULT NULL,
  `text_smry` text,
  `idstorage` int(11) DEFAULT NULL,
  PRIMARY KEY (`idlook_menu_ln_text`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_menu_pub`
--

DROP TABLE IF EXISTS `look_menu_pub`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_menu_pub` (
  `idlook_menu_pub` int(11) NOT NULL AUTO_INCREMENT,
  `lk_values` varchar(200) DEFAULT NULL,
  `lk_value_desc` varchar(250) DEFAULT NULL,
  `lk_value_code` char(4) DEFAULT NULL,
  `lk_display_id` int(5) DEFAULT NULL,
  `lk_sub_value_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`idlook_menu_pub`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_menu_pvt`
--

DROP TABLE IF EXISTS `look_menu_pvt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_menu_pvt` (
  `idlook_menu_pvt` int(11) NOT NULL AUTO_INCREMENT,
  `lk_values` varchar(200) DEFAULT NULL,
  `lk_design` varchar(45) DEFAULT NULL,
  `lk_value_desc` varchar(250) DEFAULT NULL,
  `lk_value_code` char(4) DEFAULT NULL,
  `lk_display_id` int(5) DEFAULT NULL,
  `lk_sub_value_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`idlook_menu_pvt`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_postal`
--

DROP TABLE IF EXISTS `look_postal`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_postal` (
  `postal_id` int(11) NOT NULL AUTO_INCREMENT,
  `city_id` int(11) NOT NULL,
  `zip_code` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`postal_id`),
  KEY `fk_look_city_postal_idx` (`city_id`),
  CONSTRAINT `fk_look_city_postal` FOREIGN KEY (`city_id`) REFERENCES `look_city` (`city_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_state`
--

DROP TABLE IF EXISTS `look_state`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_state` (
  `state_id` int(11) NOT NULL AUTO_INCREMENT,
  `country_id` int(11) DEFAULT NULL,
  `state_name` varchar(45) DEFAULT NULL,
  `state_full_name` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`state_id`),
  KEY `fk_look_coun_state_idx` (`country_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_street`
--

DROP TABLE IF EXISTS `look_street`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_street` (
  `look_street_id` int(11) NOT NULL AUTO_INCREMENT,
  `postal_id` int(11) DEFAULT NULL,
  `street_name` varchar(100) DEFAULT NULL,
  `street_type` int(11) DEFAULT NULL,
  PRIMARY KEY (`look_street_id`),
  KEY `fk_look_postal_street_idx` (`postal_id`),
  CONSTRAINT `fk_look_postal_street` FOREIGN KEY (`postal_id`) REFERENCES `look_postal` (`postal_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_street_no`
--

DROP TABLE IF EXISTS `look_street_no`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_street_no` (
  `look_street_no_id` int(11) NOT NULL AUTO_INCREMENT,
  `look_street_id` int(11) DEFAULT NULL,
  `look_street_no` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`look_street_no_id`),
  KEY `fk_lk_street_lk_street_no_idx` (`look_street_id`),
  CONSTRAINT `fk_lk_street_lk_street_no` FOREIGN KEY (`look_street_id`) REFERENCES `look_street` (`look_street_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_survey`
--

DROP TABLE IF EXISTS `look_survey`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_survey` (
  `idlook_survey` int(11) NOT NULL AUTO_INCREMENT,
  `lk_sec_ques_ans` text,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idlook_survey`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_survey_flow`
--

DROP TABLE IF EXISTS `look_survey_flow`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_survey_flow` (
  `idlook_survey_flow` int(11) NOT NULL AUTO_INCREMENT,
  `idlook_survey` int(11) DEFAULT NULL,
  `survey_name` varchar(45) DEFAULT NULL,
  `look_sub_survey_id` int(11) DEFAULT NULL,
  `survey_text` varchar(45) DEFAULT NULL,
  `survey_points` int(2) DEFAULT NULL,
  `survey_order` int(2) DEFAULT NULL,
  `survey_type` varchar(10) DEFAULT NULL COMMENT 'S = Section, Q = question, etc, later change it to int(5)',
  `updater` int(5) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idlook_survey_flow`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_table`
--

DROP TABLE IF EXISTS `look_table`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_table` (
  `look_table_id` int(11) NOT NULL AUTO_INCREMENT,
  `table_name` varchar(45) DEFAULT NULL,
  `table_summary` varchar(95) DEFAULT NULL,
  PRIMARY KEY (`look_table_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_values`
--

DROP TABLE IF EXISTS `look_values`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_values` (
  `look_values_id` int(11) NOT NULL AUTO_INCREMENT,
  `look_table` int(11) DEFAULT NULL,
  `look_values` varchar(200) DEFAULT NULL,
  `look_value_desc` varchar(250) DEFAULT NULL,
  `look_value_code` char(4) DEFAULT NULL,
  `look_display_id` int(5) DEFAULT NULL,
  `look_sub_value_id` int(11) DEFAULT NULL,
  `look_xtra_txt_code` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`look_values_id`),
  KEY `fk_look_value` (`look_table`),
  KEY `fk_look_table` (`look_table`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_web`
--

DROP TABLE IF EXISTS `look_web`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_web` (
  `idlook_web` int(11) NOT NULL AUTO_INCREMENT,
  `fees_columns` int(2) DEFAULT NULL,
  `fees_smry` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`idlook_web`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_web_cart`
--

DROP TABLE IF EXISTS `look_web_cart`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_web_cart` (
  `idlook_web_cart` int(11) NOT NULL AUTO_INCREMENT,
  `lk_ip_address` varchar(500) DEFAULT NULL,
  `lk_cookie_info` varchar(200) DEFAULT NULL,
  `lk_browser_nm` varchar(45) DEFAULT NULL,
  `lk_prodt_id` int(11) DEFAULT NULL,
  `lk_prodt_name` varchar(200) DEFAULT NULL,
  `lk_prodt_head_id` int(5) DEFAULT NULL,
  `lk_prodt_head` varchar(45) DEFAULT NULL COMMENT 'Online, Virtual, ',
  `lk_qty` int(5) DEFAULT NULL,
  `lk_prodt_pr_id` int(5) DEFAULT NULL,
  `lk_prodt_pr` float DEFAULT NULL,
  `lk_web_loc_id` int(5) DEFAULT NULL COMMENT 'Hardware id',
  `lk_web_loc_nm` varchar(45) DEFAULT NULL,
  `lk_web_dt_id` int(5) DEFAULT NULL,
  `lk_web_dt_val` datetime DEFAULT NULL,
  `offered_by_id` int(11) DEFAULT NULL,
  `offered_by_name` varchar(45) DEFAULT NULL,
  `added_dt` datetime DEFAULT NULL,
  `idget_prdt_dscnt` int(11) DEFAULT NULL,
  `prdt_dscn_on` varchar(45) DEFAULT NULL,
  `dscnt_from` date DEFAULT NULL,
  `dscnt_end` date DEFAULT NULL,
  `dscnt_pcnt` float DEFAULT NULL,
  `dscnt_amt` float DEFAULT NULL,
  `dscnt_net` float DEFAULT NULL,
  `idget_cpn_code` int(11) DEFAULT NULL,
  `cpn_number` varchar(45) DEFAULT NULL,
  `cpn_expire` date DEFAULT NULL,
  `cp_ad_wrd` varchar(45) DEFAULT NULL,
  `idtax_rate` int(11) DEFAULT NULL,
  `tax_pcnt` float DEFAULT NULL,
  `tax_amt` float DEFAULT NULL,
  `tot_amt` float DEFAULT NULL,
  PRIMARY KEY (`idlook_web_cart`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_web_cfrm`
--

DROP TABLE IF EXISTS `look_web_cfrm`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_web_cfrm` (
  `idlook_web_cfrm` int(11) NOT NULL,
  `idlook_web_chkout` varchar(45) DEFAULT NULL,
  `lk_ip_address` varchar(200) DEFAULT NULL,
  `lk_browser_nm` varchar(200) DEFAULT NULL,
  `pay_selection` varchar(45) DEFAULT NULL,
  `full_name` int(5) DEFAULT NULL,
  `email_address` varchar(45) DEFAULT NULL,
  `contact_info` varchar(200) DEFAULT NULL,
  `cust_note` varchar(200) DEFAULT NULL COMMENT 'Best time to call, ',
  `or_ser_pro_confirmation` varchar(45) DEFAULT NULL,
  `or_ser_pro_info_from_ext_site` varchar(45) DEFAULT NULL,
  `or_ser_pro_info_from_ext_site2` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idlook_web_cfrm`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_web_chkout`
--

DROP TABLE IF EXISTS `look_web_chkout`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_web_chkout` (
  `idlook_web_chkout` int(11) NOT NULL AUTO_INCREMENT,
  `lk_ip_address` varchar(500) DEFAULT NULL,
  `lk_cookie_info` varchar(200) DEFAULT NULL,
  `lk_browser_nm` varchar(45) DEFAULT NULL,
  `lk_prodt_id` int(11) DEFAULT NULL,
  `lk_prodt_name` varchar(200) DEFAULT NULL,
  `lk_prodt_head_id` int(5) DEFAULT NULL,
  `lk_prodt_head` varchar(45) DEFAULT NULL COMMENT 'Online, Virtual, ',
  `lk_qty` int(5) DEFAULT NULL,
  `lk_prodt_pr_id` int(5) DEFAULT NULL,
  `lk_prodt_pr` float DEFAULT NULL,
  `lk_web_loc_id` int(5) DEFAULT NULL COMMENT 'Hardware id',
  `lk_web_loc_nm` varchar(45) DEFAULT NULL,
  `lk_web_dt_id` int(5) DEFAULT NULL,
  `lk_web_dt_val` datetime DEFAULT NULL,
  `offered_by_id` int(11) DEFAULT NULL,
  `offered_by_name` varchar(45) DEFAULT NULL,
  `added_dt` datetime DEFAULT NULL,
  `purchase_dt` datetime DEFAULT NULL COMMENT 'date provided details',
  `trans_dt` datetime DEFAULT NULL,
  `idget_prdt_dscnt` int(11) DEFAULT NULL,
  `prdt_dscn_on` varchar(45) DEFAULT NULL COMMENT 'Fees, location, web, ',
  `dscnt_from` date DEFAULT NULL,
  `dscnt_end` date DEFAULT NULL,
  `dscnt_pcnt` float DEFAULT NULL,
  `dscnt_amt` float DEFAULT NULL,
  `dscnt_net` float DEFAULT NULL,
  `idget_cpn_code` int(11) DEFAULT NULL,
  `cpn_number` varchar(45) DEFAULT NULL,
  `cpn_expire` date DEFAULT NULL,
  `cpn_ad_wrd` varchar(45) DEFAULT NULL,
  `idtax_rate` int(11) DEFAULT NULL,
  `tax_pcnt` float DEFAULT NULL,
  `tax_amt` float DEFAULT NULL,
  `tot_amt` float DEFAULT NULL,
  PRIMARY KEY (`idlook_web_chkout`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_web_dt`
--

DROP TABLE IF EXISTS `look_web_dt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_web_dt` (
  `idlook_web_dt` int(11) NOT NULL AUTO_INCREMENT,
  `look_web_loc` int(11) DEFAULT NULL,
  `look_course_dt` datetime DEFAULT NULL,
  `offered_by` int(11) DEFAULT NULL COMMENT 'emp_id, if null show nothing',
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idlook_web_dt`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_web_fees`
--

DROP TABLE IF EXISTS `look_web_fees`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_web_fees` (
  `idlook_web_fees` int(11) NOT NULL AUTO_INCREMENT,
  `idlook_web` int(11) DEFAULT NULL,
  `column_header` int(11) DEFAULT NULL,
  `column_price` int(11) DEFAULT NULL,
  `column_order` int(11) DEFAULT NULL,
  `column_mandate` char(1) DEFAULT NULL COMMENT 'M',
  `col_max_dscn` float DEFAULT NULL,
  `idtax_rate` int(11) DEFAULT NULL,
  PRIMARY KEY (`idlook_web_fees`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `look_web_loc`
--

DROP TABLE IF EXISTS `look_web_loc`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `look_web_loc` (
  `idlook_web_loc` int(11) NOT NULL AUTO_INCREMENT,
  `look_course_id` int(5) DEFAULT NULL COMMENT 'Look value id',
  `look_course_loc` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idlook_web_loc`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mail_server`
--

DROP TABLE IF EXISTS `mail_server`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mail_server` (
  `mail_id` int(2) NOT NULL AUTO_INCREMENT,
  `mail_server_port` int(11) DEFAULT NULL,
  `user_id` varchar(45) DEFAULT NULL,
  `password` varbinary(45) DEFAULT NULL,
  `usage_order` int(2) DEFAULT NULL COMMENT '1, 2, 3, 4, 5, 6 ……',
  PRIMARY KEY (`mail_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 MAX_ROWS=999999999 COMMENT='Used to store Mail Server details';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_assist`
--

DROP TABLE IF EXISTS `mkt_assist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_assist` (
  `idmkt_assist` int(11) NOT NULL AUTO_INCREMENT,
  `idmkt_open` int(11) DEFAULT NULL,
  `assist_ref_table` varchar(45) DEFAULT NULL,
  `assist_ref_id` varchar(45) DEFAULT NULL,
  `assist_rate` decimal(7,2) DEFAULT NULL,
  `summary` varchar(100) DEFAULT NULL,
  `assist_status` int(5) DEFAULT NULL,
  `stat_st_dt` date DEFAULT NULL,
  `stat_e_dt` date DEFAULT NULL,
  `no_days` int(5) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `idlook_stat_order` int(5) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idmkt_assist`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_assist_inc`
--

DROP TABLE IF EXISTS `mkt_assist_inc`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_assist_inc` (
  `idassist` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `idmkt_lk_val` int(11) DEFAULT NULL,
  `from_dt` datetime DEFAULT NULL,
  `to_dt` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `assist_amt` float DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idassist`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_assist_stat_amt`
--

DROP TABLE IF EXISTS `mkt_assist_stat_amt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_assist_stat_amt` (
  `idmkt_assist_stat_amt` int(11) NOT NULL AUTO_INCREMENT,
  `idmkt_assist_status` int(11) DEFAULT NULL,
  `assist_amt` varchar(45) DEFAULT NULL,
  `assist_action` int(5) DEFAULT NULL COMMENT '(approve, denial, pending)',
  `status_by` int(11) DEFAULT NULL,
  `assist_bal` varchar(45) DEFAULT NULL,
  `assist_paid` varchar(45) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updated_on` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idmkt_assist_stat_amt`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_assist_status`
--

DROP TABLE IF EXISTS `mkt_assist_status`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_assist_status` (
  `idmkt_assist_status` int(11) NOT NULL AUTO_INCREMENT,
  `idmkt_assist` int(11) DEFAULT NULL,
  `assist_status` int(5) DEFAULT NULL,
  `stat_st_dt` date DEFAULT NULL,
  `stat_e_dt` date DEFAULT NULL,
  `no_days` int(5) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `idlook_stat_order` int(5) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idmkt_assist_status`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_assist_status_steps`
--

DROP TABLE IF EXISTS `mkt_assist_status_steps`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_assist_status_steps` (
  `idmkt_assist_status_steps` int(11) NOT NULL AUTO_INCREMENT,
  `idmkt_assist` int(11) DEFAULT NULL,
  `idmkt_assist_status` int(11) DEFAULT NULL,
  `mkt_steps_detail` varchar(100) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  PRIMARY KEY (`idmkt_assist_status_steps`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_company`
--

DROP TABLE IF EXISTS `mkt_company`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_company` (
  `idmkt_company` int(11) NOT NULL AUTO_INCREMENT,
  `companyname` varchar(100) DEFAULT NULL,
  `company_info` varchar(500) DEFAULT NULL,
  `comp_website` varchar(45) DEFAULT NULL,
  `comp_phone` varchar(45) DEFAULT NULL,
  `comp_email` varchar(45) DEFAULT NULL,
  `acc_mgr` int(11) DEFAULT NULL,
  `req_type` int(11) DEFAULT NULL,
  `track` int(5) DEFAULT NULL,
  `block` int(5) DEFAULT NULL,
  `block_dt` date DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` varchar(45) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idmkt_company`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_lk`
--

DROP TABLE IF EXISTS `mkt_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_lk` (
  `idmkt_lk` int(11) NOT NULL AUTO_INCREMENT,
  `mkt_name` varchar(45) DEFAULT NULL,
  `disp_order` int(11) DEFAULT NULL,
  PRIMARY KEY (`idmkt_lk`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_lk_val`
--

DROP TABLE IF EXISTS `mkt_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_lk_val` (
  `idmkt_lk_val` int(11) NOT NULL AUTO_INCREMENT,
  `idmkt_lk` int(11) DEFAULT NULL,
  `mkt_value` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idmkt_lk_val`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_lk_wrk_flow`
--

DROP TABLE IF EXISTS `mkt_lk_wrk_flow`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_lk_wrk_flow` (
  `idmkt_wrk_flow` int(11) NOT NULL AUTO_INCREMENT,
  `id_wrk_flow` int(11) DEFAULT NULL,
  `id_wrk_flow_parent` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idmkt_wrk_flow`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_open`
--

DROP TABLE IF EXISTS `mkt_open`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_open` (
  `idmkt_open` int(11) NOT NULL AUTO_INCREMENT,
  `compname` int(11) DEFAULT NULL,
  `client_name` int(11) DEFAULT NULL,
  `req_source` int(5) DEFAULT NULL,
  `acc_mgr` int(11) DEFAULT NULL,
  `req_type` int(11) DEFAULT NULL,
  `track` int(5) DEFAULT NULL,
  `no_days` int(5) DEFAULT NULL,
  `location` int(11) DEFAULT NULL,
  `contact_info` varchar(200) DEFAULT NULL,
  `open_details` varchar(200) DEFAULT NULL,
  `open_dt` date DEFAULT NULL,
  `summary` varchar(100) DEFAULT NULL,
  `close_dt` date DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` varchar(45) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idmkt_open`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mkt_open_log`
--

DROP TABLE IF EXISTS `mkt_open_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mkt_open_log` (
  `idmkt_open_log` int(11) NOT NULL AUTO_INCREMENT,
  `compname` varchar(100) DEFAULT NULL,
  `idmkt_open` int(11) DEFAULT NULL,
  `client_name` varchar(100) DEFAULT NULL,
  `req_source` varchar(45) DEFAULT NULL,
  `location` varchar(50) DEFAULT NULL,
  `contact_info` varchar(200) DEFAULT NULL,
  `open_details` varchar(200) DEFAULT NULL,
  `req_type` varchar(11) DEFAULT NULL,
  `track` varchar(5) DEFAULT NULL,
  `open_dt` date DEFAULT NULL,
  `summary` varchar(100) DEFAULT NULL,
  `close_dt` date DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` varchar(45) DEFAULT NULL,
  `updated_name` varchar(45) DEFAULT NULL,
  `trans_type` char(1) DEFAULT NULL,
  PRIMARY KEY (`idmkt_open_log`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `msg`
--

DROP TABLE IF EXISTS `msg`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `msg` (
  `msg_id` int(11) NOT NULL AUTO_INCREMENT,
  `msg_type` varchar(45) NOT NULL COMMENT 'Mail or Chat',
  PRIMARY KEY (`msg_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `msg_receiver`
--

DROP TABLE IF EXISTS `msg_receiver`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `msg_receiver` (
  `msg_receiver_id` int(11) NOT NULL AUTO_INCREMENT,
  `msg_sent_id` int(11) NOT NULL,
  `usr_receiver` int(11) NOT NULL,
  PRIMARY KEY (`msg_receiver_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `msg_sent`
--

DROP TABLE IF EXISTS `msg_sent`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `msg_sent` (
  `msg_sent_id` int(11) NOT NULL AUTO_INCREMENT,
  `msg_id` int(11) NOT NULL,
  `sent_by` int(11) NOT NULL,
  `subject` varchar(150) DEFAULT NULL,
  `body` varchar(1000) DEFAULT NULL,
  `sent_dt` date DEFAULT NULL,
  `msg_size` varchar(10) DEFAULT NULL COMMENT '1kb, 1mb, 50mb',
  `msg_sub_id` int(11) DEFAULT NULL COMMENT 'reply to id',
  PRIMARY KEY (`msg_sent_id`),
  KEY `fk_msg_msg_sent_id` (`msg_id`),
  CONSTRAINT `fk_msg_msg_sent_id` FOREIGN KEY (`msg_id`) REFERENCES `msg` (`msg_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `msg_status`
--

DROP TABLE IF EXISTS `msg_status`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `msg_status` (
  `msg_status_id` int(11) NOT NULL AUTO_INCREMENT,
  `msg_rec_id` int(11) NOT NULL,
  `msg_status` char(1) DEFAULT 'N' COMMENT 'N=New, O-old',
  `msg_flag` char(1) DEFAULT NULL COMMENT '1=High, 5=Low',
  `msg_folder` varchar(45) DEFAULT NULL COMMENT 'Inbox, Archive, Sent, Trash',
  `action_dt` date DEFAULT NULL,
  PRIMARY KEY (`msg_status_id`),
  KEY `fk_msg_rec_msg_status_idx` (`msg_rec_id`),
  CONSTRAINT `fk_msg_rec_msg_status` FOREIGN KEY (`msg_rec_id`) REFERENCES `msg_receiver` (`msg_receiver_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `net_domain_fwd`
--

DROP TABLE IF EXISTS `net_domain_fwd`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `net_domain_fwd` (
  `idnet_domain_fwd` int(11) NOT NULL AUTO_INCREMENT,
  `url_rcvd` text,
  `url_fwd` text,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idnet_domain_fwd`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `net_scrpt_sc_log`
--

DROP TABLE IF EXISTS `net_scrpt_sc_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `net_scrpt_sc_log` (
  `idnet_scrpt_sc_log` int(11) NOT NULL AUTO_INCREMENT,
  `folder_nm` varchar(25) DEFAULT NULL,
  `file_nm` varchar(25) DEFAULT NULL,
  `hostnm` varchar(45) DEFAULT NULL COMMENT 'dev1',
  `access_by` varchar(45) DEFAULT NULL COMMENT 'Name “Jiten Patel”',
  `port` int(5) DEFAULT NULL COMMENT '80, 443',
  `access_msg` varchar(45) DEFAULT NULL,
  `access_dt` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` varchar(45) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idnet_scrpt_sc_log`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `net_ser`
--

DROP TABLE IF EXISTS `net_ser`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `net_ser` (
  `idnet_ser` int(11) NOT NULL AUTO_INCREMENT,
  `hostnm` varchar(10) DEFAULT NULL,
  `dep_usr` char(1) DEFAULT NULL,
  `host_conf` varchar(100) DEFAULT NULL,
  `hosted` varchar(100) DEFAULT NULL,
  `hostdm` varchar(25) DEFAULT NULL,
  `host_type` varchar(45) DEFAULT NULL,
  `host_mst` varchar(10) DEFAULT NULL,
  `ip_lan` varchar(45) DEFAULT NULL,
  `ip_wan` varchar(45) DEFAULT NULL,
  `ip_usr` varchar(45) DEFAULT NULL,
  `gateway` varchar(10) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updated_on` datetime DEFAULT NULL,
  PRIMARY KEY (`idnet_ser`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `net_ser_clone`
--

DROP TABLE IF EXISTS `net_ser_clone`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `net_ser_clone` (
  `idnet_clone` int(11) NOT NULL AUTO_INCREMENT,
  `idnet_ser` int(11) DEFAULT NULL,
  `mst_app` varchar(45) DEFAULT NULL,
  `cloned_app` varchar(45) DEFAULT NULL,
  `code_bk` int(3) DEFAULT NULL,
  `db_bk` int(3) DEFAULT NULL,
  `valid_days` int(11) DEFAULT NULL,
  `validity` datetime DEFAULT NULL,
  `alert_days` int(11) DEFAULT NULL,
  `app_url` varchar(45) DEFAULT NULL,
  `deleted_on` datetime DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updated_on` datetime DEFAULT NULL,
  PRIMARY KEY (`idnet_clone`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `net_tb_vw`
--

DROP TABLE IF EXISTS `net_tb_vw`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `net_tb_vw` (
  `idnet_tb_vw` int(5) NOT NULL AUTO_INCREMENT,
  `updated_on` datetime DEFAULT NULL,
  `qry` longtext,
  `updater` int(11) DEFAULT NULL,
  PRIMARY KEY (`idnet_tb_vw`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `pay`
--

DROP TABLE IF EXISTS `pay`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pay` (
  `pay_id` int(11) NOT NULL AUTO_INCREMENT,
  `emp_id` int(11) DEFAULT NULL,
  `pay_cycle` int(5) DEFAULT NULL COMMENT 'monthly, semi-mon',
  PRIMARY KEY (`pay_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `pay_allow`
--

DROP TABLE IF EXISTS `pay_allow`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pay_allow` (
  `pay_allow_id` int(11) NOT NULL AUTO_INCREMENT,
  `pay_id` int(11) DEFAULT NULL,
  `allowance_type` varchar(45) DEFAULT NULL COMMENT 'Perdiem',
  PRIMARY KEY (`pay_allow_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `pay_allow_dt`
--

DROP TABLE IF EXISTS `pay_allow_dt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pay_allow_dt` (
  `pay_allow_dt_id` int(11) NOT NULL AUTO_INCREMENT,
  `pay_allow_id` int(11) DEFAULT NULL,
  `allow_from_dt` date DEFAULT NULL,
  `allow_to_dt` date DEFAULT NULL,
  `allow` int(6) DEFAULT NULL COMMENT '1000, 20, 10',
  `allow_calc` varchar(45) DEFAULT NULL COMMENT '$, %, #',
  `summary` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`pay_allow_dt_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `pay_deduct`
--

DROP TABLE IF EXISTS `pay_deduct`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pay_deduct` (
  `pay_deduct_id` int(9) NOT NULL,
  `bill_pay_detail` int(9) DEFAULT NULL,
  PRIMARY KEY (`pay_deduct_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `pay_detail`
--

DROP TABLE IF EXISTS `pay_detail`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pay_detail` (
  `pay_detail_id` int(11) NOT NULL AUTO_INCREMENT,
  `pay_id` int(9) DEFAULT NULL,
  `pay_from_dt` date DEFAULT NULL,
  `pay_to_dt` date DEFAULT NULL,
  `pay_amt` float DEFAULT NULL,
  `pay_dt` date DEFAULT NULL,
  PRIMARY KEY (`pay_detail_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `pay_dt`
--

DROP TABLE IF EXISTS `pay_dt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pay_dt` (
  `pay_dt_id` int(11) NOT NULL AUTO_INCREMENT,
  `pay_id` int(11) DEFAULT NULL,
  `pay_type` int(5) DEFAULT NULL COMMENT 'Cash, Fixed, Hourly, Daily',
  `pay_amt` decimal(9,2) DEFAULT NULL,
  `pay_st_dt` date DEFAULT NULL,
  `pay_e_dt` date DEFAULT NULL,
  `wrk_hr` int(4) DEFAULT NULL,
  `pay_summary` varchar(95) DEFAULT NULL,
  PRIMARY KEY (`pay_dt_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_activity`
--

DROP TABLE IF EXISTS `prosp_activity`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_activity` (
  `prosp_activity_id` int(11) NOT NULL AUTO_INCREMENT,
  `prosp_consult_id` int(11) DEFAULT NULL,
  `call_recv_dt` date DEFAULT NULL,
  `emp_id` varchar(11) DEFAULT NULL,
  `next_call_dt` date NOT NULL,
  `call_note` varchar(100) DEFAULT NULL,
  `last_update` datetime DEFAULT NULL,
  PRIMARY KEY (`prosp_activity_id`),
  KEY `fk_prosp_consult_activity_idx` (`prosp_consult_id`),
  CONSTRAINT `fk_prosp_consult_activity` FOREIGN KEY (`prosp_consult_id`) REFERENCES `prosp_consult` (`prosp_consult_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_attach`
--

DROP TABLE IF EXISTS `prosp_attach`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_attach` (
  `idprosp_attach` int(11) NOT NULL AUTO_INCREMENT,
  `idstorage` int(11) DEFAULT NULL,
  `prosp_consult_id` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idprosp_attach`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_consult`
--

DROP TABLE IF EXISTS `prosp_consult`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_consult` (
  `prosp_consult_id` int(11) NOT NULL AUTO_INCREMENT,
  `prosp_first_name` varchar(60) DEFAULT NULL,
  `prosp_last_name` varchar(45) DEFAULT NULL,
  `prosp_level` int(1) DEFAULT NULL COMMENT '1 through 5 for priority',
  `prosp_summary` varchar(500) DEFAULT NULL,
  `dob` date DEFAULT NULL,
  `ssn` varchar(20) DEFAULT NULL,
  `taxid` varchar(45) DEFAULT NULL,
  `gender` int(5) DEFAULT NULL,
  `archive` int(5) DEFAULT NULL,
  `archive_by` int(5) DEFAULT NULL,
  `archive_dt` date DEFAULT NULL,
  `emp` int(11) DEFAULT NULL,
  `emp_assigned_id` int(11) DEFAULT NULL,
  `call_recv_dt` datetime DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL,
  `next_call_dt` datetime DEFAULT NULL,
  `call_note` text,
  `last_updated` datetime DEFAULT NULL,
  `attachment` char(1) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`prosp_consult_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_consult_log`
--

DROP TABLE IF EXISTS `prosp_consult_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_consult_log` (
  `prosp_consult_log_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `prosp_consult_id` int(11) DEFAULT NULL,
  `prosp_first_name` varchar(45) DEFAULT NULL,
  `prosp_last_name` varchar(45) DEFAULT NULL,
  `prosp_level` int(11) DEFAULT NULL,
  `prosp_summary` varchar(500) DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL,
  `nickname` varchar(5) DEFAULT NULL,
  `prosp_tags` text,
  `called_on` date DEFAULT NULL,
  `next_call_dt` date DEFAULT NULL,
  `call_note` text,
  `prosp_contact` text,
  `prosp_attach` varchar(500) DEFAULT NULL,
  `last_update` datetime DEFAULT NULL,
  `updater` varchar(100) DEFAULT NULL,
  `trans_type` char(1) DEFAULT NULL COMMENT 'A, N, O, D',
  PRIMARY KEY (`prosp_consult_log_id`),
  KEY `prosp_consult` (`prosp_consult_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_consult_merger`
--

DROP TABLE IF EXISTS `prosp_consult_merger`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_consult_merger` (
  `prosp_consult_id` int(11) NOT NULL DEFAULT '0',
  `prosp_first_name` varchar(60) DEFAULT NULL,
  `prosp_last_name` varchar(45) DEFAULT NULL,
  `nickname` char(0) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `gender` int(5) DEFAULT NULL,
  `emp_assigned_id` int(11) DEFAULT NULL,
  `mod_call_recv_dt` varchar(8) CHARACTER SET utf8 DEFAULT NULL,
  `call_recv_dt` datetime DEFAULT NULL,
  `mod_next_call_dt` varchar(8) CHARACTER SET utf8 DEFAULT NULL,
  `next_call_dt` datetime DEFAULT NULL,
  `call_note` text,
  `prosp_summary` varchar(500) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `mod_last_updated` varchar(116) DEFAULT NULL,
  `prosp_level` int(1) DEFAULT NULL COMMENT '1 through 5 for priority',
  `prosp_lvl_desc` varchar(200) DEFAULT NULL,
  `contacts` longtext,
  `prosp_tag` longtext,
  `file_group` longtext,
  `258` decimal(23,0) DEFAULT NULL,
  `1358` decimal(23,0) DEFAULT NULL,
  `1369` decimal(23,0) DEFAULT NULL,
  `1666` decimal(23,0) DEFAULT NULL,
  `259` decimal(23,0) DEFAULT NULL,
  `67` decimal(23,0) DEFAULT NULL,
  `1707` decimal(23,0) DEFAULT NULL,
  `262` decimal(23,0) DEFAULT NULL,
  `263` decimal(23,0) DEFAULT NULL,
  `1022` decimal(23,0) DEFAULT NULL,
  `260` decimal(23,0) DEFAULT NULL,
  `261` decimal(23,0) DEFAULT NULL,
  `289` decimal(23,0) DEFAULT NULL,
  `290` decimal(23,0) DEFAULT NULL,
  `291` decimal(23,0) DEFAULT NULL,
  `293` decimal(23,0) DEFAULT NULL,
  `297` decimal(23,0) DEFAULT NULL,
  `1405` decimal(23,0) DEFAULT NULL,
  `255` decimal(23,0) DEFAULT NULL,
  `256` decimal(23,0) DEFAULT NULL,
  `295` decimal(23,0) DEFAULT NULL,
  `296` decimal(23,0) DEFAULT NULL,
  `975` decimal(23,0) DEFAULT NULL,
  `974` decimal(23,0) DEFAULT NULL,
  `973` decimal(23,0) DEFAULT NULL,
  `1417` decimal(23,0) DEFAULT NULL,
  `1418` decimal(23,0) DEFAULT NULL,
  `1678` decimal(23,0) DEFAULT NULL,
  `1680` decimal(23,0) DEFAULT NULL,
  `1706` decimal(23,0) DEFAULT NULL,
  `1682` decimal(23,0) DEFAULT NULL,
  `1684` decimal(23,0) DEFAULT NULL,
  `1686` decimal(23,0) DEFAULT NULL,
  `1687` decimal(23,0) DEFAULT NULL,
  `1688` decimal(23,0) DEFAULT NULL,
  `121` int(1) NOT NULL DEFAULT '0',
  `3` int(1) NOT NULL DEFAULT '0',
  `32` int(1) NOT NULL DEFAULT '0',
  `33` int(1) NOT NULL DEFAULT '0',
  `288` int(1) NOT NULL DEFAULT '0',
  `253` int(1) NOT NULL DEFAULT '0',
  `294` int(1) NOT NULL DEFAULT '0',
  `972` int(1) NOT NULL DEFAULT '0',
  `1416` int(1) NOT NULL DEFAULT '0',
  `1677` int(1) NOT NULL DEFAULT '0',
  `1681` int(1) NOT NULL DEFAULT '0',
  `1685` int(1) NOT NULL DEFAULT '0',
  `Total_Missing` int(1) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_contact`
--

DROP TABLE IF EXISTS `prosp_contact`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_contact` (
  `prosp_contact_id` int(11) NOT NULL AUTO_INCREMENT,
  `prosp_consult_id` int(9) DEFAULT NULL,
  `contact_id` int(11) DEFAULT NULL COMMENT 'email, cell, work, home',
  `prosp_contact_type` varchar(45) DEFAULT NULL,
  `summary` varchar(95) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`prosp_contact_id`),
  KEY `fk_prosp_contact_consult_idx` (`prosp_consult_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_conversion`
--

DROP TABLE IF EXISTS `prosp_conversion`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_conversion` (
  `idprosp_conversion` int(11) NOT NULL AUTO_INCREMENT,
  `table_name` varchar(50) NOT NULL COMMENT 'Name of the table from where data is to be picked uo',
  `key_col_name` varchar(50) NOT NULL COMMENT 'Name of the primary key column',
  `ref_table_col_name` varchar(50) NOT NULL COMMENT 'Name of the reference table',
  `table_to_update` varchar(50) NOT NULL COMMENT 'Table in which data to be updated',
  `table_to_insert` varchar(50) NOT NULL COMMENT 'Table in which data is to be inserted',
  `action` varchar(10) NOT NULL COMMENT 'u: Update, d: Delete, i: Insert',
  `fetch_cols` varchar(200) NOT NULL COMMENT 'list of the program variables that are to be fetched while inserting or updating the data',
  `insert_cols` varchar(200) NOT NULL COMMENT 'list of the columns in which the data is to be inserted',
  `where_col_name` varchar(50) NOT NULL COMMENT 'Name of the column to be used in where clause condition',
  `where_col_value` varchar(200) NOT NULL COMMENT 'Value of the column to be matched in where clause condition',
  PRIMARY KEY (`idprosp_conversion`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_convert`
--

DROP TABLE IF EXISTS `prosp_convert`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_convert` (
  `idprosp_convert` int(11) NOT NULL AUTO_INCREMENT,
  `tablename` varchar(45) DEFAULT NULL,
  `table_id_col` varchar(45) DEFAULT NULL,
  `table_val_col` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idprosp_convert`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_corp`
--

DROP TABLE IF EXISTS `prosp_corp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_corp` (
  `idprosp_corp` int(11) NOT NULL AUTO_INCREMENT,
  `prosp_corp_type` int(5) DEFAULT NULL COMMENT 'Individual / company',
  `corp_entity_name` varchar(95) DEFAULT NULL,
  `corp_source` int(5) DEFAULT NULL,
  `corp_level` int(5) DEFAULT NULL,
  `response` int(5) DEFAULT NULL,
  `corp_contacts` varchar(300) DEFAULT NULL,
  `corp_address` varchar(300) DEFAULT NULL,
  `register_yr` varchar(45) DEFAULT NULL,
  `register_state` varchar(45) DEFAULT NULL,
  `start_dt` date DEFAULT NULL,
  `acc_mgr` int(11) DEFAULT NULL,
  `end_dt` date DEFAULT NULL,
  `st_end_tm` int(11) DEFAULT NULL,
  `topic_discussed` varchar(300) DEFAULT NULL,
  `topic_count` int(5) DEFAULT NULL,
  `about_corp` varchar(300) DEFAULT NULL,
  `access_name` varchar(20) DEFAULT NULL,
  `tentative_en_dt` date DEFAULT NULL,
  `remind` int(3) DEFAULT NULL,
  `vm_count` int(5) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idprosp_corp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_corp_access`
--

DROP TABLE IF EXISTS `prosp_corp_access`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_corp_access` (
  `idprosp_corp_access` int(11) NOT NULL AUTO_INCREMENT,
  `corp_accessor` int(11) DEFAULT NULL,
  `corp_access_acc_mgr` int(11) DEFAULT NULL,
  `to_dt_acc` date DEFAULT NULL,
  `from_dt_acc` date DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `last_updated` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idprosp_corp_access`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_corp_act_amt`
--

DROP TABLE IF EXISTS `prosp_corp_act_amt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_corp_act_amt` (
  `idprosp_corp_act_amt` int(11) NOT NULL AUTO_INCREMENT,
  `idprosp_corp_activity` int(11) DEFAULT NULL,
  `corp_lvl_amt` int(5) DEFAULT NULL,
  `corp_action` int(5) DEFAULT NULL,
  `corp_action_by` int(11) DEFAULT NULL,
  `corp_lvl_bal` float DEFAULT NULL,
  `corp_lvl_paid` float DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `updater_on` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idprosp_corp_act_amt`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_corp_activity`
--

DROP TABLE IF EXISTS `prosp_corp_activity`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_corp_activity` (
  `idprosp_corp_activity` int(11) NOT NULL AUTO_INCREMENT,
  `idprosp_corp` int(11) DEFAULT NULL,
  `topic_disussed` varchar(300) DEFAULT NULL,
  `corp_level` int(5) DEFAULT NULL,
  `response` int(5) DEFAULT NULL,
  `start_dt` date DEFAULT NULL,
  `acc_mgr` int(11) DEFAULT NULL,
  `end_dt` date DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idprosp_corp_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_corp_attach`
--

DROP TABLE IF EXISTS `prosp_corp_attach`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_corp_attach` (
  `idprosp_corp_attach` int(11) NOT NULL AUTO_INCREMENT,
  `idprosp_corp` int(11) DEFAULT NULL,
  `idstorage` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idprosp_corp_attach`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_corp_inc`
--

DROP TABLE IF EXISTS `prosp_corp_inc`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_corp_inc` (
  `idprosp_corp_inc` int(11) NOT NULL AUTO_INCREMENT,
  `idprosp_lk_val` int(11) DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL,
  `inc_frm` datetime DEFAULT NULL,
  `inc_to` datetime DEFAULT NULL,
  `inc_amt` float DEFAULT NULL,
  `approver_id` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idprosp_corp_inc`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_corp_log`
--

DROP TABLE IF EXISTS `prosp_corp_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_corp_log` (
  `idprosp_corp_log` bigint(19) NOT NULL AUTO_INCREMENT,
  `pros_corp_type` varchar(45) DEFAULT NULL,
  `corp_entity_name` varchar(95) DEFAULT NULL,
  `corp_source` varchar(45) DEFAULT NULL,
  `corp_level` varchar(45) DEFAULT NULL,
  `response` varchar(45) DEFAULT NULL,
  `corp_contacts` varchar(300) DEFAULT NULL,
  `corp_address` varchar(300) DEFAULT NULL,
  `register_yr` varchar(45) DEFAULT NULL,
  `register_state` varchar(45) DEFAULT NULL,
  `start_dt` date DEFAULT NULL,
  `acc_mgr` int(11) DEFAULT NULL,
  `end_dt` date DEFAULT NULL,
  `st_end_tm` varchar(45) DEFAULT NULL,
  `topic_discussed` varchar(300) DEFAULT NULL,
  `topic_count` varchar(45) DEFAULT NULL,
  `about_corp` varchar(300) DEFAULT NULL,
  `access_name` varchar(45) DEFAULT NULL,
  `tentative_en_dt` datetime DEFAULT NULL,
  `remind` varchar(45) DEFAULT NULL,
  `vm_count` varchar(45) DEFAULT NULL,
  `prosp_corp_LU` datetime DEFAULT NULL,
  `prosp_crop_UB` varchar(45) DEFAULT NULL,
  `prosp_crop_del_dt` datetime DEFAULT NULL,
  `prosp_crop_del_by` varchar(45) DEFAULT NULL,
  `prosp_crop_archv_dt` datetime DEFAULT NULL,
  `prosp_crop_archv_by` varchar(45) DEFAULT NULL,
  `action` varchar(10) DEFAULT NULL,
  `idprosp_corp` int(11) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` varchar(45) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL COMMENT 'A = Added, N = new, O = Old',
  PRIMARY KEY (`idprosp_corp_log`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_lk`
--

DROP TABLE IF EXISTS `prosp_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_lk` (
  `idprosp_lk` int(11) NOT NULL AUTO_INCREMENT,
  `prosp_name` varchar(45) DEFAULT NULL,
  `disp_order` int(11) DEFAULT NULL,
  PRIMARY KEY (`idprosp_lk`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_lk_val`
--

DROP TABLE IF EXISTS `prosp_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_lk_val` (
  `idprosp_lk_val` int(11) NOT NULL AUTO_INCREMENT,
  `idprosp_lk` int(11) DEFAULT NULL,
  `prosp_value` varchar(45) DEFAULT NULL,
  `prosp_value_desc` varchar(100) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL,
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idprosp_lk_val`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_refund1`
--

DROP TABLE IF EXISTS `prosp_refund1`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_refund1` (
  `idprosp_refund1` int(11) NOT NULL AUTO_INCREMENT,
  `ref_for_id` int(11) DEFAULT NULL,
  `ref_for_table` varchar(45) DEFAULT NULL,
  `total_paid` decimal(9,2) DEFAULT NULL,
  `total_refund` decimal(9,2) DEFAULT NULL,
  `cleared` char(1) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idprosp_refund1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_refund2`
--

DROP TABLE IF EXISTS `prosp_refund2`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_refund2` (
  `idprosp_refund2` int(11) NOT NULL AUTO_INCREMENT,
  `idprosp_refund1` int(11) DEFAULT NULL,
  `paid_amt` decimal(7,2) DEFAULT NULL,
  `refund_amt` decimal(7,2) DEFAULT NULL,
  `pay_for` int(5) DEFAULT NULL COMMENT 'GC, H1,',
  `pay_dt` date DEFAULT NULL,
  `pay_smry` varchar(200) DEFAULT NULL,
  `selection` char(1) DEFAULT NULL,
  PRIMARY KEY (`idprosp_refund2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_refund_detail`
--

DROP TABLE IF EXISTS `prosp_refund_detail`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_refund_detail` (
  `idprosp_refund_details` int(11) NOT NULL AUTO_INCREMENT,
  `idprosp_refund2` int(11) DEFAULT NULL,
  `refund_type` int(5) DEFAULT NULL COMMENT 'Discount, Processing, Commision',
  `refund_amt` decimal(7,2) DEFAULT NULL,
  `ref_for_id` int(11) DEFAULT NULL,
  `ref_for_table` varchar(45) DEFAULT NULL,
  `refund_dt` varchar(45) DEFAULT NULL,
  `refund_smry` varchar(200) DEFAULT NULL,
  `display` char(1) DEFAULT NULL,
  PRIMARY KEY (`idprosp_refund_details`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_refund_test`
--

DROP TABLE IF EXISTS `prosp_refund_test`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_refund_test` (
  `idprosp_refund1` int(11) NOT NULL AUTO_INCREMENT,
  `ref_for_id` int(11) DEFAULT NULL,
  `ref_for_table` varchar(45) DEFAULT NULL,
  `total_paid` decimal(9,2) DEFAULT NULL,
  `total_refund` decimal(9,2) DEFAULT NULL,
  `cleared` char(1) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idprosp_refund1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prosp_tag`
--

DROP TABLE IF EXISTS `prosp_tag`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prosp_tag` (
  `prosp_tag_id` int(11) NOT NULL AUTO_INCREMENT,
  `prosp_consult_id` int(11) DEFAULT NULL,
  `prosp_tags` int(5) DEFAULT NULL,
  PRIMARY KEY (`prosp_tag_id`),
  KEY `prosp_consult_tag_idx` (`prosp_consult_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `rpt_bill_ts_cycle`
--

DROP TABLE IF EXISTS `rpt_bill_ts_cycle`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `rpt_bill_ts_cycle` (
  `idrpt_bill_ts_cycle` bigint(20) NOT NULL AUTO_INCREMENT,
  `idengage_entity_po` int(11) DEFAULT NULL,
  `cycle_for` char(2) DEFAULT NULL COMMENT 'TS or BI',
  `cycle_type` int(5) DEFAULT NULL,
  `cycle_st_dt` date DEFAULT NULL,
  `cycle_end_dt` date DEFAULT NULL,
  `due_dt` varchar(45) DEFAULT NULL,
  `expect_bill_hr` decimal(5,2) DEFAULT NULL,
  `expect_unbill_hr` decimal(5,2) DEFAULT NULL,
  `display` char(1) DEFAULT NULL COMMENT 'Y or N',
  `last_updated` datetime DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `expect_total_hr` decimal(7,2) DEFAULT NULL,
  `expect_bill_amt` decimal(9,2) DEFAULT NULL,
  `bill_hr` decimal(5,2) DEFAULT NULL,
  `unbill_hr` decimal(5,2) DEFAULT NULL,
  `bill_total_hr` decimal(5,2) DEFAULT NULL,
  `bill_amt` decimal(9,2) DEFAULT NULL,
  `diff_bill_hr` decimal(5,2) DEFAULT NULL,
  `diff_unbill_hr` decimal(5,2) DEFAULT NULL,
  `diff_total_hr` decimal(5,2) DEFAULT NULL,
  `diff_bill_amt` decimal(9,2) DEFAULT NULL,
  `srv_client` int(11) DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL,
  `invoiced` char(1) DEFAULT NULL,
  `approved` char(1) DEFAULT NULL,
  `timecard` char(1) DEFAULT NULL,
  PRIMARY KEY (`idrpt_bill_ts_cycle`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `rpt_bill_ts_cycle_2`
--

DROP TABLE IF EXISTS `rpt_bill_ts_cycle_2`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `rpt_bill_ts_cycle_2` (
  `idrpt_bill_ts_cycle_2` bigint(20) NOT NULL AUTO_INCREMENT,
  `idrpt_bill_ts_cycle` int(11) DEFAULT NULL,
  `hour_id` int(11) DEFAULT NULL,
  `hrs_dt` date DEFAULT NULL,
  `expect_bill_hr` decimal(5,2) DEFAULT NULL,
  `expect_unbill_hr` decimal(5,2) DEFAULT NULL,
  `expect_total_hr` decimal(5,2) DEFAULT NULL,
  `bill_hr` decimal(5,2) DEFAULT NULL,
  `unbill_hr` decimal(5,2) DEFAULT NULL,
  `bill_total_hr` decimal(5,2) DEFAULT NULL,
  `diff_bill_hr` decimal(5,2) DEFAULT NULL,
  `diff_unbill_hr` decimal(5,2) DEFAULT NULL,
  `diff_total_hr` decimal(5,2) DEFAULT NULL,
  `invoiced` char(1) DEFAULT NULL,
  `approved` char(1) DEFAULT NULL,
  `timecard_id` char(1) DEFAULT NULL,
  PRIMARY KEY (`idrpt_bill_ts_cycle_2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `shares`
--

DROP TABLE IF EXISTS `shares`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `shares` (
  `idshares` bigint(20) NOT NULL AUTO_INCREMENT,
  `comp_id` int(10) DEFAULT NULL,
  `shr_no` int(11) DEFAULT NULL,
  `owner_ref_id` int(11) DEFAULT NULL,
  `owner_ref_tab` varchar(45) DEFAULT NULL,
  `buy_type` varchar(45) DEFAULT NULL COMMENT 'cash, trade, srv',
  `buy_price` float DEFAULT NULL,
  `shr_stat` int(5) DEFAULT NULL,
  `stat_dt` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idshares`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `shares_owner`
--

DROP TABLE IF EXISTS `shares_owner`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `shares_owner` (
  `idshares_owner` bigint(20) NOT NULL AUTO_INCREMENT,
  `owner_ref_id` int(11) DEFAULT NULL,
  `owner_ref_tab` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idshares_owner`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `storage_access`
--

DROP TABLE IF EXISTS `storage_access`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `storage_access` (
  `idstorage_access` int(11) NOT NULL AUTO_INCREMENT,
  `idstorage` int(11) DEFAULT NULL,
  `access_to` int(11) DEFAULT NULL,
  `access_type` varchar(10) DEFAULT NULL COMMENT 'View, Edit, Delete',
  `updater` int(11) DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idstorage_access`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `storage_lk_tag`
--

DROP TABLE IF EXISTS `storage_lk_tag`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `storage_lk_tag` (
  `idstorage_lk_tag` int(11) NOT NULL AUTO_INCREMENT,
  `owner_id` int(11) DEFAULT NULL,
  `lk_tag` varchar(20) DEFAULT NULL,
  `lk_tag_desc` varchar(200) DEFAULT NULL,
  `lk_disp_id` int(5) DEFAULT NULL,
  `lk_parent_tag_id` int(11) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idstorage_lk_tag`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `storage_ref`
--

DROP TABLE IF EXISTS `storage_ref`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `storage_ref` (
  `idstorages_ref` int(11) NOT NULL AUTO_INCREMENT,
  `idstorage` int(11) DEFAULT NULL,
  `idlook_menu_pvt_lvl1` int(11) DEFAULT NULL COMMENT 'Agile, Asset, Employee.',
  `idlook_menu_pvt_lvl2` int(11) DEFAULT NULL COMMENT 'Req, Cube, etc, manage',
  `sto_tab_nm` varchar(45) DEFAULT NULL COMMENT 'emp_attach, ',
  PRIMARY KEY (`idstorages_ref`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `storages`
--

DROP TABLE IF EXISTS `storages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `storages` (
  `idstorage` int(11) NOT NULL AUTO_INCREMENT,
  `file_name` varchar(100) DEFAULT NULL,
  `sto_loc` varchar(45) DEFAULT NULL COMMENT 'pub or pvt',
  `file_size` varchar(45) DEFAULT NULL,
  `owner_id` int(11) DEFAULT NULL COMMENT 'C = (cabinet) F = file',
  `create_dt` datetime DEFAULT NULL,
  `ext_type` varchar(10) DEFAULT NULL COMMENT '.doc, .xls, etc',
  `public` char(1) DEFAULT 'N',
  `self_view` char(1) DEFAULT 'Y',
  `shared` char(1) DEFAULT 'Y',
  `file_summary` varchar(95) DEFAULT NULL,
  `updated_for_ref_id` int(11) DEFAULT NULL,
  `updated_for_ref_table` varchar(45) DEFAULT NULL,
  `tag_id` int(5) DEFAULT NULL,
  `emp_id` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  `usage` int(5) DEFAULT NULL,
  `del_dt` datetime DEFAULT NULL,
  `del_by` int(11) DEFAULT NULL,
  `del_day` int(5) DEFAULT NULL COMMENT '30 / 60',
  `archv_dt` datetime DEFAULT NULL,
  `archv_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`idstorage`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `storages_lk`
--

DROP TABLE IF EXISTS `storages_lk`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `storages_lk` (
  `idstorages_lk` int(11) NOT NULL AUTO_INCREMENT,
  `sto_name` varchar(45) DEFAULT NULL,
  `disp_order` int(11) DEFAULT NULL,
  PRIMARY KEY (`idstorages_lk`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `storages_lk_val`
--

DROP TABLE IF EXISTS `storages_lk_val`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `storages_lk_val` (
  `idstorages_lk_val` int(11) NOT NULL AUTO_INCREMENT,
  `idstorages_lk` int(11) DEFAULT NULL,
  `sto_value` varchar(45) DEFAULT NULL,
  `disp_order` int(5) DEFAULT NULL,
  `updater` int(11) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL,
  PRIMARY KEY (`idstorages_lk_val`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `tax`
--

DROP TABLE IF EXISTS `tax`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tax` (
  `idtax` int(11) NOT NULL AUTO_INCREMENT,
  `state_id` int(11) DEFAULT NULL,
  `dept_id` int(11) DEFAULT NULL COMMENT 'look from look value or dept',
  `tax_for` varchar(5) DEFAULT NULL COMMENT 'Emp /  Er',
  `creditable` char(1) DEFAULT NULL,
  PRIMARY KEY (`idtax`),
  KEY `fk_taxes_lk_state_idx` (`state_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `tax_amt`
--

DROP TABLE IF EXISTS `tax_amt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tax_amt` (
  `idtax_amt` int(11) NOT NULL AUTO_INCREMENT,
  `idtax` int(11) DEFAULT NULL,
  `tax_to_dt` date DEFAULT NULL,
  `tax_from_dt` date DEFAULT NULL,
  `tax_limit` float DEFAULT NULL,
  `gender` char(1) DEFAULT NULL,
  `tax_amt` float DEFAULT NULL,
  `idtax_rate_sub` int(11) DEFAULT NULL,
  `tax_type` char(1) DEFAULT NULL,
  PRIMARY KEY (`idtax_amt`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Temporary table structure for view `vw_activity`
--

DROP TABLE IF EXISTS `vw_activity`;
/*!50001 DROP VIEW IF EXISTS `vw_activity`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_activity` AS SELECT 
 1 AS `name`,
 1 AS `prosp_activity_id`,
 1 AS `prosp_consult_id`,
 1 AS `call_recv_dt`,
 1 AS `emp_id`,
 1 AS `next_call_dt`,
 1 AS `call_note`,
 1 AS `last_update`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_addresses`
--

DROP TABLE IF EXISTS `vw_addresses`;
/*!50001 DROP VIEW IF EXISTS `vw_addresses`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_addresses` AS SELECT 
 1 AS `country_id`,
 1 AS `con_name`,
 1 AS `state_id`,
 1 AS `state_name`,
 1 AS `city_id`,
 1 AS `city_name`,
 1 AS `postal_id`,
 1 AS `zip_code`,
 1 AS `look_street_id`,
 1 AS `street_name`,
 1 AS `street_type`,
 1 AS `look_street_no_id`,
 1 AS `look_street_no`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_addresses2`
--

DROP TABLE IF EXISTS `vw_addresses2`;
/*!50001 DROP VIEW IF EXISTS `vw_addresses2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_addresses2` AS SELECT 
 1 AS `look_street_no_id`,
 1 AS `addresses`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_all_attration`
--

DROP TABLE IF EXISTS `vw_all_attration`;
/*!50001 DROP VIEW IF EXISTS `vw_all_attration`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_all_attration` AS SELECT 
 1 AS `idall_attration`,
 1 AS `att_dt2`,
 1 AS `att_dt`,
 1 AS `att_for`,
 1 AS `att_start`,
 1 AS `att_end`,
 1 AS `att_open_total`,
 1 AS `att_percent`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_all_users_login`
--

DROP TABLE IF EXISTS `vw_all_users_login`;
/*!50001 DROP VIEW IF EXISTS `vw_all_users_login`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_all_users_login` AS SELECT 
 1 AS `login_id`,
 1 AS `lastlogin`,
 1 AS `lastlogin_unformatted`,
 1 AS `lastlogout`,
 1 AS `lastlogout_unformatted`,
 1 AS `logged_in`,
 1 AS `login_IP_add`,
 1 AS `domain_name`,
 1 AS `isp`,
 1 AS `country`,
 1 AS `state`,
 1 AS `city`,
 1 AS `postal_code`,
 1 AS `main_menu_id`,
 1 AS `main_menu`,
 1 AS `sub_menu_id`,
 1 AS `sub_menu`,
 1 AS `logouttype`,
 1 AS `emp_id`,
 1 AS `username`,
 1 AS `del_dt_unformatted`,
 1 AS `del_dt`,
 1 AS `virtual_del_day`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `del_day`,
 1 AS `archv_dt_unformatted`,
 1 AS `archv_dt`,
 1 AS `archv_by`,
 1 AS `archv_by_id`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_asset_mgmt`
--

DROP TABLE IF EXISTS `vw_asset_mgmt`;
/*!50001 DROP VIEW IF EXISTS `vw_asset_mgmt`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_asset_mgmt` AS SELECT 
 1 AS `idasset_mgmt`,
 1 AS `tangible`,
 1 AS `prchse_dt`,
 1 AS `prchse_expy`,
 1 AS `asset_serial_no`,
 1 AS `prchse_pr`,
 1 AS `prchse_type`,
 1 AS `category_type`,
 1 AS `category`,
 1 AS `depriciate_pcnt`,
 1 AS `depriciate_calc`,
 1 AS `companyname`,
 1 AS `comp_id`,
 1 AS `asset_name`,
 1 AS `idasset_look`,
 1 AS `idasset_look_value`,
 1 AS `asset_value`,
 1 AS `emp_id`,
 1 AS `updater`,
 1 AS `prchse_expy_usa`,
 1 AS `prchse_dt_usa`,
 1 AS `warranty_usa`,
 1 AS `last_updated_usa`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_bill_attration`
--

DROP TABLE IF EXISTS `vw_bill_attration`;
/*!50001 DROP VIEW IF EXISTS `vw_bill_attration`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_bill_attration` AS SELECT 
 1 AS `year`,
 1 AS `month`,
 1 AS `started`,
 1 AS `ended`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_bill_attration_end`
--

DROP TABLE IF EXISTS `vw_bill_attration_end`;
/*!50001 DROP VIEW IF EXISTS `vw_bill_attration_end`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_bill_attration_end` AS SELECT 
 1 AS `year`,
 1 AS `month`,
 1 AS `cnt`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_bill_attration_start`
--

DROP TABLE IF EXISTS `vw_bill_attration_start`;
/*!50001 DROP VIEW IF EXISTS `vw_bill_attration_start`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_bill_attration_start` AS SELECT 
 1 AS `year`,
 1 AS `month`,
 1 AS `cnt`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_bill_attration_sub`
--

DROP TABLE IF EXISTS `vw_bill_attration_sub`;
/*!50001 DROP VIEW IF EXISTS `vw_bill_attration_sub`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_bill_attration_sub` AS SELECT 
 1 AS `st_year`,
 1 AS `st_month`,
 1 AS `started`,
 1 AS `ed_year`,
 1 AS `ed_month`,
 1 AS `ended`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_billingto`
--

DROP TABLE IF EXISTS `vw_billingto`;
/*!50001 DROP VIEW IF EXISTS `vw_billingto`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_billingto` AS SELECT 
 1 AS `id`,
 1 AS `name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_budget`
--

DROP TABLE IF EXISTS `vw_budget`;
/*!50001 DROP VIEW IF EXISTS `vw_budget`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_budget` AS SELECT 
 1 AS `idengage_budget`,
 1 AS `idengage_entity_po`,
 1 AS `engage_ref_id_po`,
 1 AS `engage_ref_tab_po`,
 1 AS `po_candidate_name`,
 1 AS `comp_emp_detail_po`,
 1 AS `idengage_entity`,
 1 AS `engage_id`,
 1 AS `srv_client`,
 1 AS `client_name`,
 1 AS `srv_vendor`,
 1 AS `Vender_name`,
 1 AS `engage_ref_id`,
 1 AS `engage_ref_table`,
 1 AS `engage_ref_id_name`,
 1 AS `engage_calc`,
 1 AS `engage_amt`,
 1 AS `show_emp`,
 1 AS `engage_st_dt`,
 1 AS `engage_st_dt1`,
 1 AS `sort_engage_st_dt`,
 1 AS `engage_end_st`,
 1 AS `engage_end_st1`,
 1 AS `sort_engage_end_st`,
 1 AS `limit_amt`,
 1 AS `engage_summary`,
 1 AS `bill_start_dt`,
 1 AS `bill_start_dt1`,
 1 AS `bill_cycle`,
 1 AS `bill_end_dt`,
 1 AS `bill_end_dt1`,
 1 AS `bill_pay_rate`,
 1 AS `mod_last_updated`,
 1 AS `updated_by`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_check_ssn_taxid`
--

DROP TABLE IF EXISTS `vw_check_ssn_taxid`;
/*!50001 DROP VIEW IF EXISTS `vw_check_ssn_taxid`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_check_ssn_taxid` AS SELECT 
 1 AS `emp_id`,
 1 AS `ssn`,
 1 AS `taxid`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_client_vendor_1`
--

DROP TABLE IF EXISTS `vw_client_vendor_1`;
/*!50001 DROP VIEW IF EXISTS `vw_client_vendor_1`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_client_vendor_1` AS SELECT 
 1 AS `idengage_comp`,
 1 AS `engage_id`,
 1 AS `clients`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_client_vendor_11`
--

DROP TABLE IF EXISTS `vw_client_vendor_11`;
/*!50001 DROP VIEW IF EXISTS `vw_client_vendor_11`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_client_vendor_11` AS SELECT 
 1 AS `idengage_comp`,
 1 AS `engage_id`,
 1 AS `vendors`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp1`
--

DROP TABLE IF EXISTS `vw_comp1`;
/*!50001 DROP VIEW IF EXISTS `vw_comp1`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp1` AS SELECT 
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `company_info`,
 1 AS `comp_website`,
 1 AS `comp_phone`,
 1 AS `comp_email`,
 1 AS `comp_merge_id`,
 1 AS `comp_tax_id`,
 1 AS `updater`,
 1 AS `last_updated`,
 1 AS `comp_contact`,
 1 AS `comp_addresses`,
 1 AS `logofile`,
 1 AS `mod_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp2`
--

DROP TABLE IF EXISTS `vw_comp2`;
/*!50001 DROP VIEW IF EXISTS `vw_comp2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp2` AS SELECT 
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `comp_contact_id`,
 1 AS `emp_id`,
 1 AS `comp_contact_no_id`,
 1 AS `contact_id`,
 1 AS `emp_name`,
 1 AS `contact_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp3`
--

DROP TABLE IF EXISTS `vw_comp3`;
/*!50001 DROP VIEW IF EXISTS `vw_comp3`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp3` AS SELECT 
 1 AS `comp_id`,
 1 AS `emp_id`,
 1 AS `comp_contact_id`,
 1 AS `Employee_Name`,
 1 AS `title`,
 1 AS `description`,
 1 AS `contact`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp4`
--

DROP TABLE IF EXISTS `vw_comp4`;
/*!50001 DROP VIEW IF EXISTS `vw_comp4`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp4` AS SELECT 
 1 AS `comp_id`,
 1 AS `Comp_Contact`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_active`
--

DROP TABLE IF EXISTS `vw_comp_active`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_active`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_active` AS SELECT 
 1 AS `idcomp_active`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `company_logo`,
 1 AS `comp_background`,
 1 AS `active_type`,
 1 AS `publish`,
 1 AS `manage_by`,
 1 AS `manager_name`,
 1 AS `client_since`,
 1 AS `last_updated`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `del_dt_unformatted`,
 1 AS `del_dt`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt_unformatted`,
 1 AS `archv_dt`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_billing_details`
--

DROP TABLE IF EXISTS `vw_comp_billing_details`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_billing_details`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_billing_details` AS SELECT 
 1 AS `companyname`,
 1 AS `bill_pay_rate`,
 1 AS `engage_calc`,
 1 AS `engage_amt`,
 1 AS `engage_st_dt`,
 1 AS `engage_end_st`,
 1 AS `limit_amt`,
 1 AS `engage_summary`,
 1 AS `engage_ref_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_contracts`
--

DROP TABLE IF EXISTS `vw_comp_contracts`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_contracts` AS SELECT 
 1 AS `engage_id`,
 1 AS `srv_st_dt`,
 1 AS `srv_e_dt`,
 1 AS `sr_frequency`,
 1 AS `srv_paytype`,
 1 AS `srv_amount`,
 1 AS `eg_sumry`,
 1 AS `srv_client`,
 1 AS `comp_id`,
 1 AS `mod_srv_st_dt`,
 1 AS `mod_srv_st_dt1`,
 1 AS `mod_srv_e_dt`,
 1 AS `mod_srv_e_dt1`,
 1 AS `frequency`,
 1 AS `paytype`,
 1 AS `engage_doc_id`,
 1 AS `last_updated`,
 1 AS `srv_client_name`,
 1 AS `companyname`,
 1 AS `updated_by`,
 1 AS `freqypaytype`,
 1 AS `last_updter`,
 1 AS `last_updter1`,
 1 AS `idengage_comp`,
 1 AS `client_address`,
 1 AS `vendor_address`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_contracts_addr_contacts`
--

DROP TABLE IF EXISTS `vw_comp_contracts_addr_contacts`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_addr_contacts`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_contracts_addr_contacts` AS SELECT 
 1 AS `idengage_add`,
 1 AS `idengage_comp`,
 1 AS `comp_add_id`,
 1 AS `add_type`,
 1 AS `idengage_add_con`,
 1 AS `comp_contact_no_id`,
 1 AS `contact_notes`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_contracts_addr_contacts2`
--

DROP TABLE IF EXISTS `vw_comp_contracts_addr_contacts2`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_addr_contacts2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_contracts_addr_contacts2` AS SELECT 
 1 AS `engage_id`,
 1 AS `srv_st_dt`,
 1 AS `srv_e_dt`,
 1 AS `sr_frequency`,
 1 AS `srv_paytype`,
 1 AS `srv_amount`,
 1 AS `eg_sumry`,
 1 AS `srv_client`,
 1 AS `idengage_comp`,
 1 AS `comp_id`,
 1 AS `mod_srv_st_dt`,
 1 AS `mod_srv_e_dt`,
 1 AS `frequency`,
 1 AS `paytype`,
 1 AS `srv_client_name`,
 1 AS `companyname`,
 1 AS `last_updated`,
 1 AS `updated_by`,
 1 AS `freqypaytype`,
 1 AS `last_updter`,
 1 AS `idengage_add_vendor`,
 1 AS `comp_add_id_vendor`,
 1 AS `idengage_add_client`,
 1 AS `comp_add_id_client`,
 1 AS `client_contacts`,
 1 AS `vendor_contacts`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_contracts_addr_contacts_details`
--

DROP TABLE IF EXISTS `vw_comp_contracts_addr_contacts_details`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_addr_contacts_details`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_contracts_addr_contacts_details` AS SELECT 
 1 AS `idengage_add`,
 1 AS `idengage_comp`,
 1 AS `comp_add_id`,
 1 AS `add_type_id`,
 1 AS `add_type`,
 1 AS `idengage_add_con`,
 1 AS `comp_contact_no_id`,
 1 AS `contact_notes`,
 1 AS `comp_id`,
 1 AS `client_vendor_contacts`,
 1 AS `addresses`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_contracts_contacts`
--

DROP TABLE IF EXISTS `vw_comp_contracts_contacts`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_contacts`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_contracts_contacts` AS SELECT 
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `comp_contact_id`,
 1 AS `emp_id`,
 1 AS `comp_contact_no_id`,
 1 AS `contact_id`,
 1 AS `emp_name`,
 1 AS `contact_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_contracts_contacts_details`
--

DROP TABLE IF EXISTS `vw_comp_contracts_contacts_details`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_contacts_details`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_contracts_contacts_details` AS SELECT 
 1 AS `idengage_comp`,
 1 AS `engage_id`,
 1 AS `comp_id`,
 1 AS `idengage_add`,
 1 AS `comp_add_id`,
 1 AS `companyname`,
 1 AS `add_type`,
 1 AS `contact_notes`,
 1 AS `client_vendor_contacts`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_contracts_old`
--

DROP TABLE IF EXISTS `vw_comp_contracts_old`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_old`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_contracts_old` AS SELECT 
 1 AS `engage_id`,
 1 AS `srv_st_dt`,
 1 AS `srv_e_dt`,
 1 AS `sr_frequency`,
 1 AS `srv_paytype`,
 1 AS `srv_amount`,
 1 AS `eg_sumry`,
 1 AS `srv_client`,
 1 AS `idengage_comp`,
 1 AS `client_address`,
 1 AS `vendor_address`,
 1 AS `comp_id`,
 1 AS `mod_srv_st_dt`,
 1 AS `mod_srv_e_dt`,
 1 AS `frequency`,
 1 AS `paytype`,
 1 AS `srv_client_name`,
 1 AS `engage_doc_id`,
 1 AS `companyname`,
 1 AS `last_updated`,
 1 AS `updated_by`,
 1 AS `freqypaytype`,
 1 AS `last_updter`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_prdt`
--

DROP TABLE IF EXISTS `vw_comp_prdt`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_prdt`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_prdt` AS SELECT 
 1 AS `idcomp_prdt`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `prdt_nm`,
 1 AS `prdt_family`,
 1 AS `idasset_look`,
 1 AS `asset_name`,
 1 AS `idasset_look_value`,
 1 AS `asset_value`,
 1 AS `stocking`,
 1 AS `dscont_dt`,
 1 AS `updater`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_comp_reg_report`
--

DROP TABLE IF EXISTS `vw_comp_reg_report`;
/*!50001 DROP VIEW IF EXISTS `vw_comp_reg_report`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_comp_reg_report` AS SELECT 
 1 AS `comp_reg_id`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `state_id`,
 1 AS `state_name`,
 1 AS `comp_reg_dept_id`,
 1 AS `dept`,
 1 AS `dept_id`,
 1 AS `reg_number`,
 1 AS `comp_reg_dept_dt_id`,
 1 AS `comp_open_dt`,
 1 AS `comp_close_dt`,
 1 AS `mod_comp_open_dt`,
 1 AS `mod_comp_close_dt`,
 1 AS `mod_last_updated`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_company`
--

DROP TABLE IF EXISTS `vw_company`;
/*!50001 DROP VIEW IF EXISTS `vw_company`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_company` AS SELECT 
 1 AS `comp_id`,
 1 AS `idstorage`,
 1 AS `storage_file_name`,
 1 AS `companyname`,
 1 AS `comp_tax_id`,
 1 AS `company_info`,
 1 AS `comp_website`,
 1 AS `comp_phone`,
 1 AS `comp_email`,
 1 AS `comp_merge_id`,
 1 AS `last_updated_unformatted`,
 1 AS `last_updated`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `del_dt_unformatted`,
 1 AS `del_dt`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt_unformatted`,
 1 AS `archv_dt`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_company_address`
--

DROP TABLE IF EXISTS `vw_company_address`;
/*!50001 DROP VIEW IF EXISTS `vw_company_address`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_company_address` AS SELECT 
 1 AS `comp_add_id`,
 1 AS `add_type`,
 1 AS `add_type2`,
 1 AS `comp_id`,
 1 AS `suite_no`,
 1 AS `look_street_no`,
 1 AS `street_name`,
 1 AS `zip_code`,
 1 AS `city_name`,
 1 AS `state_name`,
 1 AS `look_street_no_id`,
 1 AS `look_street_id`,
 1 AS `street_type`,
 1 AS `street_type_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_company_address2`
--

DROP TABLE IF EXISTS `vw_company_address2`;
/*!50001 DROP VIEW IF EXISTS `vw_company_address2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_company_address2` AS SELECT 
 1 AS `comp_add_id`,
 1 AS `add_type`,
 1 AS `add_type2`,
 1 AS `comp_id`,
 1 AS `addresses`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_company_contacts`
--

DROP TABLE IF EXISTS `vw_company_contacts`;
/*!50001 DROP VIEW IF EXISTS `vw_company_contacts`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_company_contacts` AS SELECT 
 1 AS `emp_id`,
 1 AS `emp_contact_id`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `contact`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_company_owners`
--

DROP TABLE IF EXISTS `vw_company_owners`;
/*!50001 DROP VIEW IF EXISTS `vw_company_owners`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_company_owners` AS SELECT 
 1 AS `comp_own_id`,
 1 AS `comp_id`,
 1 AS `emp_id`,
 1 AS `companyname`,
 1 AS `employee`,
 1 AS `owner_share`,
 1 AS `share_dt_from`,
 1 AS `share_dt_to`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_company_reg`
--

DROP TABLE IF EXISTS `vw_company_reg`;
/*!50001 DROP VIEW IF EXISTS `vw_company_reg`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_company_reg` AS SELECT 
 1 AS `comp_reg_id`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `state_id`,
 1 AS `state_name`,
 1 AS `comp_reg_dept_id`,
 1 AS `dept`,
 1 AS `dept_id`,
 1 AS `reg_number`,
 1 AS `comp_reg_dept_dt_id`,
 1 AS `comp_open_dt`,
 1 AS `comp_close_dt`,
 1 AS `mod_comp_open_dt`,
 1 AS `mod_comp_close_dt`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_company_reg_cmp`
--

DROP TABLE IF EXISTS `vw_company_reg_cmp`;
/*!50001 DROP VIEW IF EXISTS `vw_company_reg_cmp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_company_reg_cmp` AS SELECT 
 1 AS `comp_reg_id`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `state_id`,
 1 AS `state_name`,
 1 AS `comp_reg_dept_id`,
 1 AS `dept`,
 1 AS `dept_id`,
 1 AS `reg_number`,
 1 AS `comp_reg_dept_dt_id`,
 1 AS `comp_open_dt`,
 1 AS `comp_close_dt`,
 1 AS `comp_close_dt1`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_config_feature_grp`
--

DROP TABLE IF EXISTS `vw_config_feature_grp`;
/*!50001 DROP VIEW IF EXISTS `vw_config_feature_grp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_config_feature_grp` AS SELECT 
 1 AS `idfeature_grp`,
 1 AS `updater_file_name`,
 1 AS `feature_id`,
 1 AS `group_name`,
 1 AS `group_desc`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_config_feature_load_emp`
--

DROP TABLE IF EXISTS `vw_config_feature_load_emp`;
/*!50001 DROP VIEW IF EXISTS `vw_config_feature_load_emp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_config_feature_load_emp` AS SELECT 
 1 AS `access_id`,
 1 AS `emp_file_name`,
 1 AS `feature_id`,
 1 AS `emp_id`,
 1 AS `emp_name`,
 1 AS `last_updated`,
 1 AS `updater`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_constctzip`
--

DROP TABLE IF EXISTS `vw_constctzip`;
/*!50001 DROP VIEW IF EXISTS `vw_constctzip`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_constctzip` AS SELECT 
 1 AS `country_id`,
 1 AS `con_name`,
 1 AS `state_id`,
 1 AS `state_name`,
 1 AS `city_id`,
 1 AS `city_name`,
 1 AS `postal_id`,
 1 AS `zip_code`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_constctzipstreet`
--

DROP TABLE IF EXISTS `vw_constctzipstreet`;
/*!50001 DROP VIEW IF EXISTS `vw_constctzipstreet`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_constctzipstreet` AS SELECT 
 1 AS `country_id`,
 1 AS `con_name`,
 1 AS `state_id`,
 1 AS `state_name`,
 1 AS `city_id`,
 1 AS `city_name`,
 1 AS `postal_id`,
 1 AS `zip_code`,
 1 AS `look_street_id`,
 1 AS `street_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_consultant`
--

DROP TABLE IF EXISTS `vw_consultant`;
/*!50001 DROP VIEW IF EXISTS `vw_consultant`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_consultant` AS SELECT 
 1 AS `name`,
 1 AS `prosp_consult_id`,
 1 AS `prosp_first_name`,
 1 AS `prosp_last_name`,
 1 AS `prosp_level`,
 1 AS `prosp_summary`,
 1 AS `prosp_activity_id`,
 1 AS `call_recv_dt`,
 1 AS `emp_id`,
 1 AS `next_call_dt`,
 1 AS `call_note`,
 1 AS `last_update`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_contracts_attach`
--

DROP TABLE IF EXISTS `vw_contracts_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_contracts_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_contracts_attach` AS SELECT 
 1 AS `engage_doc_id`,
 1 AS `doc_type`,
 1 AS `doc_look_values`,
 1 AS `expire_dt`,
 1 AS `mod_expire_dt`,
 1 AS `engage_id`,
 1 AS `idstorage`,
 1 AS `owner_id`,
 1 AS `file_name`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `emp_id`,
 1 AS `updated_for_ref_id`,
 1 AS `updated_for_ref_table`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_contracts_po`
--

DROP TABLE IF EXISTS `vw_contracts_po`;
/*!50001 DROP VIEW IF EXISTS `vw_contracts_po`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_contracts_po` AS SELECT 
 1 AS `idengage_entity_po`,
 1 AS `idengage_entity`,
 1 AS `engage_id`,
 1 AS `engage_ref_id`,
 1 AS `engage_ref_tab_id`,
 1 AS `engage_ref_tab`,
 1 AS `engage_ref_id_name`,
 1 AS `po_candidate_name`,
 1 AS `entity_parent`,
 1 AS `client name`,
 1 AS `Vender name`,
 1 AS `client_address`,
 1 AS `vendor_address`,
 1 AS `con_srv_st_dt`,
 1 AS `con_srv_e_dt`,
 1 AS `bill_start_dt`,
 1 AS `mod_bill_start_dt`,
 1 AS `mod_bill_start_dt1`,
 1 AS `bill_cycle`,
 1 AS `bill_cycle_name`,
 1 AS `bill_end_dt`,
 1 AS `mod_bill_end_dt`,
 1 AS `mod_bill_end_dt1`,
 1 AS `bill_fst_dt`,
 1 AS `mod_bill_fst_dt`,
 1 AS `bill_day`,
 1 AS `bill_day_name`,
 1 AS `bill_pay_type`,
 1 AS `bill_pay_type_name`,
 1 AS `bill_pay_rate`,
 1 AS `ts_cycle`,
 1 AS `bill_cyle_run`,
 1 AS `bill_last_run`,
 1 AS `ts_cycle_run`,
 1 AS `ts_last_run`,
 1 AS `mon_cycle_run`,
 1 AS `mon_last_run`,
 1 AS `ts_cycle_name`,
 1 AS `ts_fst_dt`,
 1 AS `mod_ts_fst_dt`,
 1 AS `netpay`,
 1 AS `bill_pay_rate_xtra`,
 1 AS `bill_hrs_min`,
 1 AS `bill_title`,
 1 AS `bill_title_name`,
 1 AS `tentative_end_dt`,
 1 AS `mod_tentative_end_dt`,
 1 AS `summary`,
 1 AS `cloud_drive`,
 1 AS `idstorage`,
 1 AS `actions`,
 1 AS `updated_by`,
 1 AS `last_update`,
 1 AS `allow_inv`,
 1 AS `show_emp`,
 1 AS `last_updter`,
 1 AS `last_updter1`,
 1 AS `comp_emp_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_apps`
--

DROP TABLE IF EXISTS `vw_dev_apps`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_apps`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_apps` AS SELECT 
 1 AS `iddev_apps`,
 1 AS `disp_order`,
 1 AS `app_name`,
 1 AS `app_description`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `start_dt`,
 1 AS `start_dt_unformatted`,
 1 AS `end_dt`,
 1 AS `end_dt_unformatted`,
 1 AS `dev_est_cnt`,
 1 AS `dev_est_pcnt`,
 1 AS `dev_est_req_cnt`,
 1 AS `dev_est_req_pcnt`,
 1 AS `dev_est_req_stat_cnt`,
 1 AS `dev_est_req_stat_pcnt`,
 1 AS `del_by`,
 1 AS `del_by_id`,
 1 AS `del_by_file_name`,
 1 AS `del_dt`,
 1 AS `del_dt_unformatted`,
 1 AS `del_day`,
 1 AS `virtual_del_day`,
 1 AS `arch_by`,
 1 AS `arch_by_id`,
 1 AS `arch_by_file_name`,
 1 AS `arch_dt`,
 1 AS `arch_dt_unformatted`,
 1 AS `updater_file_name`,
 1 AS `updater`,
 1 AS `last_updated`,
 1 AS `last_updated_unformatted`,
 1 AS `mylast_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_apps_attachment`
--

DROP TABLE IF EXISTS `vw_dev_apps_attachment`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_apps_attachment`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_apps_attachment` AS SELECT 
 1 AS `iddev_app_attach`,
 1 AS `iddev_apps`,
 1 AS `idstorage`,
 1 AS `updater`,
 1 AS `owner_id`,
 1 AS `file_name`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `emp_id`,
 1 AS `updated_for_ref_id`,
 1 AS `updated_for_ref_table`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est`
--

DROP TABLE IF EXISTS `vw_dev_est`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est` AS SELECT 
 1 AS `iddev_est`,
 1 AS `attach`,
 1 AS `iddev_apps`,
 1 AS `owner_file_name`,
 1 AS `estimater_file_name`,
 1 AS `updater_file_name`,
 1 AS `app_name`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `dev_est_smry`,
 1 AS `owner_ref_id`,
 1 AS `owner_ref_tab`,
 1 AS `est_ref_id`,
 1 AS `est_ref_tab`,
 1 AS `category`,
 1 AS `category_name`,
 1 AS `priority`,
 1 AS `priority_name`,
 1 AS `est_ref_name`,
 1 AS `estimater_name`,
 1 AS `owner_ref_name`,
 1 AS `owner_name`,
 1 AS `est_amt`,
 1 AS `est_amt_pay`,
 1 AS `est_amt_bal`,
 1 AS `est_skill`,
 1 AS `est_gap_lvl`,
 1 AS `est_type`,
 1 AS `dev_st_dt`,
 1 AS `dev_st_dt_unformatted`,
 1 AS `dev_en_dt`,
 1 AS `dev_en_dt_unformatted`,
 1 AS `dev_st_dt_time`,
 1 AS `dev_en_dt_time`,
 1 AS `est_time`,
 1 AS `pseudo_est_time`,
 1 AS `cnt_actual`,
 1 AS `cnt_est`,
 1 AS `cnt_actual_est`,
 1 AS `cnt_pcnt`,
 1 AS `cnt_req_actual`,
 1 AS `cnt_req_est`,
 1 AS `cnt_req_actual_est`,
 1 AS `cnt_req_pcnt`,
 1 AS `updater`,
 1 AS `last_updated`,
 1 AS `mylast_updated`,
 1 AS `del_dt`,
 1 AS `del_dt_unformatted`,
 1 AS `del_by`,
 1 AS `del_by_id`,
 1 AS `del_by_file_name`,
 1 AS `del_day`,
 1 AS `virtual_del_day`,
 1 AS `arch_by`,
 1 AS `arch_by_id`,
 1 AS `arch_by_file_name`,
 1 AS `arch_dt`,
 1 AS `arch_dt_unformatted`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_access`
--

DROP TABLE IF EXISTS `vw_dev_est_access`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_access`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_access` AS SELECT 
 1 AS `iddev_est_access`,
 1 AS `iddev_est`,
 1 AS `access_to`,
 1 AS `nickname`,
 1 AS `dev_est_emp_id`,
 1 AS `dev_est_access`,
 1 AS `dev_est_req_access`,
 1 AS `dev_est_reqs_case_access`,
 1 AS `access_updater`,
 1 AS `last_updated`,
 1 AS `attach`,
 1 AS `iddev_apps`,
 1 AS `app_name`,
 1 AS `dev_est_smry`,
 1 AS `owner_ref_id`,
 1 AS `owner_ref_tab`,
 1 AS `est_ref_id`,
 1 AS `est_ref_tab`,
 1 AS `category`,
 1 AS `priority`,
 1 AS `est_ref_name`,
 1 AS `owner_ref_name`,
 1 AS `est_amt_pay`,
 1 AS `est_amt_bal`,
 1 AS `est_skill`,
 1 AS `est_gap_lvl`,
 1 AS `est_type`,
 1 AS `category_name`,
 1 AS `priority_name`,
 1 AS `dev_st_dt`,
 1 AS `dev_st_dt_unformatted`,
 1 AS `dev_en_dt`,
 1 AS `dev_en_dt_unformatted`,
 1 AS `dev_st_dt_time`,
 1 AS `dev_en_dt_time`,
 1 AS `est_time`,
 1 AS `pseudo_est_time`,
 1 AS `owner_name`,
 1 AS `estimater_name`,
 1 AS `est_amt`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_access_my_reqs`
--

DROP TABLE IF EXISTS `vw_dev_est_access_my_reqs`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_access_my_reqs`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_access_my_reqs` AS SELECT 
 1 AS `dev_est_emp_id`,
 1 AS `dev_est_req_access`,
 1 AS `dev_est_access`,
 1 AS `iddev_est_reqs`,
 1 AS `iddev_est`,
 1 AS `open_dt_time`,
 1 AS `open_dt_time_unformatted`,
 1 AS `close_dt_time`,
 1 AS `close_dt_time_unformatted`,
 1 AS `req_time`,
 1 AS `pseudo_req_time`,
 1 AS `pseudo_req_days`,
 1 AS `disp_order`,
 1 AS `req_desc`,
 1 AS `estimater_id`,
 1 AS `owner_id`,
 1 AS `est_type`,
 1 AS `req_status_id`,
 1 AS `req_status`,
 1 AS `req_type`,
 1 AS `category`,
 1 AS `skill_lvl`,
 1 AS `skill_lvl_val`,
 1 AS `gap_lvl`,
 1 AS `gap_lvl_val`,
 1 AS `st_dt_time`,
 1 AS `st_dt_time_unformatted`,
 1 AS `e_dt_time`,
 1 AS `e_dt_time_unformatted`,
 1 AS `stat_time`,
 1 AS `pseudo_stat_time`,
 1 AS `idlook_stat_order`,
 1 AS `assigned_to_id`,
 1 AS `assigned_to`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `last_updated`,
 1 AS `last_updated_unformatted`,
 1 AS `expire_diff`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_access_my_reqs_case`
--

DROP TABLE IF EXISTS `vw_dev_est_access_my_reqs_case`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_access_my_reqs_case`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_access_my_reqs_case` AS SELECT 
 1 AS `dev_est_emp_id`,
 1 AS `dev_est_reqs_case_access`,
 1 AS `dev_est_req_access`,
 1 AS `iddev_est_reqs_case`,
 1 AS `iddev_est_reqs`,
 1 AS `iddev_est`,
 1 AS `open_dt_time`,
 1 AS `close_dt_time`,
 1 AS `req_status`,
 1 AS `req_status_name`,
 1 AS `req_desc`,
 1 AS `created_by`,
 1 AS `created_by_name`,
 1 AS `create_dt`,
 1 AS `mod_created_by`,
 1 AS `mod_create_dt`,
 1 AS `create_end_dt`,
 1 AS `mod_create_end_dt`,
 1 AS `reqs_cases`,
 1 AS `case_data`,
 1 AS `case_result_desc`,
 1 AS `case_status`,
 1 AS `case_status_name`,
 1 AS `executed_by`,
 1 AS `executed_by_name`,
 1 AS `execute_dt`,
 1 AS `mod_execute_dt`,
 1 AS `mod_executed_by`,
 1 AS `updated_by`,
 1 AS `updated_by_name`,
 1 AS `last_updated`,
 1 AS `mod_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_reqs`
--

DROP TABLE IF EXISTS `vw_dev_est_reqs`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_reqs` AS SELECT 
 1 AS `iddev_est_reqs`,
 1 AS `iddev_est`,
 1 AS `owner_file_name`,
 1 AS `estimater_file_name`,
 1 AS `assigned_to_file_name`,
 1 AS `updater_file_name`,
 1 AS `app_name`,
 1 AS `dev_est_smry`,
 1 AS `open_dt_time`,
 1 AS `open_dt_time_unformatted`,
 1 AS `close_dt_time`,
 1 AS `close_dt_time_unformatted`,
 1 AS `req_time`,
 1 AS `pseudo_req_time`,
 1 AS `pseudo_req_days`,
 1 AS `disp_order`,
 1 AS `req_desc`,
 1 AS `estimater_id`,
 1 AS `est_ref_name`,
 1 AS `owner_id`,
 1 AS `owner_ref_name`,
 1 AS `est_type`,
 1 AS `req_status_id`,
 1 AS `req_status`,
 1 AS `req_type`,
 1 AS `category`,
 1 AS `skill_lvl`,
 1 AS `skill_lvl_val`,
 1 AS `gap_lvl`,
 1 AS `gap_lvl_val`,
 1 AS `case`,
 1 AS `st_dt_time`,
 1 AS `st_dt_time_unformatted`,
 1 AS `e_dt_time`,
 1 AS `e_dt_time_unformatted`,
 1 AS `stat_time`,
 1 AS `pseudo_stat_time`,
 1 AS `idlook_stat_order`,
 1 AS `assigned_to_id`,
 1 AS `assigned_to`,
 1 AS `reqs_cnt_actual`,
 1 AS `reqs_cnt_est`,
 1 AS `reqs_cnt_actual_est`,
 1 AS `reqs_cnt_pcnt`,
 1 AS `est_cnt_actual`,
 1 AS `est_cnt_est`,
 1 AS `est_cnt_actual_est`,
 1 AS `est_cnt_pcnt`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `last_updated`,
 1 AS `last_updated_unformatted`,
 1 AS `expire_diff`,
 1 AS `del_dt`,
 1 AS `del_dt_unformatted`,
 1 AS `del_by`,
 1 AS `del_by_id`,
 1 AS `del_by_file_name`,
 1 AS `del_day`,
 1 AS `virtual_del_day`,
 1 AS `arch_by`,
 1 AS `arch_by_id`,
 1 AS `arch_by_file_name`,
 1 AS `arch_dt`,
 1 AS `arch_dt_unformatted`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_reqs_case`
--

DROP TABLE IF EXISTS `vw_dev_est_reqs_case`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_case`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_reqs_case` AS SELECT 
 1 AS `iddev_est_reqs_case`,
 1 AS `iddev_est_reqs`,
 1 AS `iddev_est`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `dev_st_dt`,
 1 AS `dev_st_dt_unformatted`,
 1 AS `dev_en_dt`,
 1 AS `dev_en_dt_unformatted`,
 1 AS `est_time`,
 1 AS `open_dt_time`,
 1 AS `open_dt_time_unformatted`,
 1 AS `close_dt_time`,
 1 AS `close_dt_time_unformatted`,
 1 AS `req_time`,
 1 AS `skill_lvl_val`,
 1 AS `category`,
 1 AS `gap_lvl_val`,
 1 AS `req_status`,
 1 AS `req_status_name`,
 1 AS `req_desc`,
 1 AS `dev_est_smry`,
 1 AS `created_by_file_name`,
 1 AS `created_by`,
 1 AS `created_by_name`,
 1 AS `create_dt`,
 1 AS `mod_created_by`,
 1 AS `mod_create_dt`,
 1 AS `create_end_dt`,
 1 AS `mod_create_end_dt`,
 1 AS `create_time`,
 1 AS `reqs_cases`,
 1 AS `case_data`,
 1 AS `case_result_desc`,
 1 AS `case_status`,
 1 AS `case_status_name`,
 1 AS `executed_by_file_name`,
 1 AS `executed_by`,
 1 AS `executed_by_name`,
 1 AS `execute_dt`,
 1 AS `mod_execute_dt`,
 1 AS `mod_executed_by`,
 1 AS `updater_file_name`,
 1 AS `updated_by`,
 1 AS `updated_by_name`,
 1 AS `last_updated`,
 1 AS `mod_last_updated`,
 1 AS `cur_stat`,
 1 AS `estimater_id`,
 1 AS `est_ref_name`,
 1 AS `estimater_file_name`,
 1 AS `owner_id`,
 1 AS `owner_ref_name`,
 1 AS `owner_file_name`,
 1 AS `reqs_cnt_actual_est`,
 1 AS `reqs_cnt_pcnt`,
 1 AS `est_cnt_actual_est`,
 1 AS `est_cnt_pcnt`,
 1 AS `dev_est_cnt`,
 1 AS `dev_est_pcnt`,
 1 AS `del_dt`,
 1 AS `del_by`,
 1 AS `del_by_id`,
 1 AS `del_day`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt`,
 1 AS `archv_by`,
 1 AS `archv_by_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_reqs_case_result`
--

DROP TABLE IF EXISTS `vw_dev_est_reqs_case_result`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_case_result`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_reqs_case_result` AS SELECT 
 1 AS `iddev_est_reqs_case_result`,
 1 AS `iddev_est_reqs_case`,
 1 AS `iddev_est_reqs`,
 1 AS `case_result_desc_cases`,
 1 AS `req_desc`,
 1 AS `case_data`,
 1 AS `case_result_desc`,
 1 AS `case_status`,
 1 AS `execute_date`,
 1 AS `executed_by`,
 1 AS `executed_by_name`,
 1 AS `executed_by_name2`,
 1 AS `req_status_name`,
 1 AS `updated_by`,
 1 AS `updated_by_name`,
 1 AS `execute_dt`,
 1 AS `mod_execute_dt`,
 1 AS `last_updated`,
 1 AS `mod_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_reqs_filter`
--

DROP TABLE IF EXISTS `vw_dev_est_reqs_filter`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_filter`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_reqs_filter` AS SELECT 
 1 AS `iddev_est_reqs`,
 1 AS `iddev_est`,
 1 AS `open_dt_time`,
 1 AS `open_dt_time_unformatted`,
 1 AS `close_dt_time`,
 1 AS `close_dt_time_unformatted`,
 1 AS `req_status_id`,
 1 AS `req_status`,
 1 AS `assigned_to_id`,
 1 AS `assigned_to`,
 1 AS `updater_id`,
 1 AS `updater`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_reqs_status`
--

DROP TABLE IF EXISTS `vw_dev_est_reqs_status`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_status`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_reqs_status` AS SELECT 
 1 AS `iddev_est_reqs_status`,
 1 AS `iddev_est`,
 1 AS `app_name`,
 1 AS `dev_est_smry`,
 1 AS `owner_file_name`,
 1 AS `estimater_file_name`,
 1 AS `wk_or_st_dt`,
 1 AS `wk_or_en_dt`,
 1 AS `iddev_est_reqs`,
 1 AS `status_id`,
 1 AS `status`,
 1 AS `assigned_to_file_name`,
 1 AS `updater_file_name`,
 1 AS `idlook_stat_order`,
 1 AS `stat_st_dt`,
 1 AS `stat_e_dt`,
 1 AS `stat_st_dt_unformatted`,
 1 AS `stat_e_dt_unformatted`,
 1 AS `stat_time`,
 1 AS `lag_time`,
 1 AS `assigned_to_id`,
 1 AS `assigned_to`,
 1 AS `nickname`,
 1 AS `req_desc`,
 1 AS `cur_stat_id`,
 1 AS `cur_stat`,
 1 AS `cur_st_dt_tm`,
 1 AS `cur_st_dt_tm_fmt`,
 1 AS `req_cur_open_month`,
 1 AS `req_cur_open_year`,
 1 AS `cur_e_dt_tm`,
 1 AS `cur_e_dt_tm_fmt`,
 1 AS `cur_stat_tm`,
 1 AS `req_open_dt_time`,
 1 AS `req_open_dt_time_unformatted`,
 1 AS `req_open_month`,
 1 AS `req_open_year`,
 1 AS `req_close_dt_time`,
 1 AS `req_close_dt_time_unformatted`,
 1 AS `req_time`,
 1 AS `pseudo_req_days`,
 1 AS `estimater_id`,
 1 AS `owner_id`,
 1 AS `req_est_type`,
 1 AS `req_type`,
 1 AS `category`,
 1 AS `skill_lvl`,
 1 AS `skill_lvl_val`,
 1 AS `gap_lvl`,
 1 AS `reqs_cnt_actual`,
 1 AS `reqs_cnt_est`,
 1 AS `reqs_cnt_actual_est`,
 1 AS `reqs_cnt_pcnt`,
 1 AS `est_cnt_actual`,
 1 AS `est_cnt_est`,
 1 AS `est_cnt_actual_est`,
 1 AS `est_cnt_pcnt`,
 1 AS `cur_assignee_id`,
 1 AS `cur_assignee_nm`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `last_updated`,
 1 AS `del_dt`,
 1 AS `del_dt_unformatted`,
 1 AS `del_by`,
 1 AS `del_by_id`,
 1 AS `del_by_file_name`,
 1 AS `del_day`,
 1 AS `virtual_del_day`,
 1 AS `arch_by`,
 1 AS `arch_by_id`,
 1 AS `arch_by_file_name`,
 1 AS `arch_dt`,
 1 AS `arch_dt_unformatted`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_reqs_status_forcast`
--

DROP TABLE IF EXISTS `vw_dev_est_reqs_status_forcast`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_status_forcast`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_reqs_status_forcast` AS SELECT 
 1 AS `iddev_est_reqs_status_forcast`,
 1 AS `iddev_est`,
 1 AS `iddev_est_reqs`,
 1 AS `status_id`,
 1 AS `status`,
 1 AS `owner_file_name`,
 1 AS `estimater_file_name`,
 1 AS `assigned_to_file_name`,
 1 AS `updater_file_name`,
 1 AS `idlook_stat_order`,
 1 AS `stat_st_dt`,
 1 AS `stat_e_dt`,
 1 AS `stat_st_dt_unformatted`,
 1 AS `stat_e_dt_unformatted`,
 1 AS `stat_time`,
 1 AS `lag_time`,
 1 AS `assigned_to_id`,
 1 AS `assigned_to`,
 1 AS `nickname`,
 1 AS `dev_est_smry`,
 1 AS `req_desc`,
 1 AS `cur_stat_id`,
 1 AS `cur_stat`,
 1 AS `cur_st_dt_tm`,
 1 AS `cur_st_dt_tm_fmt`,
 1 AS `cur_e_dt_tm`,
 1 AS `cur_e_dt_tm_fmt`,
 1 AS `cur_stat_tm`,
 1 AS `req_open_dt_time`,
 1 AS `req_open_dt_time_unformatted`,
 1 AS `req_close_dt_time`,
 1 AS `req_close_dt_time_unformatted`,
 1 AS `req_time`,
 1 AS `pseudo_req_days`,
 1 AS `estimater_id`,
 1 AS `owner_id`,
 1 AS `req_est_type`,
 1 AS `req_type`,
 1 AS `category`,
 1 AS `skill_lvl`,
 1 AS `skill_lvl_val`,
 1 AS `gap_lvl`,
 1 AS `gap_lvl_val`,
 1 AS `cur_assignee_id`,
 1 AS `cur_assignee_nm`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_reqs_status_steps`
--

DROP TABLE IF EXISTS `vw_dev_est_reqs_status_steps`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_status_steps`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_reqs_status_steps` AS SELECT 
 1 AS `iddev_est_req_status_steps`,
 1 AS `iddev_est_reqs_status`,
 1 AS `iddev_est_reqs`,
 1 AS `updater_file_name`,
 1 AS `req_status_id`,
 1 AS `status`,
 1 AS `dev_steps_details`,
 1 AS `last_updated`,
 1 AS `last_updated_unformatted`,
 1 AS `update_id`,
 1 AS `updater`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_est_reqs_status_without_steps`
--

DROP TABLE IF EXISTS `vw_dev_est_reqs_status_without_steps`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_status_without_steps`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_est_reqs_status_without_steps` AS SELECT 
 1 AS `iddev_est_req_status_steps`,
 1 AS `iddev_est_reqs_status`,
 1 AS `dev_steps_details`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_lk_label`
--

DROP TABLE IF EXISTS `vw_dev_lk_label`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_lk_label`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_lk_label` AS SELECT 
 1 AS `iddev_lk_label`,
 1 AS `dev_label_nm`,
 1 AS `hover_fields`,
 1 AS `disp_order`,
 1 AS `lk_parent_val_id`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `updater_file_name`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_lk_wrk_flow`
--

DROP TABLE IF EXISTS `vw_dev_lk_wrk_flow`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_lk_wrk_flow`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_lk_wrk_flow` AS SELECT 
 1 AS `iddev_lk_wrk_flow`,
 1 AS `wrk_flow_nm`,
 1 AS `id_wrk_flow`,
 1 AS `wrk_flow_desc`,
 1 AS `id_wrk_flow_parent`,
 1 AS `look_initial`,
 1 AS `look_restart`,
 1 AS `disp_order`,
 1 AS `updater`,
 1 AS `updater_fmt`,
 1 AS `last_updated`,
 1 AS `last_updated_fmt`,
 1 AS `last_updated_by`,
 1 AS `look_value`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_look_value`
--

DROP TABLE IF EXISTS `vw_dev_look_value`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_look_value`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_look_value` AS SELECT 
 1 AS `iddev_look_value`,
 1 AS `look_value`,
 1 AS `look_value_desc`,
 1 AS `disp_order`,
 1 AS `parent_id`,
 1 AS `updater`,
 1 AS `updater_fmt`,
 1 AS `updater_file_name`,
 1 AS `last_updated`,
 1 AS `last_updated_fmt`,
 1 AS `last_updated_by`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_rpt`
--

DROP TABLE IF EXISTS `vw_dev_rpt`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_rpt`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_rpt` AS SELECT 
 1 AS `iddev_rpt`,
 1 AS `iddev_apps`,
 1 AS `app_name`,
 1 AS `iddev_est`,
 1 AS `dev_est_smry`,
 1 AS `category`,
 1 AS `category_nm`,
 1 AS `priority_id`,
 1 AS `priority_value`,
 1 AS `app_wr_id_wr_summary_prid`,
 1 AS `iddev_est_reqs`,
 1 AS `req_desc`,
 1 AS `acpt_cnt`,
 1 AS `acpt_attmpt_cnt`,
 1 AS `skill_level`,
 1 AS `skll_level_avg`,
 1 AS `req_type_value`,
 1 AS `req_type`,
 1 AS `wrk_or_gap`,
 1 AS `req_gap`,
 1 AS `req_gap_avg`,
 1 AS `req_measure`,
 1 AS `owner_ref_tab`,
 1 AS `owner_ref_id`,
 1 AS `owner_ref_nm`,
 1 AS `owner`,
 1 AS `est_ref_tab`,
 1 AS `est_ref_id`,
 1 AS `est_ref_nm`,
 1 AS `estimator`,
 1 AS `w_or_opned`,
 1 AS `w_or_closed`,
 1 AS `w_or_duration`,
 1 AS `pseudo_w_or_duration`,
 1 AS `pseudo_w_or_duration_filter`,
 1 AS `pseudo_w_or_duration2`,
 1 AS `w_or_cnvr`,
 1 AS `w_or_statistics`,
 1 AS `req_disp_ord`,
 1 AS `req_open`,
 1 AS `req_close`,
 1 AS `req_tm`,
 1 AS `pseudo_req_time`,
 1 AS `pha_cur_prior_st_en_dt`,
 1 AS `req_statistics`,
 1 AS `est_type`,
 1 AS `pha_cnt`,
 1 AS `pha_curr_id`,
 1 AS `pha_curr_value`,
 1 AS `pha_cur_st_dt`,
 1 AS `pha_cur_end_dt`,
 1 AS `pha_cur_by_id`,
 1 AS `pha_cur_by_nm`,
 1 AS `current_phase`,
 1 AS `pha_cur_duration`,
 1 AS `pseudo_pha_cur_duration`,
 1 AS `phase_cycle`,
 1 AS `phase_cycle_by`,
 1 AS `pha1_id`,
 1 AS `pha1_nm`,
 1 AS `pha1_by_id`,
 1 AS `pha1_by_nm`,
 1 AS `pha1_lag`,
 1 AS `pseudo_pha1_lag`,
 1 AS `pha1_duration`,
 1 AS `pseudo_pha1_duration`,
 1 AS `phase1`,
 1 AS `phase2`,
 1 AS `phase3`,
 1 AS `phase4`,
 1 AS `phase5`,
 1 AS `pha6_plus`,
 1 AS `last_phase`,
 1 AS `pha_smry`,
 1 AS `last_updated`,
 1 AS `pha_cur_lag`,
 1 AS `pseudo_pha_cur_lag`,
 1 AS `tot_duration`,
 1 AS `pseudo_tot_duration`,
 1 AS `tot_lag`,
 1 AS `pseudo_tot_lag`,
 1 AS `pha2_id`,
 1 AS `pha2_nm`,
 1 AS `pha2_by_id`,
 1 AS `pha2_by_nm`,
 1 AS `pha2_lag`,
 1 AS `pseudo_pha2_lag`,
 1 AS `pha2_duration`,
 1 AS `pseudo_pha2_duration`,
 1 AS `pha3_id`,
 1 AS `pha3_nm`,
 1 AS `pha3_by_id`,
 1 AS `pha3_by_nm`,
 1 AS `pha3_lag`,
 1 AS `pseudo_pha3_lag`,
 1 AS `pha3_duration`,
 1 AS `pseudo_pha3_duration`,
 1 AS `pha4_id`,
 1 AS `pha4_nm`,
 1 AS `pha4_by_id`,
 1 AS `pha4_by_nm`,
 1 AS `pha4_lag`,
 1 AS `pseudo_pha4_lag`,
 1 AS `pha4_duration`,
 1 AS `pseudo_pha4_duration`,
 1 AS `pha5_id`,
 1 AS `pha5_nm`,
 1 AS `pha5_by_id`,
 1 AS `pha5_by_nm`,
 1 AS `pha5_lag`,
 1 AS `pseudo_pha5_lag`,
 1 AS `pha5_duration`,
 1 AS `pseudo_pha5_duration`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `last_updated_formated`,
 1 AS `pha_last_id`,
 1 AS `pha_last_name`,
 1 AS `pha_last_by_id`,
 1 AS `pha_last_by_name`,
 1 AS `pha_last_lag`,
 1 AS `pha_last_duration`,
 1 AS `assigned_to_ids`,
 1 AS `pseudo_pha_last_lag`,
 1 AS `pseudo_pha_last_duration`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_trng`
--

DROP TABLE IF EXISTS `vw_dev_trng`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_trng`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_trng` AS SELECT 
 1 AS `iddev_trng`,
 1 AS `disp_order`,
 1 AS `train_nm`,
 1 AS `train_desc`,
 1 AS `duration`,
 1 AS `cnt`,
 1 AS `practical`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `last_updated_by`,
 1 AS `del_dt`,
 1 AS `del_dt_formatted`,
 1 AS `del_by`,
 1 AS `del_by_formatted`,
 1 AS `del_by_file_name`,
 1 AS `del_day`,
 1 AS `del_day_formatted`,
 1 AS `arch_by`,
 1 AS `arch_by_formatted`,
 1 AS `arch_by_file_name`,
 1 AS `arch_dt`,
 1 AS `arch_dt_formatted`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dev_trng_attach`
--

DROP TABLE IF EXISTS `vw_dev_trng_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_dev_trng_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dev_trng_attach` AS SELECT 
 1 AS `iddev_trng_attach`,
 1 AS `iddev_trng`,
 1 AS `disp_order`,
 1 AS `trng_desc`,
 1 AS `duration`,
 1 AS `idstorage`,
 1 AS `cloud_link`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `last_updated_by`,
 1 AS `del_dt`,
 1 AS `del_dt_formatted`,
 1 AS `del_by`,
 1 AS `del_by_formatted`,
 1 AS `del_by_file_name`,
 1 AS `del_day`,
 1 AS `del_day_formatted`,
 1 AS `arch_by`,
 1 AS `arch_by_formatted`,
 1 AS `arch_by_file_name`,
 1 AS `arch_dt`,
 1 AS `arch_dt_formatted`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dyn_emp_attach`
--

DROP TABLE IF EXISTS `vw_dyn_emp_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_dyn_emp_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dyn_emp_attach` AS SELECT 
 1 AS `emp_id`,
 1 AS `file_group`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dyn_emp_contact`
--

DROP TABLE IF EXISTS `vw_dyn_emp_contact`;
/*!50001 DROP VIEW IF EXISTS `vw_dyn_emp_contact`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dyn_emp_contact` AS SELECT 
 1 AS `emp_id`,
 1 AS `employee_name`,
 1 AS `contacts`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dyn_emp_tag`
--

DROP TABLE IF EXISTS `vw_dyn_emp_tag`;
/*!50001 DROP VIEW IF EXISTS `vw_dyn_emp_tag`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dyn_emp_tag` AS SELECT 
 1 AS `emp_id`,
 1 AS `tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dyn_prosp_attach`
--

DROP TABLE IF EXISTS `vw_dyn_prosp_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_dyn_prosp_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dyn_prosp_attach` AS SELECT 
 1 AS `prosp_consult_id`,
 1 AS `file_group`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_dyn_prosp_contact`
--

DROP TABLE IF EXISTS `vw_dyn_prosp_contact`;
/*!50001 DROP VIEW IF EXISTS `vw_dyn_prosp_contact`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_dyn_prosp_contact` AS SELECT 
 1 AS `prosp_consult_id`,
 1 AS `group_contact`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp`
--

DROP TABLE IF EXISTS `vw_emp`;
/*!50001 DROP VIEW IF EXISTS `vw_emp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp` AS SELECT 
 1 AS `emp_id`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `fullname`,
 1 AS `nickname`,
 1 AS `unique_id`,
 1 AS `unique_id_type`,
 1 AS `ssn`,
 1 AS `dob`,
 1 AS `gender_id`,
 1 AS `gender`,
 1 AS `sto_limit`,
 1 AS `sto_limit_format`,
 1 AS `emp_file_name`,
 1 AS `taxid`,
 1 AS `login_id`,
 1 AS `isp`,
 1 AS `domain_name`,
 1 AS `country`,
 1 AS `lastlogin`,
 1 AS `logged_in`,
 1 AS `lastlogout`,
 1 AS `loggged_out`,
 1 AS `main_menu`,
 1 AS `sub_menu`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `updater_file_name`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `del_dt_unformatted`,
 1 AS `del_dt`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt_unformatted`,
 1 AS `archv_dt`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_access`
--

DROP TABLE IF EXISTS `vw_emp_access`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_access`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_access` AS SELECT 
 1 AS `access_id`,
 1 AS `emp_id`,
 1 AS `emp_name`,
 1 AS `feature_id`,
 1 AS `feature_name`,
 1 AS `feature_desc`,
 1 AS `disp_order`,
 1 AS `last_updated`,
 1 AS `updated_by`,
 1 AS `del_dt`,
 1 AS `del_by`,
 1 AS `del_day`,
 1 AS `archv_dt`,
 1 AS `archv_by`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_activity`
--

DROP TABLE IF EXISTS `vw_emp_activity`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_activity`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_activity` AS SELECT 
 1 AS `idemp_activity`,
 1 AS `empd_id`,
 1 AS `call_recv_dt`,
 1 AS `emp_id`,
 1 AS `updater`,
 1 AS `next_call_dt`,
 1 AS `call_note`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_add1`
--

DROP TABLE IF EXISTS `vw_emp_add1`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_add1`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_add1` AS SELECT 
 1 AS `emp_add_id`,
 1 AS `emp_id`,
 1 AS `from_dt`,
 1 AS `sort_from_dt`,
 1 AS `to_dt`,
 1 AS `no_days_lived`,
 1 AS `no_years_lived`,
 1 AS `sort_to_dt`,
 1 AS `add_type`,
 1 AS `house_apt_no`,
 1 AS `look_street_no_id`,
 1 AS `look_street_no_id2`,
 1 AS `addresses`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_add2`
--

DROP TABLE IF EXISTS `vw_emp_add2`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_add2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_add2` AS SELECT 
 1 AS `emp_id`,
 1 AS `addresses`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_address`
--

DROP TABLE IF EXISTS `vw_emp_address`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_address`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_address` AS SELECT 
 1 AS `emp_add_id`,
 1 AS `emp_id`,
 1 AS `house_apt_no`,
 1 AS `house_apt_type`,
 1 AS `house_apt_type_nm`,
 1 AS `look_street_no_id`,
 1 AS `look_street_no`,
 1 AS `street_name`,
 1 AS `street_type`,
 1 AS `street_type_name`,
 1 AS `zip_code`,
 1 AS `city_name`,
 1 AS `state_name`,
 1 AS `con_name`,
 1 AS `addresses`,
 1 AS `add_type`,
 1 AS `add_type_nm`,
 1 AS `from_dt`,
 1 AS `to_dt`,
 1 AS `from_dt_formatted`,
 1 AS `to_dt_formatted`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `updater_file_name`,
 1 AS `last_updated`,
 1 AS `format_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_attach`
--

DROP TABLE IF EXISTS `vw_emp_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_attach` AS SELECT 
 1 AS `idstorage`,
 1 AS `file_name`,
 1 AS `file_size`,
 1 AS `create_dt`,
 1 AS `updater`,
 1 AS `emp_id`,
 1 AS `emp_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_attachment`
--

DROP TABLE IF EXISTS `vw_emp_attachment`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_attachment`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_attachment` AS SELECT 
 1 AS `emp_legal_id`,
 1 AS `doc_type`,
 1 AS `doc_look_values`,
 1 AS `expire_dt`,
 1 AS `emp_id`,
 1 AS `idstorage`,
 1 AS `updater`,
 1 AS `owner_id`,
 1 AS `file_name`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `updated_for_ref_id`,
 1 AS `updated_for_ref_table`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_billing_details`
--

DROP TABLE IF EXISTS `vw_emp_billing_details`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_billing_details`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_billing_details` AS SELECT 
 1 AS `companyname`,
 1 AS `bill_pay_rate`,
 1 AS `engage_calc`,
 1 AS `engage_amt`,
 1 AS `engage_st_dt`,
 1 AS `engage_end_st`,
 1 AS `limit_amt`,
 1 AS `engage_summary`,
 1 AS `engage_ref_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_contact`
--

DROP TABLE IF EXISTS `vw_emp_contact`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_contact`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_contact` AS SELECT 
 1 AS `emp_contact_id`,
 1 AS `emp_id`,
 1 AS `contact_id`,
 1 AS `emp_contact_type`,
 1 AS `contact_type`,
 1 AS `contact_detail`,
 1 AS `summary`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `updater_file_name`,
 1 AS `last_updated`,
 1 AS `format_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_contact1`
--

DROP TABLE IF EXISTS `vw_emp_contact1`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_contact1`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_contact1` AS SELECT 
 1 AS `emp_id`,
 1 AS `employee_name`,
 1 AS `emp_contact_id`,
 1 AS `contact_type`,
 1 AS `summary`,
 1 AS `contact_id`,
 1 AS `contact_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_contact2`
--

DROP TABLE IF EXISTS `vw_emp_contact2`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_contact2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_contact2` AS SELECT 
 1 AS `emp_id`,
 1 AS `employee_name`,
 1 AS `contacts`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_contact3`
--

DROP TABLE IF EXISTS `vw_emp_contact3`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_contact3`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_contact3` AS SELECT 
 1 AS `emp_id`,
 1 AS `img`,
 1 AS `employee_name`,
 1 AS `contacts`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_contact4`
--

DROP TABLE IF EXISTS `vw_emp_contact4`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_contact4`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_contact4` AS SELECT 
 1 AS `emp_id`,
 1 AS `img`,
 1 AS `employee_name`,
 1 AS `contacts`,
 1 AS `personel`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_contact5`
--

DROP TABLE IF EXISTS `vw_emp_contact5`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_contact5`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_contact5` AS SELECT 
 1 AS `emp_id`,
 1 AS `img`,
 1 AS `employee_name`,
 1 AS `contacts`,
 1 AS `personel`,
 1 AS `addresses`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_contact6`
--

DROP TABLE IF EXISTS `vw_emp_contact6`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_contact6`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_contact6` AS SELECT 
 1 AS `emp_id`,
 1 AS `img`,
 1 AS `employee_name`,
 1 AS `personel`,
 1 AS `contacts`,
 1 AS `addresses`,
 1 AS `companies`,
 1 AS `employment_days`,
 1 AS `consulting_companies`,
 1 AS `consulting_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_contact6_bench`
--

DROP TABLE IF EXISTS `vw_emp_contact6_bench`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_contact6_bench`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_contact6_bench` AS SELECT 
 1 AS `emp_id`,
 1 AS `img`,
 1 AS `employee_name`,
 1 AS `personel`,
 1 AS `contacts`,
 1 AS `addresses`,
 1 AS `companies`,
 1 AS `employment_days`,
 1 AS `consulting_companies`,
 1 AS `consulting_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_contact6_x`
--

DROP TABLE IF EXISTS `vw_emp_contact6_x`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_contact6_x`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_contact6_x` AS SELECT 
 1 AS `emp_id`,
 1 AS `img`,
 1 AS `employee_name`,
 1 AS `personel`,
 1 AS `contacts`,
 1 AS `addresses`,
 1 AS `companies`,
 1 AS `employment_days`,
 1 AS `consulting_companies`,
 1 AS `consulting_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_details`
--

DROP TABLE IF EXISTS `vw_emp_details`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_details`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_details` AS SELECT 
 1 AS `emp_id`,
 1 AS `idstorage`,
 1 AS `file_name`,
 1 AS `personal_details`,
 1 AS `other_details`,
 1 AS `contacts`,
 1 AS `mod_last_updated`,
 1 AS `addresses`,
 1 AS `companies`,
 1 AS `employment_days`,
 1 AS `consulting_companies`,
 1 AS `consulting_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_exp_docs`
--

DROP TABLE IF EXISTS `vw_emp_exp_docs`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_exp_docs`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_exp_docs` AS SELECT 
 1 AS `idstorage`,
 1 AS `file_name`,
 1 AS `file_size`,
 1 AS `create_dt`,
 1 AS `owner_id`,
 1 AS `ext_type`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `expire_dt`,
 1 AS `emp_legal_id`,
 1 AS `updater`,
 1 AS `mod_expiry`,
 1 AS `emp_id`,
 1 AS `emp_name`,
 1 AS `doc_type`,
 1 AS `owner_name`,
 1 AS `updater_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_extra_tags`
--

DROP TABLE IF EXISTS `vw_emp_extra_tags`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_extra_tags`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_extra_tags` AS SELECT 
 1 AS `idemp_tag`,
 1 AS `emp_id`,
 1 AS `emp_tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_extra_values_in_tags`
--

DROP TABLE IF EXISTS `vw_emp_extra_values_in_tags`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_extra_values_in_tags`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_extra_values_in_tags` AS SELECT 
 1 AS `idemp_tag`,
 1 AS `emp_id`,
 1 AS `emp_tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_legal`
--

DROP TABLE IF EXISTS `vw_emp_legal`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_legal`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_legal` AS SELECT 
 1 AS `emp_legal_id`,
 1 AS `emp_id`,
 1 AS `emp_name`,
 1 AS `doc_type`,
 1 AS `idstorage`,
 1 AS `file_name`,
 1 AS `file_summary`,
 1 AS `file_size`,
 1 AS `file_size_formatted`,
 1 AS `owner_id`,
 1 AS `create_dt`,
 1 AS `create_dt_formatted`,
 1 AS `ext_type`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `expire_dt`,
 1 AS `expire_dt_formatted`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `updater_file_name`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_legal_attach`
--

DROP TABLE IF EXISTS `vw_emp_legal_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_legal_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_legal_attach` AS SELECT 
 1 AS `emp_legal_id`,
 1 AS `doc_type`,
 1 AS `doc_look_values`,
 1 AS `expire_dt`,
 1 AS `emp_id`,
 1 AS `idstorage`,
 1 AS `updater`,
 1 AS `owner_id`,
 1 AS `file_name`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `updated_for_ref_id`,
 1 AS `updated_for_ref_table`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_load`
--

DROP TABLE IF EXISTS `vw_emp_load`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_load`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_load` AS SELECT 
 1 AS `emp_id`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `nickname`,
 1 AS `fullname`,
 1 AS `emp_file_name`,
 1 AS `unique_id`,
 1 AS `uniqueid_type`,
 1 AS `ssn`,
 1 AS `uniqueid`,
 1 AS `contacts`,
 1 AS `all_addresses`,
 1 AS `employment`,
 1 AS `emp_days`,
 1 AS `emp_+_days`,
 1 AS `consulting`,
 1 AS `consulting_days`,
 1 AS `consult_days`,
 1 AS `gender_id`,
 1 AS `gender`,
 1 AS `dob`,
 1 AS `dob_format`,
 1 AS `age`,
 1 AS `login_id`,
 1 AS `isp`,
 1 AS `domain_name`,
 1 AS `country`,
 1 AS `lastlogin`,
 1 AS `logged_in`,
 1 AS `lastlogout`,
 1 AS `loggged_out`,
 1 AS `main_menu`,
 1 AS `sub_menu`,
 1 AS `last_updated`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `del_dt_unformatted`,
 1 AS `del_dt`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt_unformatted`,
 1 AS `archv_dt`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`,
 1 AS `total_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_org`
--

DROP TABLE IF EXISTS `vw_emp_org`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_org`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_org` AS SELECT 
 1 AS `emp_org_id`,
 1 AS `emp_id`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `org_start_dt`,
 1 AS `org_start_dt_formatted`,
 1 AS `org_end_dt`,
 1 AS `org_end_dt_formatted`,
 1 AS `days`,
 1 AS `days_formatted`,
 1 AS `company_formatted`,
 1 AS `emp_type`,
 1 AS `emp_type_nm`,
 1 AS `run_script`,
 1 AS `updater`,
 1 AS `updater_formatted`,
 1 AS `updater_nm`,
 1 AS `updater_file_name`,
 1 AS `last_updated`,
 1 AS `format_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_org2`
--

DROP TABLE IF EXISTS `vw_emp_org2`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_org2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_org2` AS SELECT 
 1 AS `emp_id`,
 1 AS `comp_id`,
 1 AS `companies_formatted`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt1`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt1`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt1`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt1` AS SELECT 
 1 AS `emp_org_id`,
 1 AS `emp_id`,
 1 AS `gender`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `org_start_dt`,
 1 AS `sort_org_start_dt`,
 1 AS `org_end_dt`,
 1 AS `sort_org_end_dt`,
 1 AS `days`,
 1 AS `billable_type`,
 1 AS `employment`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt11`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt11`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt11`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt11` AS SELECT 
 1 AS `emp_id`,
 1 AS `comp_id`,
 1 AS `org_start_dt`,
 1 AS `org_end_dt`,
 1 AS `no_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt11_x`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt11_x`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt11_x`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt11_x` AS SELECT 
 1 AS `emp_id`,
 1 AS `comp_id`,
 1 AS `org_start_dt`,
 1 AS `org_end_dt`,
 1 AS `no_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt12`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt12`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt12`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt12` AS SELECT 
 1 AS `emp_id`,
 1 AS `comp_id`,
 1 AS `org_dates_days`,
 1 AS `total`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt12_x`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt12_x`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt12_x`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt12_x` AS SELECT 
 1 AS `emp_id`,
 1 AS `comp_id`,
 1 AS `org_dates_days`,
 1 AS `total`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt13`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt13`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt13`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt13` AS SELECT 
 1 AS `emp_id`,
 1 AS `companies`,
 1 AS `employment_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt13_x`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt13_x`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt13_x`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt13_x` AS SELECT 
 1 AS `emp_id`,
 1 AS `companies`,
 1 AS `employment_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt2`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt2`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt2` AS SELECT 
 1 AS `emp_id`,
 1 AS `gender`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `bill_start_dt`,
 1 AS `sort_bill_start_dt`,
 1 AS `bill_end_dt`,
 1 AS `sort_bill_end_dt`,
 1 AS `days`,
 1 AS `billable_type`,
 1 AS `employment`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt21`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt21`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt21`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt21` AS SELECT 
 1 AS `emp_id`,
 1 AS `srv_client`,
 1 AS `bill_start_dt`,
 1 AS `bill_end_dt`,
 1 AS `consulting_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt22`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt22`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt22`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt22` AS SELECT 
 1 AS `emp_id`,
 1 AS `srv_client`,
 1 AS `consulting_dates_days`,
 1 AS `total`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt22_bench`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt22_bench`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt22_bench`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt22_bench` AS SELECT 
 1 AS `emp_id`,
 1 AS `srv_client`,
 1 AS `consulting_dates_days`,
 1 AS `total`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt23`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt23`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt23`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt23` AS SELECT 
 1 AS `emp_id`,
 1 AS `consulting_companies`,
 1 AS `total`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt23_bench`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt23_bench`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt23_bench`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt23_bench` AS SELECT 
 1 AS `emp_id`,
 1 AS `consulting_companies`,
 1 AS `total`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt3`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt3`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt3`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt3` AS SELECT 
 1 AS `emp_id`,
 1 AS `gender`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `fullname`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `start_dt`,
 1 AS `end_dt`,
 1 AS `sort_start_dt`,
 1 AS `sort_end_dt`,
 1 AS `days`,
 1 AS `billable_type`,
 1 AS `employment`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt4`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt4`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt4`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt4` AS SELECT 
 1 AS `emp_id`,
 1 AS `gender`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `fullname`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `start_dt`,
 1 AS `end_dt`,
 1 AS `sort_start_dt`,
 1 AS `sort_end_dt`,
 1 AS `billable_type`,
 1 AS `employment`,
 1 AS `no_of_days`,
 1 AS `sort_employment`,
 1 AS `sort_no_of_days`,
 1 AS `routed_days`,
 1 AS `routed_employment`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_st_end_dt_11_new`
--

DROP TABLE IF EXISTS `vw_emp_st_end_dt_11_new`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt_11_new`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_st_end_dt_11_new` AS SELECT 
 1 AS `emp_id`,
 1 AS `org_start_dt`,
 1 AS `org_end_dt`,
 1 AS `no_days`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_tag_extra_1`
--

DROP TABLE IF EXISTS `vw_emp_tag_extra_1`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_tag_extra_1`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_tag_extra_1` AS SELECT 
 1 AS `idemp_tag`,
 1 AS `emp_id`,
 1 AS `emp_tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_tag_extra_2`
--

DROP TABLE IF EXISTS `vw_emp_tag_extra_2`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_tag_extra_2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_tag_extra_2` AS SELECT 
 1 AS `idemp_tag`,
 1 AS `emp_id`,
 1 AS `emp_tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_emp_tag_extra_3`
--

DROP TABLE IF EXISTS `vw_emp_tag_extra_3`;
/*!50001 DROP VIEW IF EXISTS `vw_emp_tag_extra_3`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_emp_tag_extra_3` AS SELECT 
 1 AS `idemp_tag`,
 1 AS `emp_id`,
 1 AS `emp_tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_empend`
--

DROP TABLE IF EXISTS `vw_empend`;
/*!50001 DROP VIEW IF EXISTS `vw_empend`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_empend` AS SELECT 
 1 AS `year`,
 1 AS `month`,
 1 AS `cnt`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_employee`
--

DROP TABLE IF EXISTS `vw_employee`;
/*!50001 DROP VIEW IF EXISTS `vw_employee`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_employee` AS SELECT 
 1 AS `emp_id`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `ssn`,
 1 AS `dob`,
 1 AS `gender`,
 1 AS `sdate`,
 1 AS `edate`,
 1 AS `noOfDays`,
 1 AS `comp_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_empstart`
--

DROP TABLE IF EXISTS `vw_empstart`;
/*!50001 DROP VIEW IF EXISTS `vw_empstart`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_empstart` AS SELECT 
 1 AS `year`,
 1 AS `month`,
 1 AS `cnt`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_engage`
--

DROP TABLE IF EXISTS `vw_engage`;
/*!50001 DROP VIEW IF EXISTS `vw_engage`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_engage` AS SELECT 
 1 AS `engage_id`,
 1 AS `comp_id`,
 1 AS `idengage_comp`,
 1 AS `companyname`,
 1 AS `srv_st_dt`,
 1 AS `formatted_srv_st_dt`,
 1 AS `srv_e_dt`,
 1 AS `formatted_srv_e_dt`,
 1 AS `sr_frequency`,
 1 AS `srv_paytype`,
 1 AS `eg_sumry`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_engage_budget`
--

DROP TABLE IF EXISTS `vw_engage_budget`;
/*!50001 DROP VIEW IF EXISTS `vw_engage_budget`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_engage_budget` AS SELECT 
 1 AS `idengage_entity_po`,
 1 AS `budget_contact`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_engage_details`
--

DROP TABLE IF EXISTS `vw_engage_details`;
/*!50001 DROP VIEW IF EXISTS `vw_engage_details`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_engage_details` AS SELECT 
 1 AS `engage_id`,
 1 AS `srv_st_dt`,
 1 AS `srv_e_dt`,
 1 AS `sr_frequency`,
 1 AS `srv_paytype`,
 1 AS `srv_amount`,
 1 AS `eg_sumry`,
 1 AS `srv_client`,
 1 AS `comp_id`,
 1 AS `mod_srv_st_dt`,
 1 AS `mod_srv_st_dt1`,
 1 AS `mod_srv_e_dt`,
 1 AS `mod_srv_e_dt1`,
 1 AS `frequency`,
 1 AS `paytype`,
 1 AS `engage_doc_id`,
 1 AS `last_updated`,
 1 AS `srv_client_name`,
 1 AS `companyname`,
 1 AS `updated_by`,
 1 AS `freqypaytype`,
 1 AS `last_updter`,
 1 AS `last_updter1`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_engage_inv`
--

DROP TABLE IF EXISTS `vw_engage_inv`;
/*!50001 DROP VIEW IF EXISTS `vw_engage_inv`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_engage_inv` AS SELECT 
 1 AS `idengage_inv`,
 1 AS `idengage_entity_po`,
 1 AS `display`,
 1 AS `idengage_add_con`,
 1 AS `last_updated`,
 1 AS `comp_contact_no_id`,
 1 AS `emp_contact_id`,
 1 AS `contact_id`,
 1 AS `emp_contact_type`,
 1 AS `emp_id`,
 1 AS `employee`,
 1 AS `contact_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_engage_inv_gp`
--

DROP TABLE IF EXISTS `vw_engage_inv_gp`;
/*!50001 DROP VIEW IF EXISTS `vw_engage_inv_gp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_engage_inv_gp` AS SELECT 
 1 AS `idengage_inv`,
 1 AS `idengage_entity_po`,
 1 AS `display`,
 1 AS `idengage_add_con`,
 1 AS `last_updated`,
 1 AS `comp_contact_no_id`,
 1 AS `emp_contact_id`,
 1 AS `contact_id`,
 1 AS `emp_contact_type`,
 1 AS `emp_id`,
 1 AS `employee`,
 1 AS `contact_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_engage_po_inv`
--

DROP TABLE IF EXISTS `vw_engage_po_inv`;
/*!50001 DROP VIEW IF EXISTS `vw_engage_po_inv`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_engage_po_inv` AS SELECT 
 1 AS `idengage_entity_po`,
 1 AS `idengage_entity`,
 1 AS `engage_id`,
 1 AS `srv_client`,
 1 AS `idengage_comp`,
 1 AS `idengage_add`,
 1 AS `comp_contact_no_id`,
 1 AS `idengage_add_con`,
 1 AS `emp_contact_id`,
 1 AS `contact_id`,
 1 AS `emp_contact_type`,
 1 AS `emp_id`,
 1 AS `employee`,
 1 AS `contact_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_engage_tree`
--

DROP TABLE IF EXISTS `vw_engage_tree`;
/*!50001 DROP VIEW IF EXISTS `vw_engage_tree`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_engage_tree` AS SELECT 
 1 AS `comp_name`,
 1 AS `idengage_entity_po`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_feature`
--

DROP TABLE IF EXISTS `vw_feature`;
/*!50001 DROP VIEW IF EXISTS `vw_feature`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_feature` AS SELECT 
 1 AS `feature_no`,
 1 AS `feature_id`,
 1 AS `feature_name`,
 1 AS `feature_desc`,
 1 AS `disp_order`,
 1 AS `assigned`,
 1 AS `groups`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_feature_grp`
--

DROP TABLE IF EXISTS `vw_feature_grp`;
/*!50001 DROP VIEW IF EXISTS `vw_feature_grp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_feature_grp` AS SELECT 
 1 AS `idfeature_grp_list`,
 1 AS `idfeature_grp`,
 1 AS `feature_id`,
 1 AS `disp_order`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_feature_grp_load`
--

DROP TABLE IF EXISTS `vw_feature_grp_load`;
/*!50001 DROP VIEW IF EXISTS `vw_feature_grp_load`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_feature_grp_load` AS SELECT 
 1 AS `idfeature_grp`,
 1 AS `idfeature_grp_load`,
 1 AS `group_name`,
 1 AS `group_desc`,
 1 AS `idfeature_grp_list`,
 1 AS `feature_id`,
 1 AS `feature_nm`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_festival`
--

DROP TABLE IF EXISTS `vw_festival`;
/*!50001 DROP VIEW IF EXISTS `vw_festival`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_festival` AS SELECT 
 1 AS `idfestival`,
 1 AS `look_values_id`,
 1 AS `comp_id`,
 1 AS `festival_yr`,
 1 AS `festival_day`,
 1 AS `day`,
 1 AS `festival_name`,
 1 AS `festival_type`,
 1 AS `last_updated`,
 1 AS `updated_by`,
 1 AS `mod_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_festival_company`
--

DROP TABLE IF EXISTS `vw_festival_company`;
/*!50001 DROP VIEW IF EXISTS `vw_festival_company`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_festival_company` AS SELECT 
 1 AS `idfestival`,
 1 AS `look_values_id`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `festival_yr`,
 1 AS `festival_day`,
 1 AS `day`,
 1 AS `festival_name`,
 1 AS `festival_type`,
 1 AS `last_updated`,
 1 AS `updated_by`,
 1 AS `mod_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_hours`
--

DROP TABLE IF EXISTS `vw_hours`;
/*!50001 DROP VIEW IF EXISTS `vw_hours`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_hours` AS SELECT 
 1 AS `hour_id`,
 1 AS `emp_id`,
 1 AS `employee`,
 1 AS `comp_id`,
 1 AS `inv_num`,
 1 AS `sort_hoursdate`,
 1 AS `timecard_id`,
 1 AS `hoursday`,
 1 AS `totaltime`,
 1 AS `total_mm`,
 1 AS `hrs_type`,
 1 AS `hrs_type_val`,
 1 AS `iddev_apps`,
 1 AS `hoursdate`,
 1 AS `hoursyear`,
 1 AS `hoursmonth`,
 1 AS `starttime`,
 1 AS `endtime`,
 1 AS `enter_dt`,
 1 AS `approve_dt`,
 1 AS `app_name`,
 1 AS `dev_est`,
 1 AS `dev_est_id1`,
 1 AS `dev_est_smry`,
 1 AS `dev_est_reqs`,
 1 AS `dev_est_reqs1`,
 1 AS `req_desc`,
 1 AS `req_type`,
 1 AS `category`,
 1 AS `expected_hrs`,
 1 AS `companyname`,
 1 AS `update_by_id`,
 1 AS `update_by`,
 1 AS `enterby`,
 1 AS `last_updated`,
 1 AS `entered_by`,
 1 AS `entered_by_nm`,
 1 AS `approve_by`,
 1 AS `approve_by_name`,
 1 AS `approved_name`,
 1 AS `approver`,
 1 AS `approver_by_name`,
 1 AS `process_by`,
 1 AS `process_by_name`,
 1 AS `process_dt`,
 1 AS `summary`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_hr_meeting`
--

DROP TABLE IF EXISTS `vw_hr_meeting`;
/*!50001 DROP VIEW IF EXISTS `vw_hr_meeting`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_hr_meeting` AS SELECT 
 1 AS `idhr_meeting`,
 1 AS `st_tm_est`,
 1 AS `e_tm_est`,
 1 AS `est_meeting_time`,
 1 AS `st_tm_ist`,
 1 AS `e_tm_ist`,
 1 AS `ist_meeting_time`,
 1 AS `description`,
 1 AS `attendants`,
 1 AS `scrum_master`,
 1 AS `last_updated`,
 1 AS `updater`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immi_attach`
--

DROP TABLE IF EXISTS `vw_immi_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_immi_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immi_attach` AS SELECT 
 1 AS `idimmi_attach`,
 1 AS `status_id`,
 1 AS `rec_status`,
 1 AS `status`,
 1 AS `receipt_id`,
 1 AS `idstorage`,
 1 AS `updater`,
 1 AS `owner_id`,
 1 AS `file_name`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `emp_id`,
 1 AS `updated_for_ref_id`,
 1 AS `updated_for_ref_table`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immi_lk_wrk_flow`
--

DROP TABLE IF EXISTS `vw_immi_lk_wrk_flow`;
/*!50001 DROP VIEW IF EXISTS `vw_immi_lk_wrk_flow`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immi_lk_wrk_flow` AS SELECT 
 1 AS `idimmi_lk_wrk_flow`,
 1 AS `id_wrk_flow`,
 1 AS `id_wrk_flow_parent`,
 1 AS `look_restart`,
 1 AS `updater`,
 1 AS `last_updated`,
 1 AS `immi_value`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immi_qry`
--

DROP TABLE IF EXISTS `vw_immi_qry`;
/*!50001 DROP VIEW IF EXISTS `vw_immi_qry`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immi_qry` AS SELECT 
 1 AS `idimmi_qry`,
 1 AS `immi_desc`,
 1 AS `immi_desc_detail`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `immi_year`,
 1 AS `immi_month`,
 1 AS `updated_by`,
 1 AS `updater`,
 1 AS `updater_file_name`,
 1 AS `del_dt`,
 1 AS `del_dt_formatted`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immi_receipt_qry`
--

DROP TABLE IF EXISTS `vw_immi_receipt_qry`;
/*!50001 DROP VIEW IF EXISTS `vw_immi_receipt_qry`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immi_receipt_qry` AS SELECT 
 1 AS `idimmi_receipt_qry`,
 1 AS `immi_receipts`,
 1 AS `comp_id`,
 1 AS `company`,
 1 AS `receipt_type`,
 1 AS `receipt_no`,
 1 AS `immi_ref_tab`,
 1 AS `immi_ref_id`,
 1 AS `name`,
 1 AS `typst`,
 1 AS `filed_dt`,
 1 AS `filed_dt_formatted`,
 1 AS `filed_dt_m`,
 1 AS `filed_dt_y`,
 1 AS `ad_title`,
 1 AS `ad`,
 1 AS `imi_source`,
 1 AS `immi_source_nm`,
 1 AS `combo`,
 1 AS `from_dt`,
 1 AS `from_dt_formatted`,
 1 AS `to_dt`,
 1 AS `to_dt_formatted`,
 1 AS `valid_days`,
 1 AS `expire_dt`,
 1 AS `expire_dt_formatted`,
 1 AS `validity`,
 1 AS `look_street_no_id`,
 1 AS `addresses`,
 1 AS `suite_no`,
 1 AS `stat_st_dt_formatted`,
 1 AS `stat_e_dt_formatted`,
 1 AS `no_days`,
 1 AS `status`,
 1 AS `immi_summary`,
 1 AS `due_dt`,
 1 AS `due_dt_formatted`,
 1 AS `due_dt1`,
 1 AS `qry_stat`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `receipt_qry_year`,
 1 AS `receipt_qry_month`,
 1 AS `updated_by`,
 1 AS `updater`,
 1 AS `updater_file_name`,
 1 AS `del_dt`,
 1 AS `del_dt_formatted`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt`,
 1 AS `archv_dt_formatted`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immi_receipt_qry_list`
--

DROP TABLE IF EXISTS `vw_immi_receipt_qry_list`;
/*!50001 DROP VIEW IF EXISTS `vw_immi_receipt_qry_list`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immi_receipt_qry_list` AS SELECT 
 1 AS `idimmi_receipt_qry_list`,
 1 AS `idimmi_receipt_qry`,
 1 AS `idimmi_qry`,
 1 AS `immi_receipts`,
 1 AS `company`,
 1 AS `company_logo`,
 1 AS `receipt_type`,
 1 AS `receipt_no`,
 1 AS `immi_ref_id`,
 1 AS `immi_ref_tab`,
 1 AS `name`,
 1 AS `typst`,
 1 AS `filed_dt_formatted`,
 1 AS `imi_source`,
 1 AS `immi_source_nm`,
 1 AS `combo`,
 1 AS `expire_dt_formatted`,
 1 AS `validity`,
 1 AS `salary_type`,
 1 AS `salary_type_nm`,
 1 AS `salary_amt`,
 1 AS `rec_status`,
 1 AS `status`,
 1 AS `immi_desc`,
 1 AS `start_dt`,
 1 AS `end_dt`,
 1 AS `due_dt`,
 1 AS `no_days`,
 1 AS `file_name`,
 1 AS `idstorage`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `updated_by`,
 1 AS `updated_nm`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immi_receipt_qry_list_rpt`
--

DROP TABLE IF EXISTS `vw_immi_receipt_qry_list_rpt`;
/*!50001 DROP VIEW IF EXISTS `vw_immi_receipt_qry_list_rpt`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immi_receipt_qry_list_rpt` AS SELECT 
 1 AS `idimmi_receipt_qry`,
 1 AS `idimmi_qry`,
 1 AS `immi_receipts`,
 1 AS `immi_desc`,
 1 AS `immi_receiptscount`,
 1 AS `updated_by`,
 1 AS `updated_nm`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `receipt_qry_year`,
 1 AS `receipt_qry_month`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immi_receipts`
--

DROP TABLE IF EXISTS `vw_immi_receipts`;
/*!50001 DROP VIEW IF EXISTS `vw_immi_receipts`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immi_receipts` AS SELECT 
 1 AS `receipt_id`,
 1 AS `comp_id`,
 1 AS `company`,
 1 AS `company_logo`,
 1 AS `receipt_type`,
 1 AS `receipt_no`,
 1 AS `immi_ref_id`,
 1 AS `immi_ref_tab`,
 1 AS `name`,
 1 AS `typst`,
 1 AS `filed_dt`,
 1 AS `filed_dt_formatted`,
 1 AS `filed_dt_m`,
 1 AS `filed_dt_y`,
 1 AS `ad_title`,
 1 AS `ad`,
 1 AS `imi_source`,
 1 AS `immi_source_nm`,
 1 AS `occ_code`,
 1 AS `occ_code_nm`,
 1 AS `skill_level`,
 1 AS `skill_level_nm`,
 1 AS `combo`,
 1 AS `from_dt`,
 1 AS `from_dt_formatted`,
 1 AS `to_dt`,
 1 AS `to_dt_formatted`,
 1 AS `valid_days`,
 1 AS `expire_dt`,
 1 AS `expire_dt_formatted`,
 1 AS `expire_dt_new`,
 1 AS `expire_diff`,
 1 AS `validity`,
 1 AS `education`,
 1 AS `education_nm`,
 1 AS `exp_years`,
 1 AS `exp_years_nm`,
 1 AS `salary_type`,
 1 AS `salary_type_nm`,
 1 AS `salary_amt`,
 1 AS `look_street_no_id`,
 1 AS `addresses`,
 1 AS `suite_no`,
 1 AS `rec_status`,
 1 AS `status`,
 1 AS `stat_st_dt`,
 1 AS `stat_st_dt_formatted`,
 1 AS `stat_e_dt`,
 1 AS `stat_e_dt_formatted`,
 1 AS `no_days`,
 1 AS `immi_summary`,
 1 AS `idlook_stat_order`,
 1 AS `idlook_stat_order_nm`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `updater_file_name`,
 1 AS `del_dt`,
 1 AS `del_dt_formatted`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt`,
 1 AS `archv_dt_formatted`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immi_recpt_qry_list_attach`
--

DROP TABLE IF EXISTS `vw_immi_recpt_qry_list_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_immi_recpt_qry_list_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immi_recpt_qry_list_attach` AS SELECT 
 1 AS `idimmi_recpt_qry_list_attach`,
 1 AS `idimmi_receipt_qry_list`,
 1 AS `immi_receipts`,
 1 AS `idimmi_qry`,
 1 AS `immi_desc`,
 1 AS `idimmi_receipt_qry`,
 1 AS `idstorage`,
 1 AS `updater`,
 1 AS `owner_id`,
 1 AS `file_name`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `emp_id`,
 1 AS `updated_for_ref_id`,
 1 AS `updated_for_ref_table`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immi_status`
--

DROP TABLE IF EXISTS `vw_immi_status`;
/*!50001 DROP VIEW IF EXISTS `vw_immi_status`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immi_status` AS SELECT 
 1 AS `status_id`,
 1 AS `receipt_id`,
 1 AS `rec_status_id`,
 1 AS `rec_status_nm`,
 1 AS `stat_dt_dt`,
 1 AS `stat_st_dt_formatted`,
 1 AS `stat_e_dt`,
 1 AS `stat_e_dt_formatted`,
 1 AS `no_days`,
 1 AS `idlook_stat_order`,
 1 AS `idlook_stat_order_nm`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `updater_file_name`,
 1 AS `del_dt`,
 1 AS `del_dt_formatted`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt`,
 1 AS `archv_dt_formatted`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immi_status_steps`
--

DROP TABLE IF EXISTS `vw_immi_status_steps`;
/*!50001 DROP VIEW IF EXISTS `vw_immi_status_steps`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immi_status_steps` AS SELECT 
 1 AS `idimmi_status_steps`,
 1 AS `immi_status_id`,
 1 AS `receipt_id`,
 1 AS `rec_status_id`,
 1 AS `rec_status`,
 1 AS `immi_steps_detail`,
 1 AS `last_updated`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `updater_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_immisource_del`
--

DROP TABLE IF EXISTS `vw_immisource_del`;
/*!50001 DROP VIEW IF EXISTS `vw_immisource_del`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_immisource_del` AS SELECT 
 1 AS `look_values_id`,
 1 AS `look_table`,
 1 AS `look_values`,
 1 AS `look_value_desc`,
 1 AS `look_value_code`,
 1 AS `look_display_id`,
 1 AS `look_sub_value_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_inv`
--

DROP TABLE IF EXISTS `vw_inv`;
/*!50001 DROP VIEW IF EXISTS `vw_inv`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_inv` AS SELECT 
 1 AS `inv_num`,
 1 AS `comp_id`,
 1 AS `companyname`,
 1 AS `idstorage`,
 1 AS `comp_add_ref_id`,
 1 AS `comp_addresses`,
 1 AS `inv_phone`,
 1 AS `comp_add_suite_no`,
 1 AS `inv_email`,
 1 AS `invoice_no`,
 1 AS `from_dt`,
 1 AS `from_dt_formatted`,
 1 AS `to_dt`,
 1 AS `to_dt_formatted`,
 1 AS `billed_dt`,
 1 AS `billed_dt_formatted`,
 1 AS `due_dt`,
 1 AS `due_dt_formatted`,
 1 AS `summary`,
 1 AS `inv_to_ref_id`,
 1 AS `inv_to_ref_table`,
 1 AS `inv_ref_id_name`,
 1 AS `bill_to`,
 1 AS `inv_add_ref_id`,
 1 AS `client _addresses`,
 1 AS `inv_add_suite_no`,
 1 AS `amt_sub`,
 1 AS `amt_tax`,
 1 AS `amt_tol`,
 1 AS `amt_paid`,
 1 AS `updatedby`,
 1 AS `lastupdated`,
 1 AS `contact_detail`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_inv_engage`
--

DROP TABLE IF EXISTS `vw_inv_engage`;
/*!50001 DROP VIEW IF EXISTS `vw_inv_engage`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_inv_engage` AS SELECT 
 1 AS `idengage_inv`,
 1 AS `idengage_entity_po`,
 1 AS `display`,
 1 AS `idengage_add_con`,
 1 AS `last_updated`,
 1 AS `comp_contact_no_id`,
 1 AS `emp_contact_id`,
 1 AS `contact_id`,
 1 AS `emp_contact_type`,
 1 AS `emp_id`,
 1 AS `employee`,
 1 AS `contact_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_inv_engage_gp`
--

DROP TABLE IF EXISTS `vw_inv_engage_gp`;
/*!50001 DROP VIEW IF EXISTS `vw_inv_engage_gp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_inv_engage_gp` AS SELECT 
 1 AS `idengage_inv`,
 1 AS `idengage_entity_po`,
 1 AS `display`,
 1 AS `idengage_add_con`,
 1 AS `last_updated`,
 1 AS `comp_contact_no_id`,
 1 AS `emp_contact_id`,
 1 AS `contact_id`,
 1 AS `emp_contact_type`,
 1 AS `emp_id`,
 1 AS `employee`,
 1 AS `contact_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_inv_engage_po`
--

DROP TABLE IF EXISTS `vw_inv_engage_po`;
/*!50001 DROP VIEW IF EXISTS `vw_inv_engage_po`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_inv_engage_po` AS SELECT 
 1 AS `idengage_entity_po`,
 1 AS `idengage_entity`,
 1 AS `engage_id`,
 1 AS `srv_client`,
 1 AS `idengage_comp`,
 1 AS `idengage_add`,
 1 AS `comp_contact_no_id`,
 1 AS `idengage_add_con`,
 1 AS `emp_contact_id`,
 1 AS `contact_id`,
 1 AS `emp_contact_type`,
 1 AS `emp_id`,
 1 AS `employee`,
 1 AS `contact_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_inv_po`
--

DROP TABLE IF EXISTS `vw_inv_po`;
/*!50001 DROP VIEW IF EXISTS `vw_inv_po`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_inv_po` AS SELECT 
 1 AS `con_srv_st_dt`,
 1 AS `con_srv_e_dt`,
 1 AS `mod_bill_start_dt1`,
 1 AS `mod_bill_end_dt1`,
 1 AS `client_address`,
 1 AS `vendor_address`,
 1 AS `engage_ref_id_name`,
 1 AS `engage_ref_tab`,
 1 AS `comp_emp_detail`,
 1 AS `idengage_inv`,
 1 AS `idengage_entity_po`,
 1 AS `idengage_add_con`,
 1 AS `comp_contact_no_id`,
 1 AS `emp_contact_id`,
 1 AS `contact_id`,
 1 AS `emp_contact_type`,
 1 AS `contact_detail`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_load_contracts`
--

DROP TABLE IF EXISTS `vw_load_contracts`;
/*!50001 DROP VIEW IF EXISTS `vw_load_contracts`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_load_contracts` AS SELECT 
 1 AS `idload_contracts`,
 1 AS `engage_id`,
 1 AS `srv_st_dt`,
 1 AS `srv_e_dt`,
 1 AS `eng_tentitive_en_dt`,
 1 AS `sr_frequency`,
 1 AS `srv_paytype`,
 1 AS `srv_amount`,
 1 AS `eg_sumry`,
 1 AS `cloud_drive`,
 1 AS `srv_client`,
 1 AS `comp_id`,
 1 AS `mod_srv_st_dt`,
 1 AS `mod_srv_st_dt1`,
 1 AS `mod_srv_e_dt`,
 1 AS `mod_srv_e_dt1`,
 1 AS `mod_eng_tentitive_en_dt`,
 1 AS `mod_eng_tentitive_en_dt1`,
 1 AS `eng_tentitive_en_dt_filter`,
 1 AS `frequency`,
 1 AS `paytype`,
 1 AS `engage_doc_id`,
 1 AS `last_updated`,
 1 AS `srv_client_name`,
 1 AS `companyname`,
 1 AS `updated_by`,
 1 AS `freqypaytype`,
 1 AS `last_updter`,
 1 AS `last_updter1`,
 1 AS `idengage_comp`,
 1 AS `client_address`,
 1 AS `vendor_address`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_log_global`
--

DROP TABLE IF EXISTS `vw_log_global`;
/*!50001 DROP VIEW IF EXISTS `vw_log_global`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_log_global` AS SELECT 
 1 AS `last_updated`,
 1 AS `last_update`,
 1 AS `table_update`,
 1 AS `updater`,
 1 AS `tabledetails`,
 1 AS `col1`,
 1 AS `col2`,
 1 AS `col3`,
 1 AS `col4`,
 1 AS `col5`,
 1 AS `col6`,
 1 AS `idglb_log`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_look_addresses`
--

DROP TABLE IF EXISTS `vw_look_addresses`;
/*!50001 DROP VIEW IF EXISTS `vw_look_addresses`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_look_addresses` AS SELECT 
 1 AS `country_id`,
 1 AS `con_name`,
 1 AS `state_id`,
 1 AS `state_name`,
 1 AS `state_full_name`,
 1 AS `city_id`,
 1 AS `city_name`,
 1 AS `postal_id`,
 1 AS `zip_code`,
 1 AS `look_street_id`,
 1 AS `street_name`,
 1 AS `look_street_no_id`,
 1 AS `look_street_no`,
 1 AS `street_type`,
 1 AS `street_type_name`,
 1 AS `street_name_type`,
 1 AS `addresses`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_look_bank_rec`
--

DROP TABLE IF EXISTS `vw_look_bank_rec`;
/*!50001 DROP VIEW IF EXISTS `vw_look_bank_rec`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_look_bank_rec` AS SELECT 
 1 AS `value_id1`,
 1 AS `value1`,
 1 AS `value_id2`,
 1 AS `value2`,
 1 AS `sub_value_id1`,
 1 AS `value_id3`,
 1 AS `value3`,
 1 AS `sub_value_id2`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_manage_emp`
--

DROP TABLE IF EXISTS `vw_manage_emp`;
/*!50001 DROP VIEW IF EXISTS `vw_manage_emp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_manage_emp` AS SELECT 
 1 AS `emp_id`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `ssn`,
 1 AS `dob`,
 1 AS `gender`,
 1 AS `sdate`,
 1 AS `edate`,
 1 AS `noOfDays`,
 1 AS `feature_id`,
 1 AS `comp_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_manage_employee`
--

DROP TABLE IF EXISTS `vw_manage_employee`;
/*!50001 DROP VIEW IF EXISTS `vw_manage_employee`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_manage_employee` AS SELECT 
 1 AS `emp_id`,
 1 AS `firstname`,
 1 AS `lastname`,
 1 AS `ssn`,
 1 AS `dob`,
 1 AS `gender`,
 1 AS `sdate`,
 1 AS `edate`,
 1 AS `noOfDays`,
 1 AS `comp_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_mkt_assist`
--

DROP TABLE IF EXISTS `vw_mkt_assist`;
/*!50001 DROP VIEW IF EXISTS `vw_mkt_assist`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_mkt_assist` AS SELECT 
 1 AS `idmkt_assist`,
 1 AS `idmkt_open`,
 1 AS `assist_ref_table`,
 1 AS `Name`,
 1 AS `assist_ref_id`,
 1 AS `prosp_status`,
 1 AS `prosp_status_id`,
 1 AS `stat_st_dt`,
 1 AS `mkt_year`,
 1 AS `mkt_month`,
 1 AS `stat_st_dt2`,
 1 AS `stat_e_dt`,
 1 AS `stat_e_dt2`,
 1 AS `no_days`,
 1 AS `compname`,
 1 AS `client_name`,
 1 AS `assist_rate`,
 1 AS `summary`,
 1 AS `location`,
 1 AS `contact_info`,
 1 AS `open_details`,
 1 AS `last_updated`,
 1 AS `updated_by`,
 1 AS `updator`,
 1 AS `mod_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_mkt_assist_status`
--

DROP TABLE IF EXISTS `vw_mkt_assist_status`;
/*!50001 DROP VIEW IF EXISTS `vw_mkt_assist_status`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_mkt_assist_status` AS SELECT 
 1 AS `idmkt_assist_status`,
 1 AS `idmkt_assist`,
 1 AS `assist_status`,
 1 AS `stat_st_dt`,
 1 AS `stat_e_dt`,
 1 AS `no_days`,
 1 AS `last_updated`,
 1 AS `updated_by`,
 1 AS `status`,
 1 AS `mod_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_mkt_assist_status_steps`
--

DROP TABLE IF EXISTS `vw_mkt_assist_status_steps`;
/*!50001 DROP VIEW IF EXISTS `vw_mkt_assist_status_steps`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_mkt_assist_status_steps` AS SELECT 
 1 AS `idmkt_assist_status_steps`,
 1 AS `idmkt_assist`,
 1 AS `idmkt_assist_status`,
 1 AS `assist_status_id`,
 1 AS `status`,
 1 AS `mkt_steps_details`,
 1 AS `last_updated`,
 1 AS `updated_by`,
 1 AS `mod_last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_mkt_company`
--

DROP TABLE IF EXISTS `vw_mkt_company`;
/*!50001 DROP VIEW IF EXISTS `vw_mkt_company`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_mkt_company` AS SELECT 
 1 AS `idmkt_company`,
 1 AS `companyname`,
 1 AS `company_info`,
 1 AS `comp_website`,
 1 AS `comp_phone`,
 1 AS `req_type`,
 1 AS `req_type_name`,
 1 AS `track`,
 1 AS `block`,
 1 AS `block_name`,
 1 AS `track_name`,
 1 AS `block_dt`,
 1 AS `sort_block_dt`,
 1 AS `block_dt_new`,
 1 AS `acc_mgr`,
 1 AS `acc_mgr_name`,
 1 AS `comp_email`,
 1 AS `updated_by`,
 1 AS `mod_last_updated`,
 1 AS `mkt_month`,
 1 AS `mkt_year`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_mkt_lk_wrk_flow`
--

DROP TABLE IF EXISTS `vw_mkt_lk_wrk_flow`;
/*!50001 DROP VIEW IF EXISTS `vw_mkt_lk_wrk_flow`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_mkt_lk_wrk_flow` AS SELECT 
 1 AS `idmkt_wrk_flow`,
 1 AS `id_wrk_flow`,
 1 AS `id_wrk_flow_parent`,
 1 AS `updater`,
 1 AS `last_updated`,
 1 AS `mkt_value`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_mkt_open`
--

DROP TABLE IF EXISTS `vw_mkt_open`;
/*!50001 DROP VIEW IF EXISTS `vw_mkt_open`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_mkt_open` AS SELECT 
 1 AS `idmkt_open`,
 1 AS `compname`,
 1 AS `client_name`,
 1 AS `req_source`,
 1 AS `req_source_nm`,
 1 AS `location`,
 1 AS `state_id`,
 1 AS `state_name`,
 1 AS `city_id`,
 1 AS `city_name`,
 1 AS `contact_info`,
 1 AS `req_type`,
 1 AS `req_type_name`,
 1 AS `track`,
 1 AS `track_name`,
 1 AS `acc_mgr`,
 1 AS `no_days`,
 1 AS `open_details`,
 1 AS `open_dt`,
 1 AS `open_dt1`,
 1 AS `close_dt`,
 1 AS `close_dt1`,
 1 AS `Pstate`,
 1 AS `last_updated`,
 1 AS `updated_by`,
 1 AS `mod_last_updated`,
 1 AS `summary`,
 1 AS `open_dt_y`,
 1 AS `close_dt_y`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_mod_hoursx`
--

DROP TABLE IF EXISTS `vw_mod_hoursx`;
/*!50001 DROP VIEW IF EXISTS `vw_mod_hoursx`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_mod_hoursx` AS SELECT 
 1 AS `emp_id`,
 1 AS `comp_id`,
 1 AS `yr_hours`,
 1 AS `mon_name`,
 1 AS `mon_hrs`,
 1 AS `WithoutTimeSheet`,
 1 AS `UnInvoice_hours`,
 1 AS `Unaproved_hours`,
 1 AS `billable_hrs`,
 1 AS `non_billable_hrs`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_mon_emp`
--

DROP TABLE IF EXISTS `vw_mon_emp`;
/*!50001 DROP VIEW IF EXISTS `vw_mon_emp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_mon_emp` AS SELECT 
 1 AS `year`,
 1 AS `month`,
 1 AS `started`,
 1 AS `ended`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_mon_emp_sub`
--

DROP TABLE IF EXISTS `vw_mon_emp_sub`;
/*!50001 DROP VIEW IF EXISTS `vw_mon_emp_sub`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_mon_emp_sub` AS SELECT 
 1 AS `st_year`,
 1 AS `st_month`,
 1 AS `started`,
 1 AS `ed_year`,
 1 AS `ed_month`,
 1 AS `ended`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_net_ser`
--

DROP TABLE IF EXISTS `vw_net_ser`;
/*!50001 DROP VIEW IF EXISTS `vw_net_ser`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_net_ser` AS SELECT 
 1 AS `idnet_ser`,
 1 AS `hostnm`,
 1 AS `dep_usr`,
 1 AS `host_conf`,
 1 AS `hosted`,
 1 AS `hostdm`,
 1 AS `host_type`,
 1 AS `host_mst`,
 1 AS `ip_lan`,
 1 AS `ip_wan`,
 1 AS `ip_usr`,
 1 AS `gateway`,
 1 AS `updater`,
 1 AS `updated_on`,
 1 AS `mst_hostnm`,
 1 AS `mst_hostdm`,
 1 AS `mst_ip_lan`,
 1 AS `mst_ip_wan`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_net_ser_clone`
--

DROP TABLE IF EXISTS `vw_net_ser_clone`;
/*!50001 DROP VIEW IF EXISTS `vw_net_ser_clone`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_net_ser_clone` AS SELECT 
 1 AS `idnet_clone`,
 1 AS `idnet_ser`,
 1 AS `hostnm`,
 1 AS `hostdm`,
 1 AS `host_mst`,
 1 AS `ip_lan`,
 1 AS `ip_wan`,
 1 AS `ip_usr`,
 1 AS `gateway`,
 1 AS `mst_app`,
 1 AS `cloned_app`,
 1 AS `code_bk`,
 1 AS `db_bk`,
 1 AS `valid_days`,
 1 AS `validity`,
 1 AS `alert_days`,
 1 AS `app_url`,
 1 AS `deleted_on`,
 1 AS `updater`,
 1 AS `updated_on`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_newengage`
--

DROP TABLE IF EXISTS `vw_newengage`;
/*!50001 DROP VIEW IF EXISTS `vw_newengage`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_newengage` AS SELECT 
 1 AS `engage_id`,
 1 AS `srv_st_dt`,
 1 AS `srv_e_dt`,
 1 AS `sr_frequency`,
 1 AS `srv_paytype`,
 1 AS `eg_sumry`,
 1 AS `srv_client`,
 1 AS `comp_id`,
 1 AS `companyname`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_po_attach`
--

DROP TABLE IF EXISTS `vw_po_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_po_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_po_attach` AS SELECT 
 1 AS `idengage_entity_po_doc`,
 1 AS `doc_type`,
 1 AS `doc_look_values`,
 1 AS `expire_dt`,
 1 AS `mod_expire_dt`,
 1 AS `idengage_entity_po`,
 1 AS `idstorage`,
 1 AS `owner_id`,
 1 AS `file_name`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `emp_id`,
 1 AS `updated_for_ref_id`,
 1 AS `updated_for_ref_table`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_activity`
--

DROP TABLE IF EXISTS `vw_prosp_activity`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_activity`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_activity` AS SELECT 
 1 AS `name`,
 1 AS `prosp_activity_id`,
 1 AS `prosp_consult_id`,
 1 AS `call_recv_dt`,
 1 AS `emp_id`,
 1 AS `next_call_dt`,
 1 AS `call_note`,
 1 AS `last_update`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_consult`
--

DROP TABLE IF EXISTS `vw_prosp_consult`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_consult`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_consult` AS SELECT 
 1 AS `prosp_consult_id`,
 1 AS `prosp_first_name`,
 1 AS `prosp_last_name`,
 1 AS `prosp_fullname`,
 1 AS `prosp_level_id`,
 1 AS `prosp_level`,
 1 AS `prosp_summary`,
 1 AS `dob`,
 1 AS `ssn`,
 1 AS `taxid`,
 1 AS `gender_id`,
 1 AS `gender`,
 1 AS `updater_id`,
 1 AS `updater`,
 1 AS `emp_assigned_id`,
 1 AS `call_recv_dt_unformatted`,
 1 AS `call_recv_dt`,
 1 AS `next_call_dt_unformatted`,
 1 AS `next_call_dt`,
 1 AS `call_note`,
 1 AS `last_updated_unformatted`,
 1 AS `last_updated`,
 1 AS `attachment`,
 1 AS `del_dt_unformatted`,
 1 AS `del_dt`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt_unformatted`,
 1 AS `archv_dt`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_consult_activity`
--

DROP TABLE IF EXISTS `vw_prosp_consult_activity`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_consult_activity`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_consult_activity` AS SELECT 
 1 AS `prosp_consult_id`,
 1 AS `prosp_first_name`,
 1 AS `prosp_last_name`,
 1 AS `prosp_level`,
 1 AS `prosp_summary`,
 1 AS `prosp_activity_id`,
 1 AS `call_recv_dt`,
 1 AS `emp_id`,
 1 AS `next_call_dt`,
 1 AS `call_note`,
 1 AS `last_update`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_corp`
--

DROP TABLE IF EXISTS `vw_prosp_corp`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_corp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_corp` AS SELECT 
 1 AS `idprosp_corp`,
 1 AS `prosp_corp_type`,
 1 AS `prosp_corp_type_name`,
 1 AS `corp_entity_name`,
 1 AS `corp_source`,
 1 AS `corp_source_nm`,
 1 AS `corp_level`,
 1 AS `corp_level_nm`,
 1 AS `response`,
 1 AS `response_nm`,
 1 AS `corp_contacts`,
 1 AS `corp_address`,
 1 AS `register_yr`,
 1 AS `register_state`,
 1 AS `start_dt`,
 1 AS `start_dt_formatted`,
 1 AS `end_dt`,
 1 AS `end_dt_formatted`,
 1 AS `lead_time`,
 1 AS `pseudo_leads_time`,
 1 AS `acc_mgr`,
 1 AS `acc_mgr_name`,
 1 AS `acc_mgr_file_name`,
 1 AS `topic_discussed`,
 1 AS `topic_count`,
 1 AS `about_corp`,
 1 AS `access_name`,
 1 AS `tentative_en_dt`,
 1 AS `tentative_en_dt_formatted`,
 1 AS `remind`,
 1 AS `vm_count`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `updated_by`,
 1 AS `updated_by_nm`,
 1 AS `updater_file_name`,
 1 AS `del_dt`,
 1 AS `del_dt_formatted`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `del_day`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt`,
 1 AS `archv_dt_formatted`,
 1 AS `archv_by_id`,
 1 AS `arch_by`,
 1 AS `arch_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_corp_activity`
--

DROP TABLE IF EXISTS `vw_prosp_corp_activity`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_corp_activity`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_corp_activity` AS SELECT 
 1 AS `idprosp_corp_activity`,
 1 AS `idprosp_corp`,
 1 AS `topic_disussed`,
 1 AS `corp_level`,
 1 AS `corp_level_nm`,
 1 AS `response`,
 1 AS `response_nm`,
 1 AS `start_dt`,
 1 AS `start_dt_formatted`,
 1 AS `acc_mgr`,
 1 AS `acc_mgr_name`,
 1 AS `end_dt`,
 1 AS `end_dt_formatted`,
 1 AS `updated_by`,
 1 AS `updater`,
 1 AS `updater_file_name`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `del_dt`,
 1 AS `del_dt_formatted`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt`,
 1 AS `archv_dt_formatted`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_corp_attach`
--

DROP TABLE IF EXISTS `vw_prosp_corp_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_corp_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_corp_attach` AS SELECT 
 1 AS `idprosp_corp_attach`,
 1 AS `idprosp_corp`,
 1 AS `idstorage`,
 1 AS `owner_id`,
 1 AS `owner_name`,
 1 AS `file_name`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `emp_id`,
 1 AS `emp_name`,
 1 AS `updater`,
 1 AS `updated_by`,
 1 AS `updater_file_name`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_corp_inc`
--

DROP TABLE IF EXISTS `vw_prosp_corp_inc`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_corp_inc`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_corp_inc` AS SELECT 
 1 AS `idprosp_corp_inc`,
 1 AS `idprosp_lk_val`,
 1 AS `prosp_value`,
 1 AS `emp_id`,
 1 AS `emp_name`,
 1 AS `emp_file_name`,
 1 AS `inc_frm`,
 1 AS `inc_frm_formatted`,
 1 AS `inc_to`,
 1 AS `inc_to_formatted`,
 1 AS `inc_amt`,
 1 AS `approver_id`,
 1 AS `approver_name`,
 1 AS `approver_file_name`,
 1 AS `last_updated_unformatted`,
 1 AS `last_updated`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `updater_file_name`,
 1 AS `del_dt`,
 1 AS `del_dt_formatted`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt`,
 1 AS `archv_dt_formatted`,
 1 AS `archv_by_id`,
 1 AS `arch_by`,
 1 AS `arch_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_extra_tags`
--

DROP TABLE IF EXISTS `vw_prosp_extra_tags`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_extra_tags`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_extra_tags` AS SELECT 
 1 AS `prosp_tag_id`,
 1 AS `prosp_consult_id`,
 1 AS `prosp_tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_extra_values_in_tags`
--

DROP TABLE IF EXISTS `vw_prosp_extra_values_in_tags`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_extra_values_in_tags`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_extra_values_in_tags` AS SELECT 
 1 AS `prosp_tag_id`,
 1 AS `prosp_consult_id`,
 1 AS `prosp_tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_initiate`
--

DROP TABLE IF EXISTS `vw_prosp_initiate`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_initiate`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_initiate` AS SELECT 
 1 AS `idprosp_refund1`,
 1 AS `payee_id`,
 1 AS `payee_from`,
 1 AS `payee`,
 1 AS `total_paid`,
 1 AS `total_refund`,
 1 AS `cleared`,
 1 AS `idprosp_refund2`,
 1 AS `paid_amt`,
 1 AS `refund_amt`,
 1 AS `purpose`,
 1 AS `pay_dt`,
 1 AS `pay_smry`,
 1 AS `selection`,
 1 AS `refund_details`,
 1 AS `refund_type`,
 1 AS `refund_phases`,
 1 AS `ref_for_id`,
 1 AS `ref_for_table`,
 1 AS `refunded_to`,
 1 AS `refund_dt`,
 1 AS `refund_smry`,
 1 AS `display`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_lk_val`
--

DROP TABLE IF EXISTS `vw_prosp_lk_val`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_lk_val`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_lk_val` AS SELECT 
 1 AS `idprosp_lk_val`,
 1 AS `idprosp_lk`,
 1 AS `prosp_name`,
 1 AS `prosp_value`,
 1 AS `disp_order`,
 1 AS `updater`,
 1 AS `updater_nm`,
 1 AS `updater_file_name`,
 1 AS `last_updated`,
 1 AS `last_updated_formatted`,
 1 AS `del_dt`,
 1 AS `del_dt_formatted`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt`,
 1 AS `archv_dt_formatted`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_multi_date`
--

DROP TABLE IF EXISTS `vw_prosp_multi_date`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_multi_date`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_multi_date` AS SELECT 
 1 AS `prosp_activity_id`,
 1 AS `prosp_consult_id`,
 1 AS `last_update`,
 1 AS `cnt`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_tag_extra_1`
--

DROP TABLE IF EXISTS `vw_prosp_tag_extra_1`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_tag_extra_1`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_tag_extra_1` AS SELECT 
 1 AS `prosp_tag_id`,
 1 AS `prosp_consult_id`,
 1 AS `prosp_tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_tag_extra_2`
--

DROP TABLE IF EXISTS `vw_prosp_tag_extra_2`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_tag_extra_2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_tag_extra_2` AS SELECT 
 1 AS `prosp_tag_id`,
 1 AS `prosp_consult_id`,
 1 AS `prosp_tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_prosp_tag_extra_3`
--

DROP TABLE IF EXISTS `vw_prosp_tag_extra_3`;
/*!50001 DROP VIEW IF EXISTS `vw_prosp_tag_extra_3`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_prosp_tag_extra_3` AS SELECT 
 1 AS `prosp_tag_id`,
 1 AS `prosp_consult_id`,
 1 AS `prosp_tags`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_rpt_all_data_process_2`
--

DROP TABLE IF EXISTS `vw_rpt_all_data_process_2`;
/*!50001 DROP VIEW IF EXISTS `vw_rpt_all_data_process_2`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_rpt_all_data_process_2` AS SELECT 
 1 AS `iddev_est_reqs`,
 1 AS `status_count`,
 1 AS `status_list`,
 1 AS `req_developer`,
 1 AS `rpt_req_analyst`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_rpt_bill_ts_cycle`
--

DROP TABLE IF EXISTS `vw_rpt_bill_ts_cycle`;
/*!50001 DROP VIEW IF EXISTS `vw_rpt_bill_ts_cycle`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_rpt_bill_ts_cycle` AS SELECT 
 1 AS `idrpt_bill_ts_cycle`,
 1 AS `idengage_entity_po`,
 1 AS `cycle_for`,
 1 AS `cycle_type`,
 1 AS `frequency`,
 1 AS `engage_ref_tab`,
 1 AS `engage_ref_id`,
 1 AS `summary`,
 1 AS `idengage_entity`,
 1 AS `engage_ref_id_name`,
 1 AS `expect_bill_hr`,
 1 AS `expect_unbill_hr`,
 1 AS `expect_total_hr`,
 1 AS `bill_pay_rate`,
 1 AS `expect_bill_amt`,
 1 AS `bill_hr`,
 1 AS `unbill_hr`,
 1 AS `bill_total_hr`,
 1 AS `bill_amt`,
 1 AS `diff_bill_hr`,
 1 AS `diff_unbill_hr`,
 1 AS `diff_total_hr`,
 1 AS `diff_bill_amt`,
 1 AS `cycle_st_dt`,
 1 AS `cycle_st_dt0`,
 1 AS `cycle_st_dt1`,
 1 AS `cycle_end_dt`,
 1 AS `cycle_end_dt0`,
 1 AS `cycle_end_dt1`,
 1 AS `due_dt`,
 1 AS `due_dt0`,
 1 AS `due_dt1`,
 1 AS `display`,
 1 AS `invoiced`,
 1 AS `approved`,
 1 AS `timecard`,
 1 AS `last_updated`,
 1 AS `last_run`,
 1 AS `last_run2`,
 1 AS `updated_by`,
 1 AS `allow_inv`,
 1 AS `mod_last_updated`,
 1 AS `srv_client`,
 1 AS `srv_client_name`,
 1 AS `emp_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_rpt_dev_status_lag_time`
--

DROP TABLE IF EXISTS `vw_rpt_dev_status_lag_time`;
/*!50001 DROP VIEW IF EXISTS `vw_rpt_dev_status_lag_time`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_rpt_dev_status_lag_time` AS SELECT 
 1 AS `iddev_est_reqs`,
 1 AS `lag_time`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_sale_current_location`
--

DROP TABLE IF EXISTS `vw_sale_current_location`;
/*!50001 DROP VIEW IF EXISTS `vw_sale_current_location`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_sale_current_location` AS SELECT 
 1 AS `prosp_consult_id`,
 1 AS `Current Location_USA`,
 1 AS `Current Location_india`,
 1 AS `Current Location_UK`,
 1 AS `Current Location_ENG`,
 1 AS `Missing_current_location`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_sale_shr`
--

DROP TABLE IF EXISTS `vw_sale_shr`;
/*!50001 DROP VIEW IF EXISTS `vw_sale_shr`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_sale_shr` AS SELECT 
 1 AS `look_values_id`,
 1 AS `look_table`,
 1 AS `look_values`,
 1 AS `look_display_id`,
 1 AS `look_sub_value_id`,
 1 AS `group_title`,
 1 AS `group_display_id`,
 1 AS `look_value_code`,
 1 AS `look_value_desc`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_sales_consult_attach`
--

DROP TABLE IF EXISTS `vw_sales_consult_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_sales_consult_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_sales_consult_attach` AS SELECT 
 1 AS `idprosp_attach`,
 1 AS `prosp_consult_id`,
 1 AS `idstorage`,
 1 AS `owner_id`,
 1 AS `file_name`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `emp_id`,
 1 AS `updated_for_ref_id`,
 1 AS `updater`,
 1 AS `updated_for_ref_table`,
 1 AS `last_updated`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_sales_prosp_activity`
--

DROP TABLE IF EXISTS `vw_sales_prosp_activity`;
/*!50001 DROP VIEW IF EXISTS `vw_sales_prosp_activity`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_sales_prosp_activity` AS SELECT 
 1 AS `prosp_activity_id`,
 1 AS `prosp_consult_id`,
 1 AS `call_recv_dt`,
 1 AS `emp_id`,
 1 AS `updater`,
 1 AS `next_call_dt`,
 1 AS `call_note`,
 1 AS `last_update`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_sales_prosp_attach`
--

DROP TABLE IF EXISTS `vw_sales_prosp_attach`;
/*!50001 DROP VIEW IF EXISTS `vw_sales_prosp_attach`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_sales_prosp_attach` AS SELECT 
 1 AS `idstorage`,
 1 AS `file_name`,
 1 AS `file_size`,
 1 AS `create_dt`,
 1 AS `updater`,
 1 AS `prosp_consult_id`,
 1 AS `prsp_consult_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_sales_prosp_contact`
--

DROP TABLE IF EXISTS `vw_sales_prosp_contact`;
/*!50001 DROP VIEW IF EXISTS `vw_sales_prosp_contact`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_sales_prosp_contact` AS SELECT 
 1 AS `prosp_contact_id`,
 1 AS `prosp_consult_id`,
 1 AS `contact_id`,
 1 AS `prosp_contact_type`,
 1 AS `prosp_contact_type_id`,
 1 AS `summary`,
 1 AS `contact_detail`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_show_emp`
--

DROP TABLE IF EXISTS `vw_show_emp`;
/*!50001 DROP VIEW IF EXISTS `vw_show_emp`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_show_emp` AS SELECT 
 1 AS `companyname`,
 1 AS `bill_pay_rate`,
 1 AS `engage_calc`,
 1 AS `engage_amt`,
 1 AS `engage_st_dt`,
 1 AS `engage_end_st`,
 1 AS `limit_amt`,
 1 AS `engage_summary`,
 1 AS `engage_ref_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_storage_lk_tag`
--

DROP TABLE IF EXISTS `vw_storage_lk_tag`;
/*!50001 DROP VIEW IF EXISTS `vw_storage_lk_tag`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_storage_lk_tag` AS SELECT 
 1 AS `idstorage_lk_tag`,
 1 AS `lk_tag`,
 1 AS `lk_tag_desc`,
 1 AS `lk_disp_id`,
 1 AS `lk_parent_tag_id`,
 1 AS `updater`,
 1 AS `updater_fmt`,
 1 AS `updater_file_name`,
 1 AS `last_updated`,
 1 AS `last_updated_fmt`,
 1 AS `last_updated_by`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_storages`
--

DROP TABLE IF EXISTS `vw_storages`;
/*!50001 DROP VIEW IF EXISTS `vw_storages`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_storages` AS SELECT 
 1 AS `idstorage`,
 1 AS `file_name`,
 1 AS `file_size`,
 1 AS `owner_id`,
 1 AS `owner_name`,
 1 AS `create_dt_unformatted`,
 1 AS `create_dt`,
 1 AS `ext_type`,
 1 AS `public`,
 1 AS `self_view`,
 1 AS `shared`,
 1 AS `file_summary`,
 1 AS `updated_for_ref_id`,
 1 AS `updated_for_ref_name`,
 1 AS `last_updated`,
 1 AS `emp_id`,
 1 AS `emp_name`,
 1 AS `del_dt_unformatted`,
 1 AS `del_dt`,
 1 AS `del_by_id`,
 1 AS `del_by`,
 1 AS `del_by_file_name`,
 1 AS `virtual_del_day`,
 1 AS `archv_dt_unformatted`,
 1 AS `archv_dt`,
 1 AS `archv_by_id`,
 1 AS `archv_by`,
 1 AS `archv_by_file_name`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary table structure for view `vw_timesheet`
--

DROP TABLE IF EXISTS `vw_timesheet`;
/*!50001 DROP VIEW IF EXISTS `vw_timesheet`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `vw_timesheet` AS SELECT 
 1 AS `timecard_id`,
 1 AS `emp_id`,
 1 AS `comp_id`,
 1 AS `timefrom_dt1`,
 1 AS `timefrom_dt`,
 1 AS `timeto_dt1`,
 1 AS `timeto_dt`,
 1 AS `bill_hrs`,
 1 AS `unbill_hrs`,
 1 AS `total_hrs`,
 1 AS `validate_dt`,
 1 AS `validate_dt1`,
 1 AS `validate_by`,
 1 AS `updated_by`,
 1 AS `updated_by_name`,
 1 AS `summary`,
 1 AS `idstorage`,
 1 AS `filename`,
 1 AS `companyname`,
 1 AS `fullname`,
 1 AS `last_updated`,
 1 AS `last_updated_o`*/;
SET character_set_client = @saved_cs_client;

--
-- Dumping routines for database 'aerion'
--
/*!50003 DROP PROCEDURE IF EXISTS `Attration` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `Attration`(IN `scriptid` int,OUT `scriptlogid` int,IN `param` text,OUT `stime` datetime,OUT `etime` datetime)
BEGIN
/*DECLARE int_idscript_log INT;*/
     DECLARE log_file VARCHAR(900);
 DECLARE log_filepath VARCHAR(2000);
 INSERT INTO script_calls(script_id,script_st) VALUES(scriptid,NOW());
    SET stime=NOW() ;
    SET scriptlogid=LAST_INSERT_ID();
    DO SLEEP(10);
    SET etime=NOW();
UPDATE script_calls SET script_end=NOW(),script_log_file=CONCAT('log_',scriptlogid,'.text') ,`script_summary detail`=CONCAT('successfully executed with parameter  ',param) WHERE idscript_log=scriptlogid;




END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `Bill_TS_cycle` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `Bill_TS_cycle`(IN `scriptid` int,OUT `scriptlogid` int,IN `param` text,OUT `stime` datetime,OUT `etime` datetime)
BEGIN
/*DECLARE int_idscript_log INT;*/
     DECLARE log_file VARCHAR(900);
 DECLARE log_filepath VARCHAR(2000);
 INSERT INTO script_calls(script_id,script_st) VALUES(scriptid,NOW());
    SET stime=NOW() ;
    SET scriptlogid=LAST_INSERT_ID();
   
    







SET etime=NOW();
UPDATE script_calls SET script_end=NOW(),script_log_file=CONCAT('log_',scriptlogid,'.text') ,`script_summary detail`=CONCAT('successfully executed with parameter  ',param) WHERE idscript_log=scriptlogid;




END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `demo_tranpose_test` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `demo_tranpose_test`()
BEGIN

/* Logic  For vw_proc_consult_master creation  */
					
	BEGIN
					
	DECLARE A_name_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct look_values_id as tag FROM vw_sale_shr where group_title is not null  order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
set @vw_proc_consult_master = " create view vw_proc_consult_master as select
a.prosp_consult_id,
a.prosp_first_name,
a.prosp_last_name,
a.gender,
a.emp_assigned_id,
DATE_FORMAT(a.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
a.call_recv_dt,
DATE_FORMAT(a.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
a.next_call_dt,
a.call_note,
a.prosp_summary,
a.last_updated,
concat((select concat(`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `updater` from `emp` where (`emp`.`emp_id` = if((`a`.`emp` = 0),1,`a`.`emp`))),'\r',DATE_FORMAT(a.`last_updated`,'%m-%d-%y')) as `mod_last_updated`,
a.prosp_level AS prosp_level,
a.attachment AS `attachment`,
a.contacts AS `contacts`,
a.prosp_tag AS `prosp_tag`";

	

						
	OPEN A_cur_status;					
						
	select FOUND_ROWS() into A_num_rows;					
						
	     A_the_loop: LOOP				
						
		FETCH  A_cur_status INTO  A_name_val;				
						
		IF A_no_more_rows THEN				
			CLOSE A_cur_status;			
            			LEAVE A_the_loop;						
		END IF;				
						
		set A_name_val = TRIM(A_name_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						


		if A_loop_cntr = A_num_rows then	

    set @vw_proc_consult_master = concat(@vw_proc_consult_master,",sum((case `b`.`prosp_tags` when '",A_name_val,"' then 1 else 0 end)) AS '",A_name_val,"'");
  
ELSE
    set @vw_proc_consult_master = concat(@vw_proc_consult_master,",sum((case `b`.`prosp_tags` when '",A_name_val,"' then 1 else 0 end)) AS '",A_name_val,"'");
		
end if;				
		


						
		SET A_loop_cntr = A_loop_cntr + 1;				

	  END LOOP A_the_loop;			
						
	set @vw_proc_consult_master = concat(@vw_proc_consult_master," from (`prosp_consult` `a` left join `prosp_tag` `b` on((`a`.`prosp_consult_id` = `b`.`prosp_consult_id`))) group by `a`.`prosp_consult_id` order by `a`.`prosp_consult_id` ");	
	select @vw_proc_consult_master;

  set @drop_view = "DROP VIEW IF EXISTS `vw_proc_consult_master`; ";					
	PREPARE drop_view FROM @drop_view;					
	EXECUTE drop_view;					
	DEALLOCATE PREPARE drop_view;	

  PREPARE vw_proc_consult_master_defination FROM @vw_proc_consult_master;					
	EXECUTE vw_proc_consult_master_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_defination;	


  END;

/* Logic  For Group Missing Dynamic View */

  BEGIN
/*
  DECLARE B_name_val VARCHAR(900);	
  DECLARE B_sub_val VARCHAR(900);					
  DECLARE B_t_val INT DEFAULT 0;					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;	

  DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct look_sub_value_id FROM vw_sale_shr where group_title is not null  group by look_sub_value_id order by group_display_id,look_display_id;				
						
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET B_no_more_rows = TRUE;	
	SET @Z = 0;		
set @vw_proc_consult_master_1 = " select
* ";

						
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
						
	     B_the_loop: LOOP				
						
		FETCH  B_cur_status INTO  B_sub_val;				
						
		IF B_no_more_rows THEN				
			CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
		END IF;				
						
	
		set B_sub_val = TRIM(B_sub_val);
						
		IF (B_sub_val IS NULL OR length(B_sub_val) = 0) THEN				
			set B_sub_val = "blank";			
		END IF;				
						

   
  
 
    
  set  @vw_proc_consult_master_1 = concat(@vw_proc_consult_master_1," , if('",B_sub_val,"' = 0,1,0) as  '",B_sub_val,"' ");
    
		


						
		SET B_loop_cntr = B_loop_cntr + 1;				

	  END LOOP B_the_loop;			
						
	 set @vw_proc_consult_master_1 = concat(@vw_proc_consult_master_1," from vw_proc_consult_master as d");		
						
		
  select  @vw_proc_consult_master_1;*/
  
  END;


END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `emp_billing` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `emp_billing`()
BEGIN

    DECLARE done INT DEFAULT 0;
    DECLARE strDate DATE;
    DECLARE endDate DATE;
    DECLARE cur_emp_id INT;
    DECLARE cur_bill_cycle INT;
    DECLARE end_cur_date DATE;
    DECLARE totaltime_cur INT;
    
    
    
    DECLARE cursorWard CURSOR FOR SELECT emp_id,bill_cycle FROM vw_billrate;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;    
    TRUNCATE TABLE emp_billing;
    SET end_cur_date=null;
		OPEN cursorWard;
 
		REPEAT
        FETCH cursorWard INTO cur_emp_id,cur_bill_cycle;
        SET strDate=(SELECT MIN(hoursdate) FROM hours WHERE emp_id=cur_emp_id AND inv_num IS NULL OR inv_num='' OR inv_num=null);
        
        SET endDate=(SELECT MAX(hoursdate) FROM hours WHERE emp_id=cur_emp_id AND inv_num IS NULL OR inv_num='' OR inv_num=null);

    IF NOT done THEN
                WHILE strDate <= endDate DO

/*select cur_emp_id, strDate, endDate, end_cur_date;*/


                /*IF end_cur_date < strDate THEN
                    SET end_cur_date=(SELECT DATE_ADD(strDate,INTERVAL cur_bill_cycle DAY)
                    FROM hours WHERE emp_id=cur_emp_id); 
                    */
                    SET end_cur_date= DATE_ADD(strDate,INTERVAL (cur_bill_cycle-1) DAY);

/*select cur_emp_id AS EMPID, strDate AS ST, endDate AS ED, end_cur_date AS CED;*/

                    SET totaltime_cur=(SELECT SUM(totaltime) FROM hours WHERE emp_id=cur_emp_id 
                    AND hoursdate BETWEEN strDate AND end_cur_date AND inv_num IS NULL OR inv_num='' OR inv_num=null);        

                    INSERT INTO rpt_emp_billing (emp_id,totaltime,bill_cycle,start_date,end_date)
                    SELECT cur_emp_id,totaltime_cur,cur_bill_cycle,strDate,end_cur_date;                      
                /*END IF;*/
/*select cur_emp_id AS EMPID, strDate AS ST, endDate AS ED, end_cur_date AS CED;*/
                
                SET strDate=DATE_ADD(end_cur_date,INTERVAL 1 DAY);


                END WHILE;                
			END IF;
            
		UNTIL done END REPEAT;
 		CLOSE cursorWard;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `GetAllProducts` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `GetAllProducts`()
BEGIN
   SELECT *  FROM all_users;
   END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `Immigration` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `Immigration`(IN `scriptid` int,OUT `scriptlogid` int,IN `param` text,OUT `stime` datetime,OUT `etime` datetime)
BEGIN
DECLARE done INT DEFAULT 0;
     DECLARE log_file VARCHAR(900);
 DECLARE log_filepath VARCHAR(2000);
    DECLARE cur_recid int;
    DECLARE strStatus VARCHAR(2000);
 DECLARE cursorWard CURSOR FOR SELECT receipt_id FROM immi_receipts;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; 
 INSERT INTO script_calls(script_id,script_st) VALUES(scriptid,NOW());
    SET stime=NOW() ;
    SET scriptlogid=LAST_INSERT_ID();
   
	  OPEN cursorWard;
    IF (param ='entiretable') THEN
    TRUNCATE TABLE aerion.status_reports;
    END IF;
		REPEAT
        FETCH cursorWard INTO cur_recid;
    
    IF NOT done THEN

    SET strStatus=(select GROUP_CONCAT(rec_status)  from aerion.immi_status where receipt_id=cur_recid);
    INSERT into aerion.status_reports(rid,statusflow)values(cur_recid,strStatus);


   	END IF;
            
		UNTIL done END REPEAT;
 		CLOSE cursorWard;
SET etime=NOW();
UPDATE script_calls SET script_end=NOW(),script_log_file=CONCAT('log_',scriptlogid,'.text') ,`script_summary detail`=CONCAT('successfully executed with parameter  ',param) WHERE idscript_log=scriptlogid;




END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `incrmental_lag_time` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `incrmental_lag_time`()
BEGIN

  DECLARE id INT(20);
  DECLARE temp varchar(200);

  select group_concat(`iddev_est_reqs_status`) into temp from vw_dev_est_reqs_status where `iddev_est_reqs`=537;

  insert into demo_lag_time (status) values(temp);

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `populate_billing_attration` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `populate_billing_attration`()
BEGIN


    DECLARE i_count INT;
    DECLARE minYear INT;
    DECLARE maxYear INT;
    DECLARE currentYear INT;
    DECLARE currentMonth INT;
    /*
    SET minYear=(SELECT MIN(year) FROM vw_bill_attration WHERE year > 0);
    SET maxYear=(SELECT MAX(year) FROM vw_bill_attration WHERE year > 0);
    */
    SET minYear=(SELECT MIN(year) FROM vw_mon_emp WHERE year > 0);
    SET maxYear=(SELECT MAX(year) FROM vw_mon_emp WHERE year > 0);
    
    SET currentYear=(select Year(CURDATE()));
    SET currentMonth=(select Month(CURDATE()));
    
    
    DELETE FROM rpt_billing_year_month_attrition;
    ALTER TABLE rpt_billing_year_month_attrition auto_increment=1;

  
  
    WHILE minYear < currentYear+1 DO
    SET i_count=1;
        IF minYear = currentYear then
            WHILE i_count <= currentMonth DO       
                INSERT INTO rpt_billing_year_month_attrition (year,month,started,ended,total_emp,attration_rate)
                VALUES (currentYear, i_count, 0,0,0,0);
                SET i_count=i_count+1;
            END WHILE;

        ELSE
            WHILE i_count < 13 DO       
                INSERT INTO rpt_billing_year_month_attrition (year,month,started,ended,total_emp,attration_rate)
                VALUES (minYear, i_count, 0,0,0,0);
                SET i_count=i_count+1;
            END WHILE;
        END IF;
    SET minYear=minYear+1;
    END WHILE;
    
    
  
    UPDATE rpt_billing_year_month_attrition T,vw_bill_attration V SET T.started=V.started,
    T.ended=V.ended
    WHERE T.year=V.year AND T.month=V.month;

    /*
    UPDATE rpt_billing_year_month_attrition T, (select year(contractstart) AS `year`,
    month(contractstart) AS `month`,count(comp_id) AS `cnt` 
    from `comp_engage` group by year(contractstart),month(contractstart)) V
    SET  T.comp_started=V.`cnt`
    WHERE  T.year= V.year AND T.month= V.month;

    UPDATE rpt_billing_year_month_attrition T, (select year(contractend) AS `year`,
    month(contractend) AS `month`,count(comp_id) AS `cnt` 
    from `comp_engage` group by year(contractend),month(contractend)) V
    SET  T.comp_ended=V.`cnt`
    WHERE  T.year= V.year AND T.month= V.month;
    
    */
    
    UPDATE  rpt_billing_year_month_attrition 
    SET     total_emp=started
    ORDER BY id  LIMIT 1;
  
    TRUNCATE TABLE rpt_billing_year_attrition;
    INSERT INTO rpt_billing_year_attrition (year,started,ended,total_emp,attration_rate)
    SELECT year,SUM(started),SUM(ended),0,0 
    FROM rpt_billing_year_month_attrition 
    GROUP BY year
    ORDER BY year,month;
    
    /*
    UPDATE rpt_billing_year_attrition T, (select year(contractstart) AS `year`,
    count(comp_id) AS `cnt` 
    from `comp_engage` group by year(contractstart)) V
    SET  T.comp_started=V.`cnt`
    WHERE  T.year= V.year;
    
    UPDATE rpt_billing_year_attrition T, (select year(contractend) AS `year`,
    count(comp_id) AS `cnt` 
    from `comp_engage` group by year(contractend)) V
    SET  T.comp_ended=V.`cnt`
    WHERE  T.year= V.year;
    */
    
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `populate_data_attration` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `populate_data_attration`()
BEGIN


    DECLARE i_count INT;
    DECLARE minYear INT;
    DECLARE maxYear INT;
    DECLARE currentYear INT;
    DECLARE currentMonth INT;
    
    SET minYear=(SELECT MIN(year) FROM vw_mon_emp WHERE year > 0);
    SET maxYear=(SELECT MAX(year) FROM vw_mon_emp WHERE year > 0);

    SET currentYear=(select Year(CURDATE()));
    SET currentMonth=(select Month(CURDATE()));
    
    
    DELETE FROM rpt_year_month_attrition;
    ALTER TABLE rpt_year_month_attrition auto_increment=1;

  
  
    WHILE minYear < currentYear+1 DO
    SET i_count=1;
        IF minYear = currentYear then
            WHILE i_count <= currentMonth DO       
                INSERT INTO rpt_year_month_attrition (year,month,started,ended,total_emp,attration_rate)
                VALUES (currentYear, i_count, 0,0,0,0);
                SET i_count=i_count+1;
            END WHILE;

        ELSE
            WHILE i_count < 13 DO       
                INSERT INTO rpt_year_month_attrition (year,month,started,ended,total_emp,attration_rate)
                VALUES (minYear, i_count, 0,0,0,0);
                SET i_count=i_count+1;
            END WHILE;
        END IF;
    SET minYear=minYear+1;
    END WHILE;
    
    
  
    UPDATE rpt_year_month_attrition T,vw_mon_emp V SET T.started=V.started,
    T.ended=V.ended
    WHERE T.year=V.year AND T.month=V.month;
  
    /*
    UPDATE rpt_year_month_attrition T, (select year(contractstart) AS `year`,
    month(contractstart) AS `month`,count(comp_id) AS `cnt` 
    from `comp_engage` group by year(contractstart),month(contractstart)) V
    SET  T.comp_started=V.`cnt`
    WHERE  T.year= V.year AND T.month= V.month;
    */
    UPDATE rpt_year_month_attrition T, (select year(srv_st_dt) AS `year`,
    month(srv_st_dt) AS `month`,count(engage_id) AS `cnt` 
    from `engage` 
    group by year(srv_st_dt),month(srv_st_dt)) V
    SET  T.comp_started=V.`cnt`
    WHERE  T.year= V.year AND T.month= V.month;
    
    /*
    UPDATE rpt_year_month_attrition T, (select year(contractend) AS `year`,
    month(contractend) AS `month`,count(comp_id) AS `cnt` 
    from `comp_engage` group by year(contractend),month(contractend)) V
    SET  T.comp_ended=V.`cnt`
    WHERE  T.year= V.year AND T.month= V.month;
    */
    UPDATE rpt_year_month_attrition T, (select year(srv_e_dt) AS `year`,
    month(srv_e_dt) AS `month`,count(engage_id) AS `cnt` 
    from `engage` group by year(srv_e_dt),month(srv_e_dt)) V
    SET  T.comp_ended=V.`cnt`
    WHERE  T.year= V.year AND T.month= V.month;
    
    UPDATE  rpt_year_month_attrition 
    SET     total_emp=started
    ORDER BY id  LIMIT 1;
  
    TRUNCATE TABLE rpt_year_attrition;
    INSERT INTO rpt_year_attrition (year,started,ended,total_emp,attration_rate)
    SELECT year,SUM(started),SUM(ended),0,0 FROM rpt_year_month_attrition GROUP BY year
    ORDER BY year,month;
    
    UPDATE rpt_year_attrition T, (select year(srv_st_dt) AS `year`,
    count(engage_id) AS `cnt` 
    from `engage` group by year(srv_st_dt)) V
    SET  T.comp_started=V.`cnt`
    WHERE  T.year= V.year;
    
    UPDATE rpt_year_attrition T, (select year(srv_e_dt) AS `year`,
    count(engage_id) AS `cnt` 
    from `engage` group by year(srv_e_dt)) V
    SET  T.comp_ended=V.`cnt`
    WHERE  T.year= V.year;
        
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_emp_tag` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`jitenpatel`@`%` PROCEDURE `proc_emp_tag`()
BEGIN


BEGIN

    set @vw_sales_shr_defination="create view  vw_sale_shr as  (select `c`.`look_values_id` AS `look_values_id`,`c`.`look_table` AS `look_table`,`c`.`look_values` AS `look_values`,`c`.`look_display_id` AS `look_display_id`,`c`.`look_sub_value_id` AS `look_sub_value_id`,(select distinct `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_title`,(select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_display_id`,(select distinct `look_values`.`look_value_code` AS `look_value_code` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_code`,(select distinct `look_values`.`look_value_desc` AS `look_value_desc` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_desc` from `look_values` `c` where ((`c`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section'))) and (`c`.`look_sub_value_id` > 0)) order by (select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)),`c`.`look_display_id` )";

    set @vw_sales_shr_drop = "DROP VIEW IF EXISTS `vw_sale_shr`; ";
	PREPARE vw_sales_shr_drop_statement FROM @vw_sales_shr_drop;
	EXECUTE vw_sales_shr_drop_statement;
	DEALLOCATE PREPARE vw_sales_shr_drop_statement;
	
	PREPARE vw_sales_shr_defination_create FROM @vw_sales_shr_defination;
	EXECUTE vw_sales_shr_defination_create;
	DEALLOCATE PREPARE vw_sales_shr_defination_create;


    END;


BEGIN

    set @vw_emp_activity_defination="create view  vw_emp_activity as  select `a`.`idemp_activity` AS `idemp_activity`,`a`.`emp_id` AS `empd_id`,date_format(`a`.`call_recv_dt`,_utf8'%m.%d.%y') AS `call_recv_dt`,`a`.`emp_id` AS `emp_id`,(case when (`a`.`emp_id` <> 0) then concat_ws(_latin1' ',`b`.`firstname`,`b`.`lastname`) else _utf8'Admin' end) AS `updater`,date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') AS `next_call_dt`,`a`.`call_note` AS `call_note`,date_format(`a`.`last_updated`,_utf8'%m.%d.%y %T') AS `last_updated` from (`emp_activity` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') desc
";

    set @vw_emp_activity_drop = "DROP VIEW IF EXISTS `vw_emp_activity; ";
	PREPARE vw_emp_activity_drop FROM @vw_emp_activity_drop;
	EXECUTE vw_emp_activity_drop;
	DEALLOCATE PREPARE vw_emp_activity_drop;
	
	PREPARE vw_emp_activity_defination FROM @vw_emp_activity_defination;
	EXECUTE vw_emp_activity_defination;
	DEALLOCATE PREPARE vw_emp_activity_defination;


    END;


BEGIN

  set @vw_dyn_emp_tag_defination="create view vw_dyn_emp_tag as 
select `emp_id`,CONCAT(GROUP_CONCAT((select look_values from  aerion. look_values where look_values_id=emp_tags order by look_values.look_display_id ) SEPARATOR ' , ')) as tags from  aerion.emp_tag  group by `emp_id` order by (select look_display_id from  aerion. look_values where look_values_id=emp_tags),`emp_id";

  set @vw_dyn_emp_tag_drop = "DROP VIEW IF EXISTS `vw_dyn_emp_tag`; ";
	PREPARE vw_dyn_emp_tag_drop FROM @vw_dyn_emp_tag_drop;
	EXECUTE vw_dyn_emp_tag_drop;
	DEALLOCATE PREPARE vw_dyn_emp_tag_drop;
	
	PREPARE vw_dyn_emp_tag_defination FROM @vw_dyn_emp_tag_defination;
	EXECUTE vw_dyn_emp_tag_defination;
	DEALLOCATE PREPARE vw_dyn_emp_tag_defination;


    END;


  BEGIN

  set @vw_dyn_emp_attach_defination="create view vw_dyn_emp_attach as 
   SELECT emp_id,GROUP_CONCAT(ifnull(file_name,'') SEPARATOR ' , ') AS file_group FROM vw_emp_attachment  GROUP BY emp_id";
  set @vw_dyn_emp_attach_drop = "DROP VIEW IF EXISTS `vw_dyn_emp_attach`; ";
	PREPARE vw_dyn_emp_attach_drop FROM @vw_dyn_emp_attach_drop;
	EXECUTE vw_dyn_emp_attach_drop;
	DEALLOCATE PREPARE vw_dyn_emp_attach_drop;
	
	PREPARE vw_dyn_emp_attach_defination FROM @vw_dyn_emp_attach_defination;
	EXECUTE vw_dyn_emp_attach_defination;
	DEALLOCATE PREPARE vw_dyn_emp_attach_defination;


    END;






BEGIN
					
	DECLARE A_name_val VARCHAR(900);
    DECLARE A_sub_val VARCHAR(900);					
    DECLARE A_t_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct look_values_id,look_sub_value_id as tag FROM vw_sale_shr where group_title is not null  order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
set @vw_emp_dyn1 = " create view  vw_emp_dyn1 as select
a.emp_id,
a.firstname,
a.lastname,
a.gender,
DATE_FORMAT(a.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
a.call_recv_dt,
DATE_FORMAT(a.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
a.next_call_dt,
a.call_note,
a.emp_smry,
a.last_updated_sale,
concat((select concat(`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `updater` from `emp` where (`emp`.`emp_id` = if((`a`.`emp_id_updated` = 0),1,`a`.`emp_id_updated`))),'\r',DATE_FORMAT(a.`last_updated_sale`,'%m-%d-%y')) as `mod_last_updated`,
a.emp_level AS emp_level,
(select look_values from look_values where look_values_id = a.emp_level) as emp_lvl_desc,
a.attachment AS `attachment`,
e.contacts AS `contacts`,
f.file_group AS `attach`,
d.tags AS `emp_tag`";

	

  set A_t_val = "";	
  set @Q = "";	
  set @Z = "";			

	OPEN A_cur_status;					
	FETCH  A_cur_status INTO  A_name_val, A_sub_val;
	set A_t_val = A_sub_val;
    CLOSE A_cur_status;			
         
         OPEN A_cur_status;					
			select FOUND_ROWS() into A_num_rows;					
					A_the_loop: LOOP				
						FETCH  A_cur_status INTO  A_name_val, A_sub_val;				
						IF A_no_more_rows THEN				
								CLOSE A_cur_status;			
		            			LEAVE A_the_loop;						
						END IF;				
						
		set A_name_val = TRIM(A_name_val);			
        set A_sub_val = TRIM(A_sub_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
    set @vw_emp_dyn1 = concat(@vw_emp_dyn1,",sum((case `b`.`emp_tags` when '",A_name_val,"' then 1 else 0 end)) AS '",A_name_val,"'");
  
    if A_sub_val != A_t_val then
       set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");
       set @Z = "";
    end if;

		set @Z = CONCAT(@Z," or `",A_name_val,"` > 0 " );
		set A_t_val = A_sub_val;
    	SET A_loop_cntr = A_loop_cntr + 1;				

  					END LOOP A_the_loop;	

  		set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");		
		set @vw_emp_dyn1 = concat(@vw_emp_dyn1," from (`emp` `a` left join `emp_tag` `b` on((`a`.`emp_id` = `b`.`emp_id`))) LEFT JOIN   vw_dyn_emp_tag  `d`  on a.emp_id = d.emp_id  LEFT JOIN vw_emp_contact2 e on a.emp_id = e.emp_id LEFT JOIN vw_dyn_emp_attach f on a.emp_id = f.emp_id group by `a`.`emp_id` order by `a`.`emp_id` ");	
		
		set @vw_emp_dyn2 =  concat("create view vw_emp_dyn2 as  select *",@Q," from vw_emp_dyn1");
 


	  set @drop_view = "DROP VIEW IF EXISTS `vw_emp_dyn1`; ";					
		PREPARE drop_view FROM @drop_view;					
		EXECUTE drop_view;					
		DEALLOCATE PREPARE drop_view;	


	  PREPARE vw_emp_dyn1_defination FROM @vw_emp_dyn1;					
		EXECUTE vw_emp_dyn1_defination;					
		DEALLOCATE PREPARE vw_emp_dyn1_defination;	

  
	  set @drop_view_1 = "DROP VIEW IF EXISTS `vw_emp_dyn2`; ";					
		PREPARE drop_view_1 FROM @drop_view_1;					
		EXECUTE drop_view_1;					
		DEALLOCATE PREPARE drop_view_1;	

  
	  PREPARE vw_emp_dyn2_defination FROM @vw_emp_dyn2;					
		EXECUTE vw_emp_dyn2_defination;					
		DEALLOCATE PREPARE vw_emp_dyn2_defination;	

END;



BEGIN

  
  	DECLARE B_name_val VARCHAR(900);	
  	DECLARE B_sub_val VARCHAR(900);					
  	DECLARE B_t_val INT DEFAULT 0;					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;	

   	DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct look_sub_value_id FROM vw_sale_shr where group_title is not null  group by look_sub_value_id order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET B_no_more_rows = TRUE;	
	SET @y = "";	
  	SET @final = "";	
	SET @vw_emp_dyn3 = " create view  vw_emp_dyn3  as select * ";

						
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
				B_the_loop: LOOP				
				FETCH  B_cur_status INTO  B_sub_val;				
				
				IF B_no_more_rows THEN				
					CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
				END IF;				
						
	
		set B_sub_val = TRIM(B_sub_val);

		IF (B_sub_val IS NULL OR length(B_sub_val) = 0) THEN				
			set B_sub_val = "blank";			
		END IF;

		set @y = CONCAT(@y," OR `",B_sub_val,"` = 1 " );
  
    

     	SET B_loop_cntr = B_loop_cntr + 1;				

		END LOOP B_the_loop;	

    set @final = CONCAT(@final, ", if((0 ",@y," ),1,0) as Total_Missing");	
    set @vw_emp_dyn3 = concat(@vw_emp_dyn3,@final);
	set @vw_emp_dyn3 = concat(@vw_emp_dyn3," from vw_emp_dyn2 ");		
		

		
	set @drop_view_2 = "DROP VIEW IF EXISTS `vw_emp_dyn3`; ";					
	PREPARE drop_view_2 FROM @drop_view_2;					
	EXECUTE drop_view_2;					
	DEALLOCATE PREPARE drop_view_2;	


  PREPARE vw_emp_dyn3_defination FROM @vw_emp_dyn3;					
	EXECUTE vw_emp_dyn3_defination;					
	DEALLOCATE PREPARE vw_emp_dyn3_defination;	
  
  
  END;

 

  BEGIN

   set @emp_tag_merger_defination = " CREATE TABLE emp_tag_merger AS  SELECT * FROM vw_emp_dyn3";

    set @drop_table = "DROP TABLE IF EXISTS `emp_tag_merger`; ";					
	PREPARE drop_table FROM @drop_table;					
	EXECUTE drop_table;					
	DEALLOCATE PREPARE drop_table;	

  PREPARE emp_tag_merger_defination FROM @emp_tag_merger_defination;					
	EXECUTE emp_tag_merger_defination;					
	DEALLOCATE PREPARE emp_tag_merger_defination;

  END;

 

  END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_hours_cycle` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_hours_cycle`()
BEGIN
    
    DECLARE compid  INT;
    DECLARE billId  INT;
    DECLARE empId   INT;
    DECLARE billDetailId INT;
    DECLARE billPayRate INT; 
    DECLARE billFromDate DATE; 
    DECLARE billToDate DATE;
    DECLARE intermediateDate DATE;
    DECLARE cycleType  VARCHAR(200);
    DECLARE hourId VARCHAR(200);
    DECLARE expectedHours DECIMAL;
    DECLARE billable CHAR(1);
    DECLARE billDueDate DATE;
    DECLARE netPayDays INT;
    DECLARE recordCount INT;
    DECLARE totalHrs DECIMAL;
    DECLARE done INT DEFAULT 0;
  	DECLARE int_idscript_log INT;
	  DECLARE fstname VARCHAR(200);
    DECLARE lstname VARCHAR(200);
    DECLARE billCycleId INT;
    
    
DECLARE cursorWard CURSOR FOR 
    SELECT comp_id, bill_id, emp_id, bill_detail_id, bill_pay_rate, bill_from_dt, bill_to_dt, cycle_type, bill_cycle_id  
    FROM rpt_bill_cycle 
    WHERE last_update > 
    (SELECT script_end FROM script_calls 
    WHERE script_id = 2 AND idscript_log = (SELECT MAX(idscript_log) FROM script_calls where script_id = 2));
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cursorWard;

    INSERT INTO script_calls(script_id,script_st) VALUES(2,NOW());
    SET int_idscript_log=LAST_INSERT_ID();

		REPEAT
        FETCH cursorWard INTO compId, billId, empId, billDetailId, billPayRate, billFromDate, billToDate, cycleType, billCycleId;
        
        SET intermediateDate = billFromDate;
        
        SET netPayDays=(SELECT netpay from engage_entity_po where idengage_entity_po = billDetailId);
        SET billDueDate=(SELECT date_add(billToDate,INTERVAL netPayDays DAY));
               
			  
        IF NOT done THEN
				            
            WHILE intermediateDate <= billToDate DO				

                SET recordCount = (SELECT COUNT(hour_id) from hours WHERE hoursdate = intermediateDate AND emp_id = empId AND comp_id = compId);

                IF (DAYOFWEEK(intermediateDate) = 1 OR DAYOFWEEK(intermediateDate) = 7) THEN
                
                    INSERT INTO rpt_hours_calc (
                        hour_id, bill_cycle_start_dt, bill_cycle_end_dt, expected_hrs, 
                        billable, non_billable, total_hrs, hrs_diff, inv_diff,
                        cycle_type, bill_due_dt, hrs_date,comp_id, bill_id, emp_id, bill_detail_id)
                    SELECT  
                        NULL, billFromDate, billToDate, 0,
                        0, 0, 0, 0, NULL,
                        cycleType, billDueDate, intermediateDate,compId, billId, empId, billDetailId;
                        
                ELSE 
                    IF (recordCount = 0 ) THEN 

                        INSERT INTO rpt_hours_calc (
                            hour_id, bill_cycle_start_dt, bill_cycle_end_dt, expected_hrs, 
                            billable, non_billable, total_hrs, hrs_diff, inv_diff,
                            cycle_type, bill_due_dt, hrs_date,comp_id, bill_id, emp_id, bill_detail_id)
                        SELECT  
                            NULL, billFromDate, billToDate, 8,
                            0, 0, 0, -8, NULL,
                            cycleType, billDueDate, intermediateDate,compId, billId, empId, billDetailId;
                   
                    ELSE        
                    
                        SET hourId=(SELECT GROUP_CONCAT(hour_id) FROM hours WHERE hoursdate = intermediateDate AND emp_id = empId AND comp_id = compId);
                        
                        SET expectedHours=(SELECT CASE WHEN SUM(expected_hrs) IS NULL THEN 8 ELSE SUM(expected_hrs) END from hours WHERE hoursdate = intermediateDate AND emp_id = empId AND comp_id = compId);
                        
                        SET billable=(SELECT hrs_type from hours WHERE hoursdate = intermediateDate AND emp_id = empId AND comp_id = compId LIMIT 0, 1);
                        
                        SET totalHrs=(SELECT SUM(totaltime) from hours WHERE hoursdate = intermediateDate AND emp_id = empId AND comp_id = compId);
                        
                         INSERT INTO rpt_hours_calc (
                            hour_id, bill_cycle_start_dt, bill_cycle_end_dt, expected_hrs, 
                            billable, non_billable, total_hrs, hrs_diff, inv_diff,
                            cycle_type, bill_due_dt, hrs_date,comp_id, bill_id, emp_id, bill_detail_id)
                        SELECT  
                            hourId, billFromDate, billToDate, expectedHours,
                            CASE WHEN (billable = 'B') THEN totalHrs ELSE 0 END, 
                            CASE WHEN (billable = 'N' OR billable IS NULL) THEN totalHrs ELSE 0 END,  
                            totalHrs, (totalHrs-expectedHours), NULL,
                            cycleType, billDueDate, intermediateDate,compId, billId, empId, billDetailId;
                            
                     END IF;
                                        
                END IF;
                
                SET intermediateDate=date_add(intermediateDate,INTERVAL 1 DAY);
                
            END WHILE;

            /*SET fstname=(SELECT firstname from billable B INNER JOIN emp E ON B.emp_id = E.emp_id AND bill_id = int_bill_id);
            SET lstname=(SELECT lastname from billable B INNER JOIN emp E ON B.emp_id = E.emp_id AND bill_id = int_bill_id);
            */
            
					INSERT INTO script_call_detail(idscript_log,script_time,script_msgs)
					VALUES(int_idscript_log,NOW(), CONCAT('Record for Bill Cycle Id ',billCycleId,' processed'));
                    
					               
			END IF;		
		
		UNTIL done END REPEAT;
 		
CLOSE cursorWard;

UPDATE script_calls SET script_end=NOW() WHERE idscript_log=int_idscript_log;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_load_contracts` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_load_contracts`()
BEGIN
	
set @script_id= (select script_id from scripts where script_name='proc_load_contracts');

set @start_time = NOW();
insert into  aerion.script_calls(script_id,script_st) VALUES(@script_id,@start_time);
SET @LID = LAST_INSERT_ID();
	set @load_contracts = " CREATE TABLE load_contracts AS  SELECT * FROM vw_comp_contracts";
  set @drop_table = "DROP TABLE IF EXISTS `load_contracts`; ";					
	PREPARE drop_table FROM @drop_table;					
	EXECUTE drop_table;					
	DEALLOCATE PREPARE drop_table;	
  PREPARE load_contracts FROM @load_contracts;					
	EXECUTE load_contracts;					
	DEALLOCATE PREPARE load_contracts;
	
set @end_time = NOW();

update  aerion. script_calls set script_end=@end_time,script_log_file=@LID,script_summary_detail='test for contracts' where  idscript_log=@LID;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_load_emp_details` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_load_emp_details`()
BEGIN

set @script_id= (select script_id from scripts where script_name='proc_load_emp_details');

set @start_time = NOW();
update  aerion. scripts set script_st=@start_time,script_end='NUll' where  script_id=@script_id;
insert into  aerion.script_calls(script_id,script_st) VALUES(@script_id,@start_time);





SET @LID = LAST_INSERT_ID();
 set @load_emp_details = "CREATE TABLE load_emp_details AS  SELECT * FROM vw_emp_details";
  set @drop_table = "DROP TABLE IF EXISTS `load_emp_details`; ";     
 PREPARE drop_table FROM @drop_table;     
 EXECUTE drop_table;     
 DEALLOCATE PREPARE drop_table; 
  PREPARE load_emp_details FROM @load_emp_details;     
 EXECUTE load_emp_details;     
 DEALLOCATE PREPARE load_emp_details;
set @end_time = NOW();

update  aerion. script_calls set script_end=@end_time,script_log_file=@LID,script_summary_detail='test for employee' where  idscript_log=@LID; 

update  aerion. scripts set script_end=@end_time where  script_id=@script_id;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_prosp_conversion` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_prosp_conversion`()
BEGIN

BEGIN
					
    DECLARE A_table_name VARCHAR(900);
    DECLARE A_key_col_name VARCHAR(900);
    DECLARE A_ref_table_col_name VARCHAR(900);
    DECLARE A_table_to_update VARCHAR(900);
    DECLARE A_table_to_insert VARCHAR(900);
    DECLARE A_fetch_cols VARCHAR(900);
    DECLARE A_insert_cols VARCHAR(900);
    DECLARE A_action VARCHAR(900);
    DECLARE A_where_col_name VARCHAR(900);
    DECLARE A_where_col_value VARCHAR(900);

    DECLARE A_t_val VARCHAR(900);					

    DECLARE A_no_more_rows BOOLEAN;					
    DECLARE A_loop_cntr INT DEFAULT 1;					
    DECLARE A_num_rows INT DEFAULT 0;					
						
    DECLARE A_cursor CURSOR FOR  				
	SELECT table_name,key_col_name,ref_table_col_name,table_to_update,table_to_insert,fetch_cols,insert_cols,action,where_col_name,where_col_value
                FROM prosp_conversion 
                ORDER BY idprosp_conversion;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
    SET @vw_query = "";     
    OPEN A_cursor;					
    select FOUND_ROWS() into A_num_rows;					
    A_the_loop: LOOP				
	FETCH  A_cursor 
                    INTO                      
                    A_table_name,A_key_col_name,A_ref_table_col_name,A_table_to_update,A_table_to_insert,A_fetch_cols,A_insert_cols,
                    A_action,A_where_col_name,A_where_col_value;				
	IF A_no_more_rows THEN				
	    CLOSE A_cursor;			
	    LEAVE A_the_loop;						
	END IF;				
						
	IF TRIM(A_table_name) = "" THEN SET A_table_name = ""; ELSE SET A_table_name = TRIM(A_table_name); end if;
	IF TRIM(A_key_col_name) = "" THEN SET A_key_col_name = ""; ELSE SET A_key_col_name = TRIM(A_key_col_name); end if;
	IF TRIM(A_ref_table_col_name) = "" THEN SET A_ref_table_col_name = ""; ELSE SET A_ref_table_col_name = TRIM(A_ref_table_col_name); end if;
	IF TRIM(A_table_to_update) = "" THEN SET A_table_to_update = ""; ELSE SET A_table_to_update = TRIM(A_table_to_update); end if;
	IF TRIM(A_table_to_insert) = "" THEN SET A_table_to_insert = ""; ELSE SET A_table_to_insert = TRIM(A_table_to_insert); end if;
	IF TRIM(A_fetch_cols) = "" THEN SET A_fetch_cols = ""; ELSE SET A_fetch_cols = TRIM(A_fetch_cols); end if;
	IF TRIM(A_insert_cols) = "" THEN SET A_insert_cols = ""; ELSE SET A_insert_cols = TRIM(A_insert_cols); end if;
	IF TRIM(A_action) = "" THEN SET A_action = ""; ELSE SET A_action = TRIM(A_action); end if;
	IF TRIM(A_where_col_name) = "" THEN SET A_where_col_name = ""; ELSE SET A_where_col_name = TRIM(A_where_col_name); end if;
	IF TRIM(A_where_col_value) = "" THEN SET A_where_col_value = ""; ELSE SET A_where_col_value = TRIM(A_where_col_value); end if;

	if @vw_query != "" then 
	    SET @vw_query = concat(@vw_query," union ");
	end if;

	SET @vw_query = concat(@vw_query," SELECT ",A_key_col_name," as consult_id,'",A_table_name,"' as table_name,'",A_key_col_name,"' as refid,'",A_ref_table_col_name,"' as reftable,'",A_table_to_update,"' as tbl_to_update,'",A_table_to_insert,"' as tbl_to_insert,'",A_fetch_cols,"' as fetch_cols,'",A_insert_cols,"' as insert_cols,'",A_action,"' as action from ",A_table_name," ");

	 if A_where_col_name != "" then
	     SET @vw_query = concat(@vw_query," where lcase(",A_where_col_name,") = lcase('",A_where_col_value,"')");
	end if;
						
    	SET A_loop_cntr = A_loop_cntr + 1;				

    END LOOP A_the_loop;	

    SET @vw_query = concat("CREATE VIEW  vw_cnslt_con_1 AS ",@vw_query," order by table_name,consult_id,tbl_to_update,tbl_to_insert");

    SET @drop_view = "DROP VIEW IF EXISTS `vw_cnslt_con_1`; ";					
		PREPARE drop_view FROM @drop_view;					
		EXECUTE drop_view;					
		DEALLOCATE PREPARE drop_view;	

	  PREPARE vw_query_defination FROM @vw_query;					
		EXECUTE vw_query_defination;					
		DEALLOCATE PREPARE vw_query_defination;	


		SET @vw_query = concat("CREATE VIEW  vw_cnslt_con_2 AS  select consult_id AS consult_id,group_concat(table_name separator ' , ') AS table_name from vw_cnslt_con_1 group by consult_id");

    SET @drop_view = "DROP VIEW IF EXISTS `vw_cnslt_con_2`; ";					
		PREPARE drop_view FROM @drop_view;					
		EXECUTE drop_view;					
		DEALLOCATE PREPARE drop_view;	

	  PREPARE vw_query_defination FROM @vw_query;					
		EXECUTE vw_query_defination;					
		DEALLOCATE PREPARE vw_query_defination;	

		SET @vw_query = concat("CREATE VIEW  vw_cnslt_con_3 AS  select distinct table_name, refid,reftable,tbl_to_update,tbl_to_insert,fetch_cols,insert_cols,action from vw_cnslt_con_1");

    SET @drop_view = "DROP VIEW IF EXISTS `vw_cnslt_con_3`; ";					
		PREPARE drop_view FROM @drop_view;					
		EXECUTE drop_view;					
		DEALLOCATE PREPARE drop_view;	

	  PREPARE vw_query_defination FROM @vw_query;					
		EXECUTE vw_query_defination;					
		DEALLOCATE PREPARE vw_query_defination;	

END;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_prosp_conversion_view` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_prosp_conversion_view`()
BEGIN

BEGIN
					
    DECLARE A_table_name VARCHAR(900);
    DECLARE A_key_col_name VARCHAR(900);
    DECLARE A_ref_table_col_name VARCHAR(900);
    DECLARE A_table_to_update VARCHAR(900);
    DECLARE A_table_to_insert VARCHAR(900);
    DECLARE A_fetch_cols VARCHAR(900);
    DECLARE A_insert_cols VARCHAR(900);
    DECLARE A_action VARCHAR(900);
    DECLARE A_where_col_name VARCHAR(900);
    DECLARE A_where_col_value VARCHAR(900);

    DECLARE A_t_val VARCHAR(900);					

    DECLARE A_no_more_rows BOOLEAN;					
    DECLARE A_loop_cntr INT DEFAULT 1;					
    DECLARE A_num_rows INT DEFAULT 0;					
						
    DECLARE A_cursor CURSOR FOR  				
	SELECT table_name,key_col_name,ref_table_col_name,table_to_update,table_to_insert,fetch_cols,insert_cols,action,where_col_name,where_col_value
                FROM prosp_conversion 
                ORDER BY idprosp_conversion;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
    SET @vw_query = "";     
    OPEN A_cursor;					
    select FOUND_ROWS() into A_num_rows;					
    A_the_loop: LOOP				
	FETCH  A_cursor 
                    INTO                      
                    A_table_name,A_key_col_name,A_ref_table_col_name,A_table_to_update,A_table_to_insert,A_fetch_cols,A_insert_cols,
                    A_action,A_where_col_name,A_where_col_value;				
	IF A_no_more_rows THEN				
	    CLOSE A_cursor;			
	    LEAVE A_the_loop;						
	END IF;				
						
	IF TRIM(A_table_name) = "" THEN SET A_table_name = ""; ELSE SET A_table_name = TRIM(A_table_name); end if;
	IF TRIM(A_key_col_name) = "" THEN SET A_key_col_name = ""; ELSE SET A_key_col_name = TRIM(A_key_col_name); end if;
	IF TRIM(A_ref_table_col_name) = "" THEN SET A_ref_table_col_name = ""; ELSE SET A_ref_table_col_name = TRIM(A_ref_table_col_name); end if;
	IF TRIM(A_table_to_update) = "" THEN SET A_table_to_update = ""; ELSE SET A_table_to_update = TRIM(A_table_to_update); end if;
	IF TRIM(A_table_to_insert) = "" THEN SET A_table_to_insert = ""; ELSE SET A_table_to_insert = TRIM(A_table_to_insert); end if;
	IF TRIM(A_fetch_cols) = "" THEN SET A_fetch_cols = ""; ELSE SET A_fetch_cols = TRIM(A_fetch_cols); end if;
	IF TRIM(A_insert_cols) = "" THEN SET A_insert_cols = ""; ELSE SET A_insert_cols = TRIM(A_insert_cols); end if;
	IF TRIM(A_action) = "" THEN SET A_action = ""; ELSE SET A_action = TRIM(A_action); end if;
	IF TRIM(A_where_col_name) = "" THEN SET A_where_col_name = ""; ELSE SET A_where_col_name = TRIM(A_where_col_name); end if;
	IF TRIM(A_where_col_value) = "" THEN SET A_where_col_value = ""; ELSE SET A_where_col_value = TRIM(A_where_col_value); end if;

	if @vw_query != "" then 
	    SET @vw_query = concat(@vw_query," union ");
	end if;

	SET @vw_query = concat(@vw_query," SELECT ",A_key_col_name," as consult_id,'",A_table_name,"' as table_name,'",A_key_col_name,"' as refid,'",A_ref_table_col_name,"' as reftable,'",A_table_to_update,"' as tbl_to_update,'",A_table_to_insert,"' as tbl_to_insert,'",A_fetch_cols,"' as fetch_cols,'",A_insert_cols,"' as insert_cols,'",A_action,"' as action from ",A_table_name," ");

	 if A_where_col_name != "" then
	     SET @vw_query = concat(@vw_query," where lcase(",A_where_col_name,") = lcase('",A_where_col_value,"')");
	end if;
						
    	SET A_loop_cntr = A_loop_cntr + 1;				

    END LOOP A_the_loop;	

    SET @vw_query = concat("CREATE VIEW  vw_cnslt_con_1 AS ",@vw_query," order by table_name,consult_id,tbl_to_update,tbl_to_insert");

    SET @drop_view = "DROP VIEW IF EXISTS `vw_cnslt_con_1`; ";					
		PREPARE drop_view FROM @drop_view;					
		EXECUTE drop_view;					
		DEALLOCATE PREPARE drop_view;	

	  PREPARE vw_query_defination FROM @vw_query;					
		EXECUTE vw_query_defination;					
		DEALLOCATE PREPARE vw_query_defination;	


		SET @vw_query = concat("CREATE VIEW  vw_cnslt_con_2 AS  select consult_id AS consult_id,group_concat(table_name separator ' , ') AS table_name from vw_cnslt_con_1 group by consult_id");

    SET @drop_view = "DROP VIEW IF EXISTS `vw_cnslt_con_2`; ";					
		PREPARE drop_view FROM @drop_view;					
		EXECUTE drop_view;					
		DEALLOCATE PREPARE drop_view;	

	  PREPARE vw_query_defination FROM @vw_query;					
		EXECUTE vw_query_defination;					
		DEALLOCATE PREPARE vw_query_defination;	

		SET @vw_query = concat("CREATE VIEW  vw_cnslt_con_3 AS  select distinct table_name, refid,reftable,tbl_to_update,tbl_to_insert,fetch_cols,insert_cols,action from vw_cnslt_con_1");

    SET @drop_view = "DROP VIEW IF EXISTS `vw_cnslt_con_3`; ";					
		PREPARE drop_view FROM @drop_view;					
		EXECUTE drop_view;					
		DEALLOCATE PREPARE drop_view;	

	  PREPARE vw_query_defination FROM @vw_query;					
		EXECUTE vw_query_defination;					
		DEALLOCATE PREPARE vw_query_defination;	

END;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_sales_consult_views` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_sales_consult_views`()
BEGIN
	BEGIN

    set @vw_sales_shr_defination="create view  vw_sale_shr as  (select `c`.`look_values_id` AS `look_values_id`,`c`.`look_table` AS `look_table`,`c`.`look_values` AS `look_values`,`c`.`look_display_id` AS `look_display_id`,`c`.`look_sub_value_id` AS `look_sub_value_id`,(select distinct `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_title`,(select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_display_id`,(select distinct `look_values`.`look_value_code` AS `look_value_code` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_code`,(select distinct `look_values`.`look_value_desc` AS `look_value_desc` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_desc` from `look_values` `c` where ((`c`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section'))) and (`c`.`look_sub_value_id` > 0)) order by (select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)),`c`.`look_display_id` )";

    set @vw_sales_shr_drop = "DROP VIEW IF EXISTS `vw_sale_shr`; ";
	PREPARE vw_sales_shr_drop_statement FROM @vw_sales_shr_drop;
	EXECUTE vw_sales_shr_drop_statement;
	DEALLOCATE PREPARE vw_sales_shr_drop_statement;
	
	PREPARE vw_sales_shr_defination_create FROM @vw_sales_shr_defination;
	EXECUTE vw_sales_shr_defination_create;
	DEALLOCATE PREPARE vw_sales_shr_defination_create;


    END;

    BEGIN

    set @vw_vw_sales_prosp_activity_defination="create view  vw_sales_prosp_activity  as (select `a`.`prosp_activity_id` AS `prosp_activity_id`,`a`.`prosp_consult_id` AS `prosp_consult_id`,date_format(`a`.`call_recv_dt`,_utf8'%m.%d.%y') AS `call_recv_dt`,`a`.`emp_id` AS `emp_id`,(case when (`a`.`emp_id` <> 0) then concat_ws(_latin1' ',`b`.`firstname`,`b`.`lastname`) else _utf8'Admin' end) AS `updater`,date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') AS `next_call_dt`,`a`.`call_note` AS `call_note`,date_format(`a`.`last_update`,_utf8'%m.%d.%y %T') AS `last_update` from (`prosp_activity` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') desc)";
    
    set @vw_sales_prosp_activity_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_activity`; ";
		PREPARE vw_sales_prosp_activity_drop_statement FROM @vw_sales_prosp_activity_drop;
		EXECUTE vw_sales_prosp_activity_drop_statement;
		DEALLOCATE PREPARE vw_sales_prosp_activity_drop_statement;
		
		PREPARE vw_sales_prosp_activity_defination_create FROM @vw_vw_sales_prosp_activity_defination;
		EXECUTE vw_sales_prosp_activity_defination_create;
		DEALLOCATE PREPARE vw_sales_prosp_activity_defination_create;

    END;

	BEGIN
	set @vw_sales_prosp_attach_defination="create view  vw_sales_prosp_attach as (select`a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,date_format(`a`.`create_dt`,_utf8'%m-%d-%y') AS `create_dt`,(case when (`a`.`owner_id` = _latin1'') then _utf8'Admin' when isnull(`a`.`owner_id`) then _utf8'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updater`,`b`.`prosp_consult_id` AS `prosp_consult_id`,concat(`c`.`prosp_first_name`,_latin1' ',`c`.`prosp_last_name`) AS `prsp_consult_name` from (((`storages` `a` left join `prosp_attach` `b` on((`a`.`idstorage` = `b`.`idstorage`))) left join `emp` `e` on((`a`.`owner_id` = `e`.`emp_id`))) left join `prosp_consult` `c` on((`b`.`prosp_consult_id` = `c`.`prosp_consult_id`))) )";
    set @vw_sales_prosp_attach_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_attach`; ";
	PREPARE vw_sales_prosp_attach_drop_statement FROM @vw_sales_prosp_attach_drop;
	EXECUTE vw_sales_prosp_attach_drop_statement;
	DEALLOCATE PREPARE vw_sales_prosp_attach_drop_statement;
	
	PREPARE vw_sales_prosp_attach_defination_create FROM @vw_sales_prosp_attach_defination;
	EXECUTE vw_sales_prosp_attach_defination_create;
	DEALLOCATE PREPARE vw_sales_prosp_attach_defination_create;
	END;


	BEGIN	
	    set @vw_sales_prosp_contact_defination="create view  vw_sales_prosp_contact  as  (select `a`.`prosp_contact_id` AS `prosp_contact_id`,`a`.`prosp_consult_id` AS `prosp_consult_id`,`a`.`contact_id` AS `contact_id`,`a`.`prosp_contact_type` AS `prosp_contact_type`,(select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where ((`look_values`.`look_values` = `a`.`prosp_contact_type`) and (select `look_values`.`look_table` AS `look_table` from `look_values` where (`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'contact.type'))) limit 1)) limit 1) AS `prosp_contact_type_id`,`a`.`summary` AS `summary`,`b`.`contact_detail` AS `contact_detail` from (`prosp_contact` `a` left join `contact_no` `b` on((`a`.`contact_id` = `b`.`contact_id`))))";

	    set @vw_sales_prosp_contact_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_contact`; ";
		PREPARE vw_sales_prosp_contact_drop_statement FROM @vw_sales_prosp_contact_drop;
		EXECUTE vw_sales_prosp_contact_drop_statement;
		DEALLOCATE PREPARE vw_sales_prosp_contact_drop_statement;
		
		PREPARE vw_sales_prosp_contact_defination_create FROM @vw_sales_prosp_contact_defination;
		EXECUTE vw_sales_prosp_contact_defination_create;
		DEALLOCATE PREPARE vw_sales_prosp_contact_defination_create;

	END;



	BEGIN
	  set @vw_sale_consult_tag_defination="create view vw_sale_consult_tag as  (select `b`.`prosp_consult_id` AS `prosp_consult_id`,
`b`.`prosp_first_name` AS `prosp_first_name`,
`b`.`prosp_last_name` AS `prosp_last_name`,
`b`.`prosp_level` AS `prosp_level`,(select `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `b`.`prosp_level`)) AS `prosp_level_desc`,`b`.`prosp_summary` AS `prosp_summary`,
`b`.`gender` AS `gender_id`,(select `look_values`.`look_values` AS `gender` from `look_values` where (`look_values`.`look_values_id` = `b`.`gender`)) AS `gender`,
`b`.`emp` AS `updated_by`,(select concat(`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `updater` from `emp` where (`emp`.`emp_id` = if((`b`.`emp` = 0),1,`b`.`emp`))) AS `updater`,
`b`.`emp_assigned_id` AS `emp_assigned_id`,
`b`.`call_recv_dt` AS `call_recv_dt`,
`b`.`emp_id` AS `emp_id`,
`b`.`next_call_dt` AS `next_call_dt`,
`b`.`call_note` AS `call_note`,
`b`.`last_updated` AS `last_updated`,
`b`.`attachment` AS `attachment`,
`b`.`contacts` AS `contacts`,
`b`.`prosp_tag` AS `prosp_tag`,
(select `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `a`.`prosp_tags`)) AS `look_values`,
(select `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `a`.`prosp_tags`)) AS `look_display_id`,
(select `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = (select `look_values`.`look_sub_value_id` AS `look_sub_value_id` from `look_values` where (`look_values`.`look_values_id` = `a`.`prosp_tags`)))) AS `group_title`,
(select `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = (select `look_values`.`look_sub_value_id` AS `look_sub_value_id` from `look_values` where (`look_values`.`look_values_id` = `a`.`prosp_tags`)))) AS `group_display_id`

 from (`prosp_consult` `b` left join `prosp_tag` `a` on((`a`.`prosp_consult_id` = `b`.`prosp_consult_id`))) order by `a`.`prosp_consult_id`,(select `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = (select `look_values`.`look_sub_value_id` AS `look_sub_value_id` from `look_values` where (`look_values`.`look_values_id` = `a`.`prosp_tags`)))),(select `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `a`.`prosp_tags`)))";

	  set @vw_sale_consult_tag_drop = "DROP VIEW IF EXISTS `vw_sale_consult_tag`; ";
		PREPARE vw_sale_consult_tag_drop_statement FROM @vw_sale_consult_tag_drop;
		EXECUTE vw_sale_consult_tag_drop_statement;
		DEALLOCATE PREPARE vw_sale_consult_tag_drop_statement;
		
		PREPARE vw_sale_consult_tag_defination_create FROM @vw_sale_consult_tag_defination;
		EXECUTE vw_sale_consult_tag_defination_create;
		DEALLOCATE PREPARE vw_sale_consult_tag_defination_create;

	END;
 
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_sale_consult_transpose` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_sale_consult_transpose`()
    READS SQL DATA
BEGIN
call proc_sales_consult_views;
 BEGIN						
						
	DECLARE A_name_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct concat(group_title,'_',look_values) as tag FROM vw_sale_shr where group_title is not null  order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
	set @A_query_t_sale_consult_dynamic = "create view `vw_t_sale_consult_tag_tran` as select 
`vw_sale_consult_tag`.`prosp_consult_id`,
`vw_sale_consult_tag`.`prosp_first_name`,
`vw_sale_consult_tag`.`prosp_last_name`,
`vw_sale_consult_tag`.`gender`,
`vw_sale_consult_tag`.`emp_assigned_id`,
DATE_FORMAT(`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
`vw_sale_consult_tag`.`call_recv_dt`,
DATE_FORMAT(`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
`vw_sale_consult_tag`.`next_call_dt`,
`vw_sale_consult_tag`.`call_note`,
`vw_sale_consult_tag`.`prosp_summary`,
concat(`updater`,'\r',DATE_FORMAT(`last_updated`,'%m-%d-%y')) as `mod_last_updated`,
`vw_sale_consult_tag`.`last_updated`,
`vw_sale_consult_tag`.`updated_by`,
`vw_sale_consult_tag`.`updater`,
(`vw_sale_consult_tag`.`prosp_level`) AS `prosp_level`,
(`vw_sale_consult_tag`.`prosp_level_desc`) AS `prosp_level_desc`,
`vw_sale_consult_tag`.`attachment` AS `attachment`,
`vw_sale_consult_tag`.`contacts` AS `contacts`,
`vw_sale_consult_tag`.`prosp_tag` AS `prosp_tag`,
`vw_sale_consult_tag`.`look_values` AS `look_values`,
`vw_sale_consult_tag`.`look_display_id` AS `look_display_id`,
`vw_sale_consult_tag`.`group_display_id` AS `group_display_id`,
`vw_sale_consult_tag`.`group_title` AS `group_title`,";		
	
	set @A_query_vw_sale_consult_dynamic = "create view `vw_sale_consult_tag_tran` as select (`a`.`prosp_consult_id`) AS `prosp_consult_id`,(`a`.`prosp_first_name`) AS `prosp_first_name`,(`a`.`prosp_last_name`) AS `prosp_last_name`,
(`a`.`gender`) AS `gender`,(`a`.`emp_assigned_id`) AS `emp_assigned_id`,
DATE_FORMAT(`a`.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
(`a`.`call_recv_dt`) AS `call_recv_dt`,
DATE_FORMAT(`a`.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
(`a`.`next_call_dt`) AS `next_call_dt`,
(`a`.`call_note`) AS `call_note`,
(`a`.`prosp_summary`) AS `prosp_summary`,
concat(`a`.`updater`,'\r',DATE_FORMAT(`a`.`last_updated`,'%m-%d-%y')) as `mod_last_updated`,
(`a`.`last_updated`) AS `last_updated`,
(`a`.`updated_by`) AS `updated_by`,
(`a`.`updater`) AS `updater`,
(`a`.`prosp_level`) AS `prosp_level`,(`a`.`prosp_level_desc`) AS `prosp_level_desc`,
(`a`.`attachment`) AS `attachment`, (`a`.`contacts`) AS `contacts`, (`a`.`prosp_tag`) AS `prosp_tag`,";
						
	OPEN A_cur_status;					
						
	select FOUND_ROWS() into A_num_rows;					
						
	     A_the_loop: LOOP				
						
		FETCH  A_cur_status INTO  A_name_val;				
						
		IF A_no_more_rows THEN				
			CLOSE A_cur_status;			
            			LEAVE A_the_loop;						
		END IF;				
						
		set A_name_val = TRIM(A_name_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
		if A_loop_cntr = A_num_rows then				
						
      set @A_query_t_sale_consult_dynamic = concat(@A_query_t_sale_consult_dynamic," (case when (concat(`vw_sale_consult_tag`.`group_title`,'_',`vw_sale_consult_tag`.`look_values`) = '",A_name_val,"') then _utf8'",A_name_val,"' end) AS `",A_name_val,"`");
			set @A_query_vw_sale_consult_dynamic = concat(@A_query_vw_sale_consult_dynamic," count(`a`.`",A_name_val,"`) AS `",A_name_val,"`, count(0) AS `tot`");						
		else 				
			set @A_query_t_sale_consult_dynamic = concat(@A_query_t_sale_consult_dynamic," (case when (concat(`vw_sale_consult_tag`.`group_title`,'_',`vw_sale_consult_tag`.`look_values`) = '",A_name_val,"') then _utf8'",A_name_val,"' end) AS `",A_name_val,"`,");
			set @A_query_vw_sale_consult_dynamic = concat(@A_query_vw_sale_consult_dynamic," count(`a`.`",A_name_val,"`) AS `",A_name_val,"`,");								
		end if;				
						
		SET A_loop_cntr = A_loop_cntr + 1;				
	     END LOOP A_the_loop;			
						
	set @A_query_t_sale_consult_dynamic = concat(@A_query_t_sale_consult_dynamic," from `vw_sale_consult_tag` ");	
	set @A_query_vw_sale_consult_dynamic = concat(@A_query_vw_sale_consult_dynamic," from `vw_t_sale_consult_tag_tran` `a` group by `a`.`prosp_consult_id` order by `a`.`prosp_consult_id`,`a`.`group_display_id`,`a`.`look_display_id` ");				
						
  set @A_q1 = "DROP VIEW IF EXISTS `vw_t_sale_consult_tag_tran`; ";					
	PREPARE A_stmt1 FROM @A_q1;					
	EXECUTE A_stmt1;					
	DEALLOCATE PREPARE A_stmt1;					
						
	PREPARE A_stmt2 FROM @A_query_t_sale_consult_dynamic;					
	EXECUTE A_stmt2;					
	DEALLOCATE PREPARE A_stmt2;	

	set @A_q2 = "DROP VIEW IF EXISTS `vw_sale_consult_tag_tran`; ";
	PREPARE A_stmt3 FROM @A_q2;
	EXECUTE A_stmt3;
	DEALLOCATE PREPARE A_stmt3;
	
	PREPARE A_stmt4 FROM @A_query_vw_sale_consult_dynamic;
	EXECUTE A_stmt4;
	DEALLOCATE PREPARE A_stmt4;
						
 END;

 BEGIN						
						
	DECLARE B_name_val VARCHAR(900);					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;					
						
	DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct concat(group_title,'_total') as tag FROM vw_sale_shr where group_title is not null  order by group_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET B_no_more_rows = TRUE;	
	
	set @B_query_t_sale_consult_dynamic = "create view `vw_t_sale_consult_group_tran` as select `vw_sale_consult_tag`.`prosp_consult_id`,`vw_sale_consult_tag`.`group_title` AS `all_groups`,`vw_sale_consult_tag`.`group_display_id` AS `group_display_id`,";		
	
	set @B_query_vw_sale_consult_dynamic = "create view `vw_sale_consult_group_tran` as select (`a`.`prosp_consult_id`) AS `prosp_consult_id`, group_concat(`a`.`all_groups`) AS `all_groups`,";

	set @B_query_group = "";
  set @B_query_group_1 = "";
  set @B_query_group_2 = "";
  set @B_query_group_3 = "";
					
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
						
	     B_the_loop: LOOP				
						
		FETCH  B_cur_status INTO  B_name_val;				
						
		IF B_no_more_rows THEN				
			CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
		END IF;				
						
		set B_name_val = TRIM(B_name_val);				
						
		IF (B_name_val IS NULL OR length(B_name_val) = 0) THEN				
			set B_name_val = "blank";			
		END IF;				
						
		if B_loop_cntr = B_num_rows then				
						
      set @B_query_t_sale_consult_dynamic = concat(@B_query_t_sale_consult_dynamic," (case when (concat(`vw_sale_consult_tag`.`group_title`,'_total') = '",B_name_val,"') then _utf8'",B_name_val,"' end) AS `",B_name_val,"`");
			set @B_query_vw_sale_consult_dynamic = concat(@B_query_vw_sale_consult_dynamic," count(`a`.`",B_name_val,"`) AS `",B_name_val,"`, count(0) AS `tot`");			
			set @B_query_group = concat(@B_query_group,",`b`.`",B_name_val,"` AS `",B_name_val,"`");	
      set @B_query_group_1 = concat(@B_query_group_1,"if(`b`.`",B_name_val,"` = 0,1,0)");		
		else 				
			set @B_query_t_sale_consult_dynamic = concat(@B_query_t_sale_consult_dynamic," (case when (concat(`vw_sale_consult_tag`.`group_title`,'_total') = '",B_name_val,"') then _utf8'",B_name_val,"' end) AS `",B_name_val,"`,");
			set @B_query_vw_sale_consult_dynamic = concat(@B_query_vw_sale_consult_dynamic," count(`a`.`",B_name_val,"`) AS `",B_name_val,"`,");					
			set @B_query_group = concat(@B_query_group,",`b`.`",B_name_val,"` AS `",B_name_val,"`");			
			set @B_query_group_1 = concat(@B_query_group_1,"if(`b`.`",B_name_val,"` = 0,1,0)+");
		end if;				
						
		SET B_loop_cntr = B_loop_cntr + 1;				
	     END LOOP B_the_loop;			
						
	set @B_query_t_sale_consult_dynamic = concat(@B_query_t_sale_consult_dynamic," from `vw_sale_consult_tag` ");	
	set @B_query_vw_sale_consult_dynamic = concat(@B_query_vw_sale_consult_dynamic," from `vw_t_sale_consult_group_tran` `a` group by `a`.`prosp_consult_id` order by `a`.`prosp_consult_id`,`a`.`group_display_id` ");		
	
  set @B_query_group_2 = concat(@B_query_group,",",@B_query_group_1," as `missing_groups`,",B_num_rows," as `tot_groups`"); 
  set @B_query_group_3 = concat("create view vw_sale_consult_dynamic as select a.*",@B_query_group_2," from vw_sale_consult_tag_tran a left join vw_sale_consult_group_tran b on `a`.`prosp_consult_id` = `b`.`prosp_consult_id`");		
		
 	set @B_q1 = "DROP VIEW IF EXISTS `vw_t_sale_consult_group_tran`; ";					
	PREPARE B_stmt1 FROM @B_q1;					
	EXECUTE B_stmt1;					
	DEALLOCATE PREPARE B_stmt1;					
						
	PREPARE B_stmt2 FROM @B_query_t_sale_consult_dynamic;					
	EXECUTE B_stmt2;					
	DEALLOCATE PREPARE B_stmt2;	

	set @B_q2 = "DROP VIEW IF EXISTS `vw_sale_consult_group_tran`; ";
	PREPARE B_stmt3 FROM @B_q2;
	EXECUTE B_stmt3;
	DEALLOCATE PREPARE B_stmt3;
	
	PREPARE B_stmt4 FROM @B_query_vw_sale_consult_dynamic;
	EXECUTE B_stmt4;
	DEALLOCATE PREPARE B_stmt4;

	set @B_q3 = "DROP VIEW IF EXISTS `vw_sale_consult_dynamic`; ";
	PREPARE B_stmt5 FROM @B_q3;
	EXECUTE B_stmt5;
	DEALLOCATE PREPARE B_stmt5;
	
	PREPARE B_stmt6 FROM @B_query_group_3;
	EXECUTE B_stmt6;
	DEALLOCATE PREPARE B_stmt6;
						
 END;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_sale_emp_group_transpose` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_sale_emp_group_transpose`()
    READS SQL DATA
BEGIN						
						
	DECLARE A_name_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct concat(group_title,'_total') as tag FROM vw_sale_shr where group_title is not null and look_sub_value_id != 677 order by group_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
	set @A_query_t_sale_emp_dynamic = "create view `vw_t_sale_emp_group_tran` as select `vw_sale_emp_tag`.`emp_id`,`vw_sale_emp_tag`.`group_title` AS `all_groups`,`vw_sale_emp_tag`.`group_display_id` AS `group_display_id`,";		
	
	set @A_query_vw_sale_emp_dynamic = "create view `vw_sale_emp_group_tran` as select (`a`.`emp_id`) AS `emp_id`, group_concat(`a`.`all_groups`) AS `all_groups`,";

	set @A_query_group = "";
					
	OPEN A_cur_status;					
						
	select FOUND_ROWS() into A_num_rows;					
						
	     A_the_loop: LOOP				
						
		FETCH  A_cur_status INTO  A_name_val;				
						
		IF A_no_more_rows THEN				
			CLOSE A_cur_status;			
            			LEAVE A_the_loop;						
		END IF;				
						
		set A_name_val = TRIM(A_name_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
		if A_loop_cntr = A_num_rows then				
						
                                                    set @A_query_t_sale_emp_dynamic = concat(@A_query_t_sale_emp_dynamic," (case when (concat(`vw_sale_emp_tag`.`group_title`,'_total') = '",A_name_val,"') then _utf8'",A_name_val,"' end) AS `",A_name_val,"`");
			set @A_query_vw_sale_emp_dynamic = concat(@A_query_vw_sale_emp_dynamic," count(`a`.`",A_name_val,"`) AS `",A_name_val,"`, count(0) AS `tot`");			
			set @A_query_group = concat(@A_query_group,",`b`.`",A_name_val,"` AS `",A_name_val,"`");			
		else 				
			set @A_query_t_sale_emp_dynamic = concat(@A_query_t_sale_emp_dynamic," (case when (concat(`vw_sale_emp_tag`.`group_title`,'_total') = '",A_name_val,"') then _utf8'",A_name_val,"' end) AS `",A_name_val,"`,");
			set @A_query_vw_sale_emp_dynamic = concat(@A_query_vw_sale_emp_dynamic," count(`a`.`",A_name_val,"`) AS `",A_name_val,"`,");					
			set @A_query_group = concat(@A_query_group,",`b`.`",A_name_val,"` AS `",A_name_val,"`");			
			
		end if;				
						
		SET A_loop_cntr = A_loop_cntr + 1;				
	     END LOOP A_the_loop;			
						
	set @A_query_t_sale_emp_dynamic = concat(@A_query_t_sale_emp_dynamic," from `vw_sale_emp_tag` ");	
	set @A_query_vw_sale_emp_dynamic = concat(@A_query_vw_sale_emp_dynamic," from `vw_t_sale_emp_group_tran` `a` group by `a`.`emp_id` order by `a`.`emp_id`,`a`.`group_display_id` ");		
	set @A_query_group = concat("create view vw_sale_emp_dynamic as select a.*",@A_query_group," from vw_sale_emp_tag_tran a left join vw_sale_emp_group_tran b on `a`.`emp_id` = `b`.`emp_id`");		

			
  	set @A_q1 = "DROP VIEW IF EXISTS `vw_t_sale_emp_group_tran`; ";					
	PREPARE A_stmt1 FROM @A_q1;					
	EXECUTE A_stmt1;					
	DEALLOCATE PREPARE A_stmt1;					
						
	PREPARE A_stmt2 FROM @A_query_t_sale_emp_dynamic;					
	EXECUTE A_stmt2;					
	DEALLOCATE PREPARE A_stmt2;	

	set @A_q2 = "DROP VIEW IF EXISTS `vw_sale_emp_group_tran`; ";
	PREPARE A_stmt3 FROM @A_q2;
	EXECUTE A_stmt3;
	DEALLOCATE PREPARE A_stmt3;
	
	PREPARE A_stmt4 FROM @A_query_vw_sale_emp_dynamic;
	EXECUTE A_stmt4;
	DEALLOCATE PREPARE A_stmt4;

	set @A_q3 = "DROP VIEW IF EXISTS `vw_sale_emp_dynamic`; ";
	PREPARE A_stmt5 FROM @A_q3;
	EXECUTE A_stmt5;
	DEALLOCATE PREPARE A_stmt5;
	
	PREPARE A_stmt6 FROM @A_query_group;
	EXECUTE A_stmt6;
	DEALLOCATE PREPARE A_stmt6;
						
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_sale_emp_tag_transpose` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_sale_emp_tag_transpose`()
    READS SQL DATA
BEGIN						
						
	DECLARE A_name_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct concat(group_title,'_',look_values) as tag FROM vw_sale_shr where group_title is not null and look_sub_value_id != 677 order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
	set @A_query_t_sale_emp_dynamic = "create view `vw_t_sale_emp_tag_tran` as select `vw_sale_emp_tag`.`emp_id`,`vw_sale_emp_tag`.`firstname`,`vw_sale_emp_tag`.`lastname`,`vw_sale_emp_tag`.`gender`,`vw_sale_emp_tag`.`call_recv_dt`,DATE_FORMAT(`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt` ,`vw_sale_emp_tag`.`next_call_dt`,DATE_FORMAT(`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,`vw_sale_emp_tag`.`call_note`,`vw_sale_emp_tag`.`emp_smry`,
`vw_sale_emp_tag`.`last_updated_sale`,concat(`updater_sale`,'\r',DATE_FORMAT(`last_updated_sale`,'%m-%d-%y')) as `mod_last_updated_sale`,`vw_sale_emp_tag`.`updated_by_sale`,`vw_sale_emp_tag`.`updater_sale`,
(`vw_sale_emp_tag`.`emp_level`) AS `emp_level`,(`vw_sale_emp_tag`.`emp_level_desc`) AS `emp_level_desc`,`vw_sale_emp_tag`.`look_values` AS `all_tags`,`vw_sale_emp_tag`.`look_display_id` AS `look_display_id`,`vw_sale_emp_tag`.`group_display_id` AS `group_display_id`,";		
	
	set @A_query_vw_sale_emp_dynamic = "create view `vw_sale_emp_tag_tran` as select (`a`.`emp_id`) AS `emp_id`,(`a`.`firstname`) AS `firstname`,(`a`.`lastname`) AS `lastname`,(`a`.`gender`) AS `gender`,(`a`.`call_recv_dt`) AS `call_recv_dt`,DATE_FORMAT(`a`.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,(`a`.`next_call_dt`) AS `next_call_dt`,DATE_FORMAT(`a`.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,(`a`.`call_note`) AS `call_note`,(`a`.`emp_smry`) AS `emp_smry`,
(`a`.`last_updated_sale`) AS `last_updated_sale`,concat(`a`.`updater_sale`,'\r',DATE_FORMAT(`a`.`last_updated_sale`,'%m-%d-%y')) as `mod_last_updated_sale`,(`a`.`updated_by_sale`) AS `updated_by_sale`,(`a`.`updater_sale`) AS `updater_sale`,
(`a`.`emp_level`) AS `emp_level`,(`a`.`emp_level_desc`) AS `emp_level_desc`, group_concat(' ',`a`.`all_tags`,' ') AS `all_tags`,";
						
	OPEN A_cur_status;					
						
	select FOUND_ROWS() into A_num_rows;					
						
	     A_the_loop: LOOP				
						
		FETCH  A_cur_status INTO  A_name_val;				
						
		IF A_no_more_rows THEN				
			CLOSE A_cur_status;			
            			LEAVE A_the_loop;						
		END IF;				
						
		set A_name_val = TRIM(A_name_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
		if A_loop_cntr = A_num_rows then				
						
                                                    set @A_query_t_sale_emp_dynamic = concat(@A_query_t_sale_emp_dynamic," (case when (concat(`vw_sale_emp_tag`.`group_title`,'_',`vw_sale_emp_tag`.`look_values`) = '",A_name_val,"') then _utf8'",A_name_val,"' end) AS `",A_name_val,"`");
			set @A_query_vw_sale_emp_dynamic = concat(@A_query_vw_sale_emp_dynamic," count(`a`.`",A_name_val,"`) AS `",A_name_val,"`, count(0) AS `tot`");						
		else 				
			set @A_query_t_sale_emp_dynamic = concat(@A_query_t_sale_emp_dynamic," (case when (concat(`vw_sale_emp_tag`.`group_title`,'_',`vw_sale_emp_tag`.`look_values`) = '",A_name_val,"') then _utf8'",A_name_val,"' end) AS `",A_name_val,"`,");
			set @A_query_vw_sale_emp_dynamic = concat(@A_query_vw_sale_emp_dynamic," count(`a`.`",A_name_val,"`) AS `",A_name_val,"`,");								
		end if;				
						
		SET A_loop_cntr = A_loop_cntr + 1;				
	     END LOOP A_the_loop;			
						
	set @A_query_t_sale_emp_dynamic = concat(@A_query_t_sale_emp_dynamic," from `vw_sale_emp_tag` ");	
	set @A_query_vw_sale_emp_dynamic = concat(@A_query_vw_sale_emp_dynamic," from `vw_t_sale_emp_tag_tran` `a` group by `a`.`emp_id` order by `a`.`emp_id`,`a`.`group_display_id`,`a`.`look_display_id` ");				
						
  set @A_q1 = "DROP VIEW IF EXISTS `vw_t_sale_emp_tag_tran`; ";					
	PREPARE A_stmt1 FROM @A_q1;					
	EXECUTE A_stmt1;					
	DEALLOCATE PREPARE A_stmt1;					
						
	PREPARE A_stmt2 FROM @A_query_t_sale_emp_dynamic;					
	EXECUTE A_stmt2;					
	DEALLOCATE PREPARE A_stmt2;	

	set @A_q2 = "DROP VIEW IF EXISTS `vw_sale_emp_tag_tran`; ";
	PREPARE A_stmt3 FROM @A_q2;
	EXECUTE A_stmt3;
	DEALLOCATE PREPARE A_stmt3;
	
	PREPARE A_stmt4 FROM @A_query_vw_sale_emp_dynamic;
	EXECUTE A_stmt4;
	DEALLOCATE PREPARE A_stmt4;
						
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_sale_emp_transpose` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_sale_emp_transpose`()
    READS SQL DATA
BEGIN

BEGIN						
						
	DECLARE A_name_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct concat(group_title,'_',look_values) as tag FROM vw_sale_shr where group_title is not null and look_sub_value_id != 677 order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
	set @A_query_t_sale_emp_dynamic = "create view `vw_t_sale_emp_tag_tran` as select `vw_sale_emp_tag`.`emp_id`,`vw_sale_emp_tag`.`firstname`,`vw_sale_emp_tag`.`lastname`,`vw_sale_emp_tag`.`gender`,`vw_sale_emp_tag`.`call_recv_dt`,DATE_FORMAT(`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt` ,`vw_sale_emp_tag`.`next_call_dt`,DATE_FORMAT(`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,`vw_sale_emp_tag`.`call_note`,`vw_sale_emp_tag`.`emp_smry`,
`vw_sale_emp_tag`.`last_updated_sale`,concat(`updater_sale`,'\r',DATE_FORMAT(`last_updated_sale`,'%m-%d-%y')) as `mod_last_updated_sale`,`vw_sale_emp_tag`.`updated_by_sale`,`vw_sale_emp_tag`.`updater_sale`,
(`vw_sale_emp_tag`.`emp_level`) AS `emp_level`, `vw_sale_emp_tag`.`attachment`,(`vw_sale_emp_tag`.`emp_level_desc`) AS `emp_level_desc`,`vw_sale_emp_tag`.`look_values` AS `all_tags`,`vw_sale_emp_tag`.`look_display_id` AS `look_display_id`,`vw_sale_emp_tag`.`group_display_id` AS `group_display_id`,";		
	
	set @A_query_vw_sale_emp_dynamic = "create view `vw_sale_emp_tag_tran` as select (`a`.`emp_id`) AS `emp_id`,(`a`.`firstname`) AS `firstname`,(`a`.`lastname`) AS `lastname`,(`a`.`gender`) AS `gender`,(`a`.`call_recv_dt`) AS `call_recv_dt`,DATE_FORMAT(`a`.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,(`a`.`next_call_dt`) AS `next_call_dt`,DATE_FORMAT(`a`.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,(`a`.`call_note`) AS `call_note`,(`a`.`emp_smry`) AS `emp_smry`,
(`a`.`last_updated_sale`) AS `last_updated_sale`,concat(`a`.`updater_sale`,'\r',DATE_FORMAT(`a`.`last_updated_sale`,'%m-%d-%y')) as `mod_last_updated_sale`,(`a`.`updated_by_sale`) AS `updated_by_sale`,(`a`.`updater_sale`) AS `updater_sale`,
(`a`.`emp_level`) AS `emp_level`,(`a`.`emp_level_desc`) AS `emp_level_desc`,(`a`.`attachment`) AS `attachment`, group_concat(' ',`a`.`all_tags`,' ') AS `all_tags`,";
						
	OPEN A_cur_status;					
						
	select FOUND_ROWS() into A_num_rows;					
						
	     A_the_loop: LOOP				
						
		FETCH  A_cur_status INTO  A_name_val;				
						
		IF A_no_more_rows THEN				
			CLOSE A_cur_status;			
            			LEAVE A_the_loop;						
		END IF;				
						
		set A_name_val = TRIM(A_name_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
		if A_loop_cntr = A_num_rows then				
						
                                                    set @A_query_t_sale_emp_dynamic = concat(@A_query_t_sale_emp_dynamic," (case when (concat(`vw_sale_emp_tag`.`group_title`,'_',`vw_sale_emp_tag`.`look_values`) = '",A_name_val,"') then _utf8'",A_name_val,"' end) AS `",A_name_val,"`");
			set @A_query_vw_sale_emp_dynamic = concat(@A_query_vw_sale_emp_dynamic," count(`a`.`",A_name_val,"`) AS `",A_name_val,"`, count(0) AS `tot`");						
		else 				
			set @A_query_t_sale_emp_dynamic = concat(@A_query_t_sale_emp_dynamic," (case when (concat(`vw_sale_emp_tag`.`group_title`,'_',`vw_sale_emp_tag`.`look_values`) = '",A_name_val,"') then _utf8'",A_name_val,"' end) AS `",A_name_val,"`,");
			set @A_query_vw_sale_emp_dynamic = concat(@A_query_vw_sale_emp_dynamic," count(`a`.`",A_name_val,"`) AS `",A_name_val,"`,");								
		end if;				
						
		SET A_loop_cntr = A_loop_cntr + 1;				
	     END LOOP A_the_loop;			
						
	set @A_query_t_sale_emp_dynamic = concat(@A_query_t_sale_emp_dynamic," from `vw_sale_emp_tag` ");	
	set @A_query_vw_sale_emp_dynamic = concat(@A_query_vw_sale_emp_dynamic," from `vw_t_sale_emp_tag_tran` `a` group by `a`.`emp_id` order by `a`.`emp_id`,`a`.`group_display_id`,`a`.`look_display_id` ");				
						
  set @A_q1 = "DROP VIEW IF EXISTS `vw_t_sale_emp_tag_tran`; ";					
	PREPARE A_stmt1 FROM @A_q1;					
	EXECUTE A_stmt1;					
	DEALLOCATE PREPARE A_stmt1;					
						
	PREPARE A_stmt2 FROM @A_query_t_sale_emp_dynamic;					
	EXECUTE A_stmt2;					
	DEALLOCATE PREPARE A_stmt2;	

	set @A_q2 = "DROP VIEW IF EXISTS `vw_sale_emp_tag_tran`; ";
	PREPARE A_stmt3 FROM @A_q2;
	EXECUTE A_stmt3;
	DEALLOCATE PREPARE A_stmt3;
	
	PREPARE A_stmt4 FROM @A_query_vw_sale_emp_dynamic;
	EXECUTE A_stmt4;
	DEALLOCATE PREPARE A_stmt4;
						
END;

BEGIN						
						
	DECLARE B_name_val VARCHAR(900);					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;					
						
	DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct concat(group_title,'_total') as tag FROM vw_sale_shr where group_title is not null and look_sub_value_id != 677 order by group_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET B_no_more_rows = TRUE;	
	
	set @B_query_t_sale_emp_dynamic = "create view `vw_t_sale_emp_group_tran` as select `vw_sale_emp_tag`.`emp_id`,`vw_sale_emp_tag`.`group_title` AS `all_groups`,`vw_sale_emp_tag`.`group_display_id` AS `group_display_id`,";		
	
	set @B_query_vw_sale_emp_dynamic = "create view `vw_sale_emp_group_tran` as select (`a`.`emp_id`) AS `emp_id`, group_concat(`a`.`all_groups`) AS `all_groups`,";

	set @B_query_group = "";
  set @B_query_group_1 = "";
  set @B_query_group_2 = "";
  set @B_query_group_3 = "";

					
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
						
	     B_the_loop: LOOP				
						
		FETCH  B_cur_status INTO  B_name_val;				
						
		IF B_no_more_rows THEN				
			CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
		END IF;				
						
		set B_name_val = TRIM(B_name_val);				
						
		IF (B_name_val IS NULL OR length(B_name_val) = 0) THEN				
			set B_name_val = "blank";			
		END IF;				
						
		if B_loop_cntr = B_num_rows then				
						
      set @B_query_t_sale_emp_dynamic = concat(@B_query_t_sale_emp_dynamic," (case when (concat(`vw_sale_emp_tag`.`group_title`,'_total') = '",B_name_val,"') then _utf8'",B_name_val,"' end) AS `",B_name_val,"`");
			set @B_query_vw_sale_emp_dynamic = concat(@B_query_vw_sale_emp_dynamic," count(`a`.`",B_name_val,"`) AS `",B_name_val,"`, count(0) AS `tot`");			
			set @B_query_group = concat(@B_query_group,",`b`.`",B_name_val,"` AS `",B_name_val,"`");	
      set @B_query_group_1 = concat(@B_query_group_1,"if(`b`.`",B_name_val,"` = 0,1,0)");				
		else 				
			set @B_query_t_sale_emp_dynamic = concat(@B_query_t_sale_emp_dynamic," (case when (concat(`vw_sale_emp_tag`.`group_title`,'_total') = '",B_name_val,"') then _utf8'",B_name_val,"' end) AS `",B_name_val,"`,");
			set @B_query_vw_sale_emp_dynamic = concat(@B_query_vw_sale_emp_dynamic," count(`a`.`",B_name_val,"`) AS `",B_name_val,"`,");					
			set @B_query_group = concat(@B_query_group,",`b`.`",B_name_val,"` AS `",B_name_val,"`");	
			set @B_query_group_1 = concat(@B_query_group_1,"if(`b`.`",B_name_val,"` = 0,1,0)+");		
			
		end if;				
						
		SET B_loop_cntr = B_loop_cntr + 1;				
	     END LOOP B_the_loop;			
						
	set @B_query_t_sale_emp_dynamic = concat(@B_query_t_sale_emp_dynamic," from `vw_sale_emp_tag` ");	
	set @B_query_vw_sale_emp_dynamic = concat(@B_query_vw_sale_emp_dynamic," from `vw_t_sale_emp_group_tran` `a` group by `a`.`emp_id` order by `a`.`emp_id`,`a`.`group_display_id` ");		

  set @B_query_group_2 = concat(@B_query_group,",",@B_query_group_1," as `missing_groups`,",B_num_rows," as `tot_groups`"); 
  set @B_query_group_3 = concat("create view vw_sale_emp_dynamic as select a.*",@B_query_group_2," from vw_sale_emp_tag_tran a left join vw_sale_emp_group_tran b on `a`.`emp_id` = `b`.`emp_id`");		
			
 	set @B_q1 = "DROP VIEW IF EXISTS `vw_t_sale_emp_group_tran`; ";					
	PREPARE B_stmt1 FROM @B_q1;					
	EXECUTE B_stmt1;					
	DEALLOCATE PREPARE B_stmt1;					
						
	PREPARE B_stmt2 FROM @B_query_t_sale_emp_dynamic;					
	EXECUTE B_stmt2;					
	DEALLOCATE PREPARE B_stmt2;	

	set @B_q2 = "DROP VIEW IF EXISTS `vw_sale_emp_group_tran`; ";
	PREPARE B_stmt3 FROM @B_q2;
	EXECUTE B_stmt3;
	DEALLOCATE PREPARE B_stmt3;
	
	PREPARE B_stmt4 FROM @B_query_vw_sale_emp_dynamic;
	EXECUTE B_stmt4;
	DEALLOCATE PREPARE B_stmt4;

	set @B_q3 = "DROP VIEW IF EXISTS `vw_sale_emp_dynamic`; ";
	PREPARE B_stmt5 FROM @B_q3;
	EXECUTE B_stmt5;
	DEALLOCATE PREPARE B_stmt5;
	
	PREPARE B_stmt6 FROM @B_query_group_3;
	EXECUTE B_stmt6;
	DEALLOCATE PREPARE B_stmt6;
						
END;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_tags` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`jitenpatel`@`%` PROCEDURE `proc_tags`()
BEGIN


BEGIN

  set @vw_sales_shr_defination="create view  vw_sale_shr as  (select `c`.`look_values_id` AS `look_values_id`,`c`.`look_table` AS `look_table`,`c`.`look_values` AS `look_values`,`c`.`look_display_id` AS `look_display_id`,`c`.`look_sub_value_id` AS `look_sub_value_id`,(select distinct `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_title`,(select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_display_id`,(select distinct `look_values`.`look_value_code` AS `look_value_code` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_code`,(select distinct `look_values`.`look_value_desc` AS `look_value_desc` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_desc` from `look_values` `c` where ((`c`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section'))) and (`c`.`look_sub_value_id` > 0)) order by (select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)),`c`.`look_display_id` )";

  set @vw_sales_shr_drop = "DROP VIEW IF EXISTS `vw_sale_shr`; ";
	PREPARE vw_sales_shr_drop_statement FROM @vw_sales_shr_drop;
	EXECUTE vw_sales_shr_drop_statement;
	DEALLOCATE PREPARE vw_sales_shr_drop_statement;
	
	PREPARE vw_sales_shr_defination_create FROM @vw_sales_shr_defination;
	EXECUTE vw_sales_shr_defination_create;
	DEALLOCATE PREPARE vw_sales_shr_defination_create;


END;

BEGIN

    set @vw_vw_sales_prosp_activity_defination="create view  vw_sales_prosp_activity  as (select `a`.`prosp_activity_id` AS `prosp_activity_id`,`a`.`prosp_consult_id` AS `prosp_consult_id`,date_format(`a`.`call_recv_dt`,_utf8'%m.%d.%y') AS `call_recv_dt`,`a`.`emp_id` AS `emp_id`,(case when (`a`.`emp_id` <> 0) then concat_ws(_latin1' ',`b`.`firstname`,`b`.`lastname`) else _utf8'Admin' end) AS `updater`,date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') AS `next_call_dt`,`a`.`call_note` AS `call_note`,date_format(`a`.`last_update`,_utf8'%m.%d.%y %T') AS `last_update` from (`prosp_activity` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') desc)";
    
    set @vw_sales_prosp_activity_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_activity`; ";
		PREPARE vw_sales_prosp_activity_drop_statement FROM @vw_sales_prosp_activity_drop;
		EXECUTE vw_sales_prosp_activity_drop_statement;
		DEALLOCATE PREPARE vw_sales_prosp_activity_drop_statement;
		
		PREPARE vw_sales_prosp_activity_defination_create FROM @vw_vw_sales_prosp_activity_defination;
		EXECUTE vw_sales_prosp_activity_defination_create;
		DEALLOCATE PREPARE vw_sales_prosp_activity_defination_create;

END;


BEGIN

	set @vw_sales_prosp_attach_defination="create view  vw_sales_prosp_attach as (select`a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,date_format(`a`.`create_dt`,_utf8'%m-%d-%y') AS `create_dt`,(case when (`a`.`owner_id` = _latin1'') then _utf8'Admin' when isnull(`a`.`owner_id`) then _utf8'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updater`,`b`.`prosp_consult_id` AS `prosp_consult_id`,concat(`c`.`prosp_first_name`,_latin1' ',`c`.`prosp_last_name`) AS `prsp_consult_name` from (((`storages` `a` left join `prosp_attach` `b` on((`a`.`idstorage` = `b`.`idstorage`))) left join `emp` `e` on((`a`.`owner_id` = `e`.`emp_id`))) left join `prosp_consult` `c` on((`b`.`prosp_consult_id` = `c`.`prosp_consult_id`))) )";
  
  set @vw_sales_prosp_attach_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_attach`; ";
	PREPARE vw_sales_prosp_attach_drop_statement FROM @vw_sales_prosp_attach_drop;
	EXECUTE vw_sales_prosp_attach_drop_statement;
	DEALLOCATE PREPARE vw_sales_prosp_attach_drop_statement;
	
	PREPARE vw_sales_prosp_attach_defination_create FROM @vw_sales_prosp_attach_defination;
	EXECUTE vw_sales_prosp_attach_defination_create;
	DEALLOCATE PREPARE vw_sales_prosp_attach_defination_create;

END;


BEGIN	
	    
    set @vw_sales_prosp_contact_defination="create view  vw_sales_prosp_contact  as  (select `a`.`prosp_contact_id` AS `prosp_contact_id`,`a`.`prosp_consult_id` AS `prosp_consult_id`,`a`.`contact_id` AS `contact_id`,`a`.`prosp_contact_type` AS `prosp_contact_type`,(select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where ((`look_values`.`look_values` = `a`.`prosp_contact_type`) and (select `look_values`.`look_table` AS `look_table` from `look_values` where (`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'contact.type'))) limit 1)) limit 1) AS `prosp_contact_type_id`,`a`.`summary` AS `summary`,`b`.`contact_detail` AS `contact_detail` from (`prosp_contact` `a` left join `contact_no` `b` on((`a`.`contact_id` = `b`.`contact_id`))))";
    set @vw_sales_prosp_contact_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_contact`; ";
		PREPARE vw_sales_prosp_contact_drop_statement FROM @vw_sales_prosp_contact_drop;
		EXECUTE vw_sales_prosp_contact_drop_statement;
		DEALLOCATE PREPARE vw_sales_prosp_contact_drop_statement;
		
		PREPARE vw_sales_prosp_contact_defination_create FROM @vw_sales_prosp_contact_defination;
		EXECUTE vw_sales_prosp_contact_defination_create;
		DEALLOCATE PREPARE vw_sales_prosp_contact_defination_create;

END;


BEGIN

  set @dyn_prosp_contact_defination="create view vw_dyn_prosp_contact  as 
SELECT prosp_consult_id,GROUP_CONCAT(ifnull(prosp_contact_type,''),':',ifnull(contact_detail,'') SEPARATOR ' , ') AS group_contact FROM vw_sales_prosp_contact  GROUP BY prosp_consult_id";

  set @dyn_prosp_contact_drop = "DROP VIEW IF EXISTS `vw_dyn_prosp_contact`; ";
	PREPARE dyn_prosp_contact_drop FROM @dyn_prosp_contact_drop;
	EXECUTE dyn_prosp_contact_drop;
	DEALLOCATE PREPARE dyn_prosp_contact_drop;
	PREPARE dyn_prosp_contact_defination FROM @dyn_prosp_contact_defination;
	EXECUTE dyn_prosp_contact_defination;
	DEALLOCATE PREPARE dyn_prosp_contact_defination;

 END;


BEGIN

  set @dyn_prosp_tag_defination="create view vw_dyn_prosp_tag as 
select `prosp_consult_id`,CONCAT(GROUP_CONCAT((select look_values from  aerion. look_values where look_values_id=prosp_tags order by look_values.look_display_id ) SEPARATOR ' , ')) as tags from  aerion. prosp_tag  group by `prosp_consult_id` order by (select look_display_id from  aerion. look_values where look_values_id=prosp_tags),`prosp_consult_id";

  set @dyn_prosp_tag_drop = "DROP VIEW IF EXISTS `vw_dyn_prosp_tag`; ";
	PREPARE dyn_prosp_tag_drop FROM @dyn_prosp_tag_drop;
	EXECUTE dyn_prosp_tag_drop;
	DEALLOCATE PREPARE dyn_prosp_tag_drop;
	PREPARE dyn_prosp_tag_defination FROM @dyn_prosp_tag_defination;
	EXECUTE dyn_prosp_tag_defination;
	DEALLOCATE PREPARE dyn_prosp_tag_defination;

END;


BEGIN

  set @vw_dyn_prosp_attach_defination="create view vw_dyn_prosp_attach as 

SELECT prosp_consult_id,GROUP_CONCAT(ifnull(file_name,'') SEPARATOR ' , ') AS file_group FROM vw_sales_prosp_attach  GROUP BY prosp_consult_id";

  set @vw_dyn_prosp_attach_drop = "DROP VIEW IF EXISTS `vw_dyn_prosp_attach`; ";
	PREPARE vw_dyn_prosp_attach_drop FROM @vw_dyn_prosp_attach_drop;
	EXECUTE vw_dyn_prosp_attach_drop;
	DEALLOCATE PREPARE vw_dyn_prosp_attach_drop;
	PREPARE vw_dyn_prosp_attach_defination FROM @vw_dyn_prosp_attach_defination;
	EXECUTE vw_dyn_prosp_attach_defination;
	DEALLOCATE PREPARE vw_dyn_prosp_attach_defination;

END;


BEGIN
					
	DECLARE A_name_val VARCHAR(900);
  DECLARE A_sub_val VARCHAR(900);					
  DECLARE A_t_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct look_values_id,look_sub_value_id as tag FROM vw_sale_shr where group_title is not null  order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
set @vw_proc_consult_master = " create view  vw_consult_dyn1 as select
a.prosp_consult_id,
a.prosp_first_name,
a.prosp_last_name,
'' as nickname,
a.gender,
a.emp_assigned_id,
DATE_FORMAT(a.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
a.call_recv_dt,
DATE_FORMAT(a.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
a.next_call_dt,
a.call_note,
a.prosp_summary,
a.last_updated,
concat((select concat(DATE_FORMAT(a.`last_updated`,'%m-%d-%y'),'\r',`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `updater` from `emp` where (`emp`.`emp_id` = if((`a`.`emp` = 0),1,`a`.`emp`)))) as `mod_last_updated`,
a.prosp_level AS prosp_level,
(select look_values from look_values where look_values_id = a.prosp_level) as prosp_lvl_desc,
c.group_contact AS `contacts`,
d.tags AS `prosp_tag`,
e.file_group AS `file_group`";

	

	set A_t_val = "";	
  set @Q = "";	
  set @Z = "";			

	OPEN A_cur_status;					
		FETCH  A_cur_status INTO  A_name_val, A_sub_val;
		set A_t_val = A_sub_val;
  CLOSE A_cur_status;			

	OPEN A_cur_status;					
						
	select FOUND_ROWS() into A_num_rows;					
					
    A_the_loop: LOOP				
						
		FETCH  A_cur_status INTO  A_name_val, A_sub_val;				
						
		IF A_no_more_rows THEN				
			CLOSE A_cur_status;			
            			LEAVE A_the_loop;						
		END IF;				
						
		set A_name_val = TRIM(A_name_val);			
    set A_sub_val = TRIM(A_sub_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
    set @vw_proc_consult_master = concat(@vw_proc_consult_master,",sum((case `b`.`prosp_tags` when '",A_name_val,"' then 1 else 0 end)) AS '",A_name_val,"'");
  
    if A_sub_val != A_t_val then
       set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");
       set @Z = "";
    end if;

		set @Z = CONCAT(@Z," or `",A_name_val,"` > 0 " );

    set A_t_val = A_sub_val;
    
						
		SET A_loop_cntr = A_loop_cntr + 1;				

  END LOOP A_the_loop;	

  set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");		


 
						
	set @vw_proc_consult_master = concat(@vw_proc_consult_master," from (`prosp_consult` `a` left join `prosp_tag` `b` on((`a`.`prosp_consult_id` = `b`.`prosp_consult_id`))) left join vw_dyn_prosp_contact as c on a.prosp_consult_id = c.prosp_consult_id  LEFT JOIN vw_dyn_prosp_tag as d on a.prosp_consult_id=d.prosp_consult_id  left join vw_dyn_prosp_attach as e on a.prosp_consult_id = e.prosp_consult_id group by `a`.`prosp_consult_id` order by `a`.`prosp_consult_id` ");	
	
  set @vw_proc_consult_master_1 =  concat("create view vw_consult_dyn2 as  select *",@Q," from vw_consult_dyn1");
 

  set @drop_view = "DROP VIEW IF EXISTS `vw_consult_dyn1`; ";					
	PREPARE drop_view FROM @drop_view;					
	EXECUTE drop_view;					
	DEALLOCATE PREPARE drop_view;	


  PREPARE vw_proc_consult_master_defination FROM @vw_proc_consult_master;					
	EXECUTE vw_proc_consult_master_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_defination;	

  
  set @drop_view_1 = "DROP VIEW IF EXISTS `vw_consult_dyn2`; ";					
	PREPARE drop_view_1 FROM @drop_view_1;					
	EXECUTE drop_view_1;					
	DEALLOCATE PREPARE drop_view_1;	


  PREPARE vw_proc_consult_master_1_defination FROM @vw_proc_consult_master_1;					
	EXECUTE vw_proc_consult_master_1_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_1_defination;	

END;

  BEGIN

  
  DECLARE B_name_val VARCHAR(900);	
  DECLARE B_sub_val VARCHAR(900);					
  DECLARE B_t_val INT DEFAULT 0;					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;	

   DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct look_sub_value_id FROM vw_sale_shr where group_title is not null  group by look_sub_value_id order by group_display_id,look_display_id;				
						
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET B_no_more_rows = TRUE;	
	SET @y = "";	
  set @final = "";	
set @vw_proc_consult_master_2 = " create view  vw_consult_dyn3  as select
* ";

						
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
						
	     B_the_loop: LOOP				
						
		FETCH  B_cur_status INTO  B_sub_val;				
						
		IF B_no_more_rows THEN				
			CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
		END IF;				
						
	
		set B_sub_val = TRIM(B_sub_val);
						
		IF (B_sub_val IS NULL OR length(B_sub_val) = 0) THEN				
			set B_sub_val = "blank";			
		END IF;				
						

   
  set @y = CONCAT(@y," OR `",B_sub_val,"` = 1 " );
  
    
   
    SET B_loop_cntr = B_loop_cntr + 1;				

	  END LOOP B_the_loop;	

   set @final = CONCAT(@final, ", if((0 ",@y," ),1,0) as Total_Missing");	


   set @vw_proc_consult_master_2 = concat(@vw_proc_consult_master_2,@final);

						
	 set @vw_proc_consult_master_2 = concat(@vw_proc_consult_master_2," from vw_consult_dyn2  ORDER BY last_updated DESC ");		
		

		
	set @drop_view_2 = "DROP VIEW IF EXISTS `vw_consult_dyn3`; ";					
	PREPARE drop_view_2 FROM @drop_view_2;					
	EXECUTE drop_view_2;					
	DEALLOCATE PREPARE drop_view_2;	


  PREPARE vw_proc_consult_master_2_defination FROM @vw_proc_consult_master_2;					
	EXECUTE vw_proc_consult_master_2_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_2_defination;	
  
  
  END;

 

  BEGIN

   set @prosp_consult_merger_defination = " CREATE TABLE prosp_consult_merger AS  SELECT * FROM vw_consult_dyn3";

  set @drop_table = "DROP TABLE IF EXISTS `prosp_consult_merger`; ";					
	PREPARE drop_table FROM @drop_table;					
	EXECUTE drop_table;					
	DEALLOCATE PREPARE drop_table;	

  PREPARE prosp_consult_merger_defination FROM @prosp_consult_merger_defination;					
	EXECUTE prosp_consult_merger_defination;					
	DEALLOCATE PREPARE prosp_consult_merger_defination;

  END;



BEGIN

   set @prosp_cnslt_conversion_table_defination = "CREATE VIEW vw_cnslt_conversion_table AS SELECT b.table_name AS table_name, a.* FROM prosp_consult_merger a LEFT JOIN vw_cnslt_con_2 b ON a.prosp_consult_id = b.consult_id";

   set @drop_view = "DROP VIEW IF EXISTS `vw_cnslt_conversion_table`;";
	PREPARE drop_view from @drop_view;
	EXECUTE drop_view;
	DEALLOCATE PREPARE drop_view;

PREPARE prosp_cnslt_conversion_table_defination FROM @prosp_cnslt_conversion_table_defination;					
	EXECUTE prosp_cnslt_conversion_table_defination;					
	DEALLOCATE PREPARE prosp_cnslt_conversion_table_defination;
	
END;
  


BEGIN

  set @vw_sales_shr_defination="create view  vw_sale_shr as  (select `c`.`look_values_id` AS `look_values_id`,`c`.`look_table` AS `look_table`,`c`.`look_values` AS `look_values`,`c`.`look_display_id` AS `look_display_id`,`c`.`look_sub_value_id` AS `look_sub_value_id`,(select distinct `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_title`,(select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_display_id`,(select distinct `look_values`.`look_value_code` AS `look_value_code` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_code`,(select distinct `look_values`.`look_value_desc` AS `look_value_desc` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_desc` from `look_values` `c` where ((`c`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section'))) and (`c`.`look_sub_value_id` > 0)) order by (select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)),`c`.`look_display_id` )";
  set @vw_sales_shr_drop = "DROP VIEW IF EXISTS `vw_sale_shr`; ";
	PREPARE vw_sales_shr_drop_statement FROM @vw_sales_shr_drop;
	EXECUTE vw_sales_shr_drop_statement;
	DEALLOCATE PREPARE vw_sales_shr_drop_statement;
	
	PREPARE vw_sales_shr_defination_create FROM @vw_sales_shr_defination;
	EXECUTE vw_sales_shr_defination_create;
	DEALLOCATE PREPARE vw_sales_shr_defination_create;


END;


BEGIN


  set @vw_emp_activity_defination="create view  vw_emp_activity as  select `a`.`idemp_activity` AS `idemp_activity`,`a`.`emp_id` AS `empd_id`,date_format(`a`.`call_recv_dt`,_utf8'%m.%d.%y') AS `call_recv_dt`,`a`.`emp_id` AS `emp_id`,(case when (`a`.`emp_id` <> 0) then concat_ws(_latin1' ',`b`.`firstname`,`b`.`lastname`) else _utf8'Admin' end) AS `updater`,date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') AS `next_call_dt`,`a`.`call_note` AS `call_note`,date_format(`a`.`last_updated`,_utf8'%m.%d.%y %T') AS `last_updated` from (`emp_activity` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') desc
";
  set @vw_emp_activity_drop = "DROP VIEW IF EXISTS `vw_emp_activity; ";
	PREPARE vw_emp_activity_drop FROM @vw_emp_activity_drop;
	EXECUTE vw_emp_activity_drop;
	DEALLOCATE PREPARE vw_emp_activity_drop;
	PREPARE vw_emp_activity_defination FROM @vw_emp_activity_defination;
	EXECUTE vw_emp_activity_defination;
	DEALLOCATE PREPARE vw_emp_activity_defination;


END;


BEGIN

  set @vw_dyn_emp_tag_defination="create view vw_dyn_emp_tag as 
  select `emp_id`,CONCAT(GROUP_CONCAT((select look_values from  aerion. look_values where look_values_id=emp_tags order by look_values.look_display_id ) SEPARATOR ' , ')) as tags from  aerion.emp_tag  group by `emp_id` order by (select look_display_id from  aerion. look_values where look_values_id=emp_tags),`emp_id";
  set @vw_dyn_emp_tag_drop = "DROP VIEW IF EXISTS `vw_dyn_emp_tag`; ";
	PREPARE vw_dyn_emp_tag_drop FROM @vw_dyn_emp_tag_drop;
	EXECUTE vw_dyn_emp_tag_drop;
	DEALLOCATE PREPARE vw_dyn_emp_tag_drop;
	PREPARE vw_dyn_emp_tag_defination FROM @vw_dyn_emp_tag_defination;
	EXECUTE vw_dyn_emp_tag_defination;
	DEALLOCATE PREPARE vw_dyn_emp_tag_defination;


END;


BEGIN

  set @vw_emp_attach_defination="create view vw_emp_attach as select `a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,date_format(`a`.`create_dt`,_utf8'%m-%d-%y') AS `create_dt`,(case when (`a`.`owner_id` = _latin1'') then _utf8'Admin' when isnull(`a`.`owner_id`) then _utf8'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updater`,`b`.`emp_id` AS `emp_id`,concat(`c`.`firstname`,_latin1' ',`c`.`lastname`) AS `emp_name` from (((`storages` `a` left join `emp_attach` `b` on((`a`.`idstorage` = `b`.`idstorage`))) left join `emp` `e` on((`a`.`owner_id` = `e`.`emp_id`))) left join `emp` `c` on((`b`.`emp_id` = `c`.`emp_id`)))
  ";
  set @vw_emp_attach_drop = "DROP VIEW IF EXISTS `vw_emp_attach`; ";
	PREPARE vw_emp_attach_drop FROM @vw_emp_attach_drop;
	EXECUTE vw_emp_attach_drop;
	DEALLOCATE PREPARE vw_emp_attach_drop;
	PREPARE vw_emp_attach_defination FROM @vw_emp_attach_defination;
	EXECUTE vw_emp_attach_defination;
	DEALLOCATE PREPARE vw_emp_attach_defination;


END;


BEGIN

  set @vw_dyn_emp_attach_defination="create view vw_dyn_emp_attach as 
  SELECT emp_id,GROUP_CONCAT(ifnull(file_name,'') SEPARATOR ' , ') AS file_group FROM vw_emp_attach  GROUP BY emp_id";
  set @vw_dyn_emp_attach_drop = "DROP VIEW IF EXISTS `vw_dyn_emp_attach`; ";
	PREPARE vw_dyn_emp_attach_drop FROM @vw_dyn_emp_attach_drop;
	EXECUTE vw_dyn_emp_attach_drop;
	DEALLOCATE PREPARE vw_dyn_emp_attach_drop;
	PREPARE vw_dyn_emp_attach_defination FROM @vw_dyn_emp_attach_defination;
	EXECUTE vw_dyn_emp_attach_defination;
	DEALLOCATE PREPARE vw_dyn_emp_attach_defination;


END;

BEGIN

set @dyn_emp_contact_defination="create table tbl_dyn_emp_contact  as 
SELECT emp_id,employee_name,GROUP_CONCAT(contacts SEPARATOR ' , ') as contacts from vw_emp_contact2 group by emp_id";

  set @dyn_emp_contact_drop = "DROP TABLE IF EXISTS `tbl_dyn_emp_contact`; ";
	PREPARE dyn_emp_contact_drop FROM @dyn_emp_contact_drop;
	EXECUTE dyn_emp_contact_drop;
	DEALLOCATE PREPARE dyn_emp_contact_drop;
	PREPARE dyn_emp_contact_defination FROM @dyn_emp_contact_defination;
	EXECUTE dyn_emp_contact_defination;
	DEALLOCATE PREPARE dyn_emp_contact_defination;


 END;


BEGIN
					
	DECLARE A_name_val VARCHAR(900);
    DECLARE A_sub_val VARCHAR(900);					
    DECLARE A_t_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct look_values_id,look_sub_value_id as tag FROM vw_sale_shr where group_title is not null  order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
set @vw_emp_dyn1 = " create view  vw_emp_dyn1 as select
a.emp_id,
a.firstname,
a.lastname,
a.nickname,
a.gender,
0 as emp_assigned_id,
DATE_FORMAT(a.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
a.call_recv_dt,
DATE_FORMAT(a.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
a.next_call_dt,
a.call_note,
a.emp_smry,
a.last_updated_sale,
concat((select concat(DATE_FORMAT(a.`last_updated_sale`,'%m-%d-%y'),'\r',`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `updater` from `emp` where (`emp`.`emp_id` = if((`a`.`emp_id_updated` = 0),1,`a`.`emp_id_updated`)))) as `mod_last_updated`,
a.emp_level AS emp_level,
(select look_values from look_values where look_values_id = a.emp_level) as emp_lvl_desc,
e.contacts AS `contacts`,
d.tags AS `emp_tag`,
f.file_group AS `file_group`";
	

  set A_t_val = "";	
  set @Q = "";	
  set @Z = "";			

	OPEN A_cur_status;					
	FETCH  A_cur_status INTO  A_name_val, A_sub_val;
	set A_t_val = A_sub_val;
    CLOSE A_cur_status;			
         
         OPEN A_cur_status;					
			select FOUND_ROWS() into A_num_rows;					
					A_the_loop: LOOP				
						FETCH  A_cur_status INTO  A_name_val, A_sub_val;				
						IF A_no_more_rows THEN				
								CLOSE A_cur_status;			
		            			LEAVE A_the_loop;						
						END IF;				
						
		set A_name_val = TRIM(A_name_val);			
        set A_sub_val = TRIM(A_sub_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
    set @vw_emp_dyn1 = concat(@vw_emp_dyn1,",sum((case `b`.`emp_tags` when '",A_name_val,"' then 1 else 0 end)) AS '",A_name_val,"'");
  
    if A_sub_val != A_t_val then
       set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");
       set @Z = "";
    end if;

		set @Z = CONCAT(@Z," or `",A_name_val,"` > 0 " );
		set A_t_val = A_sub_val;
    	SET A_loop_cntr = A_loop_cntr + 1;				

  					END LOOP A_the_loop;	

  		set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");		
		set @vw_emp_dyn1 = concat(@vw_emp_dyn1," from (`emp` `a` left join `emp_tag` `b` on((`a`.`emp_id` = `b`.`emp_id`))) LEFT JOIN   vw_dyn_emp_tag  `d`  on a.emp_id = d.emp_id  LEFT JOIN tbl_dyn_emp_contact e on a.emp_id = e.emp_id LEFT JOIN vw_dyn_emp_attach f on a.emp_id = f.emp_id group by `a`.`emp_id` order by `a`.`emp_id` ");	
		
		set @vw_emp_dyn2 =  concat("create view vw_emp_dyn2 as  select *",@Q," from vw_emp_dyn1");
 


	  set @drop_view = "DROP VIEW IF EXISTS `vw_emp_dyn1`; ";					
		PREPARE drop_view FROM @drop_view;					
		EXECUTE drop_view;					
		DEALLOCATE PREPARE drop_view;	


	  PREPARE vw_emp_dyn1_defination FROM @vw_emp_dyn1;					
		EXECUTE vw_emp_dyn1_defination;					
		DEALLOCATE PREPARE vw_emp_dyn1_defination;	

  
	  set @drop_view_1 = "DROP VIEW IF EXISTS `vw_emp_dyn2`; ";					
		PREPARE drop_view_1 FROM @drop_view_1;					
		EXECUTE drop_view_1;					
		DEALLOCATE PREPARE drop_view_1;	

  
	  PREPARE vw_emp_dyn2_defination FROM @vw_emp_dyn2;					
		EXECUTE vw_emp_dyn2_defination;					
		DEALLOCATE PREPARE vw_emp_dyn2_defination;	

END;



BEGIN

  
  	DECLARE B_name_val VARCHAR(900);	
  	DECLARE B_sub_val VARCHAR(900);					
  	DECLARE B_t_val INT DEFAULT 0;					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;	

   	DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct look_sub_value_id FROM vw_sale_shr where group_title is not null  group by look_sub_value_id order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET B_no_more_rows = TRUE;	
	SET @y = "";	
  	SET @final = "";	
	SET @vw_emp_dyn3 = " create view  vw_emp_dyn3  as select * ";

						
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
				B_the_loop: LOOP				
				FETCH  B_cur_status INTO  B_sub_val;				
				
				IF B_no_more_rows THEN				
					CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
				END IF;				
						
	
		set B_sub_val = TRIM(B_sub_val);

		IF (B_sub_val IS NULL OR length(B_sub_val) = 0) THEN				
			set B_sub_val = "blank";			
		END IF;

		set @y = CONCAT(@y," OR `",B_sub_val,"` = 1 " );
  
    

     	SET B_loop_cntr = B_loop_cntr + 1;				

		END LOOP B_the_loop;	

    set @final = CONCAT(@final, ", if((0 ",@y," ),1,0) as Total_Missing");	
    set @vw_emp_dyn3 = concat(@vw_emp_dyn3,@final);
	set @vw_emp_dyn3 = concat(@vw_emp_dyn3," from vw_emp_dyn2 ");		
		

		
	set @drop_view_2 = "DROP VIEW IF EXISTS `vw_emp_dyn3`; ";					
	PREPARE drop_view_2 FROM @drop_view_2;					
	EXECUTE drop_view_2;					
	DEALLOCATE PREPARE drop_view_2;	


  PREPARE vw_emp_dyn3_defination FROM @vw_emp_dyn3;					
	EXECUTE vw_emp_dyn3_defination;					
	DEALLOCATE PREPARE vw_emp_dyn3_defination;	
  
  
  END;

 

BEGIN

  set @emp_tag_merger_defination = " CREATE TABLE emp_tag_merger AS  SELECT * FROM vw_emp_dyn3";
  set @drop_table = "DROP TABLE IF EXISTS `emp_tag_merger`; ";					
	PREPARE drop_table FROM @drop_table;					
	EXECUTE drop_table;					
	DEALLOCATE PREPARE drop_table;	
  PREPARE emp_tag_merger_defination FROM @emp_tag_merger_defination;					
	EXECUTE emp_tag_merger_defination;					
	DEALLOCATE PREPARE emp_tag_merger_defination;

END;


  END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `proc_tags_OLD` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `proc_tags_OLD`()
BEGIN


  


BEGIN

  set @vw_sales_shr_defination="create view  vw_sale_shr as  (select `c`.`look_values_id` AS `look_values_id`,`c`.`look_table` AS `look_table`,`c`.`look_values` AS `look_values`,`c`.`look_display_id` AS `look_display_id`,`c`.`look_sub_value_id` AS `look_sub_value_id`,(select distinct `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_title`,(select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_display_id`,(select distinct `look_values`.`look_value_code` AS `look_value_code` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_code`,(select distinct `look_values`.`look_value_desc` AS `look_value_desc` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_desc` from `look_values` `c` where ((`c`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section'))) and (`c`.`look_sub_value_id` > 0)) order by (select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)),`c`.`look_display_id` )";

  set @vw_sales_shr_drop = "DROP VIEW IF EXISTS `vw_sale_shr`; ";
	PREPARE vw_sales_shr_drop_statement FROM @vw_sales_shr_drop;
	EXECUTE vw_sales_shr_drop_statement;
	DEALLOCATE PREPARE vw_sales_shr_drop_statement;
	
	PREPARE vw_sales_shr_defination_create FROM @vw_sales_shr_defination;
	EXECUTE vw_sales_shr_defination_create;
	DEALLOCATE PREPARE vw_sales_shr_defination_create;


END;

BEGIN

    set @vw_vw_sales_prosp_activity_defination="create view  vw_sales_prosp_activity  as (select `a`.`prosp_activity_id` AS `prosp_activity_id`,`a`.`prosp_consult_id` AS `prosp_consult_id`,date_format(`a`.`call_recv_dt`,_utf8'%m.%d.%y') AS `call_recv_dt`,`a`.`emp_id` AS `emp_id`,(case when (`a`.`emp_id` <> 0) then concat_ws(_latin1' ',`b`.`firstname`,`b`.`lastname`) else _utf8'Admin' end) AS `updater`,date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') AS `next_call_dt`,`a`.`call_note` AS `call_note`,date_format(`a`.`last_update`,_utf8'%m.%d.%y %T') AS `last_update` from (`prosp_activity` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') desc)";
    
    set @vw_sales_prosp_activity_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_activity`; ";
		PREPARE vw_sales_prosp_activity_drop_statement FROM @vw_sales_prosp_activity_drop;
		EXECUTE vw_sales_prosp_activity_drop_statement;
		DEALLOCATE PREPARE vw_sales_prosp_activity_drop_statement;
		
		PREPARE vw_sales_prosp_activity_defination_create FROM @vw_vw_sales_prosp_activity_defination;
		EXECUTE vw_sales_prosp_activity_defination_create;
		DEALLOCATE PREPARE vw_sales_prosp_activity_defination_create;

END;


BEGIN

	set @vw_sales_prosp_attach_defination="create view  vw_sales_prosp_attach as (select`a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,date_format(`a`.`create_dt`,_utf8'%m-%d-%y') AS `create_dt`,(case when (`a`.`owner_id` = _latin1'') then _utf8'Admin' when isnull(`a`.`owner_id`) then _utf8'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updater`,`b`.`prosp_consult_id` AS `prosp_consult_id`,concat(`c`.`prosp_first_name`,_latin1' ',`c`.`prosp_last_name`) AS `prsp_consult_name` from (((`storages` `a` left join `prosp_attach` `b` on((`a`.`idstorage` = `b`.`idstorage`))) left join `emp` `e` on((`a`.`owner_id` = `e`.`emp_id`))) left join `prosp_consult` `c` on((`b`.`prosp_consult_id` = `c`.`prosp_consult_id`))) )";
  
  set @vw_sales_prosp_attach_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_attach`; ";
	PREPARE vw_sales_prosp_attach_drop_statement FROM @vw_sales_prosp_attach_drop;
	EXECUTE vw_sales_prosp_attach_drop_statement;
	DEALLOCATE PREPARE vw_sales_prosp_attach_drop_statement;
	
	PREPARE vw_sales_prosp_attach_defination_create FROM @vw_sales_prosp_attach_defination;
	EXECUTE vw_sales_prosp_attach_defination_create;
	DEALLOCATE PREPARE vw_sales_prosp_attach_defination_create;

END;


BEGIN	
	    
    set @vw_sales_prosp_contact_defination="create view  vw_sales_prosp_contact  as  (select `a`.`prosp_contact_id` AS `prosp_contact_id`,`a`.`prosp_consult_id` AS `prosp_consult_id`,`a`.`contact_id` AS `contact_id`,`a`.`prosp_contact_type` AS `prosp_contact_type`,(select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where ((`look_values`.`look_values` = `a`.`prosp_contact_type`) and (select `look_values`.`look_table` AS `look_table` from `look_values` where (`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'contact.type'))) limit 1)) limit 1) AS `prosp_contact_type_id`,`a`.`summary` AS `summary`,`b`.`contact_detail` AS `contact_detail` from (`prosp_contact` `a` left join `contact_no` `b` on((`a`.`contact_id` = `b`.`contact_id`))))";
    set @vw_sales_prosp_contact_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_contact`; ";
		PREPARE vw_sales_prosp_contact_drop_statement FROM @vw_sales_prosp_contact_drop;
		EXECUTE vw_sales_prosp_contact_drop_statement;
		DEALLOCATE PREPARE vw_sales_prosp_contact_drop_statement;
		
		PREPARE vw_sales_prosp_contact_defination_create FROM @vw_sales_prosp_contact_defination;
		EXECUTE vw_sales_prosp_contact_defination_create;
		DEALLOCATE PREPARE vw_sales_prosp_contact_defination_create;


END;




BEGIN

  set @dyn_prosp_contact_defination="create view vw_dyn_prosp_contact  as 
SELECT prosp_consult_id,GROUP_CONCAT(ifnull(prosp_contact_type,''),':',ifnull(contact_detail,'') SEPARATOR ' , ') AS group_contact FROM vw_sales_prosp_contact  GROUP BY prosp_consult_id";

  set @dyn_prosp_contact_drop = "DROP VIEW IF EXISTS `vw_dyn_prosp_contact`; ";
	PREPARE dyn_prosp_contact_drop FROM @dyn_prosp_contact_drop;
	EXECUTE dyn_prosp_contact_drop;
	DEALLOCATE PREPARE dyn_prosp_contact_drop;
	PREPARE dyn_prosp_contact_defination FROM @dyn_prosp_contact_defination;
	EXECUTE dyn_prosp_contact_defination;
	DEALLOCATE PREPARE dyn_prosp_contact_defination;


 END;




BEGIN

  set @dyn_prosp_tag_defination="create view vw_dyn_prosp_tag as 
select `prosp_consult_id`,CONCAT(GROUP_CONCAT((select look_values from  aerion. look_values where look_values_id=prosp_tags order by look_values.look_display_id ) SEPARATOR ' , ')) as tags from  aerion. prosp_tag  group by `prosp_consult_id` order by (select look_display_id from  aerion. look_values where look_values_id=prosp_tags),`prosp_consult_id";

  set @dyn_prosp_tag_drop = "DROP VIEW IF EXISTS `vw_dyn_prosp_tag`; ";
	PREPARE dyn_prosp_tag_drop FROM @dyn_prosp_tag_drop;
	EXECUTE dyn_prosp_tag_drop;
	DEALLOCATE PREPARE dyn_prosp_tag_drop;
	PREPARE dyn_prosp_tag_defination FROM @dyn_prosp_tag_defination;
	EXECUTE dyn_prosp_tag_defination;
	DEALLOCATE PREPARE dyn_prosp_tag_defination;


END;



BEGIN

  set @vw_dyn_prosp_attach_defination="create view vw_dyn_prosp_attach as 

SELECT prosp_consult_id,GROUP_CONCAT(ifnull(file_name,'') SEPARATOR ' , ') AS file_group FROM vw_sales_prosp_attach  GROUP BY prosp_consult_id";

  set @vw_dyn_prosp_attach_drop = "DROP VIEW IF EXISTS `vw_dyn_prosp_attach`; ";
	PREPARE vw_dyn_prosp_attach_drop FROM @vw_dyn_prosp_attach_drop;
	EXECUTE vw_dyn_prosp_attach_drop;
	DEALLOCATE PREPARE vw_dyn_prosp_attach_drop;
	PREPARE vw_dyn_prosp_attach_defination FROM @vw_dyn_prosp_attach_defination;
	EXECUTE vw_dyn_prosp_attach_defination;
	DEALLOCATE PREPARE vw_dyn_prosp_attach_defination;


END;








BEGIN
					
	DECLARE A_name_val VARCHAR(900);
  DECLARE A_sub_val VARCHAR(900);					
  DECLARE A_t_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct look_values_id,look_sub_value_id as tag FROM vw_sale_shr where group_title is not null  order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
set @vw_proc_consult_master = " create view  vw_consult_dyn1 as select
a.prosp_consult_id,
a.prosp_first_name,
a.prosp_last_name,
'' as nickname,
a.gender,
a.emp_assigned_id,
DATE_FORMAT(a.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
a.call_recv_dt,
DATE_FORMAT(a.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
a.next_call_dt,
a.call_note,
a.prosp_summary,
a.last_updated,
concat((select concat(DATE_FORMAT(a.`last_updated`,'%m-%d-%y'),'\r',`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `updater` from `emp` where (`emp`.`emp_id` = if((`a`.`emp` = 0),1,`a`.`emp`)))) as `mod_last_updated`,
a.prosp_level AS prosp_level,
(select look_values from look_values where look_values_id = a.prosp_level) as prosp_lvl_desc,
c.group_contact AS `contacts`,
d.tags AS `prosp_tag`,
e.file_group AS `file_group`";

	

	set A_t_val = "";	
  set @Q = "";	
  set @Z = "";			

	OPEN A_cur_status;					
		FETCH  A_cur_status INTO  A_name_val, A_sub_val;
		set A_t_val = A_sub_val;
  CLOSE A_cur_status;			

	OPEN A_cur_status;					
						
	select FOUND_ROWS() into A_num_rows;					
					
    A_the_loop: LOOP				
						
		FETCH  A_cur_status INTO  A_name_val, A_sub_val;				
						
		IF A_no_more_rows THEN				
			CLOSE A_cur_status;			
            			LEAVE A_the_loop;						
		END IF;				
						
		set A_name_val = TRIM(A_name_val);			
    set A_sub_val = TRIM(A_sub_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
    set @vw_proc_consult_master = concat(@vw_proc_consult_master,",sum((case `b`.`prosp_tags` when '",A_name_val,"' then 1 else 0 end)) AS '",A_name_val,"'");
  
    if A_sub_val != A_t_val then
       set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");
       set @Z = "";
    end if;

		set @Z = CONCAT(@Z," or `",A_name_val,"` > 0 " );

    set A_t_val = A_sub_val;
    
						
		SET A_loop_cntr = A_loop_cntr + 1;				

  END LOOP A_the_loop;	

  set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");		


 
						
	set @vw_proc_consult_master = concat(@vw_proc_consult_master," from (`prosp_consult` `a` left join `prosp_tag` `b` on((`a`.`prosp_consult_id` = `b`.`prosp_consult_id`))) left join vw_dyn_prosp_contact as c on a.prosp_consult_id = c.prosp_consult_id  LEFT JOIN vw_dyn_prosp_tag as d on a.prosp_consult_id=d.prosp_consult_id  left join vw_dyn_prosp_attach as e on a.prosp_consult_id = e.prosp_consult_id group by `a`.`prosp_consult_id` order by `a`.`prosp_consult_id` ");	
	
  set @vw_proc_consult_master_1 =  concat("create view vw_consult_dyn2 as  select *",@Q," from vw_consult_dyn1");
 

  set @drop_view = "DROP VIEW IF EXISTS `vw_consult_dyn1`; ";					
	PREPARE drop_view FROM @drop_view;					
	EXECUTE drop_view;					
	DEALLOCATE PREPARE drop_view;	


  PREPARE vw_proc_consult_master_defination FROM @vw_proc_consult_master;					
	EXECUTE vw_proc_consult_master_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_defination;	

  
  set @drop_view_1 = "DROP VIEW IF EXISTS `vw_consult_dyn2`; ";					
	PREPARE drop_view_1 FROM @drop_view_1;					
	EXECUTE drop_view_1;					
	DEALLOCATE PREPARE drop_view_1;	


  PREPARE vw_proc_consult_master_1_defination FROM @vw_proc_consult_master_1;					
	EXECUTE vw_proc_consult_master_1_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_1_defination;	

END;






  BEGIN

  
  DECLARE B_name_val VARCHAR(900);	
  DECLARE B_sub_val VARCHAR(900);					
  DECLARE B_t_val INT DEFAULT 0;					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;	

   DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct look_sub_value_id FROM vw_sale_shr where group_title is not null  group by look_sub_value_id order by group_display_id,look_display_id;				
						
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET B_no_more_rows = TRUE;	
	SET @y = "";	
  set @final = "";	
set @vw_proc_consult_master_2 = " create view  vw_consult_dyn3  as select
* ";

						
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
						
	     B_the_loop: LOOP				
						
		FETCH  B_cur_status INTO  B_sub_val;				
						
		IF B_no_more_rows THEN				
			CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
		END IF;				
						
	
		set B_sub_val = TRIM(B_sub_val);
						
		IF (B_sub_val IS NULL OR length(B_sub_val) = 0) THEN				
			set B_sub_val = "blank";			
		END IF;				
						

   
  set @y = CONCAT(@y," OR `",B_sub_val,"` = 1 " );
  
    
   
    SET B_loop_cntr = B_loop_cntr + 1;				

	  END LOOP B_the_loop;	

   set @final = CONCAT(@final, ", if((0 ",@y," ),1,0) as Total_Missing");	


   set @vw_proc_consult_master_2 = concat(@vw_proc_consult_master_2,@final);

						
	 set @vw_proc_consult_master_2 = concat(@vw_proc_consult_master_2," from vw_consult_dyn2  ORDER BY last_updated DESC ");		
		

		
	set @drop_view_2 = "DROP VIEW IF EXISTS `vw_consult_dyn3`; ";					
	PREPARE drop_view_2 FROM @drop_view_2;					
	EXECUTE drop_view_2;					
	DEALLOCATE PREPARE drop_view_2;	


  PREPARE vw_proc_consult_master_2_defination FROM @vw_proc_consult_master_2;					
	EXECUTE vw_proc_consult_master_2_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_2_defination;	
  
  
  END;

 

  BEGIN

   set @prosp_consult_merger_defination = " CREATE TABLE prosp_consult_merger AS  SELECT * FROM vw_consult_dyn3";

  set @drop_table = "DROP TABLE IF EXISTS `prosp_consult_merger`; ";					
	PREPARE drop_table FROM @drop_table;					
	EXECUTE drop_table;					
	DEALLOCATE PREPARE drop_table;	

  PREPARE prosp_consult_merger_defination FROM @prosp_consult_merger_defination;					
	EXECUTE prosp_consult_merger_defination;					
	DEALLOCATE PREPARE prosp_consult_merger_defination;

  END;



BEGIN

   set @prosp_cnslt_conversion_table_defination = "CREATE VIEW vw_cnslt_conversion_table AS SELECT b.table_name AS table_name, a.* FROM prosp_consult_merger a LEFT JOIN vw_cnslt_con_2 b ON a.prosp_consult_id = b.consult_id";

   set @drop_view = "DROP VIEW IF EXISTS `vw_cnslt_conversion_table`;";
	PREPARE drop_view from @drop_view;
	EXECUTE drop_view;
	DEALLOCATE PREPARE drop_view;

PREPARE prosp_cnslt_conversion_table_defination FROM @prosp_cnslt_conversion_table_defination;					
	EXECUTE prosp_cnslt_conversion_table_defination;					
	DEALLOCATE PREPARE prosp_cnslt_conversion_table_defination;
	
END;
  

BEGIN

  set @vw_sales_shr_defination="create view  vw_sale_shr as  (select `c`.`look_values_id` AS `look_values_id`,`c`.`look_table` AS `look_table`,`c`.`look_values` AS `look_values`,`c`.`look_display_id` AS `look_display_id`,`c`.`look_sub_value_id` AS `look_sub_value_id`,(select distinct `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_title`,(select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_display_id`,(select distinct `look_values`.`look_value_code` AS `look_value_code` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_code`,(select distinct `look_values`.`look_value_desc` AS `look_value_desc` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_desc` from `look_values` `c` where ((`c`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section'))) and (`c`.`look_sub_value_id` > 0)) order by (select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)),`c`.`look_display_id` )";
  set @vw_sales_shr_drop = "DROP VIEW IF EXISTS `vw_sale_shr`; ";
	PREPARE vw_sales_shr_drop_statement FROM @vw_sales_shr_drop;
	EXECUTE vw_sales_shr_drop_statement;
	DEALLOCATE PREPARE vw_sales_shr_drop_statement;
	
	PREPARE vw_sales_shr_defination_create FROM @vw_sales_shr_defination;
	EXECUTE vw_sales_shr_defination_create;
	DEALLOCATE PREPARE vw_sales_shr_defination_create;


END;


BEGIN


  set @vw_emp_activity_defination="create view  vw_emp_activity as  select `a`.`idemp_activity` AS `idemp_activity`,`a`.`emp_id` AS `empd_id`,date_format(`a`.`call_recv_dt`,_utf8'%m.%d.%y') AS `call_recv_dt`,`a`.`emp_id` AS `emp_id`,(case when (`a`.`emp_id` <> 0) then concat_ws(_latin1' ',`b`.`firstname`,`b`.`lastname`) else _utf8'Admin' end) AS `updater`,date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') AS `next_call_dt`,`a`.`call_note` AS `call_note`,date_format(`a`.`last_updated`,_utf8'%m.%d.%y %T') AS `last_updated` from (`emp_activity` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') desc
";
  set @vw_emp_activity_drop = "DROP VIEW IF EXISTS `vw_emp_activity; ";
	PREPARE vw_emp_activity_drop FROM @vw_emp_activity_drop;
	EXECUTE vw_emp_activity_drop;
	DEALLOCATE PREPARE vw_emp_activity_drop;
	PREPARE vw_emp_activity_defination FROM @vw_emp_activity_defination;
	EXECUTE vw_emp_activity_defination;
	DEALLOCATE PREPARE vw_emp_activity_defination;


END;


BEGIN

  set @vw_dyn_emp_tag_defination="create view vw_dyn_emp_tag as 
  select `emp_id`,CONCAT(GROUP_CONCAT((select look_values from  aerion. look_values where look_values_id=emp_tags order by look_values.look_display_id ) SEPARATOR ' , ')) as tags from  aerion.emp_tag  group by `emp_id` order by (select look_display_id from  aerion. look_values where look_values_id=emp_tags),`emp_id";
  set @vw_dyn_emp_tag_drop = "DROP VIEW IF EXISTS `vw_dyn_emp_tag`; ";
	PREPARE vw_dyn_emp_tag_drop FROM @vw_dyn_emp_tag_drop;
	EXECUTE vw_dyn_emp_tag_drop;
	DEALLOCATE PREPARE vw_dyn_emp_tag_drop;
	PREPARE vw_dyn_emp_tag_defination FROM @vw_dyn_emp_tag_defination;
	EXECUTE vw_dyn_emp_tag_defination;
	DEALLOCATE PREPARE vw_dyn_emp_tag_defination;


END;


BEGIN

  set @vw_emp_attach_defination="create view vw_emp_attach as select `a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,date_format(`a`.`create_dt`,_utf8'%m-%d-%y') AS `create_dt`,(case when (`a`.`owner_id` = _latin1'') then _utf8'Admin' when isnull(`a`.`owner_id`) then _utf8'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updater`,`b`.`emp_id` AS `emp_id`,concat(`c`.`firstname`,_latin1' ',`c`.`lastname`) AS `emp_name` from (((`storages` `a` left join `emp_attach` `b` on((`a`.`idstorage` = `b`.`idstorage`))) left join `emp` `e` on((`a`.`owner_id` = `e`.`emp_id`))) left join `emp` `c` on((`b`.`emp_id` = `c`.`emp_id`)))
  ";
  set @vw_emp_attach_drop = "DROP VIEW IF EXISTS `vw_emp_attach`; ";
	PREPARE vw_emp_attach_drop FROM @vw_emp_attach_drop;
	EXECUTE vw_emp_attach_drop;
	DEALLOCATE PREPARE vw_emp_attach_drop;
	PREPARE vw_emp_attach_defination FROM @vw_emp_attach_defination;
	EXECUTE vw_emp_attach_defination;
	DEALLOCATE PREPARE vw_emp_attach_defination;


END;


BEGIN

  set @vw_dyn_emp_attach_defination="create view vw_dyn_emp_attach as 
  SELECT emp_id,GROUP_CONCAT(ifnull(file_name,'') SEPARATOR ' , ') AS file_group FROM vw_emp_attach  GROUP BY emp_id";
  set @vw_dyn_emp_attach_drop = "DROP VIEW IF EXISTS `vw_dyn_emp_attach`; ";
	PREPARE vw_dyn_emp_attach_drop FROM @vw_dyn_emp_attach_drop;
	EXECUTE vw_dyn_emp_attach_drop;
	DEALLOCATE PREPARE vw_dyn_emp_attach_drop;
	PREPARE vw_dyn_emp_attach_defination FROM @vw_dyn_emp_attach_defination;
	EXECUTE vw_dyn_emp_attach_defination;
	DEALLOCATE PREPARE vw_dyn_emp_attach_defination;


END;








BEGIN
					
	DECLARE A_name_val VARCHAR(900);
    DECLARE A_sub_val VARCHAR(900);					
    DECLARE A_t_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct look_values_id,look_sub_value_id as tag FROM vw_sale_shr where group_title is not null  order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
set @vw_emp_dyn1 = " create view  vw_emp_dyn1 as select
a.emp_id,
a.firstname,
a.lastname,
a.nickname,
a.gender,
0 as emp_assigned_id,
DATE_FORMAT(a.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
a.call_recv_dt,
DATE_FORMAT(a.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
a.next_call_dt,
a.call_note,
a.emp_smry,
a.last_updated_sale,
concat((select concat(DATE_FORMAT(a.`last_updated_sale`,'%m-%d-%y'),'\r',`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `updater` from `emp` where (`emp`.`emp_id` = if((`a`.`emp_id_updated` = 0),1,`a`.`emp_id_updated`)))) as `mod_last_updated`,
a.emp_level AS emp_level,
(select look_values from look_values where look_values_id = a.emp_level) as emp_lvl_desc,
e.contacts AS `contacts`,
d.tags AS `emp_tag`,
f.file_group AS `file_group`";
	

  set A_t_val = "";	
  set @Q = "";	
  set @Z = "";			

	OPEN A_cur_status;					
	FETCH  A_cur_status INTO  A_name_val, A_sub_val;
	set A_t_val = A_sub_val;
    CLOSE A_cur_status;			
         
         OPEN A_cur_status;					
			select FOUND_ROWS() into A_num_rows;					
					A_the_loop: LOOP				
						FETCH  A_cur_status INTO  A_name_val, A_sub_val;				
						IF A_no_more_rows THEN				
								CLOSE A_cur_status;			
		            			LEAVE A_the_loop;						
						END IF;				
						
		set A_name_val = TRIM(A_name_val);			
        set A_sub_val = TRIM(A_sub_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
    set @vw_emp_dyn1 = concat(@vw_emp_dyn1,",sum((case `b`.`emp_tags` when '",A_name_val,"' then 1 else 0 end)) AS '",A_name_val,"'");
  
    if A_sub_val != A_t_val then
       set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");
       set @Z = "";
    end if;

		set @Z = CONCAT(@Z," or `",A_name_val,"` > 0 " );
		set A_t_val = A_sub_val;
    	SET A_loop_cntr = A_loop_cntr + 1;				

  					END LOOP A_the_loop;	

  		set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");		
		set @vw_emp_dyn1 = concat(@vw_emp_dyn1," from (`emp` `a` left join `emp_tag` `b` on((`a`.`emp_id` = `b`.`emp_id`))) LEFT JOIN   vw_dyn_emp_tag  `d`  on a.emp_id = d.emp_id  LEFT JOIN vw_emp_contact2 e on a.emp_id = e.emp_id LEFT JOIN vw_dyn_emp_attach f on a.emp_id = f.emp_id group by `a`.`emp_id` order by `a`.`emp_id` ");	
		
		set @vw_emp_dyn2 =  concat("create view vw_emp_dyn2 as  select *",@Q," from vw_emp_dyn1");
 


	  set @drop_view = "DROP VIEW IF EXISTS `vw_emp_dyn1`; ";					
		PREPARE drop_view FROM @drop_view;					
		EXECUTE drop_view;					
		DEALLOCATE PREPARE drop_view;	


	  PREPARE vw_emp_dyn1_defination FROM @vw_emp_dyn1;					
		EXECUTE vw_emp_dyn1_defination;					
		DEALLOCATE PREPARE vw_emp_dyn1_defination;	

  
	  set @drop_view_1 = "DROP VIEW IF EXISTS `vw_emp_dyn2`; ";					
		PREPARE drop_view_1 FROM @drop_view_1;					
		EXECUTE drop_view_1;					
		DEALLOCATE PREPARE drop_view_1;	

  
	  PREPARE vw_emp_dyn2_defination FROM @vw_emp_dyn2;					
		EXECUTE vw_emp_dyn2_defination;					
		DEALLOCATE PREPARE vw_emp_dyn2_defination;	

END;



BEGIN

  
  	DECLARE B_name_val VARCHAR(900);	
  	DECLARE B_sub_val VARCHAR(900);					
  	DECLARE B_t_val INT DEFAULT 0;					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;	

   	DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct look_sub_value_id FROM vw_sale_shr where group_title is not null  group by look_sub_value_id order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET B_no_more_rows = TRUE;	
	SET @y = "";	
  	SET @final = "";	
	SET @vw_emp_dyn3 = " create view  vw_emp_dyn3  as select * ";

						
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
				B_the_loop: LOOP				
				FETCH  B_cur_status INTO  B_sub_val;				
				
				IF B_no_more_rows THEN				
					CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
				END IF;				
						
	
		set B_sub_val = TRIM(B_sub_val);

		IF (B_sub_val IS NULL OR length(B_sub_val) = 0) THEN				
			set B_sub_val = "blank";			
		END IF;

		set @y = CONCAT(@y," OR `",B_sub_val,"` = 1 " );
  
    

     	SET B_loop_cntr = B_loop_cntr + 1;				

		END LOOP B_the_loop;	

    set @final = CONCAT(@final, ", if((0 ",@y," ),1,0) as Total_Missing");	
    set @vw_emp_dyn3 = concat(@vw_emp_dyn3,@final);
	set @vw_emp_dyn3 = concat(@vw_emp_dyn3," from vw_emp_dyn2 ");		
		

		
	set @drop_view_2 = "DROP VIEW IF EXISTS `vw_emp_dyn3`; ";					
	PREPARE drop_view_2 FROM @drop_view_2;					
	EXECUTE drop_view_2;					
	DEALLOCATE PREPARE drop_view_2;	


  PREPARE vw_emp_dyn3_defination FROM @vw_emp_dyn3;					
	EXECUTE vw_emp_dyn3_defination;					
	DEALLOCATE PREPARE vw_emp_dyn3_defination;	
  
  
  END;

 

BEGIN

  set @emp_tag_merger_defination = " CREATE TABLE emp_tag_merger AS  SELECT * FROM vw_emp_dyn3";
  set @drop_table = "DROP TABLE IF EXISTS `emp_tag_merger`; ";					
	PREPARE drop_table FROM @drop_table;					
	EXECUTE drop_table;					
	DEALLOCATE PREPARE drop_table;	
  PREPARE emp_tag_merger_defination FROM @emp_tag_merger_defination;					
	EXECUTE emp_tag_merger_defination;					
	DEALLOCATE PREPARE emp_tag_merger_defination;

END;


  END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `rpt_bill_cycle` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `rpt_bill_cycle`()
BEGIN
		
	DECLARE done INT DEFAULT 0;
    DECLARE str_date DATE;
    DECLARE end_date DATE;
	DECLARE bill_cycle INT;
	DECLARE end_cur_date DATE;
	DECLARE int_bill_id INT;
	DECLARE int_comp_id INT;
	DECLARE int_emp_id INT;
	DECLARE int_bill_pay_rate FLOAT;
	DECLARE str_date_st VARCHAR(200);
	DECLARE end_date_st VARCHAR(200);
	DECLARE detail_id INT;
	DECLARE count INT;
	DECLARE no_of_day INT;
	DECLARE add_no_of_day INT;
	DECLARE dt_bill_fst_dt DATE;
	DECLARE int_idscript_log INT;
	DECLARE int_day_diff INT;
	DECLARE mid_date DATE;
  DECLARE fstname VARCHAR(200);
  DECLARE lstname VARCHAR(200);
  
DECLARE cursorWard CURSOR FOR SELECT col8,col9,col4,table_id FROM (SELECT * FROM rpt_process ORDER BY last_update DESC) t1 GROUP BY table_id ORDER BY table_id;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cursorWard;
		INSERT INTO script_calls(script_id,script_st) VALUES(1,NOW());
		SET int_idscript_log=LAST_INSERT_ID();

		REPEAT
        FETCH cursorWard INTO str_date_st,end_date_st,bill_cycle,detail_id;
        
			SET int_bill_id=(SELECT bill_id FROM bill_detail WHERE bill_detail_id=detail_id);
			SET dt_bill_fst_dt=(SELECT bill_fst_dt FROM bill_detail WHERE bill_detail_id=detail_id);
			SET int_comp_id=(SELECT comp_engage_id FROM billable WHERE bill_id=int_bill_id);
			SET int_emp_id=(SELECT emp_id FROM billable WHERE bill_id=int_bill_id);
			SET int_bill_pay_rate=(SELECT bill_pay_rate FROM bill_detail WHERE bill_detail_id=detail_id);
			SET str_date=(SELECT RIGHT(str_date_st,(LENGTH(str_date_st)-LOCATE(".", str_date_st))));
			SET end_date=(SELECT RIGHT(end_date_st,(LENGTH(end_date_st)-LOCATE(".", end_date_st))));
        
        
        
			IF NOT done THEN
				DELETE FROM rpt_bill_cycle WHERE bill_detail_id=detail_id;

				IF (str_date <> '' AND str_date IS NOT NULL) THEN					
					IF (end_date <> '' AND end_date IS NOT NULL) THEN
						SET end_date=end_date;
					ELSE						
						SET end_date=(SELECT CASE WHEN (tentative_end_dt <> '' AND tentative_end_dt IS NOT NULL) THEN tentative_end_dt ELSE date_add(CURDATE(),INTERVAL 12 MONTH) END FROM bill_detail WHERE bill_detail_id=detail_id);
					END IF;
					
					SET count=0;
					SET no_of_day=0;
					SET int_day_diff=0;
                    
					WHILE str_date <= end_date DO				
						IF (count=0) THEN
							IF(dt_bill_fst_dt IS NOT NULL AND dt_bill_fst_dt <> '') THEN
								SET end_cur_date=dt_bill_fst_dt;
							ELSE
								SET end_cur_date= DATE(DATE_ADD(str_date, INTERVAL mod(6-DAYOFWEEK(str_date)+7,7) DAY));
							END IF;
						ELSE
							SET end_cur_date= DATE(DATE_ADD(str_date,INTERVAL bill_cycle DAY));
						END IF;


						IF(bill_cycle=15) THEN								
								IF(count=0) THEN
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-%d') AS DATE);
                    IF (DAYOFMONTH(mid_date) >=1 AND DAYOFMONTH(mid_date) <=15) THEN
                        /*SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);*/
                        SET end_cur_date= CAST(DATE_FORMAT(str_date,'%Y-%m-15') AS DATE);
                    ELSE
                        IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                        ELSE 
                            IF (MONTH(mid_date) = 2) THEN 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                            ELSE 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                            END IF;
                        END IF;
                    END IF;
                                      
                ELSE
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-%d') AS DATE);
                    
                    IF (DAYOFMONTH(mid_date) >=1 AND DAYOFMONTH(mid_date) <=15) THEN
                        SET str_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);
                        SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-15') AS DATE);
                    ELSE
                        SET str_date=CAST(DATE_FORMAT(str_date,'%Y-%m-16') AS DATE);
                        IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                        ELSE 
                            IF (MONTH(mid_date) = 2) THEN 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                            ELSE 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                            END IF;
                        END IF;
                    END IF;
                    
								END IF;
						END IF;
						
                        
						IF(bill_cycle=30) THEN	
								IF(count=0) THEN
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);
                    
                    IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                        SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                    ELSE 
                        IF (MONTH(mid_date) = 2) THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                        ELSE
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                        END IF;
                    END IF;
                 ELSE
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-%d') AS DATE);
                    
                    IF (DAYOFMONTH(mid_date) >=1 AND DAYOFMONTH(mid_date) <=15) THEN
                        SET str_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);
                        
                        IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                        ELSE
                            IF (MONTH(mid_date) = 2) THEN
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                            ELSE
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                            END IF;
                        END IF;
                    END IF;
                    
								END IF;
						END IF;
						
						
						IF end_date < end_cur_date THEN							
							SET end_cur_date=end_date;
						END IF;

						INSERT INTO rpt_bill_cycle (comp_id,bill_id,emp_id,bill_detail_id,bill_pay_rate,bill_from_dt,bill_to_dt,cycle_type)
						SELECT int_comp_id,int_bill_id,int_emp_id,detail_id,int_bill_pay_rate,str_date,end_cur_date,'BILL_CYCLE';
						
						SET str_date=DATE(DATE_ADD(end_cur_date,INTERVAL 1 DAY));				
						SET count=count+1;
						
					END WHILE;

            SET fstname=(SELECT firstname from billable B INNER JOIN emp E ON B.emp_id = E.emp_id AND bill_id = int_bill_id);
            SET lstname=(SELECT lastname from billable B INNER JOIN emp E ON B.emp_id = E.emp_id AND bill_id = int_bill_id);
            
            
					INSERT INTO script_call_detail(idscript_log,script_time,script_msgs)
					VALUES(int_idscript_log,NOW(), CONCAT('Record for ', fstname,' ',lstname,' processed with Bill Id - ',int_bill_id));
                    
					/*DELETE FROM rpt_process WHERE table_id=detail_id;			*/
                    
				END IF;
			END IF;		
		
		UNTIL done END REPEAT;
 		
CLOSE cursorWard;

UPDATE script_calls SET script_end=NOW() WHERE idscript_log=int_idscript_log;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `rpt_bill_cycle_2` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `rpt_bill_cycle_2`()
BEGIN
		
	DECLARE done INT DEFAULT 0;
  DECLARE str_date DATE;
  DECLARE end_date DATE;
	DECLARE bill_cycle_val VARCHAR(50);
	DECLARE end_cur_date DATE;
	DECLARE int_bill_id INT;
	DECLARE int_comp_id INT;
	DECLARE int_emp_id INT;
	DECLARE int_bill_pay_rate FLOAT;
	DECLARE str_date_st VARCHAR(200);
	DECLARE end_date_st VARCHAR(200);
	DECLARE detail_id INT;
	DECLARE count INT;
	DECLARE no_of_day INT;
	DECLARE add_no_of_day INT;
	DECLARE dt_bill_fst_dt DATE;
	DECLARE int_idscript_log INT;
	DECLARE int_day_diff INT;
	DECLARE mid_date DATE;
  DECLARE fstname VARCHAR(200);
  DECLARE lstname VARCHAR(200);
  DECLARE no_of_days_to_add INT;
  
DECLARE cursorWard CURSOR FOR 
    SELECT bill_start_dt, bill_end_dt, bill_cycle, idengage_entity_po
    FROM engage_entity_po 
    WHERE last_update > 
    (SELECT script_end FROM script_calls 
    WHERE script_id = 1 AND idscript_log = (SELECT MAX(idscript_log) FROM script_calls where script_id = 1));

DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cursorWard;

    INSERT INTO script_calls(script_id,script_st) VALUES(1,NOW());
		SET int_idscript_log=LAST_INSERT_ID();

		REPEAT
        FETCH cursorWard INTO str_date_st,end_date_st,bill_cycle_val,detail_id;
      
        SET bill_cycle_val=(SELECT bill_cycle FROM engage_entity_po WHERE idengage_entity_po=detail_id);
      
        SET int_bill_id=(SELECT idengage_entity FROM engage_entity_po WHERE idengage_entity_po=detail_id);
			
        SET dt_bill_fst_dt=(SELECT bill_fst_dt FROM engage_entity_po WHERE idengage_entity_po=detail_id);
      
        SET int_comp_id=(SELECT ce.srv_client FROM engage_entity b inner join engage ce on b.engage_id = ce.engage_id  WHERE idengage_entity=int_bill_id);
            
        SET int_emp_id=(SELECT engage_ref_id FROM engage_entity WHERE idengage_entity=int_bill_id AND engage_ref_tab='Employee');
            
        SET int_bill_pay_rate=(SELECT bill_pay_rate FROM engage_entity_po WHERE idengage_entity_po=detail_id);
            
			SET str_date=(SELECT RIGHT(str_date_st,(LENGTH(str_date_st)-LOCATE(".", str_date_st))));
            
			SET end_date=(SELECT RIGHT(end_date_st,(LENGTH(end_date_st)-LOCATE(".", end_date_st))));
        
        
			IF NOT done THEN
				DELETE FROM rpt_bill_cycle WHERE bill_detail_id=detail_id;

				IF (str_date <> '' AND str_date IS NOT NULL) THEN					
					IF (end_date <> '' AND end_date IS NOT NULL) THEN
						SET end_date=end_date;
					ELSE						
						SET end_date=(SELECT CASE WHEN (tentative_end_dt <> '' AND tentative_end_dt IS NOT NULL) THEN tentative_end_dt ELSE date_add(CURDATE(),INTERVAL 12 MONTH) END FROM engage_entity_po WHERE idengage_entity_po=detail_id);
					END IF;
					
					SET count=0;
					SET no_of_day=0;
					SET int_day_diff=0;
                    
					WHILE str_date <= end_date DO				
						IF (count=0) THEN
							IF(dt_bill_fst_dt IS NOT NULL AND dt_bill_fst_dt <> '') THEN
								SET end_cur_date=dt_bill_fst_dt;
							ELSE
								SET end_cur_date= DATE(DATE_ADD(str_date, INTERVAL mod(6-DAYOFWEEK(str_date)+7,7) DAY));
							END IF;
						ELSE
							SET end_cur_date= DATE(DATE_ADD(str_date,INTERVAL bill_cycle_val DAY));
						END IF;


						IF(bill_cycle_val=15) THEN								
								IF(count=0) THEN
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-%d') AS DATE);
                    IF (DAYOFMONTH(mid_date) >=1 AND DAYOFMONTH(mid_date) <=15) THEN
                        /*SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);*/
                        SET end_cur_date= CAST(DATE_FORMAT(str_date,'%Y-%m-15') AS DATE);
                    ELSE
                        IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                        ELSE 
                            IF (MONTH(mid_date) = 2) THEN 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                            ELSE 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                            END IF;
                        END IF;
                    END IF;
                                      
                ELSE
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-%d') AS DATE);
                    
                    IF (DAYOFMONTH(mid_date) >=1 AND DAYOFMONTH(mid_date) <=15) THEN
                        SET str_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);
                        SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-15') AS DATE);
                    ELSE
                        SET str_date=CAST(DATE_FORMAT(str_date,'%Y-%m-16') AS DATE);
                        IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                        ELSE 
                            IF (MONTH(mid_date) = 2) THEN 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                            ELSE 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                            END IF;
                        END IF;
                    END IF;
                    
								END IF;
						END IF;
						
                        
						IF(bill_cycle_val=30) THEN	
								IF(count=0) THEN
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);
                    
                    IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                        SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                    ELSE 
                        IF (MONTH(mid_date) = 2) THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                        ELSE
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                        END IF;
                    END IF;
                 ELSE
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-%d') AS DATE);
                    
                    IF (DAYOFMONTH(mid_date) >=1 AND DAYOFMONTH(mid_date) <=15) THEN
                        SET str_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);
                        
                        IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                        ELSE
                            IF (MONTH(mid_date) = 2) THEN
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                            ELSE
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                            END IF;
                        END IF;
                    END IF;
                    
								END IF;
						END IF;
						
						
						IF end_date < end_cur_date THEN							
							SET end_cur_date=end_date;
						END IF;
            
                
            INSERT INTO rpt_bill_cycle (comp_id,bill_id,emp_id,bill_detail_id,bill_pay_rate,bill_from_dt,bill_to_dt,cycle_type, last_update)
            SELECT int_comp_id,int_bill_id,int_emp_id,detail_id,int_bill_pay_rate,str_date,end_cur_date,'BILL_CYCLE', NOW();
                        
						SET str_date=DATE(DATE_ADD(end_cur_date,INTERVAL 1 DAY));				
						SET count=count+1;
						
					END WHILE;

        
/******************** START - Processing for Weekly********************/
            SET count=0;
            SET str_date=(SELECT RIGHT(str_date_st,(LENGTH(str_date_st)-LOCATE(".", str_date_st))));
            SET end_date=(SELECT RIGHT(end_date_st,(LENGTH(end_date_st)-LOCATE(".", end_date_st))));
            
            IF (str_date <> '' AND str_date IS NOT NULL) THEN					
                IF (end_date <> '' AND end_date IS NOT NULL) THEN
                    SET end_date=end_date;
                ELSE						
                    SET end_date=(SELECT CASE WHEN (tentative_end_dt <> '' AND tentative_end_dt IS NOT NULL) THEN tentative_end_dt ELSE date_add(CURDATE(),INTERVAL 12 MONTH) END FROM engage_entity_po WHERE idengage_entity_po=detail_id);
                END IF;
            END IF;
            
            WHILE str_date <= end_date DO				
                
                IF (count=0) THEN
                    
                    CASE
                        WHEN (DAYOFWEEK(str_date) =1) THEN SET no_of_days_to_add = 5;
                        WHEN (DAYOFWEEK(str_date) =2) THEN SET no_of_days_to_add = 4;
                        WHEN (DAYOFWEEK(str_date) =3) THEN SET no_of_days_to_add = 3;
                        WHEN (DAYOFWEEK(str_date) =4) THEN SET no_of_days_to_add = 2;
                        WHEN (DAYOFWEEK(str_date) =5) THEN SET no_of_days_to_add = 1;
                        WHEN (DAYOFWEEK(str_date) =6) THEN SET no_of_days_to_add = 0;
                        WHEN (DAYOFWEEK(str_date) =7) THEN SET no_of_days_to_add = 6;
                    END CASE;
                    
                    SET end_cur_date = DATE_ADD(str_date,INTERVAL no_of_days_to_add DAY);
                    
                END IF;
                
                
                IF end_date < end_cur_date THEN							
                    SET end_cur_date=end_date;
                END IF;

                INSERT INTO rpt_bill_cycle (comp_id,bill_id,emp_id,bill_detail_id,bill_pay_rate,bill_from_dt,bill_to_dt,cycle_type,last_update)
                SELECT int_comp_id,int_bill_id,int_emp_id,detail_id,int_bill_pay_rate,str_date,end_cur_date,'WEEKLY', NOW();
                
                SET str_date=DATE(DATE_ADD(end_cur_date,INTERVAL 1 DAY));				
                SET end_cur_date=DATE(DATE_ADD(str_date,INTERVAL 6 DAY));				
                
                SET count=count+1;
            

            END WHILE;
            
/******************** END - Processing for Weekly********************/
                


        
/******************** START - Processing for Semi-Monthly ********************/
            SET count=0;
            SET str_date=(SELECT RIGHT(str_date_st,(LENGTH(str_date_st)-LOCATE(".", str_date_st))));
            SET end_date=(SELECT RIGHT(end_date_st,(LENGTH(end_date_st)-LOCATE(".", end_date_st))));
            
            IF (str_date <> '' AND str_date IS NOT NULL) THEN					
                IF (end_date <> '' AND end_date IS NOT NULL) THEN
                    SET end_date=end_date;
                ELSE						
                    SET end_date=(SELECT CASE WHEN (tentative_end_dt <> '' AND tentative_end_dt IS NOT NULL) THEN tentative_end_dt ELSE date_add(CURDATE(),INTERVAL 12 MONTH) END FROM engage_entity_po WHERE idengage_entity_po=detail_id);
                END IF;
            END IF;
            
            WHILE str_date <= end_date DO				
                
                IF(count=0) THEN
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-%d') AS DATE);
                    IF (DAYOFMONTH(mid_date) >=1 AND DAYOFMONTH(mid_date) <=15) THEN
                        /*SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);*/
                        SET end_cur_date= CAST(DATE_FORMAT(str_date,'%Y-%m-15') AS DATE);
                    ELSE
                        IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                        ELSE 
                            IF (MONTH(mid_date) = 2) THEN 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                            ELSE 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                            END IF;
                        END IF;
                    END IF;
                                      
                ELSE
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-%d') AS DATE);
                    
                    IF (DAYOFMONTH(mid_date) >=1 AND DAYOFMONTH(mid_date) <=15) THEN
                        SET str_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);
                        SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-15') AS DATE);
                    ELSE
                        SET str_date=CAST(DATE_FORMAT(str_date,'%Y-%m-16') AS DATE);
                        IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                        ELSE 
                            IF (MONTH(mid_date) = 2) THEN 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                            ELSE 
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                            END IF;
                        END IF;
                    END IF;
                    
								END IF;
                
                
                IF end_date < end_cur_date THEN							
                    SET end_cur_date=end_date;
                END IF;

                INSERT INTO rpt_bill_cycle (comp_id,bill_id,emp_id,bill_detail_id,bill_pay_rate,bill_from_dt,bill_to_dt,cycle_type,last_update)
                SELECT int_comp_id,int_bill_id,int_emp_id,detail_id,int_bill_pay_rate,str_date,end_cur_date,'SEMI-MONTHLY',NOW();
                
                SET str_date=DATE(DATE_ADD(end_cur_date,INTERVAL 1 DAY));				
                /*SET end_cur_date=DATE(DATE_ADD(str_date,INTERVAL 6 DAY));				*/
                
                SET count=count+1;
            

            END WHILE;
            
/******************** END - Processing for Semi-Monthly ********************/
                


        
/******************** START - Processing for Monthly ********************/
            SET count=0;
            SET str_date=(SELECT RIGHT(str_date_st,(LENGTH(str_date_st)-LOCATE(".", str_date_st))));
            SET end_date=(SELECT RIGHT(end_date_st,(LENGTH(end_date_st)-LOCATE(".", end_date_st))));
            
            IF (str_date <> '' AND str_date IS NOT NULL) THEN					
                IF (end_date <> '' AND end_date IS NOT NULL) THEN
                    SET end_date=end_date;
                ELSE						
                    SET end_date=(SELECT CASE WHEN (tentative_end_dt <> '' AND tentative_end_dt IS NOT NULL) THEN tentative_end_dt ELSE date_add(CURDATE(),INTERVAL 12 MONTH) END FROM engage_entity_po WHERE idengage_entity_po=detail_id);
                END IF;
            END IF;
            
            WHILE str_date <= end_date DO				
                
                IF(count=0) THEN
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);
                    
                    IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                        SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                    ELSE 
                        IF (MONTH(mid_date) = 2) THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                        ELSE
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                        END IF;
                    END IF;
                 ELSE
                    SET mid_date=CAST(DATE_FORMAT(str_date,'%Y-%m-%d') AS DATE);
                    
                    IF (DAYOFMONTH(mid_date) >=1 AND DAYOFMONTH(mid_date) <=15) THEN
                        SET str_date=CAST(DATE_FORMAT(str_date,'%Y-%m-01') AS DATE);
                        
                        IF (MONTH(mid_date) = 1 OR MONTH(mid_date) = 3 OR MONTH(mid_date) = 5 OR MONTH(mid_date) = 7 OR MONTH(mid_date) = 8 OR MONTH(mid_date) = 10 OR MONTH(mid_date) = 12)   THEN
                            SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-31') AS DATE);
                        ELSE
                            IF (MONTH(mid_date) = 2) THEN
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-28') AS DATE);
                            ELSE
                                SET end_cur_date=CAST(DATE_FORMAT(str_date,'%Y-%m-30') AS DATE);
                            END IF;
                        END IF;
                    END IF;
                    
								END IF;
                
                
                IF end_date < end_cur_date THEN							
                    SET end_cur_date=end_date;
                END IF;

                INSERT INTO rpt_bill_cycle (comp_id,bill_id,emp_id,bill_detail_id,bill_pay_rate,bill_from_dt,bill_to_dt,cycle_type,last_update)
                SELECT int_comp_id,int_bill_id,int_emp_id,detail_id,int_bill_pay_rate,str_date,end_cur_date,'MONTHLY',NOW();
                
                SET str_date=DATE(DATE_ADD(end_cur_date,INTERVAL 1 DAY));				
                /*SET end_cur_date=DATE(DATE_ADD(str_date,INTERVAL 6 DAY));				*/
                
                SET count=count+1;
            

            END WHILE;
            
/******************** END - Processing for Monthly ********************/
                

                
					
            SET fstname=(SELECT firstname from billable B INNER JOIN emp E ON B.emp_id = E.emp_id AND bill_id = int_bill_id);
            SET lstname=(SELECT lastname from billable B INNER JOIN emp E ON B.emp_id = E.emp_id AND bill_id = int_bill_id);

            INSERT INTO script_call_detail(idscript_log,script_time,script_msgs)
            VALUES(int_idscript_log,NOW(), CONCAT('Record for ', fstname,' ',lstname,' processed with engage entity Id - ',int_bill_id));

            DELETE FROM rpt_process WHERE table_id=detail_id;	
                    
				END IF;
			END IF;		
		
		UNTIL done END REPEAT;
 		
CLOSE cursorWard;

UPDATE script_calls SET script_end=NOW() WHERE idscript_log=int_idscript_log;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `rpt_budget_sp` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `rpt_budget_sp`(

)
BEGIN
DECLARE bdid int(11);
DECLARE bfid int(11);
DECLARE beid int(11);
DECLARE eid int(11);
DECLARE ceid int(11);
DECLARE cid int(11);
DECLARE sdt date;
DECLARE edt date;
DECLARE rt float;
DECLARE hid int(11);
DECLARE hdate date;
DECLARE tt decimal(4,2);
DECLARE tt1 int(11);
DECLARE tt2 int(11);
DECLARE amt varchar(45);
DECLARE vald int(11);
DECLARE no_more_rows BOOLEAN;
  DECLARE loop_cntr INT DEFAULT 0;
  DECLARE num_rows INT DEFAULT 0;
 
DECLARE friends_cur CURSOR FOR
SELECT a.bill_detail_id,a.bill_finance_id,c.emp_id as 

billable_emp_id,a.emp_id,c.comp_engage_id,d.comp_id,a.bill_fin_st_dt,a.bin_fin_end_st,a.bill_amt
			   FROM bill_budget a 
			   LEFT JOIN bill_detail b ON a.bill_detail_id = b.bill_detail_id
			   LEFT JOIN billable c ON b.bill_id = c.bill_id
			   LEFT JOIN comp_engage d ON c.comp_engage_id = d.comp_engage_id where   a.bin_fin_end_st IS  NOT NULL 
union SELECT a.bill_detail_id,a.bill_finance_id,c.emp_id as 

billable_emp_id,a.emp_id,c.comp_engage_id,d.comp_id,a.bill_fin_st_dt,a.bill_fin_st_dt,a.bill_amt
			   FROM bill_budget a 
			   LEFT JOIN bill_detail b ON a.bill_detail_id = b.bill_detail_id
			   LEFT JOIN billable c ON b.bill_id = c.bill_id
			   LEFT JOIN comp_engage d ON c.comp_engage_id = d.comp_engage_id where   a.bin_fin_end_st IS   NULL;
DECLARE CONTINUE HANDLER FOR NOT FOUND
    SET no_more_rows = TRUE;
OPEN friends_cur;
  select FOUND_ROWS() into num_rows;
 the_loop: LOOP
  
    FETCH  friends_cur
    INTO   bdid,bfid,beid,eid,ceid,cid,sdt,edt,rt;
BLOCK2:BEGIN

  DECLARE no_more_rows2 BOOLEAN;
  DECLARE loop_cntr2 INT DEFAULT 0;
  DECLARE num_rows2 INT DEFAULT 0;
 
 
 DECLARE friends_cur2 CURSOR FOR
 
 select hour_id,hoursdate,totaltime from  hours where emp_id =beid and comp_id =cid and hoursdate >=sdt and hoursdate <=edt and 

hrs_type='B';
  

         DECLARE CONTINUE HANDLER FOR NOT FOUND
        SET no_more_rows2 = TRUE;
        OPEN friends_cur2;
           select FOUND_ROWS() into num_rows2;
           the_loop2: LOOP
                   FETCH  friends_cur2
                    INTO  hid,hdate,tt;
               
            
               
                  SET  vald=(select rpt_budget_id from rpt_budget where bill_detail_id = bdid and bill_finance_id =bfid and billable_emp_id =beid and 

emp_id =eid and comp_engage_id =ceid and comp_id =cid and hour_id =hid);
                    
        
                    IF (vald IS  NULL) OR (vald = '') OR (vald=0) THEN
                    SET tt1=CAST(tt AS SIGNED);
                    SET tt2 = (tt - tt1)*100; 
                    SET amt = (tt1 * rt) + (tt2 * (rt/60));
                insert into rpt_budget (bill_detail_id, bill_finance_id, billable_emp_id, emp_id, comp_engage_id, comp_id, hour_id, 

hoursdate, totaltime, pay_rate, bud_amt, fin_st_dt, fin_end_dt ) values(bdid,bfid,beid,eid,ceid,cid,hid,hdate,tt,rt,amt,sdt,edt);
                   END IF;     
                 
                      IF no_more_rows2 THEN
                  CLOSE friends_cur2;
                   LEAVE the_loop2;
                     END IF;

 
                   SET loop_cntr2 = loop_cntr2 + 1;

                       END LOOP the_loop2;
                       END  BLOCK2;
IF no_more_rows THEN
        CLOSE friends_cur;
        LEAVE the_loop;
    END IF;

 
 SET loop_cntr = loop_cntr + 1;

  END LOOP the_loop;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `simpleproc2` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`heshmapatel`@`%` PROCEDURE `simpleproc2`()
BEGIN
SELECT * FROM  aerion.look_values;
insert into aerion.look_values (look_values) values('testinsert2'); 
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_rpt_process_correct_data` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `sp_rpt_process_correct_data`(IN `scriptid` int,OUT `scriptlogid` int,IN 

`param`text,OUT `stime` datetime,OUT `etime` datetime)
BEGIN


DECLARE id INT(11);
DECLARE table_name varchar(100);
DECLARE action varchar(10);
DECLARE ap_name varchar(200);
DECLARE reqs_id INT(11);
DECLARE reqs_desc varchar(500);
DECLARE open_dt_tm datetime;
DECLARE close_dt_tm datetime;
DECLARE open_month varchar(50);
DECLARE open_year varchar(50);
DECLARE close_month varchar(50);
DECLARE close_year varchar(50);
DECLARE status_cnt INT(11);
DECLARE total_time INT(11);
DECLARE stat_list varchar(300);
DECLARE stat_hist varchar(500);
DECLARE est_id INT(11);
DECLARE app_id INT(11);
DECLARE done INT DEFAULT FALSE;
DECLARE rpt_process_chk_cnt INT(11);
DECLARE old_req_desc varchar(500);
DECLARE rpt_process_id INT(11);
DECLARE com_id INT(11);
DECLARE Uid INT(11);
DECLARE sid INT(11);
DECLARE ctemp varchar(2000);
DECLARE updater_name varchar(500);
DECLARE lgtim INT(11);
DECLARE Last_updated_time varchar(500);
DECLARE manager varchar(500);
DECLARE developer varchar(500);
DECLARE analyst varchar(500);

declare cur CURSOR for select iddev_est_reqs,app_name,req_desc,status_hist,open_dt_time,(SELECT DATE_FORMAT(open_dt_time,'%Y') ) AS open_year ,(SELECT DATE_FORMAT(open_dt_time,'%M')) AS open_month,close_dt_time,(SELECT DATE_FORMAT(close_dt_time,'%Y')) AS close_year ,(SELECT DATE_FORMAT(close_dt_time,'%M')) AS close_month,rpt_req_manager,req_developer,rpt_req_analyst from aerion.vw_rpt_all_data_process_3 where ((dev_st_dt is not null) and (`dev_st_dt`<`dev_en_dt` OR isnull(dev_en_dt)) and (open_dt_time > dev_st_dt) and (`open_dt_time`<`close_dt_time` OR isnull(close_dt_time) and (open_dt_time < st_dt_time)) and (st_dt_time < e_dt_time) OR isnull(st_dt_time ) and isnull(e_dt_time));



DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

open cur;

the_loop: LOOP

FETCH cur INTO reqs_id,ap_name,reqs_desc,stat_hist,open_dt_tm,open_year,open_month,close_dt_tm,close_year,close_month,manager,developer,analyst;


IF done THEN
  LEAVE the_loop;
END IF;

      SELECT GROUP_CONCAT(IFNULL(status, ' ') SEPARATOR ';') INTO stat_list  from aerion.vw_dev_est_reqs_status  where iddev_est_reqs=reqs_id;
      SELECT COUNT(req_status) AS cnt INTO status_cnt from aerion.dev_est_reqs_status where iddev_est_reqs=reqs_id;
      SELECT (SUM(stat_time)/60) INTO total_time from aerion.dev_est_reqs_status where iddev_est_reqs=reqs_id;
      SELECT last_updated  INTO Last_updated_time from aerion.dev_est_reqs where iddev_est_reqs=reqs_id;
      SELECT concat(firstname, ' ',lastname) as updr INTO  updater_name from emp where emp_id=(select if(`updater`,0,1) from dev_est_reqs where `iddev_est_reqs`=reqs_id);
      select SUM(lag_time)  INTO lgtim from aerion.dev_est_reqs_status where iddev_est_reqs=reqs_id;
	   
	INSERT INTO `aerion`.`rpt_dev_status` (`iddev_est_reqs`,`rpt_dev_app`, `rpt_dev_app_req_smry`, `rpt_dev_req_status_cnt`, `rpt_dev_stat_list`, `rpt_dev_stat_hist`,`rpt_dev_req_open_dt_time`, `rpt_dev_req_close_dt_time`, `rpt_dev_total_time_hrs`,`rpt_dev_total_lag_time`,`rpt_dev_req_open_yr`,`rpt_dev_req_open_mon`,`rpt_dev_req_close_yr`,`rpt_dev_req_close_mon`,`rpt_req_manager`,`rpt_req_developer`,`rpt_req_analyst`,`updater`,`updated`) VALUES (reqs_id,ap_name,reqs_desc,status_cnt,stat_list,stat_hist,open_dt_tm,close_dt_tm, total_time,lgtim,open_year,open_month, close_year,close_month,manager,developer,analyst,updater_name,Last_updated_time);




END LOOP the_loop;

close cur;


INSERT INTO script_calls(script_id,script_st) VALUES(scriptid,NOW());
SET stime=NOW() ;
SET scriptlogid=LAST_INSERT_ID();
SET etime=NOW();
UPDATE script_calls SET script_end=NOW(),script_log_file=CONCAT('log_',scriptlogid,'.text') ,`script_summary detail`=CONCAT('successfully executed with parameter  ',param) WHERE idscript_log=scriptlogid;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_rpt_process_status` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `sp_rpt_process_status`(IN `scriptid` int,OUT `scriptlogid` int,IN `param` text,OUT `stime` datetime,OUT `etime` datetime)
BEGIN


DECLARE id INT(11);
DECLARE table_name varchar(100);
DECLARE action varchar(10);
DECLARE ap_name varchar(200);
DECLARE reqs_id INT(11);
DECLARE reqs_desc varchar(500);
DECLARE open_dt_tm datetime;
DECLARE close_dt_tm datetime;
DECLARE open_month varchar(50);
DECLARE open_year varchar(50);
DECLARE close_month varchar(50);
DECLARE close_year varchar(50);
DECLARE status_cnt INT(11);
DECLARE total_time INT(11);
DECLARE stat_list varchar(300);
DECLARE stat_hist varchar(500);
DECLARE est_id INT(11);
DECLARE app_id INT(11);
DECLARE done INT DEFAULT FALSE;
DECLARE rpt_process_chk_cnt INT(11);
DECLARE old_req_desc varchar(500);
DECLARE rpt_process_id INT(11);
DECLARE com_id INT(11);
DECLARE Uid INT(11);
DECLARE sid INT(11);
DECLARE ctemp varchar(2000);
DECLARE updater_name varchar(500);
DECLARE lgtim INT(11);
DECLARE Last_updated_time varchar(500);
DECLARE manager varchar(500);
DECLARE developer varchar(500);
DECLARE analyst varchar(500);

declare cur CURSOR for select iddev_est_reqs,app_name,req_desc,status_hist,open_dt_time,(SELECT DATE_FORMAT(open_dt_time,'%Y') ) AS open_year ,(SELECT DATE_FORMAT(open_dt_time,'%M')) AS open_month ,close_dt_time,(SELECT DATE_FORMAT(close_dt_time,'%Y')) AS close_year ,(SELECT DATE_FORMAT(close_dt_time,'%M')) AS close_month,rpt_req_manager,req_developer,rpt_req_analyst from aerion.vw_rpt_all_data_process_3;



DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

open cur;

the_loop: LOOP

FETCH cur INTO reqs_id,ap_name,reqs_desc,stat_hist,open_dt_tm,open_year,open_month,close_dt_tm,close_year,close_month,manager,developer,analyst;


IF done THEN
  LEAVE the_loop;
END IF;





      SELECT GROUP_CONCAT(IFNULL(status, ' ') SEPARATOR ';') INTO stat_list  from aerion.vw_dev_est_reqs_status  where iddev_est_reqs=reqs_id;
      SELECT COUNT(req_status) AS cnt INTO status_cnt from aerion.dev_est_reqs_status where iddev_est_reqs=reqs_id;
      SELECT (SUM(stat_time)/60) INTO total_time from aerion.dev_est_reqs_status where iddev_est_reqs=reqs_id;
      SELECT last_updated  INTO Last_updated_time from aerion.dev_est_reqs where iddev_est_reqs=reqs_id;
      SELECT concat(firstname, ' ',lastname) as updr INTO  updater_name from emp where emp_id=(select if(`updater`,0,1) from dev_est_reqs where `iddev_est_reqs`=reqs_id);
      select SUM(lag_time)  INTO lgtim from aerion.dev_est_reqs_status where iddev_est_reqs=reqs_id;
	   
	INSERT INTO `aerion`.`rpt_dev_status` (`iddev_est_reqs`,`rpt_dev_app`, `rpt_dev_app_req_smry`, `rpt_dev_req_status_cnt`, `rpt_dev_stat_list`, `rpt_dev_stat_hist`,`rpt_dev_req_open_dt_time`, `rpt_dev_req_close_dt_time`, `rpt_dev_total_time_hrs`,`rpt_dev_total_lag_time`,`rpt_dev_req_open_yr`,`rpt_dev_req_open_mon`,`rpt_dev_req_close_yr`,`rpt_dev_req_close_mon`,`rpt_req_manager`,`rpt_req_developer`,`rpt_req_analyst`,`updater`,`updated`) VALUES (reqs_id,ap_name,reqs_desc,status_cnt,stat_list,stat_hist,open_dt_tm,close_dt_tm, total_time,lgtim,open_year,open_month, close_year,close_month,manager,developer,analyst,updater_name,Last_updated_time);




END LOOP the_loop;

close cur;


INSERT INTO script_calls(script_id,script_st) VALUES(scriptid,NOW());
SET stime=NOW() ;
SET scriptlogid=LAST_INSERT_ID();
SET etime=NOW();
UPDATE script_calls SET script_end=NOW(),script_log_file=CONCAT('log_',scriptlogid,'.text') ,`script_summary detail`=CONCAT('successfully executed with parameter  ',param) WHERE idscript_log=scriptlogid;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `transpose_demo_1` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `transpose_demo_1`()
BEGIN

/* Logic  For vw_proc_consult_master creation  */
					
	BEGIN
					
	DECLARE A_name_val VARCHAR(900);
  DECLARE A_sub_val VARCHAR(900);						
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct look_values_id,look_sub_value_id as tag FROM vw_sale_shr where group_title is not null  order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
set @vw_proc_consult_master = " select
a.prosp_consult_id,
a.prosp_first_name,
a.prosp_last_name,
a.gender,
a.emp_assigned_id,
DATE_FORMAT(a.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
a.call_recv_dt,
DATE_FORMAT(a.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
a.next_call_dt,
a.call_note,
a.prosp_summary,
a.last_updated,
concat((select concat(`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `updater` from `emp` where (`emp`.`emp_id` = if((`a`.`emp` = 0),1,`a`.`emp`))),'\r',DATE_FORMAT(a.`last_updated`,'%m-%d-%y')) as `mod_last_updated`,
a.prosp_level AS prosp_level,
a.attachment AS `attachment`,
a.contacts AS `contacts`,
a.prosp_tag AS `prosp_tag`";

	

						
	OPEN A_cur_status;					
						
	select FOUND_ROWS() into A_num_rows;					
						
	     A_the_loop: LOOP				
						
		FETCH  A_cur_status INTO  A_name_val,A_sub_val;				
						
		IF A_no_more_rows THEN				
			CLOSE A_cur_status;			
            			LEAVE A_the_loop;						
		END IF;				
						
		set A_name_val = TRIM(A_name_val);	
    set A_sub_val =  TRIM(A_sub_val);			
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						


		if A_loop_cntr = A_num_rows then	

    set @vw_proc_consult_master = concat(@vw_proc_consult_master,",sum((case `b`.`prosp_tags` when '",A_name_val,"' then 1 else 0 end)) AS concat('",A_sub_val,"',"-",'",A_name_val,"')  ");
  
ELSE
    set @vw_proc_consult_master = concat(@vw_proc_consult_master,",sum((case `b`.`prosp_tags` when '",A_name_val,"' then 1 else 0 end)) AS concat('",A_sub_val,"',"-",'",A_name_val,"') ");
		
end if;				
		


						
		SET A_loop_cntr = A_loop_cntr + 1;				

	  END LOOP A_the_loop;			
						
	set @vw_proc_consult_master = concat(@vw_proc_consult_master," from (`prosp_consult` `a` left join `prosp_tag` `b` on((`a`.`prosp_consult_id` = `b`.`prosp_consult_id`))) group by `a`.`prosp_consult_id` order by `a`.`prosp_consult_id` ");	
	select @vw_proc_consult_master;

 /* set @drop_view = "DROP VIEW IF EXISTS `vw_proc_consult_master`; ";					
	PREPARE drop_view FROM @drop_view;					
	EXECUTE drop_view;					
	DEALLOCATE PREPARE drop_view;	

  PREPARE vw_proc_consult_master_defination FROM @vw_proc_consult_master;					
	EXECUTE vw_proc_consult_master_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_defination;	
*/

  END;

/* Logic  For Group Missing Dynamic View */

  BEGIN
/*
  DECLARE B_name_val VARCHAR(900);	
  DECLARE B_sub_val VARCHAR(900);					
  DECLARE B_t_val INT DEFAULT 0;					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;	

  DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct look_sub_value_id FROM vw_sale_shr where group_title is not null  group by look_sub_value_id order by group_display_id,look_display_id;				
						
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET B_no_more_rows = TRUE;	
	SET @Z = 0;		
set @vw_proc_consult_master_1 = " select
* ";

						
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
						
	     B_the_loop: LOOP				
						
		FETCH  B_cur_status INTO  B_sub_val;				
						
		IF B_no_more_rows THEN				
			CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
		END IF;				
						
	
		set B_sub_val = TRIM(B_sub_val);
						
		IF (B_sub_val IS NULL OR length(B_sub_val) = 0) THEN				
			set B_sub_val = "blank";			
		END IF;				
						

   
  
 
    
  set  @vw_proc_consult_master_1 = concat(@vw_proc_consult_master_1," , if('",B_sub_val,"' = 0,1,0) as  '",B_sub_val,"' ");
    
		


						
		SET B_loop_cntr = B_loop_cntr + 1;				

	  END LOOP B_the_loop;			
						
	 set @vw_proc_consult_master_1 = concat(@vw_proc_consult_master_1," from vw_proc_consult_master as d");		
						
		
  select  @vw_proc_consult_master_1;*/
  
  END;


END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `update_prosp_activity_date` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `update_prosp_activity_date`()
BEGIN

        Block1: BEGIN
    
    DECLARE int_prosp_activity_id INT;
    DECLARE dt_last_update DATETIME;
    DECLARE min_last_update DATETIME;
    DECLARE fst_min_last_update DATETIME;
    DECLARE int_prosp_consult_id INT;
    DECLARE prosp_count INT;
    DECLARE counter INT;
    DECLARE done INT DEFAULT FALSE;
    DECLARE done2 INT DEFAULT FALSE;

    
    DECLARE cursorWard CURSOR FOR 
    SELECT DISTINCT prosp_consult_id FROM prosp_activity_test ;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;    
    
		OPEN cursorWard;
 
		REPEAT
        FETCH cursorWard INTO int_prosp_consult_id;
        
        SET counter = 0;

        Block2: BEGIN

            DECLARE cursorWard2 CURSOR FOR 
            SELECT  prosp_activity_id, last_update 
            FROM    prosp_activity_test 
            WHERE   prosp_consult_id = int_prosp_consult_id 
            ORDER BY prosp_activity_id;
            DECLARE CONTINUE HANDLER FOR NOT FOUND SET done2 = 1;    
            
            OPEN cursorWard2;
     
            REPEAT
            FETCH cursorWard2 INTO int_prosp_activity_id, dt_last_update;
                
                IF counter = 0 THEN
                    SET min_last_update = dt_last_update;
                    SET fst_min_last_update = dt_last_update;
                END IF;
                
                
                IF counter > 0 THEN
                
                    IF fst_min_last_update = dt_last_update THEN
                        UPDATE  prosp_activity_test
                        SET     last_update = DATE_ADD(min_last_update, INTERVAL 1 SECOND) 
                        WHERE   prosp_activity_id = int_prosp_activity_id;
                        
                        SET min_last_update = DATE_ADD(min_last_update, INTERVAL 1 SECOND) ;
                        
                    END IF;
                    
                END IF;
                
                SET counter = counter + 1;
                 
            UNTIL done2 END REPEAT;
            CLOSE cursorWard2;
            
        END Block2;
      
            
		UNTIL done END REPEAT;
 		CLOSE cursorWard;
    END Block1;
 

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `_Navicat_Temp_Stored_Proc` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`aerion`@`192.180.1.5` PROCEDURE `_Navicat_Temp_Stored_Proc`()
BEGIN


BEGIN

  set @vw_sales_shr_defination="create view  vw_sale_shr as  (select `c`.`look_values_id` AS `look_values_id`,`c`.`look_table` AS `look_table`,`c`.`look_values` AS `look_values`,`c`.`look_display_id` AS `look_display_id`,`c`.`look_sub_value_id` AS `look_sub_value_id`,(select distinct `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_title`,(select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_display_id`,(select distinct `look_values`.`look_value_code` AS `look_value_code` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_code`,(select distinct `look_values`.`look_value_desc` AS `look_value_desc` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_desc` from `look_values` `c` where ((`c`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section'))) and (`c`.`look_sub_value_id` > 0)) order by (select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)),`c`.`look_display_id` )";

  set @vw_sales_shr_drop = "DROP VIEW IF EXISTS `vw_sale_shr`; ";
	PREPARE vw_sales_shr_drop_statement FROM @vw_sales_shr_drop;
	EXECUTE vw_sales_shr_drop_statement;
	DEALLOCATE PREPARE vw_sales_shr_drop_statement;
	
	PREPARE vw_sales_shr_defination_create FROM @vw_sales_shr_defination;
	EXECUTE vw_sales_shr_defination_create;
	DEALLOCATE PREPARE vw_sales_shr_defination_create;


END;

BEGIN

    set @vw_vw_sales_prosp_activity_defination="create view  vw_sales_prosp_activity  as (select `a`.`prosp_activity_id` AS `prosp_activity_id`,`a`.`prosp_consult_id` AS `prosp_consult_id`,date_format(`a`.`call_recv_dt`,_utf8'%m.%d.%y') AS `call_recv_dt`,`a`.`emp_id` AS `emp_id`,(case when (`a`.`emp_id` <> 0) then concat_ws(_latin1' ',`b`.`firstname`,`b`.`lastname`) else _utf8'Admin' end) AS `updater`,date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') AS `next_call_dt`,`a`.`call_note` AS `call_note`,date_format(`a`.`last_update`,_utf8'%m.%d.%y %T') AS `last_update` from (`prosp_activity` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') desc)";
    
    set @vw_sales_prosp_activity_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_activity`; ";
		PREPARE vw_sales_prosp_activity_drop_statement FROM @vw_sales_prosp_activity_drop;
		EXECUTE vw_sales_prosp_activity_drop_statement;
		DEALLOCATE PREPARE vw_sales_prosp_activity_drop_statement;
		
		PREPARE vw_sales_prosp_activity_defination_create FROM @vw_vw_sales_prosp_activity_defination;
		EXECUTE vw_sales_prosp_activity_defination_create;
		DEALLOCATE PREPARE vw_sales_prosp_activity_defination_create;

END;


BEGIN

	set @vw_sales_prosp_attach_defination="create view  vw_sales_prosp_attach as (select`a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,date_format(`a`.`create_dt`,_utf8'%m-%d-%y') AS `create_dt`,(case when (`a`.`owner_id` = _latin1'') then _utf8'Admin' when isnull(`a`.`owner_id`) then _utf8'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updater`,`b`.`prosp_consult_id` AS `prosp_consult_id`,concat(`c`.`prosp_first_name`,_latin1' ',`c`.`prosp_last_name`) AS `prsp_consult_name` from (((`storages` `a` left join `prosp_attach` `b` on((`a`.`idstorage` = `b`.`idstorage`))) left join `emp` `e` on((`a`.`owner_id` = `e`.`emp_id`))) left join `prosp_consult` `c` on((`b`.`prosp_consult_id` = `c`.`prosp_consult_id`))) )";
  
  set @vw_sales_prosp_attach_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_attach`; ";
	PREPARE vw_sales_prosp_attach_drop_statement FROM @vw_sales_prosp_attach_drop;
	EXECUTE vw_sales_prosp_attach_drop_statement;
	DEALLOCATE PREPARE vw_sales_prosp_attach_drop_statement;
	
	PREPARE vw_sales_prosp_attach_defination_create FROM @vw_sales_prosp_attach_defination;
	EXECUTE vw_sales_prosp_attach_defination_create;
	DEALLOCATE PREPARE vw_sales_prosp_attach_defination_create;

END;


BEGIN	
	    
    set @vw_sales_prosp_contact_defination="create view  vw_sales_prosp_contact  as  (select `a`.`prosp_contact_id` AS `prosp_contact_id`,`a`.`prosp_consult_id` AS `prosp_consult_id`,`a`.`contact_id` AS `contact_id`,`a`.`prosp_contact_type` AS `prosp_contact_type`,(select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where ((`look_values`.`look_values` = `a`.`prosp_contact_type`) and (select `look_values`.`look_table` AS `look_table` from `look_values` where (`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'contact.type'))) limit 1)) limit 1) AS `prosp_contact_type_id`,`a`.`summary` AS `summary`,`b`.`contact_detail` AS `contact_detail` from (`prosp_contact` `a` left join `contact_no` `b` on((`a`.`contact_id` = `b`.`contact_id`))))";
    set @vw_sales_prosp_contact_drop = "DROP VIEW IF EXISTS `vw_sales_prosp_contact`; ";
		PREPARE vw_sales_prosp_contact_drop_statement FROM @vw_sales_prosp_contact_drop;
		EXECUTE vw_sales_prosp_contact_drop_statement;
		DEALLOCATE PREPARE vw_sales_prosp_contact_drop_statement;
		
		PREPARE vw_sales_prosp_contact_defination_create FROM @vw_sales_prosp_contact_defination;
		EXECUTE vw_sales_prosp_contact_defination_create;
		DEALLOCATE PREPARE vw_sales_prosp_contact_defination_create;


END;




BEGIN

  set @dyn_prosp_contact_defination="create view vw_dyn_prosp_contact  as 
SELECT prosp_consult_id,GROUP_CONCAT(ifnull(prosp_contact_type,''),':',ifnull(contact_detail,'') SEPARATOR ' , ') AS group_contact FROM vw_sales_prosp_contact  GROUP BY prosp_consult_id";

  set @dyn_prosp_contact_drop = "DROP VIEW IF EXISTS `vw_dyn_prosp_contact`; ";
	PREPARE dyn_prosp_contact_drop FROM @dyn_prosp_contact_drop;
	EXECUTE dyn_prosp_contact_drop;
	DEALLOCATE PREPARE dyn_prosp_contact_drop;
	PREPARE dyn_prosp_contact_defination FROM @dyn_prosp_contact_defination;
	EXECUTE dyn_prosp_contact_defination;
	DEALLOCATE PREPARE dyn_prosp_contact_defination;


 END;




BEGIN

  set @dyn_prosp_tag_defination="create view vw_dyn_prosp_tag as 
select `prosp_consult_id`,CONCAT(GROUP_CONCAT((select look_values from  aerion. look_values where look_values_id=prosp_tags order by look_values.look_display_id ) SEPARATOR ' , ')) as tags from  aerion. prosp_tag  group by `prosp_consult_id` order by (select look_display_id from  aerion. look_values where look_values_id=prosp_tags),`prosp_consult_id";

  set @dyn_prosp_tag_drop = "DROP VIEW IF EXISTS `vw_dyn_prosp_tag`; ";
	PREPARE dyn_prosp_tag_drop FROM @dyn_prosp_tag_drop;
	EXECUTE dyn_prosp_tag_drop;
	DEALLOCATE PREPARE dyn_prosp_tag_drop;
	PREPARE dyn_prosp_tag_defination FROM @dyn_prosp_tag_defination;
	EXECUTE dyn_prosp_tag_defination;
	DEALLOCATE PREPARE dyn_prosp_tag_defination;


END;



BEGIN

  set @vw_dyn_prosp_attach_defination="create view vw_dyn_prosp_attach as 

SELECT prosp_consult_id,GROUP_CONCAT(ifnull(file_name,'') SEPARATOR ' , ') AS file_group FROM vw_sales_prosp_attach  GROUP BY prosp_consult_id";

  set @vw_dyn_prosp_attach_drop = "DROP VIEW IF EXISTS `vw_dyn_prosp_attach`; ";
	PREPARE vw_dyn_prosp_attach_drop FROM @vw_dyn_prosp_attach_drop;
	EXECUTE vw_dyn_prosp_attach_drop;
	DEALLOCATE PREPARE vw_dyn_prosp_attach_drop;
	PREPARE vw_dyn_prosp_attach_defination FROM @vw_dyn_prosp_attach_defination;
	EXECUTE vw_dyn_prosp_attach_defination;
	DEALLOCATE PREPARE vw_dyn_prosp_attach_defination;


END;








BEGIN
					
	DECLARE A_name_val VARCHAR(900);
  DECLARE A_sub_val VARCHAR(900);					
  DECLARE A_t_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct look_values_id,look_sub_value_id as tag FROM vw_sale_shr where group_title is not null  order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
set @vw_proc_consult_master = " create view  vw_consult_dyn1 as select
a.prosp_consult_id,
a.prosp_first_name,
a.prosp_last_name,
'' as nickname,
a.gender,
a.emp_assigned_id,
DATE_FORMAT(a.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
a.call_recv_dt,
DATE_FORMAT(a.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
a.next_call_dt,
a.call_note,
a.prosp_summary,
a.last_updated,
concat((select concat(DATE_FORMAT(a.`last_updated`,'%m-%d-%y'),'\r',`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `updater` from `emp` where (`emp`.`emp_id` = if((`a`.`emp` = 0),1,`a`.`emp`)))) as `mod_last_updated`,
a.prosp_level AS prosp_level,
(select look_values from look_values where look_values_id = a.prosp_level) as prosp_lvl_desc,
c.group_contact AS `contacts`,
d.tags AS `prosp_tag`,
e.file_group AS `file_group`";

	

	set A_t_val = "";	
  set @Q = "";	
  set @Z = "";			

	OPEN A_cur_status;					
		FETCH  A_cur_status INTO  A_name_val, A_sub_val;
		set A_t_val = A_sub_val;
  CLOSE A_cur_status;			

	OPEN A_cur_status;					
						
	select FOUND_ROWS() into A_num_rows;					
					
    A_the_loop: LOOP				
						
		FETCH  A_cur_status INTO  A_name_val, A_sub_val;				
						
		IF A_no_more_rows THEN				
			CLOSE A_cur_status;			
            			LEAVE A_the_loop;						
		END IF;				
						
		set A_name_val = TRIM(A_name_val);			
    set A_sub_val = TRIM(A_sub_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
    set @vw_proc_consult_master = concat(@vw_proc_consult_master,",sum((case `b`.`prosp_tags` when '",A_name_val,"' then 1 else 0 end)) AS '",A_name_val,"'");
  
    if A_sub_val != A_t_val then
       set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");
       set @Z = "";
    end if;

		set @Z = CONCAT(@Z," or `",A_name_val,"` > 0 " );

    set A_t_val = A_sub_val;
    
						
		SET A_loop_cntr = A_loop_cntr + 1;				

  END LOOP A_the_loop;	

  set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");		


 
						
	set @vw_proc_consult_master = concat(@vw_proc_consult_master," from (`prosp_consult` `a` left join `prosp_tag` `b` on((`a`.`prosp_consult_id` = `b`.`prosp_consult_id`))) left join vw_dyn_prosp_contact as c on a.prosp_consult_id = c.prosp_consult_id  LEFT JOIN vw_dyn_prosp_tag as d on a.prosp_consult_id=d.prosp_consult_id  left join vw_dyn_prosp_attach as e on a.prosp_consult_id = e.prosp_consult_id group by `a`.`prosp_consult_id` order by `a`.`prosp_consult_id` ");	
	
  set @vw_proc_consult_master_1 =  concat("create view vw_consult_dyn2 as  select *",@Q," from vw_consult_dyn1");
 

  set @drop_view = "DROP VIEW IF EXISTS `vw_consult_dyn1`; ";					
	PREPARE drop_view FROM @drop_view;					
	EXECUTE drop_view;					
	DEALLOCATE PREPARE drop_view;	


  PREPARE vw_proc_consult_master_defination FROM @vw_proc_consult_master;					
	EXECUTE vw_proc_consult_master_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_defination;	

  
  set @drop_view_1 = "DROP VIEW IF EXISTS `vw_consult_dyn2`; ";					
	PREPARE drop_view_1 FROM @drop_view_1;					
	EXECUTE drop_view_1;					
	DEALLOCATE PREPARE drop_view_1;	


  PREPARE vw_proc_consult_master_1_defination FROM @vw_proc_consult_master_1;					
	EXECUTE vw_proc_consult_master_1_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_1_defination;	

END;






  BEGIN

  
  DECLARE B_name_val VARCHAR(900);	
  DECLARE B_sub_val VARCHAR(900);					
  DECLARE B_t_val INT DEFAULT 0;					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;	

   DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct look_sub_value_id FROM vw_sale_shr where group_title is not null  group by look_sub_value_id order by group_display_id,look_display_id;				
						
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET B_no_more_rows = TRUE;	
	SET @y = "";	
  set @final = "";	
set @vw_proc_consult_master_2 = " create view  vw_consult_dyn3  as select
* ";

						
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
						
	     B_the_loop: LOOP				
						
		FETCH  B_cur_status INTO  B_sub_val;				
						
		IF B_no_more_rows THEN				
			CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
		END IF;				
						
	
		set B_sub_val = TRIM(B_sub_val);
						
		IF (B_sub_val IS NULL OR length(B_sub_val) = 0) THEN				
			set B_sub_val = "blank";			
		END IF;				
						

   
  set @y = CONCAT(@y," OR `",B_sub_val,"` = 1 " );
  
    
   
    SET B_loop_cntr = B_loop_cntr + 1;				

	  END LOOP B_the_loop;	

   set @final = CONCAT(@final, ", if((0 ",@y," ),1,0) as Total_Missing");	


   set @vw_proc_consult_master_2 = concat(@vw_proc_consult_master_2,@final);

						
	 set @vw_proc_consult_master_2 = concat(@vw_proc_consult_master_2," from vw_consult_dyn2  ORDER BY last_updated DESC ");		
		

		
	set @drop_view_2 = "DROP VIEW IF EXISTS `vw_consult_dyn3`; ";					
	PREPARE drop_view_2 FROM @drop_view_2;					
	EXECUTE drop_view_2;					
	DEALLOCATE PREPARE drop_view_2;	


  PREPARE vw_proc_consult_master_2_defination FROM @vw_proc_consult_master_2;					
	EXECUTE vw_proc_consult_master_2_defination;					
	DEALLOCATE PREPARE vw_proc_consult_master_2_defination;	
  
  
  END;

 

  BEGIN

   set @prosp_consult_merger_defination = " CREATE TABLE prosp_consult_merger AS  SELECT * FROM vw_consult_dyn3";

  set @drop_table = "DROP TABLE IF EXISTS `prosp_consult_merger`; ";					
	PREPARE drop_table FROM @drop_table;					
	EXECUTE drop_table;					
	DEALLOCATE PREPARE drop_table;	

  PREPARE prosp_consult_merger_defination FROM @prosp_consult_merger_defination;					
	EXECUTE prosp_consult_merger_defination;					
	DEALLOCATE PREPARE prosp_consult_merger_defination;

  END;



BEGIN

   set @prosp_cnslt_conversion_table_defination = "CREATE VIEW vw_cnslt_conversion_table AS SELECT b.table_name AS table_name, a.* FROM prosp_consult_merger a LEFT JOIN vw_cnslt_con_2 b ON a.prosp_consult_id = b.consult_id";

   set @drop_view = "DROP VIEW IF EXISTS `vw_cnslt_conversion_table`;";
	PREPARE drop_view from @drop_view;
	EXECUTE drop_view;
	DEALLOCATE PREPARE drop_view;

PREPARE prosp_cnslt_conversion_table_defination FROM @prosp_cnslt_conversion_table_defination;					
	EXECUTE prosp_cnslt_conversion_table_defination;					
	DEALLOCATE PREPARE prosp_cnslt_conversion_table_defination;
	
END;
  


BEGIN

  set @vw_sales_shr_defination="create view  vw_sale_shr as  (select `c`.`look_values_id` AS `look_values_id`,`c`.`look_table` AS `look_table`,`c`.`look_values` AS `look_values`,`c`.`look_display_id` AS `look_display_id`,`c`.`look_sub_value_id` AS `look_sub_value_id`,(select distinct `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_title`,(select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_display_id`,(select distinct `look_values`.`look_value_code` AS `look_value_code` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_code`,(select distinct `look_values`.`look_value_desc` AS `look_value_desc` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_desc` from `look_values` `c` where ((`c`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section'))) and (`c`.`look_sub_value_id` > 0)) order by (select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)),`c`.`look_display_id` )";
  set @vw_sales_shr_drop = "DROP VIEW IF EXISTS `vw_sale_shr`; ";
	PREPARE vw_sales_shr_drop_statement FROM @vw_sales_shr_drop;
	EXECUTE vw_sales_shr_drop_statement;
	DEALLOCATE PREPARE vw_sales_shr_drop_statement;
	
	PREPARE vw_sales_shr_defination_create FROM @vw_sales_shr_defination;
	EXECUTE vw_sales_shr_defination_create;
	DEALLOCATE PREPARE vw_sales_shr_defination_create;


END;


BEGIN


  set @vw_emp_activity_defination="create view  vw_emp_activity as  select `a`.`idemp_activity` AS `idemp_activity`,`a`.`emp_id` AS `empd_id`,date_format(`a`.`call_recv_dt`,_utf8'%m.%d.%y') AS `call_recv_dt`,`a`.`emp_id` AS `emp_id`,(case when (`a`.`emp_id` <> 0) then concat_ws(_latin1' ',`b`.`firstname`,`b`.`lastname`) else _utf8'Admin' end) AS `updater`,date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') AS `next_call_dt`,`a`.`call_note` AS `call_note`,date_format(`a`.`last_updated`,_utf8'%m.%d.%y %T') AS `last_updated` from (`emp_activity` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') desc
";
  set @vw_emp_activity_drop = "DROP VIEW IF EXISTS `vw_emp_activity; ";
	PREPARE vw_emp_activity_drop FROM @vw_emp_activity_drop;
	EXECUTE vw_emp_activity_drop;
	DEALLOCATE PREPARE vw_emp_activity_drop;
	PREPARE vw_emp_activity_defination FROM @vw_emp_activity_defination;
	EXECUTE vw_emp_activity_defination;
	DEALLOCATE PREPARE vw_emp_activity_defination;


END;


BEGIN

  set @vw_dyn_emp_tag_defination="create view vw_dyn_emp_tag as 
  select `emp_id`,CONCAT(GROUP_CONCAT((select look_values from  aerion. look_values where look_values_id=emp_tags order by look_values.look_display_id ) SEPARATOR ' , ')) as tags from  aerion.emp_tag  group by `emp_id` order by (select look_display_id from  aerion. look_values where look_values_id=emp_tags),`emp_id";
  set @vw_dyn_emp_tag_drop = "DROP VIEW IF EXISTS `vw_dyn_emp_tag`; ";
	PREPARE vw_dyn_emp_tag_drop FROM @vw_dyn_emp_tag_drop;
	EXECUTE vw_dyn_emp_tag_drop;
	DEALLOCATE PREPARE vw_dyn_emp_tag_drop;
	PREPARE vw_dyn_emp_tag_defination FROM @vw_dyn_emp_tag_defination;
	EXECUTE vw_dyn_emp_tag_defination;
	DEALLOCATE PREPARE vw_dyn_emp_tag_defination;


END;


BEGIN

  set @vw_emp_attach_defination="create view vw_emp_attach as select `a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,date_format(`a`.`create_dt`,_utf8'%m-%d-%y') AS `create_dt`,(case when (`a`.`owner_id` = _latin1'') then _utf8'Admin' when isnull(`a`.`owner_id`) then _utf8'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updater`,`b`.`emp_id` AS `emp_id`,concat(`c`.`firstname`,_latin1' ',`c`.`lastname`) AS `emp_name` from (((`storages` `a` left join `emp_attach` `b` on((`a`.`idstorage` = `b`.`idstorage`))) left join `emp` `e` on((`a`.`owner_id` = `e`.`emp_id`))) left join `emp` `c` on((`b`.`emp_id` = `c`.`emp_id`)))
  ";
  set @vw_emp_attach_drop = "DROP VIEW IF EXISTS `vw_emp_attach`; ";
	PREPARE vw_emp_attach_drop FROM @vw_emp_attach_drop;
	EXECUTE vw_emp_attach_drop;
	DEALLOCATE PREPARE vw_emp_attach_drop;
	PREPARE vw_emp_attach_defination FROM @vw_emp_attach_defination;
	EXECUTE vw_emp_attach_defination;
	DEALLOCATE PREPARE vw_emp_attach_defination;


END;


BEGIN

  set @vw_dyn_emp_attach_defination="create view vw_dyn_emp_attach as 
  SELECT emp_id,GROUP_CONCAT(ifnull(file_name,'') SEPARATOR ' , ') AS file_group FROM vw_emp_attach  GROUP BY emp_id";
  set @vw_dyn_emp_attach_drop = "DROP VIEW IF EXISTS `vw_dyn_emp_attach`; ";
	PREPARE vw_dyn_emp_attach_drop FROM @vw_dyn_emp_attach_drop;
	EXECUTE vw_dyn_emp_attach_drop;
	DEALLOCATE PREPARE vw_dyn_emp_attach_drop;
	PREPARE vw_dyn_emp_attach_defination FROM @vw_dyn_emp_attach_defination;
	EXECUTE vw_dyn_emp_attach_defination;
	DEALLOCATE PREPARE vw_dyn_emp_attach_defination;


END;

BEGIN


set @dyn_emp_contact_defination="create table tbl_dyn_emp_contact  as 
SELECT emp_id,employee_name,GROUP_CONCAT(contacts SEPERATOR ' , ') as contacts from vw_emp_contact2 group by emp_id";

  set @dyn_emp_contact_drop = "DROP TABLE IF EXISTS `tbl_dyn_emp_contact`; ";
	PREPARE dyn_emp_contact_drop FROM @dyn_emp_contact_drop;
	EXECUTE dyn_emp_contact_drop;
	DEALLOCATE PREPARE dyn_emp_contact_drop;
	PREPARE dyn_emp_contact_defination FROM @dyn_emp_contact_defination;
	EXECUTE dyn_emp_contact_defination;
	DEALLOCATE PREPARE dyn_emp_contact_defination;


 END;


BEGIN
					
	DECLARE A_name_val VARCHAR(900);
    DECLARE A_sub_val VARCHAR(900);					
    DECLARE A_t_val VARCHAR(900);					
	DECLARE A_no_more_rows BOOLEAN;					
	DECLARE A_loop_cntr INT DEFAULT 1;					
	DECLARE A_num_rows INT DEFAULT 0;					
						
	DECLARE A_cur_status CURSOR FOR  				
	SELECT distinct look_values_id,look_sub_value_id as tag FROM vw_sale_shr where group_title is not null  order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET A_no_more_rows = TRUE;	
	
set @vw_emp_dyn1 = " create view  vw_emp_dyn1 as select
a.emp_id,
a.firstname,
a.lastname,
a.nickname,
a.gender,
0 as emp_assigned_id,
DATE_FORMAT(a.`call_recv_dt`,'%m-%d-%y') as `mod_call_recv_dt`,
a.call_recv_dt,
DATE_FORMAT(a.`next_call_dt`,'%m-%d-%y') as `mod_next_call_dt`,
a.next_call_dt,
a.call_note,
a.emp_smry,
a.last_updated_sale,
concat((select concat(DATE_FORMAT(a.`last_updated_sale`,'%m-%d-%y'),'\r',`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `updater` from `emp` where (`emp`.`emp_id` = if((`a`.`emp_id_updated` = 0),1,`a`.`emp_id_updated`)))) as `mod_last_updated`,
a.emp_level AS emp_level,
(select look_values from look_values where look_values_id = a.emp_level) as emp_lvl_desc,
e.contacts AS `contacts`,
d.tags AS `emp_tag`,
f.file_group AS `file_group`";
	

  set A_t_val = "";	
  set @Q = "";	
  set @Z = "";			

	OPEN A_cur_status;					
	FETCH  A_cur_status INTO  A_name_val, A_sub_val;
	set A_t_val = A_sub_val;
    CLOSE A_cur_status;			
         
         OPEN A_cur_status;					
			select FOUND_ROWS() into A_num_rows;					
					A_the_loop: LOOP				
						FETCH  A_cur_status INTO  A_name_val, A_sub_val;				
						IF A_no_more_rows THEN				
								CLOSE A_cur_status;			
		            			LEAVE A_the_loop;						
						END IF;				
						
		set A_name_val = TRIM(A_name_val);			
        set A_sub_val = TRIM(A_sub_val);				
						
		IF (A_name_val IS NULL OR length(A_name_val) = 0) THEN				
			set A_name_val = "blank";			
		END IF;				
						
    set @vw_emp_dyn1 = concat(@vw_emp_dyn1,",sum((case `b`.`emp_tags` when '",A_name_val,"' then 1 else 0 end)) AS '",A_name_val,"'");
  
    if A_sub_val != A_t_val then
       set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");
       set @Z = "";
    end if;

		set @Z = CONCAT(@Z," or `",A_name_val,"` > 0 " );
		set A_t_val = A_sub_val;
    	SET A_loop_cntr = A_loop_cntr + 1;				

  					END LOOP A_the_loop;	

  		set @Q = CONCAT(@Q, ", if ((0 ",@Z," ),0,1) as `",A_t_val,"`");		
		set @vw_emp_dyn1 = concat(@vw_emp_dyn1," from (`emp` `a` left join `emp_tag` `b` on((`a`.`emp_id` = `b`.`emp_id`))) LEFT JOIN   vw_dyn_emp_tag  `d`  on a.emp_id = d.emp_id  LEFT JOIN tbl_dyn_emp_contact e on a.emp_id = e.emp_id LEFT JOIN vw_dyn_emp_attach f on a.emp_id = f.emp_id group by `a`.`emp_id` order by `a`.`emp_id` ");	
		
		set @vw_emp_dyn2 =  concat("create view vw_emp_dyn2 as  select *",@Q," from vw_emp_dyn1");
 


	  set @drop_view = "DROP VIEW IF EXISTS `vw_emp_dyn1`; ";					
		PREPARE drop_view FROM @drop_view;					
		EXECUTE drop_view;					
		DEALLOCATE PREPARE drop_view;	


	  PREPARE vw_emp_dyn1_defination FROM @vw_emp_dyn1;					
		EXECUTE vw_emp_dyn1_defination;					
		DEALLOCATE PREPARE vw_emp_dyn1_defination;	

  
	  set @drop_view_1 = "DROP VIEW IF EXISTS `vw_emp_dyn2`; ";					
		PREPARE drop_view_1 FROM @drop_view_1;					
		EXECUTE drop_view_1;					
		DEALLOCATE PREPARE drop_view_1;	

  
	  PREPARE vw_emp_dyn2_defination FROM @vw_emp_dyn2;					
		EXECUTE vw_emp_dyn2_defination;					
		DEALLOCATE PREPARE vw_emp_dyn2_defination;	

END;



BEGIN

  
  	DECLARE B_name_val VARCHAR(900);	
  	DECLARE B_sub_val VARCHAR(900);					
  	DECLARE B_t_val INT DEFAULT 0;					
	DECLARE B_no_more_rows BOOLEAN;					
	DECLARE B_loop_cntr INT DEFAULT 1;					
	DECLARE B_num_rows INT DEFAULT 0;	

   	DECLARE B_cur_status CURSOR FOR  				
	SELECT distinct look_sub_value_id FROM vw_sale_shr where group_title is not null  group by look_sub_value_id order by group_display_id,look_display_id;				
						
	DECLARE CONTINUE HANDLER FOR NOT FOUND					
	SET B_no_more_rows = TRUE;	
	SET @y = "";	
  	SET @final = "";	
	SET @vw_emp_dyn3 = " create view  vw_emp_dyn3  as select * ";

						
	OPEN B_cur_status;					
						
	select FOUND_ROWS() into B_num_rows;					
				B_the_loop: LOOP				
				FETCH  B_cur_status INTO  B_sub_val;				
				
				IF B_no_more_rows THEN				
					CLOSE B_cur_status;			
            			LEAVE B_the_loop;						
				END IF;				
						
	
		set B_sub_val = TRIM(B_sub_val);

		IF (B_sub_val IS NULL OR length(B_sub_val) = 0) THEN				
			set B_sub_val = "blank";			
		END IF;

		set @y = CONCAT(@y," OR `",B_sub_val,"` = 1 " );
  
    

     	SET B_loop_cntr = B_loop_cntr + 1;				

		END LOOP B_the_loop;	

    set @final = CONCAT(@final, ", if((0 ",@y," ),1,0) as Total_Missing");	
    set @vw_emp_dyn3 = concat(@vw_emp_dyn3,@final);
	set @vw_emp_dyn3 = concat(@vw_emp_dyn3," from vw_emp_dyn2 ");		
		

		
	set @drop_view_2 = "DROP VIEW IF EXISTS `vw_emp_dyn3`; ";					
	PREPARE drop_view_2 FROM @drop_view_2;					
	EXECUTE drop_view_2;					
	DEALLOCATE PREPARE drop_view_2;	


  PREPARE vw_emp_dyn3_defination FROM @vw_emp_dyn3;					
	EXECUTE vw_emp_dyn3_defination;					
	DEALLOCATE PREPARE vw_emp_dyn3_defination;	
  
  
  END;

 

BEGIN

  set @emp_tag_merger_defination = " CREATE TABLE emp_tag_merger AS  SELECT * FROM vw_emp_dyn3";
  set @drop_table = "DROP TABLE IF EXISTS `emp_tag_merger`; ";					
	PREPARE drop_table FROM @drop_table;					
	EXECUTE drop_table;					
	DEALLOCATE PREPARE drop_table;	
  PREPARE emp_tag_merger_defination FROM @emp_tag_merger_defination;					
	EXECUTE emp_tag_merger_defination;					
	DEALLOCATE PREPARE emp_tag_merger_defination;

END;


  END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;

--
-- Final view structure for view `del_no_days`
--

/*!50001 DROP VIEW IF EXISTS `del_no_days`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `del_no_days` AS select `vw_emp_st_end_dt4`.`emp_id` AS `emp_id`,`vw_emp_st_end_dt4`.`gender` AS `gender`,`vw_emp_st_end_dt4`.`firstname` AS `firstname`,`vw_emp_st_end_dt4`.`lastname` AS `lastname`,`vw_emp_st_end_dt4`.`fullname` AS `Fullname`,`vw_emp_st_end_dt4`.`comp_id` AS `comp_id`,`vw_emp_st_end_dt4`.`companyname` AS `companyname`,`vw_emp_st_end_dt4`.`start_dt` AS `org_start_dt`,`vw_emp_st_end_dt4`.`end_dt` AS `org_end_dt`,`vw_emp_st_end_dt4`.`billable_type` AS `BillableType`,`vw_emp_st_end_dt4`.`employment` AS `Employment`,(to_days(`vw_emp_st_end_dt4`.`end_dt`) - to_days(`vw_emp_st_end_dt4`.`start_dt`)) AS `difference` from `vw_emp_st_end_dt4` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `del_temp_data`
--

/*!50001 DROP VIEW IF EXISTS `del_temp_data`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `del_temp_data` AS select `eb`.`engage_calc` AS `engage_calc`,`eb`.`engage_amt` AS `engage_amt`,`eb`.`engage_st_dt` AS `engage_st_dt`,`eb`.`engage_end_st` AS `engage_end_st`,`eb`.`limit_amt` AS `limit_amt`,`ee`.`engage_ref_id` AS `engage_ref_id`,`c`.`companyname` AS `companyname` from ((((`engage` `e` left join `engage_entity` `ee` on((`e`.`engage_id` = `ee`.`engage_id`))) left join `engage_entity_po` `eep` on((`ee`.`idengage_entity` = `eep`.`idengage_entity`))) left join `engage_budget` `eb` on((`eb`.`idengage_entity_po` = `eep`.`idengage_entity_po`))) left join `company` `c` on((`c`.`comp_id` = `e`.`srv_client`))) where (`eb`.`show_emp` = (select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where ((`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'yes_no'))) and (`look_values`.`look_values` = _latin1'Yes')))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_activity`
--

/*!50001 DROP VIEW IF EXISTS `vw_activity`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_activity` AS select (case when (`pa`.`emp_id` <> 0) then concat_ws(_latin1' ',`e`.`firstname`,`e`.`lastname`) else 'Admin' end) AS `name`,`pa`.`prosp_activity_id` AS `prosp_activity_id`,`pa`.`prosp_consult_id` AS `prosp_consult_id`,`pa`.`call_recv_dt` AS `call_recv_dt`,`pa`.`emp_id` AS `emp_id`,`pa`.`next_call_dt` AS `next_call_dt`,`pa`.`call_note` AS `call_note`,`pa`.`last_update` AS `last_update` from (`prosp_activity` `pa` left join `emp` `e` on((`e`.`emp_id` = `pa`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_addresses`
--

/*!50001 DROP VIEW IF EXISTS `vw_addresses`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_addresses` AS select `a`.`country_id` AS `country_id`,`a`.`con_name` AS `con_name`,`b`.`state_id` AS `state_id`,`b`.`state_name` AS `state_name`,`c`.`city_id` AS `city_id`,`c`.`city_name` AS `city_name`,`d`.`postal_id` AS `postal_id`,`d`.`zip_code` AS `zip_code`,`e`.`look_street_id` AS `look_street_id`,`e`.`street_name` AS `street_name`,`e`.`street_type` AS `street_type`,`f`.`look_street_no_id` AS `look_street_no_id`,`f`.`look_street_no` AS `look_street_no` from (((`look_postal` `d` left join (`look_city` `c` left join (`look_state` `b` left join `look_country` `a` on((`a`.`country_id` = `b`.`country_id`))) on((`b`.`state_id` = `c`.`state_id`))) on((`c`.`city_id` = `d`.`city_id`))) left join `look_street` `e` on((`d`.`postal_id` = `e`.`postal_id`))) left join `look_street_no` `f` on((`e`.`look_street_id` = `f`.`look_street_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_addresses2`
--

/*!50001 DROP VIEW IF EXISTS `vw_addresses2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_addresses2` AS select `vw_addresses`.`look_street_no_id` AS `look_street_no_id`,concat_ws(_latin1' ',`vw_addresses`.`look_street_no`,_latin1' ',`vw_addresses`.`street_name`,_latin1'',(select `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `vw_addresses`.`street_type`)),_latin1',',`vw_addresses`.`city_name`,_latin1' ',`vw_addresses`.`state_name`,_latin1' ',`vw_addresses`.`zip_code`) AS `addresses` from `vw_addresses` where (`vw_addresses`.`look_street_no_id` is not null) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_all_attration`
--

/*!50001 DROP VIEW IF EXISTS `vw_all_attration`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_all_attration` AS select `a`.`idall_attration` AS `idall_attration`,`a`.`att_dt` AS `att_dt2`,date_format(`a`.`att_dt`,_utf8'%b %Y') AS `att_dt`,`a`.`att_for` AS `att_for`,`a`.`att_start` AS `att_start`,`a`.`att_end` AS `att_end`,`a`.`att_open_total` AS `att_open_total`,`a`.`att_percent` AS `att_percent` from `all_attration` `a` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_all_users_login`
--

/*!50001 DROP VIEW IF EXISTS `vw_all_users_login`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_all_users_login` AS select `a`.`login_id` AS `login_id`,date_format(`a`.`lastlogin`,_utf8'%m-%d-%y %H:%i:%s') AS `lastlogin`,`a`.`lastlogin` AS `lastlogin_unformatted`,date_format(`a`.`lastlogout`,_utf8'%m-%d-%y %H:%i:%s') AS `lastlogout`,`a`.`lastlogout` AS `lastlogout_unformatted`,ifnull((unix_timestamp(`a`.`lastlogout`) - unix_timestamp(`a`.`lastlogin`)),(unix_timestamp(now()) - unix_timestamp(`a`.`lastlogin`))) AS `logged_in`,`a`.`login_IP_add` AS `login_IP_add`,`a`.`domain_name` AS `domain_name`,ifnull(`a`.`isp`,'None') AS `isp`,ifnull(`a`.`country`,'No Country') AS `country`,ifnull(`a`.`state`,'No State') AS `state`,ifnull(`a`.`city`,'No City') AS `city`,ifnull(`a`.`postal_code`,'No Postal_Code') AS `postal_code`,`a`.`idlook_menu_pvt_lvl1` AS `main_menu_id`,ifnull(`c`.`lk_values`,'None') AS `main_menu`,`a`.`idlook_menu_pvt_lvl2` AS `sub_menu_id`,ifnull(`d`.`lk_values`,'None') AS `sub_menu`,ifnull(`a`.`logouttype`,'Live') AS `logouttype`,`b`.`emp_id` AS `emp_id`,ifnull(concat(`b`.`firstname`,'  ',`b`.`lastname`),'Admin') AS `username`,`a`.`del_dt` AS `del_dt_unformatted`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`del_by` AS `del_by_id`,ifnull(concat(`e_del_by`.`firstname`,' ',`e_del_by`.`lastname`),'Admin') AS `del_by`,`o_del_by`.`file_name` AS `del_by_file_name`,`a`.`del_day` AS `del_day`,`a`.`archv_dt` AS `archv_dt_unformatted`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt`,ifnull(concat(`e_archv_by`.`firstname`,' ',`e_archv_by`.`lastname`),'Admin') AS `archv_by`,`a`.`archv_by` AS `archv_by_id`,`o_archv_by`.`file_name` AS `archv_by_file_name` from ((((((((`all_users_login` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) left join `emp` `e_del_by` on((`a`.`del_by` = `e_del_by`.`emp_id`))) left join `emp` `e_archv_by` on((`a`.`archv_by` = `e_archv_by`.`emp_id`))) left join `storages` `s` on((`b`.`idstorage` = `s`.`idstorage`))) left join `storages` `o_del_by` on((`e_del_by`.`idstorage` = `o_del_by`.`idstorage`))) left join `storages` `o_archv_by` on((`e_archv_by`.`idstorage` = `o_archv_by`.`idstorage`))) left join `look_menu_pvt` `c` on((`a`.`idlook_menu_pvt_lvl1` = `c`.`idlook_menu_pvt`))) left join `look_menu_pvt` `d` on((`a`.`idlook_menu_pvt_lvl2` = `d`.`idlook_menu_pvt`))) order by `a`.`lastlogin` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_asset_mgmt`
--

/*!50001 DROP VIEW IF EXISTS `vw_asset_mgmt`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_asset_mgmt` AS select `asset_mgmt`.`idasset_mgmt` AS `idasset_mgmt`,`asset_mgmt`.`tangible` AS `tangible`,`asset_mgmt`.`prchse_dt` AS `prchse_dt`,`asset_mgmt`.`prchse_expy` AS `prchse_expy`,`asset_mgmt`.`asset_serial_no` AS `asset_serial_no`,`asset_mgmt`.`prchse_pr` AS `prchse_pr`,`asset_mgmt`.`prchse_type` AS `prchse_type`,`asset_mgmt`.`category_type` AS `category_type`,`asset_mgmt`.`category` AS `category`,`asset_mgmt`.`depriciate_pcnt` AS `depriciate_pcnt`,`asset_mgmt`.`depriciate_calc` AS `depriciate_calc`,`company`.`companyname` AS `companyname`,`company`.`comp_id` AS `comp_id`,`asset_lk`.`asset_name` AS `asset_name`,`asset_lk`.`idasset_look` AS `idasset_look`,`asset_lk_val`.`idasset_look_value` AS `idasset_look_value`,`asset_lk_val`.`asset_value` AS `asset_value`,`emp`.`emp_id` AS `emp_id`,`emp`.`updater` AS `updater`,date_format(`asset_mgmt`.`prchse_expy`,'%m-%d-%Y') AS `prchse_expy_usa`,date_format(`asset_mgmt`.`prchse_dt`,'%m-%d-%Y') AS `prchse_dt_usa`,date_format(`asset_mgmt`.`warranty`,'%m-%d-%Y') AS `warranty_usa`,date_format(`asset_mgmt`.`last_updated`,'%m-%d-%Y') AS `last_updated_usa` from ((((`asset_mgmt` left join `company` on((`asset_mgmt`.`comp_id` = `company`.`comp_id`))) left join `asset_lk_val` on((`asset_mgmt`.`category_type` = `asset_lk_val`.`idasset_look_value`))) left join `emp` on((`asset_mgmt`.`updater` = `emp`.`emp_id`))) left join `asset_lk` on((`asset_mgmt`.`category` = `asset_lk`.`idasset_look`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_bill_attration`
--

/*!50001 DROP VIEW IF EXISTS `vw_bill_attration`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_bill_attration` AS select (case when isnull(`vw_bill_attration_sub`.`st_year`) then `vw_bill_attration_sub`.`ed_year` else `vw_bill_attration_sub`.`st_year` end) AS `year`,(case when isnull(`vw_bill_attration_sub`.`st_month`) then `vw_bill_attration_sub`.`ed_month` else `vw_bill_attration_sub`.`st_month` end) AS `month`,(case when isnull(`vw_bill_attration_sub`.`started`) then 0 else `vw_bill_attration_sub`.`started` end) AS `started`,(case when isnull(`vw_bill_attration_sub`.`ended`) then 0 else `vw_bill_attration_sub`.`ended` end) AS `ended` from `vw_bill_attration_sub` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_bill_attration_end`
--

/*!50001 DROP VIEW IF EXISTS `vw_bill_attration_end`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_bill_attration_end` AS select year(`bill_detail`.`bill_end_dt`) AS `year`,month(`bill_detail`.`bill_end_dt`) AS `month`,count(`bill_detail`.`idengage_entity_po`) AS `cnt` from `engage_entity_po` `bill_detail` group by year(`bill_detail`.`bill_end_dt`),month(`bill_detail`.`bill_end_dt`) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_bill_attration_start`
--

/*!50001 DROP VIEW IF EXISTS `vw_bill_attration_start`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_bill_attration_start` AS select year(`bill_detail`.`bill_start_dt`) AS `year`,month(`bill_detail`.`bill_start_dt`) AS `month`,count(`bill_detail`.`idengage_entity_po`) AS `cnt` from `engage_entity_po` `bill_detail` group by year(`bill_detail`.`bill_start_dt`),month(`bill_detail`.`bill_start_dt`) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_bill_attration_sub`
--

/*!50001 DROP VIEW IF EXISTS `vw_bill_attration_sub`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_bill_attration_sub` AS select `sd`.`year` AS `st_year`,`sd`.`month` AS `st_month`,`sd`.`cnt` AS `started`,`ed`.`year` AS `ed_year`,`ed`.`month` AS `ed_month`,`ed`.`cnt` AS `ended` from (`vw_bill_attration_start` `sd` left join `vw_bill_attration_end` `ed` on(((`sd`.`year` = `ed`.`year`) and (`sd`.`month` = `ed`.`month`)))) union select `sd`.`year` AS `year`,`sd`.`month` AS `month`,`sd`.`cnt` AS `cnt`,`ed`.`year` AS `year`,`ed`.`month` AS `month`,`ed`.`cnt` AS `cnt` from (`vw_bill_attration_end` `ed` left join `vw_bill_attration_start` `sd` on(((`sd`.`year` = `ed`.`year`) and (`sd`.`month` = `ed`.`month`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_billingto`
--

/*!50001 DROP VIEW IF EXISTS `vw_billingto`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_billingto` AS select `emp`.`emp_id` AS `id`,(case when (`emp`.`emp_id` <> 0) then concat_ws(_latin1' ',`emp`.`firstname`,`emp`.`lastname`) else 'Admin' end) AS `name` from `emp` union select `company`.`comp_id` AS `id`,`company`.`companyname` AS `name` from `company` union select `prosp_consult`.`prosp_consult_id` AS `id`,concat(`prosp_consult`.`prosp_first_name`,`prosp_consult`.`prosp_last_name`) AS `name` from `prosp_consult` limit 0,1000 */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_budget`
--

/*!50001 DROP VIEW IF EXISTS `vw_budget`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_budget` AS select `a`.`idengage_budget` AS `idengage_budget`,`a`.`idengage_entity_po` AS `idengage_entity_po`,`et`.`engage_ref_id` AS `engage_ref_id_po`,`et`.`engage_ref_tab` AS `engage_ref_tab_po`,concat(convert((case when isnull(`et`.`engage_ref_tab`) then '' else (case when (`et`.`engage_ref_tab` = _latin1'company') then 'Comp' when (`et`.`engage_ref_tab` = _latin1'employee') then 'Emp' end) end) using latin1),':',(case when (`et`.`engage_ref_tab` = _latin1'Company') then concat(`c1`.`companyname`) when (`et`.`engage_ref_tab` = _latin1'Employee') then (case when (`et`.`engage_ref_id` = '') then 'Admin' else concat(`em1`.`firstname`,_latin1' ',`em1`.`lastname`) end) end)) AS `po_candidate_name`,(case when (`et`.`engage_ref_tab` = _latin1'Company') then convert((select group_concat(concat(`vw_comp2`.`emp_name`,_latin1' -> ',`vw_comp2`.`contact_detail`),_latin1' | ' separator ',') AS `contact_detail` from `vw_comp2` where (`vw_comp2`.`comp_id` = `et`.`engage_ref_id`) group by `vw_comp2`.`comp_id`) using utf8) when (`et`.`engage_ref_tab` = _latin1'Employee') then (case when (`et`.`engage_ref_id` = '') then 'Admin' else convert(concat((select group_concat(`vw_emp_contact3`.`contacts`,_latin1' | ' separator ',') AS `contact_detail` from `vw_emp_contact3` where (`vw_emp_contact3`.`emp_id` = `et`.`engage_ref_id`) group by `vw_emp_contact3`.`emp_id`)) using utf8) end) end) AS `comp_emp_detail_po`,`b`.`idengage_entity` AS `idengage_entity`,`et`.`engage_id` AS `engage_id`,`f`.`srv_client` AS `srv_client`,`g`.`companyname` AS `client_name`,`f`.`srv_vendor` AS `srv_vendor`,`h`.`companyname` AS `Vender_name`,`a`.`engage_ref_id` AS `engage_ref_id`,`a`.`engage_ref_table` AS `engage_ref_table`,(case when (`a`.`engage_ref_table` = _latin1'company') then concat(`c`.`companyname`) when (`a`.`engage_ref_table` = _latin1'employee') then (case when (`a`.`engage_ref_id` = 'F') then 'Admin' else concat(`em`.`firstname`,_latin1' ',`em`.`lastname`) end) end) AS `engage_ref_id_name`,`a`.`engage_calc` AS `engage_calc`,cast(`a`.`engage_amt` as decimal(10,2)) AS `engage_amt`,`a`.`show_emp` AS `show_emp`,date_format(`a`.`engage_st_dt`,'%m-%d-%y') AS `engage_st_dt`,date_format(`a`.`engage_st_dt`,'%m.%d.%y') AS `engage_st_dt1`,date_format(`a`.`engage_st_dt`,'%Y-%m-%d') AS `sort_engage_st_dt`,date_format(`a`.`engage_end_st`,'%m-%d-%y') AS `engage_end_st`,date_format(`a`.`engage_end_st`,'%m.%d.%y') AS `engage_end_st1`,date_format(`a`.`engage_end_st`,'%Y-%m-%d') AS `sort_engage_end_st`,cast(`a`.`limit_amt` as decimal(10,2)) AS `limit_amt`,`a`.`engage_summary` AS `engage_summary`,date_format(`b`.`bill_start_dt`,'%m-%d-%y') AS `bill_start_dt`,date_format(`b`.`bill_start_dt`,'%m.%d.%y') AS `bill_start_dt1`,`b`.`bill_cycle` AS `bill_cycle`,date_format(`b`.`bill_end_dt`,'%m-%d-%y') AS `bill_end_dt`,date_format(`b`.`bill_end_dt`,'%m.%d.%y') AS `bill_end_dt1`,`b`.`bill_pay_rate` AS `bill_pay_rate`,concat(convert(date_format(`a`.`last_updated`,'%m.%d.%y %H:%i:%s') using latin1),_latin1' ',(case when isnull(`a`.`updated_by`) then 'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end)) AS `mod_last_updated`,`a`.`updated_by` AS `updated_by` from ((((((((((`engage_budget` `a` left join `emp` `e` on((`e`.`emp_id` = `a`.`updated_by`))) left join `engage_entity_po` `b` on((`a`.`idengage_entity_po` = `b`.`idengage_entity_po`))) left join `engage_entity` `et` on((`b`.`idengage_entity` = `et`.`idengage_entity`))) left join `engage` `f` on((`f`.`engage_id` = `et`.`engage_id`))) left join `company` `g` on((`f`.`srv_client` = `g`.`comp_id`))) left join `company` `h` on((`f`.`srv_vendor` = `h`.`comp_id`))) left join `emp` `em` on((`a`.`engage_ref_id` = `em`.`emp_id`))) left join `company` `c` on((`a`.`engage_ref_id` = `c`.`comp_id`))) left join `emp` `em1` on((`et`.`engage_ref_id` = `em1`.`emp_id`))) left join `company` `c1` on((`et`.`engage_ref_id` = `c1`.`comp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_check_ssn_taxid`
--

/*!50001 DROP VIEW IF EXISTS `vw_check_ssn_taxid`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_check_ssn_taxid` AS select `e`.`emp_id` AS `emp_id`,`e`.`ssn` AS `ssn`,`e`.`taxid` AS `taxid` from `emp` `e` where ((`e`.`ssn` is not null) or (`e`.`taxid` is not null)) union all select `c`.`prosp_consult_id` AS `prosp_consult_id`,`c`.`ssn` AS `ssn`,`c`.`taxid` AS `taxid` from `prosp_consult` `c` where ((`c`.`ssn` is not null) or (`c`.`taxid` is not null)) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_client_vendor_1`
--

/*!50001 DROP VIEW IF EXISTS `vw_client_vendor_1`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_client_vendor_1` AS select `a`.`idengage_comp` AS `idengage_comp`,`a`.`engage_id` AS `engage_id`,`a`.`comp_id` AS `clients` from (`engage_comp` `a` left join `engage` `b` on((`a`.`engage_id` = `b`.`engage_id`))) where ((`a`.`engage_id` = `b`.`engage_id`) and (`a`.`comp_id` = `b`.`srv_client`)) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_client_vendor_11`
--

/*!50001 DROP VIEW IF EXISTS `vw_client_vendor_11`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_client_vendor_11` AS select `engage_comp`.`idengage_comp` AS `idengage_comp`,`engage_comp`.`engage_id` AS `engage_id`,`engage_comp`.`comp_id` AS `vendors` from `engage_comp` where (not(`engage_comp`.`idengage_comp` in (select `vw_client_vendor_1`.`idengage_comp` AS `idengage_comp` from `vw_client_vendor_1`))) order by `engage_comp`.`engage_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp1`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp1`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp1` AS select `company`.`comp_id` AS `comp_id`,`company`.`companyname` AS `companyname`,`company`.`company_info` AS `company_info`,`company`.`comp_website` AS `comp_website`,`company`.`comp_phone` AS `comp_phone`,`company`.`comp_email` AS `comp_email`,`company`.`comp_merge_id` AS `comp_merge_id`,`company`.`comp_tax_id` AS `comp_tax_id`,`company`.`updater` AS `updater`,date_format(`company`.`last_updated`,_utf8'%m-%d-%y') AS `last_updated`,`vw_comp4`.`Comp_Contact` AS `comp_contact`,`vw_company_address2`.`addresses` AS `comp_addresses`,`storages`.`file_name` AS `logofile`,concat(convert(date_format(`company`.`last_updated`,_utf8'%m-%d-%y') using latin1),_latin1' ',`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `mod_last_updated` from ((((`company` left join `storages` on((`storages`.`idstorage` = `company`.`idstorage`))) left join `emp` on((`emp`.`emp_id` = `company`.`updater`))) left join `vw_comp4` on((`vw_comp4`.`comp_id` = `company`.`comp_id`))) left join `vw_company_address2` on((`vw_company_address2`.`comp_id` = `company`.`comp_id`))) order by `company`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp2`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp2` AS select `a`.`comp_id` AS `comp_id`,`a`.`companyname` AS `companyname`,`c`.`comp_contact_id` AS `comp_contact_id`,`e`.`emp_id` AS `emp_id`,`d`.`comp_contact_no_id` AS `comp_contact_no_id`,`d`.`emp_contact_id` AS `contact_id`,concat(`h`.`firstname`,_latin1' ',`h`.`lastname`) AS `emp_name`,group_concat(concat(`f`.`look_values`,_latin1'->',`g`.`contact_detail`) separator ',') AS `contact_detail` from ((((((`company` `a` left join `comp_contact` `c` on((`a`.`comp_id` = `c`.`comp_id`))) left join `comp_contact_no` `d` on((`c`.`comp_contact_id` = `d`.`comp_contact_id`))) left join `emp_contact` `e` on((`d`.`emp_contact_id` = `e`.`emp_contact_id`))) left join `look_values` `f` on((`f`.`look_values_id` = `e`.`emp_contact_type`))) left join `contact_no` `g` on((`e`.`contact_id` = `g`.`contact_id`))) left join `emp` `h` on((`e`.`emp_id` = `h`.`emp_id`))) where (`g`.`contact_detail` is not null) group by `a`.`comp_id`,`e`.`emp_id` order by `a`.`comp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp3`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp3`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp3` AS select `comp_contact`.`comp_id` AS `comp_id`,`vw_company_contacts`.`emp_id` AS `emp_id`,`comp_contact`.`comp_contact_id` AS `comp_contact_id`,concat(`vw_company_contacts`.`firstname`,_latin1' ',`vw_company_contacts`.`lastname`) AS `Employee_Name`,`comp_contact`.`title` AS `title`,`comp_contact`.`description` AS `description`,group_concat(`vw_company_contacts`.`contact` separator '<br>') AS `contact` from ((`comp_contact` left join `comp_contact_no` on((`comp_contact`.`comp_contact_id` = `comp_contact_no`.`comp_contact_id`))) join `vw_company_contacts` on((`comp_contact_no`.`emp_contact_id` = `vw_company_contacts`.`emp_contact_id`))) group by `vw_company_contacts`.`emp_id`,`comp_contact`.`comp_id` order by `comp_contact_no`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp4`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp4`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp4` AS select `vw_comp3`.`comp_id` AS `comp_id`,group_concat(concat('Name',' - ',convert(`vw_comp3`.`Employee_Name` using utf8),'\n','Title',' - ',convert(`vw_comp3`.`title` using utf8),',\n','Desc',' - ',convert(`vw_comp3`.`description` using utf8),'\n',convert(`vw_comp3`.`contact` using utf8)) separator '\n\n') AS `Comp_Contact` from `vw_comp3` group by `vw_comp3`.`comp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_active`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_active`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_active` AS select `a`.`idcomp_active` AS `idcomp_active`,`a`.`comp_id` AS `comp_id`,ifnull(`c`.`companyname`,'None') AS `companyname`,`c`.`storage_file_name` AS `company_logo`,`a`.`comp_background` AS `comp_background`,`a`.`active_type` AS `active_type`,`a`.`publish` AS `publish`,`a`.`manage_by` AS `manage_by`,ifnull(`m`.`fullname`,'Admin') AS `manager_name`,`a`.`client_since` AS `client_since`,`a`.`last_updated` AS `last_updated`,`a`.`updater` AS `updater_id`,ifnull(`u`.`fullname`,'Admin') AS `updater`,`a`.`del_dt` AS `del_dt_unformatted`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,`a`.`del_by` AS `del_by_id`,ifnull(`e_del_by`.`fullname`,'Admin') AS `del_by`,`e_del_by`.`emp_file_name` AS `del_by_file_name`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt_unformatted`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt`,`a`.`archv_by` AS `archv_by_id`,ifnull(`e_archv_by`.`fullname`,'Admin') AS `archv_by`,`e_archv_by`.`emp_file_name` AS `archv_by_file_name` from (((((`comp_active` `a` left join `vw_company` `c` on((`a`.`comp_id` = `c`.`comp_id`))) left join `vw_emp` `m` on((`a`.`manage_by` = `m`.`emp_id`))) left join `vw_emp` `u` on((`a`.`updater` = `u`.`emp_id`))) left join `vw_emp` `e_del_by` on((`a`.`del_by` = `e_del_by`.`emp_id`))) left join `vw_emp` `e_archv_by` on((`a`.`archv_by` = `e_archv_by`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_billing_details`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_billing_details`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_billing_details` AS select `c`.`companyname` AS `companyname`,`eep`.`bill_pay_rate` AS `bill_pay_rate`,`eb`.`engage_calc` AS `engage_calc`,`eb`.`engage_amt` AS `engage_amt`,`eb`.`engage_st_dt` AS `engage_st_dt`,`eb`.`engage_end_st` AS `engage_end_st`,`eb`.`limit_amt` AS `limit_amt`,`eb`.`engage_summary` AS `engage_summary`,`eb`.`engage_ref_id` AS `engage_ref_id` from ((((`engage` `e` left join `engage_entity` `ee` on((`e`.`engage_id` = `ee`.`engage_id`))) left join `engage_entity_po` `eep` on((`ee`.`idengage_entity` = `eep`.`idengage_entity`))) left join `engage_budget` `eb` on((`eb`.`idengage_entity_po` = `eep`.`idengage_entity_po`))) left join `company` `c` on((`c`.`comp_id` = `e`.`srv_client`))) where ((`eb`.`show_emp` = (select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where ((`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'yes_no'))) and (`look_values`.`look_values` = _latin1'Yes')))) and (`eb`.`engage_ref_table` = _latin1'Company')) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_contracts`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_contracts` AS select `a`.`engage_id` AS `engage_id`,`a`.`srv_st_dt` AS `srv_st_dt`,`a`.`srv_e_dt` AS `srv_e_dt`,`a`.`sr_frequency` AS `sr_frequency`,`a`.`srv_paytype` AS `srv_paytype`,`a`.`srv_amount` AS `srv_amount`,`a`.`eg_sumry` AS `eg_sumry`,`a`.`srv_client` AS `srv_client`,`a`.`comp_id` AS `comp_id`,`a`.`mod_srv_st_dt` AS `mod_srv_st_dt`,`a`.`mod_srv_st_dt1` AS `mod_srv_st_dt1`,`a`.`mod_srv_e_dt` AS `mod_srv_e_dt`,`a`.`mod_srv_e_dt1` AS `mod_srv_e_dt1`,`a`.`frequency` AS `frequency`,`a`.`paytype` AS `paytype`,`a`.`engage_doc_id` AS `engage_doc_id`,`a`.`last_updated` AS `last_updated`,`a`.`srv_client_name` AS `srv_client_name`,`a`.`companyname` AS `companyname`,`a`.`updated_by` AS `updated_by`,`a`.`freqypaytype` AS `freqypaytype`,`a`.`last_updter` AS `last_updter`,`a`.`last_updter1` AS `last_updter1`,(select `v`.`idengage_comp` AS `idengage_comp` from `vw_comp_contracts_contacts_details` `v` where ((`v`.`engage_id` = `a`.`engage_id`) and (`v`.`comp_id` = `a`.`comp_id`))) AS `idengage_comp`,(select concat(`cd`.`companyname`,_latin1' ',`cd`.`client_vendor_contacts`) AS `concat(companyname,' ',client_vendor_contacts)` from `vw_comp_contracts_contacts_details` `cd` where ((`cd`.`engage_id` = `a`.`engage_id`) and (`cd`.`comp_id` = `a`.`srv_client`))) AS `client_address`,(select concat(`vd`.`companyname`,_latin1' ',`vd`.`client_vendor_contacts`) AS `concat(companyname,' ',client_vendor_contacts)` from `vw_comp_contracts_contacts_details` `vd` where ((`vd`.`engage_id` = `a`.`engage_id`) and (`vd`.`comp_id` = `a`.`comp_id`))) AS `vendor_address` from (`vw_engage_details` `a` left join `vw_comp_contracts_contacts_details` `b` on((`a`.`engage_id` = `b`.`engage_id`))) group by `a`.`engage_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_contracts_addr_contacts`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_addr_contacts`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_contracts_addr_contacts` AS select `ad`.`idengage_add` AS `idengage_add`,`ad`.`idengage_comp` AS `idengage_comp`,`ad`.`comp_add_id` AS `comp_add_id`,`ad`.`add_type` AS `add_type`,`con`.`idengage_add_con` AS `idengage_add_con`,`con`.`comp_contact_no_id` AS `comp_contact_no_id`,`con`.`contact_notes` AS `contact_notes` from (`engage_add` `ad` left join `engage_add_con` `con` on((`ad`.`idengage_add` = `con`.`idengage_add`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_contracts_addr_contacts2`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_addr_contacts2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_contracts_addr_contacts2` AS select `en`.`engage_id` AS `engage_id`,`en`.`srv_st_dt` AS `srv_st_dt`,`en`.`srv_e_dt` AS `srv_e_dt`,`en`.`sr_frequency` AS `sr_frequency`,`en`.`srv_paytype` AS `srv_paytype`,`en`.`srv_amt` AS `srv_amount`,`en`.`eg_sumry` AS `eg_sumry`,`en`.`srv_client` AS `srv_client`,`ec`.`idengage_comp` AS `idengage_comp`,`ec`.`comp_id` AS `comp_id`,date_format(`en`.`srv_st_dt`,_utf8'%m-%d-%y') AS `mod_srv_st_dt`,date_format(`en`.`srv_e_dt`,_utf8'%m-%d-%y') AS `mod_srv_e_dt`,`lv`.`look_values` AS `frequency`,`lvp`.`look_values` AS `paytype`,`c`.`companyname` AS `srv_client_name`,`cc`.`companyname` AS `companyname`,`en`.`last_updated` AS `last_updated`,(case when (`en`.`updated_by` = _utf8'0') then 'Admin' else concat(`e`.`firstname`,_latin1'',`e`.`lastname`) end) AS `updated_by`,concat(`lv`.`look_values`,_latin1'-',`lvp`.`look_values`) AS `freqypaytype`,concat(convert(date_format(`en`.`last_updated`,_utf8'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',(case when (`en`.`updated_by` = _utf8'0') then 'Admin' else concat(`e`.`firstname`,_latin1'',`e`.`lastname`) end)) AS `last_updter`,`ad`.`idengage_add` AS `idengage_add_vendor`,`ad`.`comp_add_id` AS `comp_add_id_vendor`,`ad2`.`idengage_add` AS `idengage_add_client`,`ad2`.`comp_add_id` AS `comp_add_id_client`,(select cast(group_concat(`vw_comp_contracts_addr_contacts`.`comp_contact_no_id` separator ',') as char charset utf8) AS `convert( GROUP_CONCAT( comp_contact_no_id ) , char )` from `vw_comp_contracts_addr_contacts` where (`vw_comp_contracts_addr_contacts`.`idengage_add` = `ad2`.`idengage_add`)) AS `client_contacts`,(select cast(group_concat(`vw_comp_contracts_addr_contacts`.`comp_contact_no_id` separator ',') as char charset utf8) AS `convert( GROUP_CONCAT( comp_contact_no_id ) , char )` from `vw_comp_contracts_addr_contacts` where (`vw_comp_contracts_addr_contacts`.`idengage_add` = `ad`.`idengage_add`)) AS `vendor_contacts` from ((((((((`engage_comp` `ec` left join `engage` `en` on((`en`.`engage_id` = `ec`.`engage_id`))) left join `company` `c` on((`en`.`srv_client` = `c`.`comp_id`))) left join `company` `cc` on((`ec`.`comp_id` = `cc`.`comp_id`))) left join `look_values` `lv` on((`en`.`sr_frequency` = `lv`.`look_values_id`))) left join `look_values` `lvp` on((`en`.`srv_paytype` = `lvp`.`look_values_id`))) left join `emp` `e` on((`en`.`updated_by` = `e`.`emp_id`))) left join `engage_add` `ad` on((`ec`.`idengage_comp` = `ad`.`idengage_comp`))) left join `engage_add` `ad2` on(((`ec`.`idengage_comp` - 1) = `ad2`.`idengage_comp`))) where ((`lv`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'bill.detail.bill.cycle'))) and (`lvp`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'contract_pay_type'))) and (`en`.`srv_client` <> `ec`.`comp_id`)) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_contracts_addr_contacts_details`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_addr_contacts_details`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_contracts_addr_contacts_details` AS select `a`.`idengage_add` AS `idengage_add`,`a`.`idengage_comp` AS `idengage_comp`,`a`.`comp_add_id` AS `comp_add_id`,`a`.`add_type` AS `add_type_id`,`c`.`look_values` AS `add_type`,`a`.`idengage_add_con` AS `idengage_add_con`,`a`.`comp_contact_no_id` AS `comp_contact_no_id`,group_concat(`a`.`contact_notes` separator ', ') AS `contact_notes`,`b`.`comp_id` AS `comp_id`,group_concat(concat(`b`.`emp_name`,_latin1' - ',`b`.`contact_detail`) separator ', ') AS `client_vendor_contacts`,`d`.`addresses` AS `addresses` from (((`vw_comp_contracts_addr_contacts` `a` left join `vw_comp_contracts_contacts` `b` on((`a`.`comp_contact_no_id` = `b`.`comp_contact_no_id`))) left join `look_values` `c` on((`a`.`add_type` = `c`.`look_values_id`))) left join `vw_company_address2` `d` on(((`b`.`comp_id` = `d`.`comp_id`) and (`a`.`comp_add_id` = `d`.`comp_add_id`)))) group by `a`.`idengage_add`,`a`.`idengage_comp`,`a`.`comp_add_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_contracts_contacts`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_contacts`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_contracts_contacts` AS select `a`.`comp_id` AS `comp_id`,`a`.`companyname` AS `companyname`,`c`.`comp_contact_id` AS `comp_contact_id`,`e`.`emp_id` AS `emp_id`,`d`.`comp_contact_no_id` AS `comp_contact_no_id`,`d`.`emp_contact_id` AS `contact_id`,concat(`h`.`firstname`,_latin1' ',`h`.`lastname`) AS `emp_name`,concat(`f`.`look_values`,_latin1'->',`g`.`contact_detail`) AS `contact_detail` from ((((((`company` `a` left join `comp_contact` `c` on((`a`.`comp_id` = `c`.`comp_id`))) left join `comp_contact_no` `d` on((`c`.`comp_contact_id` = `d`.`comp_contact_id`))) left join `emp_contact` `e` on((`d`.`emp_contact_id` = `e`.`emp_contact_id`))) left join `look_values` `f` on((`f`.`look_values_id` = `e`.`emp_contact_type`))) left join `contact_no` `g` on((`e`.`contact_id` = `g`.`contact_id`))) left join `emp` `h` on((`e`.`emp_id` = `h`.`emp_id`))) where (`g`.`contact_detail` is not null) order by `a`.`comp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_contracts_contacts_details`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_contacts_details`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_contracts_contacts_details` AS select `a`.`idengage_comp` AS `idengage_comp`,`a`.`engage_id` AS `engage_id`,`a`.`comp_id` AS `comp_id`,`b`.`idengage_add` AS `idengage_add`,`b`.`comp_add_id` AS `comp_add_id`,`c`.`companyname` AS `companyname`,group_concat(`b`.`add_type` separator ', ') AS `add_type`,group_concat(`b`.`contact_notes` separator ' ') AS `contact_notes`,group_concat(concat(`b`.`addresses`,_latin1' Contacts: ',`b`.`client_vendor_contacts`) separator ' || ') AS `client_vendor_contacts` from ((`engage_comp` `a` left join `vw_comp_contracts_addr_contacts_details` `b` on(((`a`.`idengage_comp` = `b`.`idengage_comp`) and (`a`.`comp_id` = `b`.`comp_id`)))) left join `company` `c` on((`a`.`comp_id` = `c`.`comp_id`))) group by `a`.`engage_id`,`a`.`comp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_contracts_old`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_contracts_old`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_contracts_old` AS select `en`.`engage_id` AS `engage_id`,`en`.`srv_st_dt` AS `srv_st_dt`,`en`.`srv_e_dt` AS `srv_e_dt`,`en`.`sr_frequency` AS `sr_frequency`,`en`.`srv_paytype` AS `srv_paytype`,`en`.`srv_amt` AS `srv_amount`,`en`.`eg_sumry` AS `eg_sumry`,`en`.`srv_client` AS `srv_client`,`ec`.`idengage_comp` AS `idengage_comp`,concat(convert(`c`.`companyname` using utf8),_utf8' -  ',(select group_concat(cast(`vw_company_address2`.`addresses` as char charset utf8) separator ',') AS `cli` from `vw_company_address2` where `vw_company_address2`.`comp_add_id` in (select `engage_add`.`comp_add_id` AS `comp_add_id` from `engage_add` where (`engage_add`.`idengage_comp` = (`ec`.`idengage_comp` - 1))))) AS `client_address`,concat(convert(`cc`.`companyname` using utf8),_utf8' -  ',(select group_concat(cast(`vw_company_address2`.`addresses` as char charset utf8) separator ',') AS `vcli` from `vw_company_address2` where `vw_company_address2`.`comp_add_id` in (select `engage_add`.`comp_add_id` AS `comp_add_id` from `engage_add` where (`engage_add`.`idengage_comp` = `ec`.`idengage_comp`)))) AS `vendor_address`,`ec`.`comp_id` AS `comp_id`,date_format(`en`.`srv_st_dt`,_utf8'%m-%d-%y') AS `mod_srv_st_dt`,date_format(`en`.`srv_e_dt`,_utf8'%m-%d-%y') AS `mod_srv_e_dt`,`lv`.`look_values` AS `frequency`,`lvp`.`look_values` AS `paytype`,`c`.`companyname` AS `srv_client_name`,`t`.`engage_doc_id` AS `engage_doc_id`,`cc`.`companyname` AS `companyname`,`en`.`last_updated` AS `last_updated`,(case when (`en`.`updated_by` = _utf8'0') then 'Admin' else concat(`e`.`firstname`,_latin1'',`e`.`lastname`) end) AS `updated_by`,concat(`lv`.`look_values`,_latin1'-',`lvp`.`look_values`) AS `freqypaytype`,concat(convert(date_format(`en`.`last_updated`,_utf8'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',(case when (`en`.`updated_by` = _utf8'0') then 'Admin' else concat(`e`.`firstname`,_latin1'',`e`.`lastname`) end)) AS `last_updter` from (((((((`engage_comp` `ec` left join `engage` `en` on((`en`.`engage_id` = `ec`.`engage_id`))) left join `company` `c` on((`en`.`srv_client` = `c`.`comp_id`))) left join `company` `cc` on((`ec`.`comp_id` = `cc`.`comp_id`))) left join `look_values` `lv` on((`en`.`sr_frequency` = `lv`.`look_values_id`))) left join `look_values` `lvp` on((`en`.`srv_paytype` = `lvp`.`look_values_id`))) left join `emp` `e` on((`en`.`updated_by` = `e`.`emp_id`))) left join `vw_contracts_attach` `t` on((`t`.`engage_id` = `en`.`engage_id`))) where ((`lv`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'bill.detail.bill.cycle'))) and (`lvp`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'contract_pay_type'))) and (`en`.`srv_client` <> `ec`.`comp_id`)) group by `en`.`engage_id` order by `en`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_prdt`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_prdt`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`heshmapatel`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_prdt` AS select `cp`.`idcomp_prdt` AS `idcomp_prdt`,`cp`.`comp_id` AS `comp_id`,`cmp`.`companyname` AS `companyname`,`cp`.`prdt_nm` AS `prdt_nm`,`cp`.`prdt_family` AS `prdt_family`,`cp`.`idasset_look` AS `idasset_look`,`asl`.`asset_name` AS `asset_name`,`cp`.`idasset_look_value` AS `idasset_look_value`,`aslv`.`asset_value` AS `asset_value`,`cp`.`stocking` AS `stocking`,`cp`.`dscont_dt` AS `dscont_dt`,`cp`.`updater` AS `updater` from (((`development`.`comp_prdt` `cp` join `development`.`company` `cmp` on((`cmp`.`comp_id` = `cp`.`comp_id`))) join `development`.`asset_lk` `asl` on((`asl`.`idasset_look` = `cp`.`idasset_look`))) join `development`.`asset_lk_val` `aslv` on((`aslv`.`idasset_look_value` = `cp`.`idasset_look_value`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_comp_reg_report`
--

/*!50001 DROP VIEW IF EXISTS `vw_comp_reg_report`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_comp_reg_report` AS select `CR`.`comp_reg_id` AS `comp_reg_id`,`CR`.`comp_id` AS `comp_id`,`C`.`companyname` AS `companyname`,`CR`.`state_id` AS `state_id`,`LS`.`state_name` AS `state_name`,`CRD`.`comp_reg_dept_id` AS `comp_reg_dept_id`,`LV`.`look_values` AS `dept`,`CRD`.`dept_id` AS `dept_id`,`CRD`.`reg_number` AS `reg_number`,`CRDT`.`comp_reg_dept_dt_id` AS `comp_reg_dept_dt_id`,`CRDT`.`comp_open_dt` AS `comp_open_dt`,`CRDT`.`comp_close_dt` AS `comp_close_dt`,date_format(`CRDT`.`comp_open_dt`,_utf8'%m-%d-%y') AS `mod_comp_open_dt`,date_format(`CRDT`.`comp_close_dt`,_utf8'%m-%d-%y') AS `mod_comp_close_dt`,`CR`.`last_updated` AS `mod_last_updated`,concat(convert(date_format(`CR`.`last_updated`,_utf8'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',(case when (`CR`.`updated_by` = _utf8'0') then 'Admin' else concat(`e`.`firstname`,_latin1'',`e`.`lastname`) end)) AS `last_updated` from ((((((`comp_reg` `CR` left join `comp_reg_dept` `CRD` on((`CR`.`comp_reg_id` = `CRD`.`comp_reg_id`))) left join `comp_reg_dept_dt` `CRDT` on((`CRD`.`comp_reg_dept_id` = `CRDT`.`comp_reg_dept_id`))) left join `company` `C` on((`CR`.`comp_id` = `C`.`comp_id`))) left join `look_state` `LS` on((`CR`.`state_id` = `LS`.`state_id`))) left join `look_values` `LV` on((`CRD`.`dept_id` = `LV`.`look_values_id`))) left join `emp` `e` on((`CR`.`updated_by` = `e`.`emp_id`))) where ((`LV`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'department'))) and (`CRDT`.`comp_reg_dept_dt_id` is not null)) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_company`
--

/*!50001 DROP VIEW IF EXISTS `vw_company`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_company` AS select `a`.`comp_id` AS `comp_id`,`a`.`idstorage` AS `idstorage`,`s`.`file_name` AS `storage_file_name`,`a`.`companyname` AS `companyname`,`a`.`comp_tax_id` AS `comp_tax_id`,`a`.`company_info` AS `company_info`,`a`.`comp_website` AS `comp_website`,`a`.`comp_phone` AS `comp_phone`,`a`.`comp_email` AS `comp_email`,`a`.`comp_merge_id` AS `comp_merge_id`,`a`.`last_updated` AS `last_updated_unformatted`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated`,`a`.`updater` AS `updater_id`,ifnull(`u`.`fullname`,'Admin') AS `updater`,`a`.`del_dt` AS `del_dt_unformatted`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,`a`.`del_by` AS `del_by_id`,ifnull(`e_del_by`.`fullname`,'Admin') AS `del_by`,`e_del_by`.`emp_file_name` AS `del_by_file_name`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt_unformatted`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt`,`a`.`archv_by` AS `archv_by_id`,ifnull(`e_archv_by`.`fullname`,'Admin') AS `archv_by`,`e_archv_by`.`emp_file_name` AS `archv_by_file_name` from ((((`company` `a` left join `vw_emp` `u` on((`a`.`updater` = `u`.`emp_id`))) left join `vw_emp` `e_del_by` on((`a`.`del_by` = `e_del_by`.`emp_id`))) left join `vw_emp` `e_archv_by` on((`a`.`archv_by` = `e_archv_by`.`emp_id`))) left join `storages` `s` on((`a`.`idstorage` = `s`.`idstorage`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_company_address`
--

/*!50001 DROP VIEW IF EXISTS `vw_company_address`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_company_address` AS select `comp_address`.`comp_add_id` AS `comp_add_id`,`comp_address`.`add_type` AS `add_type`,`comp_address`.`add_type2` AS `add_type2`,`comp_address`.`comp_id` AS `comp_id`,`comp_address`.`suite_no` AS `suite_no`,`look_street_no`.`look_street_no` AS `look_street_no`,`look_street`.`street_name` AS `street_name`,`look_postal`.`zip_code` AS `zip_code`,`look_city`.`city_name` AS `city_name`,`look_state`.`state_name` AS `state_name`,`comp_address`.`look_street_no_id` AS `look_street_no_id`,`look_street_no`.`look_street_id` AS `look_street_id`,`look_street`.`street_type` AS `street_type`,`look_values`.`look_values` AS `street_type_name` from ((((((`comp_address` left join `look_street_no` on((`comp_address`.`look_street_no_id` = `look_street_no`.`look_street_no_id`))) left join `look_street` on((`look_street_no`.`look_street_id` = `look_street`.`look_street_id`))) left join `look_postal` on((`look_street`.`postal_id` = `look_postal`.`postal_id`))) left join `look_city` on((`look_postal`.`city_id` = `look_city`.`city_id`))) left join `look_state` on((`look_city`.`state_id` = `look_state`.`state_id`))) left join `look_values` on((`look_values`.`look_values_id` = `look_street`.`street_type`))) order by `comp_address`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_company_address2`
--

/*!50001 DROP VIEW IF EXISTS `vw_company_address2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_company_address2` AS select `vw_company_address`.`comp_add_id` AS `comp_add_id`,`vw_company_address`.`add_type` AS `add_type`,`vw_company_address`.`add_type2` AS `add_type2`,`vw_company_address`.`comp_id` AS `comp_id`,concat_ws(_latin1' ',`vw_company_address`.`look_street_no`,_latin1' ',`vw_company_address`.`street_name`,_latin1'',(select `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `vw_company_address`.`street_type`)),(case when (`vw_company_address`.`suite_no` = _latin1'') then _latin1'' else concat(_latin1'Suite:',`vw_company_address`.`suite_no`) end),_latin1',',`vw_company_address`.`city_name`,_latin1' ',`vw_company_address`.`state_name`,_latin1' ',`vw_company_address`.`zip_code`) AS `addresses` from `vw_company_address` where (`vw_company_address`.`look_street_no_id` is not null) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_company_contacts`
--

/*!50001 DROP VIEW IF EXISTS `vw_company_contacts`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_company_contacts` AS select `e`.`emp_id` AS `emp_id`,`ec`.`emp_contact_id` AS `emp_contact_id`,`e`.`firstname` AS `firstname`,`e`.`lastname` AS `lastname`,concat(`l`.`look_values`,_latin1' - ',`cn`.`contact_detail`) AS `contact` from (((`emp` `e` left join `emp_contact` `ec` on((`e`.`emp_id` = `ec`.`emp_id`))) left join `look_values` `l` on((`l`.`look_values_id` = `ec`.`emp_contact_type`))) left join `contact_no` `cn` on((`cn`.`contact_id` = `ec`.`contact_id`))) order by `e`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_company_owners`
--

/*!50001 DROP VIEW IF EXISTS `vw_company_owners`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_company_owners` AS select `co`.`comp_own_id` AS `comp_own_id`,`co`.`comp_id` AS `comp_id`,`co`.`emp_id` AS `emp_id`,`cmp`.`companyname` AS `companyname`,(case when (`co`.`emp_id` <> 0) then concat_ws(_latin1' ',`e`.`firstname`,`e`.`lastname`) else 'Admin' end) AS `employee`,`co`.`owner_share` AS `owner_share`,date_format(`co`.`share_dt_from`,_utf8'%m-%d-%y') AS `share_dt_from`,date_format(`co`.`share_dt_to`,_utf8'%m-%d-%y') AS `share_dt_to` from ((`company_owners` `co` left join `company` `cmp` on((`co`.`comp_id` = `cmp`.`comp_id`))) left join `emp` `e` on((`co`.`emp_id` = `e`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_company_reg`
--

/*!50001 DROP VIEW IF EXISTS `vw_company_reg`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_company_reg` AS select `CR`.`comp_reg_id` AS `comp_reg_id`,`CR`.`comp_id` AS `comp_id`,`C`.`companyname` AS `companyname`,`CR`.`state_id` AS `state_id`,`LS`.`state_name` AS `state_name`,`CRD`.`comp_reg_dept_id` AS `comp_reg_dept_id`,`LV`.`look_values` AS `dept`,`CRD`.`dept_id` AS `dept_id`,`CRD`.`reg_number` AS `reg_number`,`CRDT`.`comp_reg_dept_dt_id` AS `comp_reg_dept_dt_id`,`CRDT`.`comp_open_dt` AS `comp_open_dt`,`CRDT`.`comp_close_dt` AS `comp_close_dt`,date_format(`CRDT`.`comp_open_dt`,_utf8'%m-%d-%y') AS `mod_comp_open_dt`,date_format(`CRDT`.`comp_close_dt`,_utf8'%m-%d-%y') AS `mod_comp_close_dt` from (((((`comp_reg` `CR` join `comp_reg_dept` `CRD` on((`CR`.`comp_reg_id` = `CRD`.`comp_reg_id`))) join `comp_reg_dept_dt` `CRDT` on((`CRD`.`comp_reg_dept_id` = `CRDT`.`comp_reg_dept_id`))) join `company` `C` on((`CR`.`comp_id` = `C`.`comp_id`))) join `look_state` `LS` on((`CR`.`state_id` = `LS`.`state_id`))) join `look_values` `LV` on((`CRD`.`dept_id` = `LV`.`look_values_id`))) where (`LV`.`look_table` = 3) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_company_reg_cmp`
--

/*!50001 DROP VIEW IF EXISTS `vw_company_reg_cmp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_company_reg_cmp` AS select `vw_company_reg`.`comp_reg_id` AS `comp_reg_id`,`vw_company_reg`.`comp_id` AS `comp_id`,`vw_company_reg`.`companyname` AS `companyname`,`vw_company_reg`.`state_id` AS `state_id`,`vw_company_reg`.`state_name` AS `state_name`,`vw_company_reg`.`comp_reg_dept_id` AS `comp_reg_dept_id`,`vw_company_reg`.`dept` AS `dept`,`vw_company_reg`.`dept_id` AS `dept_id`,`vw_company_reg`.`reg_number` AS `reg_number`,`vw_company_reg`.`comp_reg_dept_dt_id` AS `comp_reg_dept_dt_id`,`vw_company_reg`.`comp_open_dt` AS `comp_open_dt`,`vw_company_reg`.`comp_close_dt` AS `comp_close_dt`,if((`vw_company_reg`.`comp_close_dt` <> _utf8'1969-12-31'),`vw_company_reg`.`comp_close_dt`,curdate()) AS `comp_close_dt1` from `vw_company_reg` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_config_feature_grp`
--

/*!50001 DROP VIEW IF EXISTS `vw_config_feature_grp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_config_feature_grp` AS select `a`.`idfeature_grp` AS `idfeature_grp`,`s`.`file_name` AS `updater_file_name`,`a`.`feature_id` AS `feature_id`,`b`.`group_name` AS `group_name`,`b`.`group_desc` AS `group_desc`,`b`.`updater` AS `updater_id`,if((isnull(`b`.`updater`) or (`b`.`updater` = 0)),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updater`,`b`.`last_updated` AS `last_updated` from (((`feature_grp_list` `a` left join `feature_grp` `b` on((`a`.`idfeature_grp` = `b`.`idfeature_grp`))) left join `emp` `e` on((`b`.`updater` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_config_feature_load_emp`
--

/*!50001 DROP VIEW IF EXISTS `vw_config_feature_load_emp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_config_feature_load_emp` AS select `a`.`access_id` AS `access_id`,`s`.`file_name` AS `emp_file_name`,`b`.`feature_id` AS `feature_id`,`a`.`emp_id` AS `emp_id`,concat(`e`.`firstname`,' ',`e`.`lastname`) AS `emp_name`,`a`.`last_updated` AS `last_updated`,`a`.`updated_by` AS `updater` from (((`emp_access` `a` left join `vw_feature` `b` on((`a`.`feature_id` = `b`.`feature_id`))) left join `emp` `e` on((`a`.`emp_id` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_constctzip`
--

/*!50001 DROP VIEW IF EXISTS `vw_constctzip`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_constctzip` AS select `con`.`country_id` AS `country_id`,`con`.`con_name` AS `con_name`,`st`.`state_id` AS `state_id`,`st`.`state_name` AS `state_name`,`ct`.`city_id` AS `city_id`,`ct`.`city_name` AS `city_name`,`p`.`postal_id` AS `postal_id`,`p`.`zip_code` AS `zip_code` from (((`look_country` `con` join `look_state` `st`) join `look_city` `ct`) join `look_postal` `p`) where ((`con`.`country_id` = `st`.`country_id`) and (`st`.`state_id` = `ct`.`state_id`) and (`ct`.`city_id` = `p`.`city_id`)) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_constctzipstreet`
--

/*!50001 DROP VIEW IF EXISTS `vw_constctzipstreet`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_constctzipstreet` AS select `con`.`country_id` AS `country_id`,`con`.`con_name` AS `con_name`,`st`.`state_id` AS `state_id`,`st`.`state_name` AS `state_name`,`ct`.`city_id` AS `city_id`,`ct`.`city_name` AS `city_name`,`p`.`postal_id` AS `postal_id`,`p`.`zip_code` AS `zip_code`,`s`.`look_street_id` AS `look_street_id`,`s`.`street_name` AS `street_name` from ((((`look_country` `con` join `look_state` `st`) join `look_city` `ct`) join `look_postal` `p`) join `look_street` `s`) where ((`con`.`country_id` = `st`.`country_id`) and (`st`.`state_id` = `ct`.`state_id`) and (`ct`.`city_id` = `p`.`city_id`) and (`p`.`postal_id` = `s`.`postal_id`)) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_consultant`
--

/*!50001 DROP VIEW IF EXISTS `vw_consultant`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_consultant` AS select concat_ws(_latin1'',`e`.`firstname`,`e`.`lastname`) AS `name`,`vpca`.`prosp_consult_id` AS `prosp_consult_id`,`vpca`.`prosp_first_name` AS `prosp_first_name`,`vpca`.`prosp_last_name` AS `prosp_last_name`,`vpca`.`prosp_level` AS `prosp_level`,`vpca`.`prosp_summary` AS `prosp_summary`,`vpca`.`prosp_activity_id` AS `prosp_activity_id`,`vpca`.`call_recv_dt` AS `call_recv_dt`,`vpca`.`emp_id` AS `emp_id`,`vpca`.`next_call_dt` AS `next_call_dt`,`vpca`.`call_note` AS `call_note`,`vpca`.`last_update` AS `last_update` from (`vw_prosp_consult_activity` `vpca` left join `emp` `e` on((`e`.`emp_id` = `vpca`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_contracts_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_contracts_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_contracts_attach` AS select `a`.`engage_doc_id` AS `engage_doc_id`,`a`.`doc_type` AS `doc_type`,`d`.`look_values` AS `doc_look_values`,`a`.`expire_dt` AS `expire_dt`,date_format(`a`.`expire_dt`,_utf8'%m-%d-%y') AS `mod_expire_dt`,`b`.`engage_id` AS `engage_id`,`a`.`idstorage` AS `idstorage`,`c`.`owner_id` AS `owner_id`,`c`.`file_name` AS `file_name`,`c`.`public` AS `public`,`c`.`self_view` AS `self_view`,`c`.`shared` AS `shared`,`c`.`emp_id` AS `emp_id`,`c`.`updated_for_ref_id` AS `updated_for_ref_id`,`c`.`updated_for_ref_table` AS `updated_for_ref_table` from (((`engage_doc` `a` left join `storages` `c` on((`a`.`idstorage` = `c`.`idstorage`))) left join `engage` `b` on((`a`.`engage_id` = `b`.`engage_id`))) left join `look_values` `d` on((`a`.`doc_type` = `d`.`look_values_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_contracts_po`
--

/*!50001 DROP VIEW IF EXISTS `vw_contracts_po`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_contracts_po` AS select `p`.`idengage_entity_po` AS `idengage_entity_po`,`p`.`idengage_entity` AS `idengage_entity`,`et`.`engage_id` AS `engage_id`,`et`.`engage_ref_id` AS `engage_ref_id`,`lvr`.`look_values_id` AS `engage_ref_tab_id`,`et`.`engage_ref_tab` AS `engage_ref_tab`,(case when (`et`.`engage_ref_tab` = 'Company') then concat(`c`.`companyname`) when (`et`.`engage_ref_tab` = 'Employee') then (case when isnull(`et`.`engage_ref_id`) then 'Admin' else concat(`em`.`firstname`,_latin1' ',`em`.`lastname`) end) end) AS `engage_ref_id_name`,concat(convert((case when isnull(`et`.`engage_ref_tab`) then '' else (case when (`et`.`engage_ref_tab` = 'Company') then 'Comp' when (`et`.`engage_ref_tab` = 'Employee') then 'Emp' end) end) using latin1),':',(case when (`et`.`engage_ref_tab` = 'Company') then concat(`c`.`companyname`) when (`et`.`engage_ref_tab` = 'Employee') then (case when (`et`.`engage_ref_id` = '') then 'Admin' else concat(`em`.`firstname`,_latin1' ',`em`.`lastname`) end) end)) AS `po_candidate_name`,`et`.`entity_parent` AS `entity_parent`,`c1`.`companyname` AS `client name`,`cc`.`companyname` AS `Vender name`,`cn`.`client_address` AS `client_address`,`cn`.`vendor_address` AS `vendor_address`,`cn`.`mod_srv_st_dt1` AS `con_srv_st_dt`,`cn`.`mod_srv_e_dt1` AS `con_srv_e_dt`,`p`.`bill_start_dt` AS `bill_start_dt`,date_format(`p`.`bill_start_dt`,'%m-%d-%y') AS `mod_bill_start_dt`,date_format(`p`.`bill_start_dt`,'%m.%d.%y') AS `mod_bill_start_dt1`,`p`.`bill_cycle` AS `bill_cycle`,`lv`.`look_values` AS `bill_cycle_name`,`p`.`bill_end_dt` AS `bill_end_dt`,date_format(`p`.`bill_end_dt`,'%m-%d-%y') AS `mod_bill_end_dt`,date_format(`p`.`bill_end_dt`,'%m.%d.%y') AS `mod_bill_end_dt1`,`p`.`bill_fst_dt` AS `bill_fst_dt`,date_format(`p`.`bill_fst_dt`,'%m-%d-%y') AS `mod_bill_fst_dt`,`p`.`bill_day` AS `bill_day`,`lvp`.`look_values` AS `bill_day_name`,`p`.`bill_pay_type` AS `bill_pay_type`,`lvt`.`look_values` AS `bill_pay_type_name`,`p`.`bill_pay_rate` AS `bill_pay_rate`,`p`.`ts_cycle` AS `ts_cycle`,`p`.`bill_cyle_run` AS `bill_cyle_run`,date_format(`p`.`bill_last_run`,'%m.%d.%y') AS `bill_last_run`,`p`.`ts_cycle_run` AS `ts_cycle_run`,date_format(`p`.`ts_last_run`,'%m.%d.%y') AS `ts_last_run`,`p`.`mon_cycle_run` AS `mon_cycle_run`,date_format(`p`.`mon_last_run`,'%m.%d.%y') AS `mon_last_run`,`lvts`.`look_values` AS `ts_cycle_name`,`p`.`ts_fst_dt` AS `ts_fst_dt`,date_format(`p`.`ts_fst_dt`,'%m-%d-%y') AS `mod_ts_fst_dt`,`p`.`netpay` AS `netpay`,`p`.`bill_pay_rate_xtra` AS `bill_pay_rate_xtra`,`p`.`bill_hrs_min` AS `bill_hrs_min`,`p`.`bill_title` AS `bill_title`,`dlvts`.`look_value` AS `bill_title_name`,`p`.`tentative_end_dt` AS `tentative_end_dt`,date_format(`p`.`tentative_end_dt`,'%m-%d-%y') AS `mod_tentative_end_dt`,`p`.`summary` AS `summary`,`p`.`cloud_drive` AS `cloud_drive`,`p`.`idstorage` AS `idstorage`,`p`.`actions` AS `actions`,(case when isnull(`p`.`updated_by`) then 'Admin' else concat(`e`.`firstname`,_latin1'',`e`.`lastname`) end) AS `updated_by`,`p`.`last_update` AS `last_update`,`p`.`allow_inv` AS `allow_inv`,`p`.`show_emp` AS `show_emp`,concat(convert(date_format(`p`.`last_update`,'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',(case when isnull(`p`.`updated_by`) then 'Admin' else concat(`e`.`firstname`,_latin1'',`e`.`lastname`) end)) AS `last_updter`,concat(convert(date_format(`p`.`last_update`,'%m.%d.%y %H:%i:%s') using latin1),_latin1' ',(case when isnull(`p`.`updated_by`) then 'Admin' else concat(`e`.`firstname`,_latin1'',`e`.`lastname`) end)) AS `last_updter1`,(case when (`et`.`engage_ref_tab` = 'Company') then (select group_concat(concat(`vw_comp2`.`emp_name`,_latin1' -> ',`vw_comp2`.`contact_detail`),_latin1' | ' separator ',') AS `contact_detail` from `vw_comp2` where (`vw_comp2`.`comp_id` = `et`.`engage_ref_id`) group by `vw_comp2`.`comp_id`) when (`et`.`engage_ref_tab` = 'Employee') then convert((case when isnull(`et`.`engage_ref_id`) then 'Admin' else convert(concat((select group_concat(`vw_emp_contact3`.`contacts`,_latin1' | ' separator ',') AS `contact_detail` from `vw_emp_contact3` where (`vw_emp_contact3`.`emp_id` = `et`.`engage_ref_id`) group by `vw_emp_contact3`.`emp_id`)) using utf8) end) using latin1) end) AS `comp_emp_detail` from (((((((((((((((`engage_entity_po` `p` left join `look_values` `lv` on((`p`.`bill_cycle` = `lv`.`look_values_id`))) left join `look_values` `lvp` on((`p`.`bill_day` = `lvp`.`look_values_id`))) left join `look_values` `lvt` on((`p`.`bill_pay_type` = `lvt`.`look_values_id`))) left join `look_values` `lvts` on((`p`.`ts_cycle` = `lvts`.`look_values_id`))) left join `emp` `e` on((`p`.`updated_by` = `e`.`emp_id`))) left join `engage_entity` `et` on((`p`.`idengage_entity` = `et`.`idengage_entity`))) left join `look_values` `lvr` on((`et`.`engage_ref_tab` = `lvr`.`look_values`))) left join `emp` `em` on((`et`.`engage_ref_id` = `em`.`emp_id`))) left join `company` `c` on((`et`.`engage_ref_id` = `c`.`comp_id`))) left join `load_contracts` `cn` on((`et`.`engage_id` = `cn`.`engage_id`))) left join `engage` `en` on((`en`.`engage_id` = `et`.`engage_id`))) left join `engage_comp` `ec` on((`ec`.`engage_id` = `en`.`engage_id`))) left join `company` `c1` on((`en`.`srv_client` = `c1`.`comp_id`))) left join `company` `cc` on((`en`.`srv_vendor` = `cc`.`comp_id`))) left join `dev_look_value` `dlvts` on((`p`.`bill_title` = `dlvts`.`iddev_look_value`))) group by `p`.`idengage_entity_po` order by `p`.`last_update` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_apps`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_apps`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_apps` AS select `a`.`iddev_apps` AS `iddev_apps`,`a`.`disp_order` AS `disp_order`,`a`.`app_name` AS `app_name`,`a`.`app_description` AS `app_description`,`a`.`comp_id` AS `comp_id`,ifnull(`comp`.`companyname`,'No Company') AS `companyname`,if(isnull(`a`.`start_dt`),'Not Started',date_format(`a`.`start_dt`,'%m-%d-%y %h:%i %p')) AS `start_dt`,`a`.`start_dt` AS `start_dt_unformatted`,date_format(`a`.`end_dt`,'%m-%d-%y %h:%i %p') AS `end_dt`,`a`.`end_dt` AS `end_dt_unformatted`,`a`.`dev_est_cnt` AS `dev_est_cnt`,ifnull(`a`.`dev_est_pcnt`,'0%') AS `dev_est_pcnt`,`a`.`dev_est_req_cnt` AS `dev_est_req_cnt`,ifnull(`a`.`dev_est_req_pcnt`,'0%') AS `dev_est_req_pcnt`,`a`.`dev_est_req_stat_cnt` AS `dev_est_req_stat_cnt`,ifnull(`a`.`dev_est_req_stat_pcnt`,'0%') AS `dev_est_req_stat_pcnt`,if(isnull(`a`.`del_by`),'Admin',concat(`e_del_by`.`firstname`,'',`e_del_by`.`lastname`)) AS `del_by`,`a`.`del_by` AS `del_by_id`,`o_del_by`.`file_name` AS `del_by_file_name`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,`a`.`del_dt` AS `del_dt_unformatted`,`a`.`del_day` AS `del_day`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,if(isnull(`a`.`arch_by`),'Admin',concat(`e_arch_by`.`firstname`,'',`e_arch_by`.`lastname`)) AS `arch_by`,`a`.`arch_by` AS `arch_by_id`,`o_arch_by`.`file_name` AS `arch_by_file_name`,date_format(`a`.`arch_dt`,'%m-%d-%y %h:%i %p') AS `arch_dt`,`a`.`arch_dt` AS `arch_dt_unformatted`,`o`.`file_name` AS `updater_file_name`,if(isnull(`a`.`updater`),'Admin',concat(`e`.`firstname`,'',`e`.`lastname`)) AS `updater`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated`,`a`.`last_updated` AS `last_updated_unformatted`,date_format(`a`.`last_updated`,_utf8'%Y-%m-%d %H:%i:%s') AS `mylast_updated` from (((((((`dev_apps` `a` left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `emp` `e_del_by` on((`a`.`del_dt` = `e_del_by`.`emp_id`))) left join `emp` `e_arch_by` on((`a`.`arch_by` = `e_arch_by`.`emp_id`))) left join `company` `comp` on((`a`.`comp_id` = `comp`.`comp_id`))) left join `storages` `o` on((`e`.`idstorage` = `o`.`idstorage`))) left join `storages` `o_del_by` on((`e_del_by`.`idstorage` = `o_del_by`.`idstorage`))) left join `storages` `o_arch_by` on((`e_arch_by`.`idstorage` = `o_arch_by`.`idstorage`))) group by `a`.`iddev_apps` order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_apps_attachment`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_apps_attachment`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_apps_attachment` AS select `a`.`iddev_app_attach` AS `iddev_app_attach`,`b`.`iddev_apps` AS `iddev_apps`,`a`.`idstorage` AS `idstorage`,`a`.`updater` AS `updater`,`c`.`owner_id` AS `owner_id`,`c`.`file_name` AS `file_name`,`c`.`public` AS `public`,`c`.`self_view` AS `self_view`,`c`.`shared` AS `shared`,`c`.`emp_id` AS `emp_id`,`c`.`updated_for_ref_id` AS `updated_for_ref_id`,`c`.`updated_for_ref_table` AS `updated_for_ref_table` from ((`dev_apps_attach` `a` left join `storages` `c` on((`a`.`idstorage` = `c`.`idstorage`))) left join `dev_apps` `b` on((`a`.`iddev_apps` = `b`.`iddev_apps`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est` AS select `a`.`iddev_est` AS `iddev_est`,`a`.`attach` AS `attach`,`a`.`iddev_apps` AS `iddev_apps`,(case when (`a`.`owner_ref_tab` = 'emp') then `s`.`file_name` when (`a`.`owner_ref_tab` = 'comp') then `t`.`file_name` end) AS `owner_file_name`,(case when (`a`.`est_ref_tab` = 'emp') then `u`.`file_name` when (`a`.`est_ref_tab` = 'comp') then `v`.`file_name` end) AS `estimater_file_name`,`w`.`file_name` AS `updater_file_name`,`b`.`app_name` AS `app_name`,`b`.`comp_id` AS `comp_id`,ifnull(`comp`.`companyname`,'No Company') AS `companyname`,`a`.`dev_est_smry` AS `dev_est_smry`,`a`.`owner_ref_id` AS `owner_ref_id`,`a`.`owner_ref_tab` AS `owner_ref_tab`,`a`.`est_ref_id` AS `est_ref_id`,`a`.`est_ref_tab` AS `est_ref_tab`,`a`.`category` AS `category`,ifnull(`a`.`category`,'No Category') AS `category_name`,`a`.`priority` AS `priority`,ifnull(`a`.`priority`,'No Priority') AS `priority_name`,(case when (`a`.`est_ref_tab` = 'emp') then concat(`d`.`firstname`,' ',`d`.`lastname`) when (`a`.`est_ref_tab` = 'comp') then `j`.`companyname` end) AS `est_ref_name`,ifnull(concat(`d`.`firstname`,' ',`d`.`lastname`),'No Estimater') AS `estimater_name`,(case when (`a`.`owner_ref_tab` = 'emp') then concat(`c`.`firstname`,' ',`c`.`lastname`) when (`a`.`owner_ref_tab` = 'comp') then `m`.`companyname` end) AS `owner_ref_name`,ifnull(concat(`c`.`firstname`,' ',`c`.`lastname`),'No Owner') AS `owner_name`,`a`.`est_amt` AS `est_amt`,`a`.`est_amt_pay` AS `est_amt_pay`,`a`.`est_amt_bal` AS `est_amt_bal`,`a`.`est_skill` AS `est_skill`,ifnull(`a`.`est_gap_lvl`,'No Gap') AS `est_gap_lvl`,ifnull(`a`.`est_type`,'Flex') AS `est_type`,date_format(`a`.`dev_st_dt`,_utf8'%m-%d-%y') AS `dev_st_dt`,`a`.`dev_st_dt` AS `dev_st_dt_unformatted`,date_format(`a`.`dev_en_dt`,_utf8'%m-%d-%y') AS `dev_en_dt`,`a`.`dev_en_dt` AS `dev_en_dt_unformatted`,date_format(`a`.`dev_st_dt`,'%m-%d-%y %h:%i %p') AS `dev_st_dt_time`,date_format(`a`.`dev_en_dt`,'%m-%d-%y %h:%i %p') AS `dev_en_dt_time`,(case when isnull(`a`.`dev_en_dt`) then round(((unix_timestamp(now()) - unix_timestamp(`a`.`dev_st_dt`)) / 60),0) else round(((unix_timestamp(`a`.`dev_en_dt`) - unix_timestamp(`a`.`dev_st_dt`)) / 60),0) end) AS `est_time`,if(isnull(`a`.`dev_en_dt`),concat(round(((unix_timestamp(now()) - unix_timestamp(`a`.`dev_st_dt`)) / 3600),0),_utf8':',round((round(((unix_timestamp(now()) - unix_timestamp(`a`.`dev_st_dt`)) % 3600),0) / 60),0)),concat(floor((`a`.`est_time` / 60)),_utf8':',round((`a`.`est_time` % 60),0))) AS `pseudo_est_time`,`a`.`cnt_actual` AS `cnt_actual`,`a`.`cnt_est` AS `cnt_est`,`a`.`cnt_actual_est` AS `cnt_actual_est`,ifnull(`a`.`cnt_pcnt`,'0%') AS `cnt_pcnt`,`a`.`cnt_req_actual` AS `cnt_req_actual`,`a`.`cnt_req_est` AS `cnt_req_est`,`a`.`cnt_req_actual_est` AS `cnt_req_actual_est`,ifnull(`a`.`cnt_req_pcnt`,'0%') AS `cnt_req_pcnt`,ifnull(concat(`e`.`firstname`,' ',`e`.`lastname`),'Admin') AS `updater`,date_format(`a`.`last_updated`,_utf8'%m-%d-%y %h:%i %p') AS `last_updated`,date_format(`a`.`last_updated`,_utf8'%Y-%m-%d %h:%i %p') AS `mylast_updated`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,`a`.`del_dt` AS `del_dt_unformatted`,ifnull(concat(`e_del_by`.`firstname`,' ',`e_del_by`.`lastname`),'Admin') AS `del_by`,`a`.`del_by` AS `del_by_id`,`o_del_by`.`file_name` AS `del_by_file_name`,`a`.`del_day` AS `del_day`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,ifnull(concat(`e_arch_by`.`firstname`,' ',`e_arch_by`.`lastname`),'Admin') AS `arch_by`,`a`.`archv_by` AS `arch_by_id`,`o_arch_by`.`file_name` AS `arch_by_file_name`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `arch_dt`,`a`.`archv_dt` AS `arch_dt_unformatted` from ((((((((((((((((((`dev_est` `a` left join `dev_apps` `b` on((`a`.`iddev_apps` = `b`.`iddev_apps`))) left join `company` `comp` on((`b`.`comp_id` = `comp`.`comp_id`))) left join `emp` `c` on((`a`.`owner_ref_id` = `c`.`emp_id`))) left join `emp` `e_del_by` on((`a`.`del_dt` = `e_del_by`.`emp_id`))) left join `emp` `e_arch_by` on((`a`.`archv_by` = `e_arch_by`.`emp_id`))) left join `storages` `s` on((`c`.`idstorage` = `s`.`idstorage`))) left join `company` `m` on((`a`.`owner_ref_id` = `m`.`comp_id`))) left join `storages` `t` on((`m`.`idstorage` = `t`.`idstorage`))) left join `emp` `d` on((`a`.`est_ref_id` = `d`.`emp_id`))) left join `storages` `u` on((`d`.`idstorage` = `u`.`idstorage`))) left join `company` `j` on((`a`.`est_ref_id` = `j`.`comp_id`))) left join `storages` `v` on((`j`.`idstorage` = `v`.`idstorage`))) left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `storages` `w` on((`e`.`idstorage` = `w`.`idstorage`))) left join `dev_look_value` `f` on((`a`.`category` = `f`.`iddev_look_value`))) left join `dev_look_value` `g` on((`a`.`priority` = `g`.`iddev_look_value`))) left join `storages` `o_del_by` on((`e_del_by`.`idstorage` = `o_del_by`.`idstorage`))) left join `storages` `o_arch_by` on((`e_arch_by`.`idstorage` = `o_arch_by`.`idstorage`))) group by `a`.`iddev_est` order by date_format(`a`.`last_updated`,_utf8'%Y-%m-%d %h:%i %p') desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_access`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_access`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_access` AS select `a`.`iddev_est_access` AS `iddev_est_access`,`a`.`iddev_est` AS `iddev_est`,concat(`b`.`firstname`,' ',`b`.`lastname`) AS `access_to`,`b`.`nickname` AS `nickname`,`a`.`dev_est_emp_id` AS `dev_est_emp_id`,`a`.`dev_est_access` AS `dev_est_access`,`a`.`dev_est_req_access` AS `dev_est_req_access`,`a`.`dev_est_reqs_case_access` AS `dev_est_reqs_case_access`,ifnull(concat(`c`.`firstname`,' ',`c`.`lastname`),'Admin') AS `access_updater`,`a`.`last_updated` AS `last_updated`,`e`.`attach` AS `attach`,`e`.`iddev_apps` AS `iddev_apps`,`e`.`app_name` AS `app_name`,`e`.`dev_est_smry` AS `dev_est_smry`,`e`.`owner_ref_id` AS `owner_ref_id`,`e`.`owner_ref_tab` AS `owner_ref_tab`,`e`.`est_ref_id` AS `est_ref_id`,`e`.`est_ref_tab` AS `est_ref_tab`,`e`.`category` AS `category`,`e`.`priority` AS `priority`,`e`.`est_ref_name` AS `est_ref_name`,`e`.`owner_ref_name` AS `owner_ref_name`,`e`.`est_amt_pay` AS `est_amt_pay`,`e`.`est_amt_bal` AS `est_amt_bal`,`e`.`est_skill` AS `est_skill`,`e`.`est_gap_lvl` AS `est_gap_lvl`,`e`.`est_type` AS `est_type`,`e`.`category_name` AS `category_name`,`e`.`priority_name` AS `priority_name`,`e`.`dev_st_dt` AS `dev_st_dt`,`e`.`dev_st_dt_unformatted` AS `dev_st_dt_unformatted`,`e`.`dev_en_dt` AS `dev_en_dt`,`e`.`dev_en_dt_unformatted` AS `dev_en_dt_unformatted`,`e`.`dev_st_dt_time` AS `dev_st_dt_time`,`e`.`dev_en_dt_time` AS `dev_en_dt_time`,`e`.`est_time` AS `est_time`,`e`.`pseudo_est_time` AS `pseudo_est_time`,`e`.`owner_name` AS `owner_name`,`e`.`estimater_name` AS `estimater_name`,`e`.`est_amt` AS `est_amt` from (((`dev_est_access` `a` left join `emp` `b` on((`a`.`dev_est_emp_id` = `b`.`emp_id`))) left join `emp` `c` on((`a`.`updater` = `c`.`emp_id`))) left join `vw_dev_est` `e` on((`a`.`iddev_est` = `e`.`iddev_est`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_access_my_reqs`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_access_my_reqs`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_access_my_reqs` AS select `dev_est_access`.`dev_est_emp_id` AS `dev_est_emp_id`,`dev_est_access`.`dev_est_req_access` AS `dev_est_req_access`,`dev_est_access`.`dev_est_access` AS `dev_est_access`,`vw_dev_est_reqs`.`iddev_est_reqs` AS `iddev_est_reqs`,`vw_dev_est_reqs`.`iddev_est` AS `iddev_est`,`vw_dev_est_reqs`.`open_dt_time` AS `open_dt_time`,`vw_dev_est_reqs`.`open_dt_time_unformatted` AS `open_dt_time_unformatted`,`vw_dev_est_reqs`.`close_dt_time` AS `close_dt_time`,`vw_dev_est_reqs`.`close_dt_time_unformatted` AS `close_dt_time_unformatted`,`vw_dev_est_reqs`.`req_time` AS `req_time`,`vw_dev_est_reqs`.`pseudo_req_time` AS `pseudo_req_time`,`vw_dev_est_reqs`.`pseudo_req_days` AS `pseudo_req_days`,`vw_dev_est_reqs`.`disp_order` AS `disp_order`,`vw_dev_est_reqs`.`req_desc` AS `req_desc`,`vw_dev_est_reqs`.`estimater_id` AS `estimater_id`,`vw_dev_est_reqs`.`owner_id` AS `owner_id`,`vw_dev_est_reqs`.`est_type` AS `est_type`,`vw_dev_est_reqs`.`req_status_id` AS `req_status_id`,`vw_dev_est_reqs`.`req_status` AS `req_status`,`vw_dev_est_reqs`.`req_type` AS `req_type`,`vw_dev_est_reqs`.`category` AS `category`,`vw_dev_est_reqs`.`skill_lvl` AS `skill_lvl`,`vw_dev_est_reqs`.`skill_lvl_val` AS `skill_lvl_val`,`vw_dev_est_reqs`.`gap_lvl` AS `gap_lvl`,`vw_dev_est_reqs`.`gap_lvl_val` AS `gap_lvl_val`,`vw_dev_est_reqs`.`st_dt_time` AS `st_dt_time`,`vw_dev_est_reqs`.`st_dt_time_unformatted` AS `st_dt_time_unformatted`,`vw_dev_est_reqs`.`e_dt_time` AS `e_dt_time`,`vw_dev_est_reqs`.`e_dt_time_unformatted` AS `e_dt_time_unformatted`,`vw_dev_est_reqs`.`stat_time` AS `stat_time`,`vw_dev_est_reqs`.`pseudo_stat_time` AS `pseudo_stat_time`,`vw_dev_est_reqs`.`idlook_stat_order` AS `idlook_stat_order`,`vw_dev_est_reqs`.`assigned_to_id` AS `assigned_to_id`,`vw_dev_est_reqs`.`assigned_to` AS `assigned_to`,`vw_dev_est_reqs`.`updater_id` AS `updater_id`,`vw_dev_est_reqs`.`updater` AS `updater`,`vw_dev_est_reqs`.`last_updated` AS `last_updated`,`vw_dev_est_reqs`.`last_updated_unformatted` AS `last_updated_unformatted`,`vw_dev_est_reqs`.`expire_diff` AS `expire_diff` from (`dev_est_access` left join `vw_dev_est_reqs` on((`dev_est_access`.`iddev_est` = `vw_dev_est_reqs`.`iddev_est`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_access_my_reqs_case`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_access_my_reqs_case`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_access_my_reqs_case` AS select `dev_est_access`.`dev_est_emp_id` AS `dev_est_emp_id`,`dev_est_access`.`dev_est_reqs_case_access` AS `dev_est_reqs_case_access`,`dev_est_access`.`dev_est_req_access` AS `dev_est_req_access`,`vw_dev_est_reqs_case`.`iddev_est_reqs_case` AS `iddev_est_reqs_case`,`vw_dev_est_reqs_case`.`iddev_est_reqs` AS `iddev_est_reqs`,`vw_dev_est_reqs_case`.`iddev_est` AS `iddev_est`,`vw_dev_est_reqs_case`.`open_dt_time` AS `open_dt_time`,`vw_dev_est_reqs_case`.`close_dt_time` AS `close_dt_time`,`vw_dev_est_reqs_case`.`req_status` AS `req_status`,`vw_dev_est_reqs_case`.`req_status_name` AS `req_status_name`,`vw_dev_est_reqs_case`.`req_desc` AS `req_desc`,`vw_dev_est_reqs_case`.`created_by` AS `created_by`,`vw_dev_est_reqs_case`.`created_by_name` AS `created_by_name`,`vw_dev_est_reqs_case`.`create_dt` AS `create_dt`,`vw_dev_est_reqs_case`.`mod_created_by` AS `mod_created_by`,`vw_dev_est_reqs_case`.`mod_create_dt` AS `mod_create_dt`,`vw_dev_est_reqs_case`.`create_end_dt` AS `create_end_dt`,`vw_dev_est_reqs_case`.`mod_create_end_dt` AS `mod_create_end_dt`,`vw_dev_est_reqs_case`.`reqs_cases` AS `reqs_cases`,`vw_dev_est_reqs_case`.`case_data` AS `case_data`,`vw_dev_est_reqs_case`.`case_result_desc` AS `case_result_desc`,`vw_dev_est_reqs_case`.`case_status` AS `case_status`,`vw_dev_est_reqs_case`.`case_status_name` AS `case_status_name`,`vw_dev_est_reqs_case`.`executed_by` AS `executed_by`,`vw_dev_est_reqs_case`.`executed_by_name` AS `executed_by_name`,`vw_dev_est_reqs_case`.`execute_dt` AS `execute_dt`,`vw_dev_est_reqs_case`.`mod_execute_dt` AS `mod_execute_dt`,`vw_dev_est_reqs_case`.`mod_executed_by` AS `mod_executed_by`,`vw_dev_est_reqs_case`.`updated_by` AS `updated_by`,`vw_dev_est_reqs_case`.`updated_by_name` AS `updated_by_name`,`vw_dev_est_reqs_case`.`last_updated` AS `last_updated`,`vw_dev_est_reqs_case`.`mod_last_updated` AS `mod_last_updated` from (`vw_dev_est_reqs_case` join `dev_est_access` on((`dev_est_access`.`iddev_est` = `vw_dev_est_reqs_case`.`iddev_est`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_reqs`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_reqs` AS select `a`.`iddev_est_reqs` AS `iddev_est_reqs`,`a`.`iddev_est` AS `iddev_est`,`dev`.`owner_file_name` AS `owner_file_name`,`dev`.`estimater_file_name` AS `estimater_file_name`,`s`.`file_name` AS `assigned_to_file_name`,`t`.`file_name` AS `updater_file_name`,`dev`.`app_name` AS `app_name`,`dev`.`dev_est_smry` AS `dev_est_smry`,date_format(`a`.`open_dt_time`,'%m-%d-%y %h:%i %p') AS `open_dt_time`,`a`.`open_dt_time` AS `open_dt_time_unformatted`,date_format(`a`.`close_dt_time`,'%m-%d-%y %h:%i %p') AS `close_dt_time`,`a`.`close_dt_time` AS `close_dt_time_unformatted`,(case when (isnull(`a`.`req_time`) and (`a`.`open_dt_time` is not null)) then round(((unix_timestamp(now()) - unix_timestamp(`a`.`open_dt_time`)) / 60),0) else `a`.`req_time` end) AS `req_time`,if(isnull(`a`.`close_dt_time`),concat(round(((unix_timestamp(now()) - unix_timestamp(`a`.`open_dt_time`)) / 3600),0),_utf8':',round((round(((unix_timestamp(now()) - unix_timestamp(`a`.`open_dt_time`)) % 3600),0) / 60),0)),concat(floor((`a`.`req_time` / 60)),_utf8':',round((`a`.`req_time` % 60),0))) AS `pseudo_req_time`,NULL AS `pseudo_req_days`,`a`.`disp_order` AS `disp_order`,`a`.`req_desc` AS `req_desc`,`dev`.`est_ref_id` AS `estimater_id`,`dev`.`est_ref_name` AS `est_ref_name`,`dev`.`owner_ref_id` AS `owner_id`,`dev`.`owner_ref_name` AS `owner_ref_name`,`dev`.`est_type` AS `est_type`,`a`.`req_status` AS `req_status_id`,`l`.`look_value` AS `req_status`,`a`.`req_type` AS `req_type`,ifnull(`m`.`look_value`,'No Category') AS `category`,`a`.`skill_lvl` AS `skill_lvl`,ifnull(`f`.`look_value`,'No Skill') AS `skill_lvl_val`,`a`.`gap_lvl` AS `gap_lvl`,ifnull(`g`.`look_value`,'No Gap') AS `gap_lvl_val`,ifnull(`a`.`case`,'None') AS `case`,date_format(`a`.`st_dt_time`,'%m-%d-%y %h:%i %p') AS `st_dt_time`,`a`.`st_dt_time` AS `st_dt_time_unformatted`,date_format(`a`.`e_dt_time`,'%m-%d-%y %h:%i %p') AS `e_dt_time`,`a`.`e_dt_time` AS `e_dt_time_unformatted`,(case when (isnull(`a`.`stat_time`) and (`a`.`st_dt_time` is not null)) then round(((unix_timestamp(now()) - unix_timestamp(`a`.`st_dt_time`)) / 60),0) else `a`.`stat_time` end) AS `stat_time`,if(isnull(`a`.`e_dt_time`),concat(round(((unix_timestamp(now()) - unix_timestamp(`a`.`st_dt_time`)) / 3600),0),_utf8':',round((round(((unix_timestamp(now()) - unix_timestamp(`a`.`st_dt_time`)) % 3600),0) / 60),0)),concat(round((`a`.`stat_time` / 60),0),_utf8':',round((`a`.`stat_time` % 60),0))) AS `pseudo_stat_time`,`a`.`idlook_stat_order` AS `idlook_stat_order`,`a`.`assigned_to` AS `assigned_to_id`,ifnull(concat(`b`.`firstname`,' ',`b`.`lastname`),'No-Assignee') AS `assigned_to`,`a`.`cnt_actual` AS `reqs_cnt_actual`,`a`.`cnt_est` AS `reqs_cnt_est`,`a`.`cnt_actual_est` AS `reqs_cnt_actual_est`,ifnull(`a`.`cnt_pcnt`,'0%') AS `reqs_cnt_pcnt`,`dev`.`cnt_actual` AS `est_cnt_actual`,`dev`.`cnt_est` AS `est_cnt_est`,`dev`.`cnt_actual_est` AS `est_cnt_actual_est`,`dev`.`cnt_pcnt` AS `est_cnt_pcnt`,`a`.`updater` AS `updater_id`,ifnull(concat(`e`.`firstname`,' ',`e`.`lastname`),'Admin') AS `updater`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated`,`a`.`last_updated` AS `last_updated_unformatted`,(to_days(`a`.`close_dt_time`) - to_days(now())) AS `expire_diff`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,`a`.`del_dt` AS `del_dt_unformatted`,ifnull(concat(`e_del_by`.`firstname`,' ',`e_del_by`.`lastname`),'Admin') AS `del_by`,`a`.`del_by` AS `del_by_id`,`o_del_by`.`file_name` AS `del_by_file_name`,`a`.`del_day` AS `del_day`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,ifnull(concat(`e_arch_by`.`firstname`,' ',`e_arch_by`.`lastname`),'Admin') AS `arch_by`,`a`.`archv_by` AS `arch_by_id`,`o_arch_by`.`file_name` AS `arch_by_file_name`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `arch_dt`,`a`.`archv_dt` AS `arch_dt_unformatted` from (((((((((((((`dev_est_reqs` `a` left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `emp` `e_del_by` on((`a`.`del_dt` = `e_del_by`.`emp_id`))) left join `emp` `e_arch_by` on((`a`.`archv_by` = `e_arch_by`.`emp_id`))) left join `storages` `t` on((`e`.`idstorage` = `t`.`idstorage`))) left join `dev_look_value` `l` on((`a`.`req_status` = `l`.`iddev_look_value`))) left join `dev_look_value` `m` on((`a`.`req_type` = `m`.`iddev_look_value`))) left join `dev_look_value` `f` on((`a`.`skill_lvl` = `f`.`iddev_look_value`))) left join `dev_look_value` `g` on((`a`.`gap_lvl` = `g`.`iddev_look_value`))) left join `emp` `b` on((`a`.`assigned_to` = `b`.`emp_id`))) left join `storages` `s` on((`b`.`idstorage` = `s`.`idstorage`))) left join `vw_dev_est` `dev` on((`dev`.`iddev_est` = `a`.`iddev_est`))) left join `storages` `o_del_by` on((`e_del_by`.`idstorage` = `o_del_by`.`idstorage`))) left join `storages` `o_arch_by` on((`e_arch_by`.`idstorage` = `o_arch_by`.`idstorage`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_reqs_case`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_case`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_reqs_case` AS select `a`.`iddev_est_reqs_case` AS `iddev_est_reqs_case`,`a`.`iddev_est_reqs` AS `iddev_est_reqs`,`req`.`iddev_est` AS `iddev_est`,`dev_est`.`comp_id` AS `comp_id`,`dev_est`.`companyname` AS `companyname`,`dev_est`.`dev_st_dt` AS `dev_st_dt`,`dev_est`.`dev_st_dt_unformatted` AS `dev_st_dt_unformatted`,`dev_est`.`dev_en_dt` AS `dev_en_dt`,`dev_est`.`dev_en_dt_unformatted` AS `dev_en_dt_unformatted`,`dev_est`.`est_time` AS `est_time`,`req`.`open_dt_time` AS `open_dt_time`,`req`.`open_dt_time_unformatted` AS `open_dt_time_unformatted`,`req`.`close_dt_time` AS `close_dt_time`,`req`.`close_dt_time_unformatted` AS `close_dt_time_unformatted`,`req`.`req_time` AS `req_time`,`req`.`skill_lvl_val` AS `skill_lvl_val`,`req`.`category` AS `category`,`req`.`gap_lvl_val` AS `gap_lvl_val`,`req`.`req_status` AS `req_status`,`l`.`look_value` AS `req_status_name`,`req`.`req_desc` AS `req_desc`,`req`.`dev_est_smry` AS `dev_est_smry`,`s`.`file_name` AS `created_by_file_name`,`a`.`created_by` AS `created_by`,if(isnull(`a`.`created_by`),'Admin',concat(`c`.`firstname`,' ',`c`.`lastname`)) AS `created_by_name`,`a`.`create_dt` AS `create_dt`,concat(convert(date_format(`a`.`create_dt`,'%m.%d.%y') using latin1),' ',if(isnull(`a`.`created_by`),'Admin',concat(`c`.`firstname`,' ',`c`.`lastname`))) AS `mod_created_by`,date_format(`a`.`create_dt`,'%m-%d-%y') AS `mod_create_dt`,`a`.`create_end_dt` AS `create_end_dt`,date_format(`a`.`create_end_dt`,'%m-%d-%y') AS `mod_create_end_dt`,(case when ((`a`.`create_dt` is not null) and isnull(`a`.`create_end_dt`)) then round(((unix_timestamp(now()) - unix_timestamp(`a`.`create_dt`)) / 60),0) else round(((unix_timestamp(`a`.`create_end_dt`) - unix_timestamp(`a`.`create_dt`)) / 60),0) end) AS `create_time`,`a`.`reqs_cases` AS `reqs_cases`,`a`.`case_data` AS `case_data`,`a`.`case_result_desc` AS `case_result_desc`,`a`.`case_status` AS `case_status`,if(isnull(`a`.`case_status`),'None',`lp`.`look_value`) AS `case_status_name`,`s2`.`file_name` AS `executed_by_file_name`,`a`.`executed_by` AS `executed_by`,if(isnull(`a`.`executed_by`),'Admin',concat(`d`.`firstname`,' ',`d`.`lastname`)) AS `executed_by_name`,`a`.`execute_dt` AS `execute_dt`,date_format(`a`.`execute_dt`,'%m-%d-%y') AS `mod_execute_dt`,concat(convert(date_format(`a`.`execute_dt`,'%m.%d.%y') using latin1),' ',if(isnull(`a`.`executed_by`),'Admin',concat(`d`.`firstname`,'',`d`.`lastname`))) AS `mod_executed_by`,`s3`.`file_name` AS `updater_file_name`,`a`.`updated_by` AS `updated_by`,if(isnull(`a`.`updated_by`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updated_by_name`,`a`.`last_updated` AS `last_updated`,concat(convert(date_format(`a`.`last_updated`,'%m-%d-%y %H:%i:%s %p') using latin1),' ') AS `mod_last_updated`,`req`.`req_status` AS `cur_stat`,`req`.`estimater_id` AS `estimater_id`,`req`.`est_ref_name` AS `est_ref_name`,`req`.`estimater_file_name` AS `estimater_file_name`,`req`.`owner_id` AS `owner_id`,`req`.`owner_ref_name` AS `owner_ref_name`,`req`.`owner_file_name` AS `owner_file_name`,`req`.`reqs_cnt_actual_est` AS `reqs_cnt_actual_est`,`req`.`reqs_cnt_pcnt` AS `reqs_cnt_pcnt`,`dev_est`.`cnt_actual_est` AS `est_cnt_actual_est`,`dev_est`.`cnt_pcnt` AS `est_cnt_pcnt`,`dev_apps`.`dev_est_cnt` AS `dev_est_cnt`,ifnull(`dev_apps`.`dev_est_pcnt`,'0%') AS `dev_est_pcnt`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,if(isnull(`a`.`del_by`),'Admin',concat(`del`.`firstname`,' ',`del`.`lastname`)) AS `del_by`,`a`.`del_by` AS `del_by_id`,`a`.`del_day` AS `del_day`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt`,if(isnull(`a`.`archv_by`),'Admin',concat(`arc`.`firstname`,' ',`arc`.`lastname`)) AS `archv_by`,`a`.`archv_by` AS `archv_by_id` from (((((((((((((`dev_est_reqs_case` `a` left join `vw_dev_est_reqs` `req` on((`a`.`iddev_est_reqs` = `req`.`iddev_est_reqs`))) left join `vw_dev_est` `dev_est` on((`req`.`iddev_est` = `dev_est`.`iddev_est`))) left join `vw_dev_apps` `dev_apps` on((`dev_est`.`iddev_apps` = `dev_apps`.`iddev_apps`))) left join `emp` `c` on((`a`.`created_by` = `c`.`emp_id`))) left join `emp` `del` on((`a`.`del_by` = `del`.`emp_id`))) left join `emp` `arc` on((`a`.`archv_by` = `arc`.`emp_id`))) left join `storages` `s` on((`c`.`idstorage` = `s`.`idstorage`))) left join `emp` `d` on((`a`.`executed_by` = `d`.`emp_id`))) left join `storages` `s2` on((`d`.`idstorage` = `s2`.`idstorage`))) left join `emp` `e` on((`a`.`updated_by` = `e`.`emp_id`))) left join `storages` `s3` on((`e`.`idstorage` = `s3`.`idstorage`))) left join `dev_look_value` `l` on((`req`.`req_status` = `l`.`iddev_look_value`))) left join `dev_look_value` `lp` on((`a`.`case_status` = `lp`.`iddev_look_value`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_reqs_case_result`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_case_result`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_reqs_case_result` AS select `a`.`iddev_est_reqs_case_result` AS `iddev_est_reqs_case_result`,`a`.`iddev_est_reqs_case` AS `iddev_est_reqs_case`,`b`.`iddev_est_reqs` AS `iddev_est_reqs`,`b`.`case_result_desc` AS `case_result_desc_cases`,`c`.`req_desc` AS `req_desc`,`a`.`case_data` AS `case_data`,`a`.`case_result_desc` AS `case_result_desc`,`a`.`case_status` AS `case_status`,`a`.`execute_dt` AS `execute_date`,`a`.`executed_by` AS `executed_by`,concat(convert(if(isnull(`a`.`execute_dt`),' ',date_format(`a`.`execute_dt`,'%m.%d.%y')) using latin1),' ',if(isnull(`a`.`executed_by`),'Admin',concat(`d`.`firstname`,' ',`d`.`lastname`))) AS `executed_by_name`,if(isnull(`a`.`executed_by`),'Admin',concat(`d`.`firstname`,' ',`d`.`lastname`)) AS `executed_by_name2`,`l`.`look_value` AS `req_status_name`,`a`.`updated_by` AS `updated_by`,if(isnull(`a`.`updated_by`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updated_by_name`,`a`.`execute_dt` AS `execute_dt`,date_format(`a`.`execute_dt`,'%m-%d-%y') AS `mod_execute_dt`,concat(convert(date_format(`a`.`last_updated`,'%m.%d.%y %H:%i:%s') using latin1),' ',if(isnull(`a`.`updated_by`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`))) AS `last_updated`,concat(convert(date_format(`a`.`last_updated`,'%m.%d.%y ') using latin1),' ',if(isnull(`a`.`updated_by`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`))) AS `mod_last_updated` from (((((`dev_est_reqs_case_result` `a` left join `dev_est_reqs_case` `b` on((`a`.`iddev_est_reqs_case` = `b`.`iddev_est_reqs_case`))) left join `dev_est_reqs` `c` on((`b`.`iddev_est_reqs` = `c`.`iddev_est_reqs`))) left join `emp` `d` on((`a`.`executed_by` = `d`.`emp_id`))) left join `dev_look_value` `l` on((`a`.`case_status` = `l`.`iddev_look_value`))) left join `emp` `e` on((`a`.`updated_by` = `e`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_reqs_filter`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_filter`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_reqs_filter` AS select `a`.`iddev_est_reqs` AS `iddev_est_reqs`,`a`.`iddev_est` AS `iddev_est`,date_format(`a`.`open_dt_time`,_utf8'%m-%d-%y %H:%i:%s') AS `open_dt_time`,`a`.`open_dt_time` AS `open_dt_time_unformatted`,date_format(`a`.`close_dt_time`,_utf8'%m-%d-%y %H:%i:%s') AS `close_dt_time`,`a`.`close_dt_time` AS `close_dt_time_unformatted`,`a`.`req_status` AS `req_status_id`,`l`.`look_value` AS `req_status`,`a`.`assigned_to` AS `assigned_to_id`,concat(`b`.`firstname`,_latin1' ',`b`.`lastname`) AS `assigned_to`,`a`.`updater` AS `updater_id`,if(isnull(`a`.`updater`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updater` from ((((`dev_est_reqs` `a` left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `dev_look_value` `l` on((`a`.`req_status` = `l`.`iddev_look_value`))) left join `emp` `b` on((`a`.`assigned_to` = `b`.`emp_id`))) left join `dev_est_reqs_status` `d` on((`a`.`iddev_est_reqs` = `d`.`iddev_est_reqs`))) group by `a`.`iddev_est_reqs` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_reqs_status`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_status`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_reqs_status` AS select `a`.`iddev_est_reqs_status` AS `iddev_est_reqs_status`,`dev`.`iddev_est` AS `iddev_est`,`e`.`app_name` AS `app_name`,`e`.`dev_est_smry` AS `dev_est_smry`,`dev`.`owner_file_name` AS `owner_file_name`,`dev`.`estimater_file_name` AS `estimater_file_name`,`dev`.`dev_st_dt` AS `wk_or_st_dt`,`dev`.`dev_en_dt` AS `wk_or_en_dt`,`a`.`iddev_est_reqs` AS `iddev_est_reqs`,`a`.`req_status` AS `status_id`,`b`.`look_value` AS `status`,`t`.`file_name` AS `assigned_to_file_name`,`s`.`file_name` AS `updater_file_name`,`a`.`idlook_stat_order` AS `idlook_stat_order`,date_format(`a`.`stat_st_dt`,'%m-%d-%y %h:%i %p') AS `stat_st_dt`,date_format(`a`.`stat_e_dt`,'%m-%d-%y %h:%i %p') AS `stat_e_dt`,`a`.`stat_st_dt` AS `stat_st_dt_unformatted`,`a`.`stat_e_dt` AS `stat_e_dt_unformatted`,`a`.`stat_time` AS `stat_time`,`a`.`lag_time` AS `lag_time`,`a`.`assigned_to` AS `assigned_to_id`,ifnull(concat(`d`.`firstname`,' ',`d`.`lastname`),'No-Assignee') AS `assigned_to`,`d`.`nickname` AS `nickname`,`e`.`req_desc` AS `req_desc`,`e`.`req_status_id` AS `cur_stat_id`,`e`.`req_status` AS `cur_stat`,`e`.`st_dt_time` AS `cur_st_dt_tm`,`e`.`st_dt_time_unformatted` AS `cur_st_dt_tm_fmt`,date_format(`e`.`st_dt_time_unformatted`,'%m') AS `req_cur_open_month`,date_format(`e`.`st_dt_time_unformatted`,'%Y') AS `req_cur_open_year`,`e`.`e_dt_time` AS `cur_e_dt_tm`,`e`.`e_dt_time_unformatted` AS `cur_e_dt_tm_fmt`,`e`.`stat_time` AS `cur_stat_tm`,`e`.`open_dt_time` AS `req_open_dt_time`,`e`.`open_dt_time_unformatted` AS `req_open_dt_time_unformatted`,date_format(`e`.`open_dt_time_unformatted`,'%m') AS `req_open_month`,date_format(`e`.`open_dt_time_unformatted`,'%Y') AS `req_open_year`,`e`.`close_dt_time` AS `req_close_dt_time`,`e`.`close_dt_time_unformatted` AS `req_close_dt_time_unformatted`,`e`.`req_time` AS `req_time`,`e`.`pseudo_req_days` AS `pseudo_req_days`,`e`.`estimater_id` AS `estimater_id`,`e`.`owner_id` AS `owner_id`,`e`.`est_type` AS `req_est_type`,`e`.`req_type` AS `req_type`,`e`.`category` AS `category`,`e`.`skill_lvl` AS `skill_lvl`,`e`.`skill_lvl_val` AS `skill_lvl_val`,`e`.`gap_lvl` AS `gap_lvl`,`e`.`reqs_cnt_actual` AS `reqs_cnt_actual`,`e`.`reqs_cnt_est` AS `reqs_cnt_est`,`e`.`reqs_cnt_actual_est` AS `reqs_cnt_actual_est`,`e`.`reqs_cnt_pcnt` AS `reqs_cnt_pcnt`,`e`.`est_cnt_actual` AS `est_cnt_actual`,`e`.`est_cnt_est` AS `est_cnt_est`,`e`.`est_cnt_actual_est` AS `est_cnt_actual_est`,`e`.`est_cnt_pcnt` AS `est_cnt_pcnt`,`e`.`assigned_to_id` AS `cur_assignee_id`,`e`.`assigned_to` AS `cur_assignee_nm`,`a`.`updater` AS `updater_id`,ifnull(concat(`c`.`firstname`,' ',`c`.`lastname`),'Admin') AS `updater`,`a`.`last_updated` AS `last_updated`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,`a`.`del_dt` AS `del_dt_unformatted`,ifnull(concat(`e_del_by`.`firstname`,' ',`e_del_by`.`lastname`),'Admin') AS `del_by`,`a`.`del_by` AS `del_by_id`,`o_del_by`.`file_name` AS `del_by_file_name`,`a`.`del_day` AS `del_day`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,ifnull(concat(`e_arch_by`.`firstname`,' ',`e_arch_by`.`lastname`),'Admin') AS `arch_by`,`a`.`archv_by` AS `arch_by_id`,`o_arch_by`.`file_name` AS `arch_by_file_name`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `arch_dt`,`a`.`archv_dt` AS `arch_dt_unformatted` from (((((((((((`dev_est_reqs_status` `a` left join `dev_look_value` `b` on((`a`.`req_status` = `b`.`iddev_look_value`))) left join `emp` `c` on((`a`.`updater` = `c`.`emp_id`))) left join `emp` `e_del_by` on((`a`.`del_dt` = `e_del_by`.`emp_id`))) left join `emp` `e_arch_by` on((`a`.`archv_by` = `e_arch_by`.`emp_id`))) left join `storages` `s` on((`c`.`idstorage` = `s`.`idstorage`))) left join `emp` `d` on((`a`.`assigned_to` = `d`.`emp_id`))) left join `storages` `t` on((`d`.`idstorage` = `t`.`idstorage`))) left join `vw_dev_est_reqs` `e` on((`a`.`iddev_est_reqs` = `e`.`iddev_est_reqs`))) left join `vw_dev_est` `dev` on((`e`.`iddev_est` = `dev`.`iddev_est`))) left join `storages` `o_del_by` on((`e_del_by`.`idstorage` = `o_del_by`.`idstorage`))) left join `storages` `o_arch_by` on((`e_arch_by`.`idstorage` = `o_arch_by`.`idstorage`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_reqs_status_forcast`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_status_forcast`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_reqs_status_forcast` AS select `a`.`iddev_est_reqs_status_forcast` AS `iddev_est_reqs_status_forcast`,`dev`.`iddev_est` AS `iddev_est`,`a`.`iddev_est_reqs` AS `iddev_est_reqs`,`a`.`req_status` AS `status_id`,`b`.`look_value` AS `status`,`dev`.`owner_file_name` AS `owner_file_name`,`dev`.`estimater_file_name` AS `estimater_file_name`,`t`.`file_name` AS `assigned_to_file_name`,`s`.`file_name` AS `updater_file_name`,`a`.`idlook_stat_order` AS `idlook_stat_order`,date_format(`a`.`stat_st_dt`,'%m-%d-%y %h:%i %p') AS `stat_st_dt`,date_format(`a`.`stat_e_dt`,'%m-%d-%y %h:%i %p') AS `stat_e_dt`,`a`.`stat_st_dt` AS `stat_st_dt_unformatted`,`a`.`stat_e_dt` AS `stat_e_dt_unformatted`,`a`.`stat_time` AS `stat_time`,`a`.`lag_time` AS `lag_time`,`a`.`assigned_to` AS `assigned_to_id`,concat(`d`.`firstname`,' ',`d`.`lastname`) AS `assigned_to`,`d`.`nickname` AS `nickname`,`e`.`dev_est_smry` AS `dev_est_smry`,`e`.`req_desc` AS `req_desc`,`e`.`req_status_id` AS `cur_stat_id`,`e`.`req_status` AS `cur_stat`,`e`.`st_dt_time` AS `cur_st_dt_tm`,`e`.`st_dt_time_unformatted` AS `cur_st_dt_tm_fmt`,`e`.`e_dt_time` AS `cur_e_dt_tm`,`e`.`e_dt_time_unformatted` AS `cur_e_dt_tm_fmt`,`e`.`stat_time` AS `cur_stat_tm`,`e`.`open_dt_time` AS `req_open_dt_time`,`e`.`open_dt_time_unformatted` AS `req_open_dt_time_unformatted`,`e`.`close_dt_time` AS `req_close_dt_time`,`e`.`close_dt_time_unformatted` AS `req_close_dt_time_unformatted`,`e`.`req_time` AS `req_time`,`e`.`pseudo_req_days` AS `pseudo_req_days`,`e`.`estimater_id` AS `estimater_id`,`e`.`owner_id` AS `owner_id`,`e`.`est_type` AS `req_est_type`,`e`.`req_type` AS `req_type`,`e`.`category` AS `category`,`e`.`skill_lvl` AS `skill_lvl`,`e`.`skill_lvl_val` AS `skill_lvl_val`,`e`.`gap_lvl` AS `gap_lvl`,`e`.`gap_lvl_val` AS `gap_lvl_val`,`e`.`assigned_to_id` AS `cur_assignee_id`,`e`.`assigned_to` AS `cur_assignee_nm`,`a`.`updater` AS `updater_id`,if((isnull(`a`.`updater`) or (`a`.`updater` = 0)),'Admin',concat(`c`.`firstname`,' ',`c`.`lastname`)) AS `updater`,`a`.`last_updated` AS `last_updated` from (((((((`dev_est_reqs_status_forcast` `a` left join `dev_look_value` `b` on((`a`.`req_status` = `b`.`iddev_look_value`))) left join `emp` `c` on((`a`.`updater` = `c`.`emp_id`))) left join `storages` `s` on((`c`.`idstorage` = `s`.`idstorage`))) left join `emp` `d` on((`a`.`assigned_to` = `d`.`emp_id`))) left join `storages` `t` on((`d`.`idstorage` = `t`.`idstorage`))) left join `vw_dev_est_reqs` `e` on((`a`.`iddev_est_reqs` = `e`.`iddev_est_reqs`))) left join `vw_dev_est` `dev` on((`e`.`iddev_est` = `dev`.`iddev_est`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_reqs_status_steps`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_status_steps`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_reqs_status_steps` AS select `a`.`iddev_est_req_status_steps` AS `iddev_est_req_status_steps`,`a`.`iddev_est_reqs_status` AS `iddev_est_reqs_status`,`b`.`iddev_est_reqs` AS `iddev_est_reqs`,`s`.`file_name` AS `updater_file_name`,`b`.`req_status` AS `req_status_id`,`c`.`look_value` AS `status`,`a`.`dev_steps_details` AS `dev_steps_details`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated`,`a`.`last_updated` AS `last_updated_unformatted`,`a`.`updater` AS `update_id`,ifnull(concat(`d`.`firstname`,'',`d`.`lastname`),'Admin') AS `updater` from ((((`dev_est_reqs_status_steps` `a` left join `dev_est_reqs_status` `b` on((`a`.`iddev_est_reqs_status` = `b`.`iddev_est_reqs_status`))) left join `dev_look_value` `c` on((`b`.`req_status` = `c`.`iddev_look_value`))) left join `emp` `d` on((`a`.`updater` = `d`.`emp_id`))) left join `storages` `s` on((`d`.`idstorage` = `s`.`idstorage`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_est_reqs_status_without_steps`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_est_reqs_status_without_steps`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_est_reqs_status_without_steps` AS select `dev_est_reqs_status_steps`.`iddev_est_req_status_steps` AS `iddev_est_req_status_steps`,`dev_est_reqs_status_steps`.`iddev_est_reqs_status` AS `iddev_est_reqs_status`,`dev_est_reqs_status_steps`.`dev_steps_details` AS `dev_steps_details`,`dev_est_reqs_status_steps`.`last_updated` AS `last_updated` from `dev_est_reqs_status_steps` where (not(`dev_est_reqs_status_steps`.`iddev_est_reqs_status` in (select `dev_est_reqs_status`.`iddev_est_reqs_status` AS `iddev_est_reqs_status` from `dev_est_reqs_status`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_lk_label`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_lk_label`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_lk_label` AS select `a`.`iddev_lk_label` AS `iddev_lk_label`,`a`.`dev_label_nm` AS `dev_label_nm`,`a`.`hover_fields` AS `hover_fields`,`a`.`disp_order` AS `disp_order`,`a`.`lk_parent_val_id` AS `lk_parent_val_id`,`a`.`updater` AS `updater_id`,if(isnull(`a`.`updater`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updater`,`s`.`file_name` AS `updater_file_name`,if(isnull(`a`.`last_updated`),'Never',date_format(`a`.`last_updated`,'%m-%d-%y')) AS `last_updated` from ((`dev_lk_label` `a` left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_lk_wrk_flow`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_lk_wrk_flow`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_lk_wrk_flow` AS select `a`.`iddev_lk_wrk_flow` AS `iddev_lk_wrk_flow`,`a`.`wrk_flow_nm` AS `wrk_flow_nm`,`a`.`id_wrk_flow` AS `id_wrk_flow`,`a`.`wrk_flow_desc` AS `wrk_flow_desc`,`a`.`id_wrk_flow_parent` AS `id_wrk_flow_parent`,`a`.`look_initial` AS `look_initial`,`a`.`look_restart` AS `look_restart`,`a`.`disp_order` AS `disp_order`,`a`.`updater` AS `updater`,ifnull(concat(`c`.`firstname`,' ',`c`.`lastname`),'Admin') AS `updater_fmt`,`a`.`last_updated` AS `last_updated`,if(isnull(`a`.`last_updated`),'Never',date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p')) AS `last_updated_fmt`,concat(ifnull(concat(`c`.`firstname`,' ',`c`.`lastname`),'Admin'),' ',convert(if(isnull(`a`.`last_updated`),'Never',date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p')) using latin1)) AS `last_updated_by`,`b`.`look_value` AS `look_value` from ((`dev_lk_wrk_flow` `a` left join `dev_look_value` `b` on((`a`.`id_wrk_flow` = `b`.`iddev_look_value`))) left join `emp` `c` on((`a`.`updater` = `c`.`emp_id`))) order by `a`.`disp_order` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_look_value`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_look_value`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_look_value` AS select `dlv`.`iddev_look_value` AS `iddev_look_value`,`dlv`.`look_value` AS `look_value`,`dlv`.`look_value_desc` AS `look_value_desc`,`dlv`.`disp_order` AS `disp_order`,`dlv`.`iddev_look` AS `parent_id`,`dlv`.`updater` AS `updater`,if(isnull(`dlv`.`updater`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updater_fmt`,`s`.`file_name` AS `updater_file_name`,`dlv`.`last_updated` AS `last_updated`,if(isnull(`dlv`.`last_updated`),'Never',date_format(`dlv`.`last_updated`,'%m-%d-%y %h:%i %p')) AS `last_updated_fmt`,concat(if(isnull(`dlv`.`updater`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)),' ',convert(if(isnull(`dlv`.`last_updated`),'Never',date_format(`dlv`.`last_updated`,'%m-%d-%y %h:%i %p')) using latin1)) AS `last_updated_by` from ((`dev_look_value` `dlv` left join `emp` `e` on((`dlv`.`updater` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) union all select `dl`.`iddev_look` AS `iddev_look`,`dl`.`look_name` AS `look_name`,`dl`.`look_name_desc` AS `look_name_desc`,`dl`.`disp_order` AS `disp_order`,NULL AS `parent_id`,`dl`.`updater` AS `updater`,if(isnull(`dl`.`updater`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updater_fmt`,`s`.`file_name` AS `updater_file_name`,`dl`.`last_updated` AS `last_updated`,if(isnull(`dl`.`last_updated`),'Never',date_format(`dl`.`last_updated`,'%m-%d-%y %h:%i %p')) AS `last_updated_fmt`,concat(if(isnull(`dl`.`updater`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)),' ',convert(if(isnull(`dl`.`last_updated`),'Never',date_format(`dl`.`last_updated`,'%m-%d-%y %h:%i %p')) using latin1)) AS `last_updated_by` from ((`dev_look` `dl` left join `emp` `e` on((`dl`.`updater` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_rpt`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_rpt`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_rpt` AS select `dev_rpt`.`iddev_rpt` AS `iddev_rpt`,`dev_rpt`.`iddev_apps` AS `iddev_apps`,`dev_rpt`.`app_name` AS `app_name`,`dev_rpt`.`iddev_est` AS `iddev_est`,`dev_rpt`.`dev_est_smry` AS `dev_est_smry`,`dev_rpt`.`category` AS `category`,`dev_rpt`.`category_nm` AS `category_nm`,`dev_rpt`.`priority_id` AS `priority_id`,`dev_rpt`.`priority_value` AS `priority_value`,concat('',convert(if(isnull(`dev_rpt`.`app_name`),'',`dev_rpt`.`app_name`) using utf8),':',if(isnull(`dev_rpt`.`iddev_est`),'',cast(`dev_rpt`.`iddev_est` as char charset utf8)),':',convert(if(isnull(`dev_rpt`.`dev_est_smry`),'',`dev_rpt`.`dev_est_smry`) using utf8),'<br>Category: ',convert(if(isnull(`dev_rpt`.`category_nm`),'',`dev_rpt`.`category_nm`) using utf8),'<br>Priority: ',if(isnull(`dev_rpt`.`priority_value`),'',cast(`dev_rpt`.`priority_value` as char charset utf8)),'<br>W.Or.Skill: ',if(isnull(`dev_rpt`.`skll_level_avg`),'',cast(`dev_rpt`.`skll_level_avg` as char charset utf8)),'<br>W.Or.Gap Level: ',if(isnull(`dev_rpt`.`req_gap_avg`),'',cast(`dev_rpt`.`req_gap_avg` as char charset utf8))) AS `app_wr_id_wr_summary_prid`,`dev_rpt`.`iddev_est_reqs` AS `iddev_est_reqs`,`dev_rpt`.`req_desc` AS `req_desc`,`dev_rpt`.`acpt_cnt` AS `acpt_cnt`,`dev_rpt`.`acpt_attmpt_cnt` AS `acpt_attmpt_cnt`,`dev_rpt`.`skill_level` AS `skill_level`,`dev_rpt`.`skll_level_avg` AS `skll_level_avg`,`dev_rpt`.`req_type_value` AS `req_type_value`,`dev_rpt`.`req_type` AS `req_type`,`dev_rpt`.`wrk_or_gap` AS `wrk_or_gap`,`dev_rpt`.`req_gap` AS `req_gap`,`dev_rpt`.`req_gap_avg` AS `req_gap_avg`,concat('',if(isnull(`dev_rpt`.`iddev_est_reqs`),'',cast(`dev_rpt`.`iddev_est_reqs` as char charset utf8)),':',convert(if(isnull(`dev_rpt`.`req_desc`),'',`dev_rpt`.`req_desc`) using utf8),'<br>Acpt: ',if(isnull(`dev_rpt`.`acpt_cnt`),'',cast(`dev_rpt`.`acpt_cnt` as char charset utf8)),'<br>AcptCnt: ',if(isnull(`dev_rpt`.`acpt_attmpt_cnt`),'',cast(`dev_rpt`.`acpt_attmpt_cnt` as char charset utf8)),'<br>Req skill: ',if(isnull(`dev_rpt`.`skill_level`),'',cast(`dev_rpt`.`skill_level` as char charset utf8)),'<br>Req type: ',if(isnull(`dev_rpt`.`req_type_value`),'',cast(`dev_rpt`.`req_type_value` as char charset utf8)),'<br>Req gap: ',if(isnull(`dev_rpt`.`req_gap`),'',cast(`dev_rpt`.`req_gap` as char charset utf8))) AS `req_measure`,`dev_rpt`.`owner_ref_tab` AS `owner_ref_tab`,`dev_rpt`.`owner_ref_id` AS `owner_ref_id`,`dev_rpt`.`owner_ref_nm` AS `owner_ref_nm`,concat('',if(isnull(`dev_rpt`.`owner_ref_tab`),'',`dev_rpt`.`owner_ref_tab`),':',if(isnull(`dev_rpt`.`owner_ref_nm`),'',`dev_rpt`.`owner_ref_nm`)) AS `owner`,`dev_rpt`.`est_ref_tab` AS `est_ref_tab`,`dev_rpt`.`est_ref_id` AS `est_ref_id`,`dev_rpt`.`est_ref_nm` AS `est_ref_nm`,concat('',if(isnull(`dev_rpt`.`est_ref_tab`),'',`dev_rpt`.`est_ref_tab`),':',if(isnull(`dev_rpt`.`est_ref_nm`),'',`dev_rpt`.`est_ref_nm`)) AS `estimator`,`dev_rpt`.`w_or_opned` AS `w_or_opned`,`dev_rpt`.`w_or_closed` AS `w_or_closed`,`dev_rpt`.`w_or_duration` AS `w_or_duration`,if(isnull(`dev_rpt`.`w_or_closed`),concat(round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`w_or_opned`)) / 3600),0),':',round((round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`w_or_opned`)) % 3600),0) / 60),0)),concat(floor((`dev_rpt`.`w_or_duration` / 60)),':',round((`dev_rpt`.`w_or_duration` % 60),0))) AS `pseudo_w_or_duration`,if(isnull(`dev_rpt`.`w_or_closed`),concat(round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`w_or_opned`)) / 3600),0),'.',round((round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`w_or_opned`)) % 3600),0) / 60),0)),concat(floor((`dev_rpt`.`w_or_duration` / 60)),'.',round((`dev_rpt`.`w_or_duration` % 60),0))) AS `pseudo_w_or_duration_filter`,timestampdiff(SECOND,`dev_rpt`.`w_or_opned`,`dev_rpt`.`w_or_closed`) AS `pseudo_w_or_duration2`,`dev_rpt`.`w_or_cnvr` AS `w_or_cnvr`,concat('Duration: ',if(isnull(`dev_rpt`.`w_or_closed`),concat(round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`w_or_opned`)) / 3600),0),':',round((round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`w_or_opned`)) % 3600),0) / 60),0)),if(isnull(`dev_rpt`.`w_or_duration`),'',concat(floor((`dev_rpt`.`w_or_duration` / 60)),':',round((`dev_rpt`.`w_or_duration` % 60),0)))),'<br>St: ',convert(if(isnull(`dev_rpt`.`w_or_opned`),'',convert(date_format(cast(`dev_rpt`.`w_or_opned` as char charset utf8),'%m-%d-%y %H:%i:%s') using latin1)) using utf8),'<br>End: ',convert(if(isnull(`dev_rpt`.`w_or_closed`),'(Not ended )',convert(date_format(cast(`dev_rpt`.`w_or_closed` as char charset utf8),'%m-%d-%y %H:%i:%s') using latin1)) using utf8),'<br> ',convert(if(isnull(`dev_rpt`.`w_or_cnvr`),'',`dev_rpt`.`w_or_cnvr`) using utf8)) AS `w_or_statistics`,`dev_rpt`.`req_disp_ord` AS `req_disp_ord`,`dev_rpt`.`req_open` AS `req_open`,`dev_rpt`.`req_close` AS `req_close`,`dev_rpt`.`req_tm` AS `req_tm`,if(isnull(`dev_rpt`.`req_close`),concat(round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`req_open`)) / 3600),0),':',round((round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`req_open`)) % 3600),0) / 60),0)),concat(floor((`dev_rpt`.`req_tm` / 60)),':',round((`dev_rpt`.`req_tm` % 60),0))) AS `pseudo_req_time`,`dev_rpt`.`pha_cur_prior_st_en_dt` AS `pha_cur_prior_st_en_dt`,concat('Disp.Or: ',if(isnull(`dev_rpt`.`req_disp_ord`),'',cast(`dev_rpt`.`req_disp_ord` as char charset utf8)),'<br>Open: ',convert(if(isnull(`dev_rpt`.`req_open`),'',convert(date_format(cast(`dev_rpt`.`req_open` as char charset utf8),'%m-%d-%y %H:%i:%s') using latin1)) using utf8),'<br>End: ',convert(if(isnull(`dev_rpt`.`req_close`),'(Not ended )',convert(date_format(cast(`dev_rpt`.`req_close` as char charset utf8),'%m-%d-%y %H:%i:%s') using latin1)) using utf8),'<br>Req TM: ',if(isnull(`dev_rpt`.`req_close`),concat(round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`req_open`)) / 3600),0),':',round((round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`req_open`)) % 3600),0) / 60),0)),concat(floor((`dev_rpt`.`req_tm` / 60)),':',round((`dev_rpt`.`req_tm` % 60),0)))) AS `req_statistics`,`dev_rpt`.`est_type` AS `est_type`,`dev_rpt`.`pha_cnt` AS `pha_cnt`,`dev_rpt`.`pha_curr_id` AS `pha_curr_id`,`dev_rpt`.`pha_curr_value` AS `pha_curr_value`,`dev_rpt`.`pha_cur_st_dt` AS `pha_cur_st_dt`,`dev_rpt`.`pha_cur_end_dt` AS `pha_cur_end_dt`,`dev_rpt`.`pha_cur_by_id` AS `pha_cur_by_id`,`dev_rpt`.`pha_cur_by_nm` AS `pha_cur_by_nm`,concat('Phase: ',if(isnull(`dev_rpt`.`pha_curr_value`),'(No Phase)',cast(`dev_rpt`.`pha_curr_value` as char charset utf8)),'<br>St: ',convert(if(isnull(`dev_rpt`.`pha_cur_st_dt`),'(Not Started)',convert(date_format(cast(`dev_rpt`.`pha_cur_st_dt` as char charset utf8),'%m-%d-%y %H:%i:%s') using latin1)) using utf8),'<br>End: ',convert(if(isnull(`dev_rpt`.`pha_cur_end_dt`),'(Not Ended )',convert(date_format(cast(`dev_rpt`.`pha_cur_end_dt` as char charset utf8),'%m-%d-%y %H:%i:%s') using latin1)) using utf8),'<br>Phases Count: ',if(isnull(`dev_rpt`.`pha_cnt`),'0',cast(`dev_rpt`.`pha_cnt` as char charset utf8)),'<br>Assigned to: ',if(isnull(`dev_rpt`.`pha_cur_by_nm`),'',cast(`dev_rpt`.`pha_cur_by_nm` as char charset utf8))) AS `current_phase`,`dev_rpt`.`pha_cur_duration` AS `pha_cur_duration`,if(isnull(`dev_rpt`.`pha_cur_end_dt`),concat(round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`pha_cur_st_dt`)) / 3600),0),':',round((round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`pha_cur_st_dt`)) % 3600),0) / 60),0)),concat(floor((`dev_rpt`.`pha_cur_duration` / 60)),':',round((`dev_rpt`.`pha_cur_duration` % 60),0))) AS `pseudo_pha_cur_duration`,concat(`dev_rpt`.`pha1_nm`,'->',`dev_rpt`.`pha_last_name`) AS `phase_cycle`,concat(`dev_rpt`.`pha1_by_nm`,'->',`dev_rpt`.`pha_last_by_name`) AS `phase_cycle_by`,`dev_rpt`.`pha1_id` AS `pha1_id`,`dev_rpt`.`pha1_nm` AS `pha1_nm`,`dev_rpt`.`pha1_by_id` AS `pha1_by_id`,`dev_rpt`.`pha1_by_nm` AS `pha1_by_nm`,`dev_rpt`.`pha1_lag` AS `pha1_lag`,concat(floor((`dev_rpt`.`pha1_lag` / 60)),':',round((`dev_rpt`.`pha1_lag` % 60),0)) AS `pseudo_pha1_lag`,`dev_rpt`.`pha1_duration` AS `pha1_duration`,concat(floor((`dev_rpt`.`pha1_duration` / 60)),':',round((`dev_rpt`.`pha1_duration` % 60),0)) AS `pseudo_pha1_duration`,concat('',if(isnull(`dev_rpt`.`pha1_nm`),'No Phase',concat(' Phase:',cast(`dev_rpt`.`pha1_nm` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha1_by_nm`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha1_by_nm`)) using utf8),'<br>Lag: ',if(isnull(`dev_rpt`.`pha1_lag`),'',cast(concat(floor((`dev_rpt`.`pha1_lag` / 60)),':',round((`dev_rpt`.`pha1_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha1_duration`),'',cast(concat(floor((`dev_rpt`.`pha1_duration` / 60)),':',round((`dev_rpt`.`pha1_duration` % 60),0)) as char charset utf8))) AS `phase1`,concat('',if(isnull(`dev_rpt`.`pha2_nm`),'No Phase',concat(' Phase:',cast(`dev_rpt`.`pha2_nm` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha2_by_nm`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha2_by_nm`)) using utf8),'<br>Lag: ',if(isnull(`dev_rpt`.`pha2_lag`),'',cast(concat(floor((`dev_rpt`.`pha2_lag` / 60)),':',round((`dev_rpt`.`pha2_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha2_duration`),'',cast(concat(floor((`dev_rpt`.`pha2_duration` / 60)),':',round((`dev_rpt`.`pha2_duration` % 60),0)) as char charset utf8))) AS `phase2`,concat('',if(isnull(`dev_rpt`.`pha3_nm`),'No Phase',concat(' Phase:',cast(`dev_rpt`.`pha3_nm` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha3_by_nm`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha3_by_nm`)) using utf8),'<br>Lag: ',if(isnull(`dev_rpt`.`pha3_lag`),'',cast(concat(floor((`dev_rpt`.`pha3_lag` / 60)),':',round((`dev_rpt`.`pha3_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha3_duration`),'',cast(concat(floor((`dev_rpt`.`pha3_duration` / 60)),':',round((`dev_rpt`.`pha3_duration` % 60),0)) as char charset utf8))) AS `phase3`,concat('',if(isnull(`dev_rpt`.`pha4_nm`),'No Phase',concat(' Phase:',cast(`dev_rpt`.`pha4_nm` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha4_by_nm`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha4_by_nm`)) using utf8),'<br>Lag: ',if(isnull(`dev_rpt`.`pha4_lag`),'',cast(concat(floor((`dev_rpt`.`pha4_lag` / 60)),':',round((`dev_rpt`.`pha4_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha4_duration`),'',cast(concat(floor((`dev_rpt`.`pha4_duration` / 60)),':',round((`dev_rpt`.`pha4_duration` % 60),0)) as char charset utf8))) AS `phase4`,concat('',if(isnull(`dev_rpt`.`pha5_nm`),'No Phase',concat(' Phase:',cast(`dev_rpt`.`pha5_nm` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha5_by_nm`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha5_by_nm`)) using utf8),'<br>Lag: ',if(isnull(`dev_rpt`.`pha5_lag`),'',cast(concat(floor((`dev_rpt`.`pha5_lag` / 60)),':',round((`dev_rpt`.`pha5_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha5_duration`),'',cast(concat(floor((`dev_rpt`.`pha5_duration` / 60)),':',round((`dev_rpt`.`pha5_duration` % 60),0)) as char charset utf8))) AS `phase5`,concat('',if(isnull(`dev_rpt`.`pha1_nm`),'No Phase',concat('',if(isnull(`dev_rpt`.`pha1_nm`),'No Phase',concat(' Phase1:',cast(`dev_rpt`.`pha1_nm` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha1_by_nm`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha1_by_nm`)) using utf8),'<br>Lag: ',if(isnull(`dev_rpt`.`pha1_lag`),'',cast(concat(floor((`dev_rpt`.`pha1_lag` / 60)),':',round((`dev_rpt`.`pha1_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha1_duration`),'',cast(concat(floor((`dev_rpt`.`pha1_duration` / 60)),':',round((`dev_rpt`.`pha1_duration` % 60),0)) as char charset utf8)),'<br><br>',if(isnull(`dev_rpt`.`pha2_nm`),'',concat('',if(isnull(`dev_rpt`.`pha2_nm`),'No Phase',concat(' Phase2:',cast(`dev_rpt`.`pha2_nm` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha2_by_nm`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha2_by_nm`)) using utf8),'<br>Lag: ',if(isnull(`dev_rpt`.`pha2_lag`),'',cast(concat(floor((`dev_rpt`.`pha2_lag` / 60)),':',round((`dev_rpt`.`pha2_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha2_duration`),'',cast(concat(floor((`dev_rpt`.`pha2_duration` / 60)),':',round((`dev_rpt`.`pha2_duration` % 60),0)) as char charset utf8)),'<br><br>',if(isnull(`dev_rpt`.`pha3_nm`),'',concat('',if(isnull(`dev_rpt`.`pha3_nm`),'No Phase',concat(' Phase3:',cast(`dev_rpt`.`pha3_nm` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha3_by_nm`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha3_by_nm`)) using utf8),'<br>Lag: ',if(`dev_rpt`.`pha3_lag`,'',cast(concat(floor((`dev_rpt`.`pha3_lag` / 60)),':',round((`dev_rpt`.`pha3_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha3_duration`),'',cast(concat(floor((`dev_rpt`.`pha3_duration` / 60)),':',round((`dev_rpt`.`pha3_duration` % 60),0)) as char charset utf8)),'<br><br>',if(isnull(`dev_rpt`.`pha4_nm`),'',concat('',if(isnull(`dev_rpt`.`pha4_nm`),'No Phase',concat(' Phase4:',cast(`dev_rpt`.`pha4_nm` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha4_by_nm`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha4_by_nm`)) using utf8),'<br>Lag: ',if(isnull(`dev_rpt`.`pha4_lag`),'',cast(concat(floor((`dev_rpt`.`pha4_lag` / 60)),':',round((`dev_rpt`.`pha4_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha4_duration`),'',cast(concat(floor((`dev_rpt`.`pha4_duration` / 60)),':',round((`dev_rpt`.`pha4_duration` % 60),0)) as char charset utf8)),'<br><br>',if(isnull(`dev_rpt`.`pha5_nm`),'',concat('',if(isnull(`dev_rpt`.`pha5_nm`),'No Phase',concat(' Phase5:',cast(`dev_rpt`.`pha5_nm` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha5_by_nm`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha5_by_nm`)) using utf8),'<br>Lag: ',if(isnull(`dev_rpt`.`pha5_lag`),'',cast(concat(floor((`dev_rpt`.`pha5_lag` / 60)),':',round((`dev_rpt`.`pha5_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha5_duration`),'',cast(concat(floor((`dev_rpt`.`pha5_duration` / 60)),':',round((`dev_rpt`.`pha5_duration` % 60),0)) as char charset utf8)),'<br><br>: ',convert(if(isnull(`dev_rpt`.`pha6_plus`),'',`dev_rpt`.`pha6_plus`) using utf8)))))))))))) AS `pha6_plus`,concat('',if(isnull(`dev_rpt`.`pha_last_name`),'No Phase',concat(' Phase:',cast(`dev_rpt`.`pha_last_name` as char charset utf8))),convert(if(isnull(`dev_rpt`.`pha_last_by_name`),' :No Assignee',concat('<br>Assigned to:',`dev_rpt`.`pha_last_by_name`)) using utf8),'<br>Lag: ',if(isnull(`dev_rpt`.`pha_last_lag`),'',cast(concat(floor((`dev_rpt`.`pha_last_lag` / 60)),':',round((`dev_rpt`.`pha_last_lag` % 60),0)) as char charset utf8)),'<br>Duration: ',if(isnull(`dev_rpt`.`pha_last_duration`),'',cast(concat(floor((`dev_rpt`.`pha_last_duration` / 60)),':',round((`dev_rpt`.`pha_last_duration` % 60),0)) as char charset utf8))) AS `last_phase`,`dev_rpt`.`pha_smry` AS `pha_smry`,`dev_rpt`.`last_updated` AS `last_updated`,`dev_rpt`.`pha_cur_lag` AS `pha_cur_lag`,if((`dev_rpt`.`pha_cur_lag` = '0'),concat(round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`pha_cur_prior_st_en_dt`)) / 3600),0),':',round((round(((unix_timestamp(now()) - unix_timestamp(`dev_rpt`.`pha_cur_prior_st_en_dt`)) % 3600),0) / 60),0)),'0') AS `pseudo_pha_cur_lag`,`dev_rpt`.`tot_duration` AS `tot_duration`,concat(floor((`dev_rpt`.`tot_duration` / 60)),':',round((`dev_rpt`.`tot_duration` % 60),0)) AS `pseudo_tot_duration`,`dev_rpt`.`tot_lag` AS `tot_lag`,concat(floor((`dev_rpt`.`tot_lag` / 60)),':',round((`dev_rpt`.`tot_lag` % 60),0)) AS `pseudo_tot_lag`,`dev_rpt`.`pha2_id` AS `pha2_id`,`dev_rpt`.`pha2_nm` AS `pha2_nm`,`dev_rpt`.`pha2_by_id` AS `pha2_by_id`,`dev_rpt`.`pha2_by_nm` AS `pha2_by_nm`,`dev_rpt`.`pha2_lag` AS `pha2_lag`,concat(floor((`dev_rpt`.`pha2_lag` / 60)),':',round((`dev_rpt`.`pha2_lag` % 60),0)) AS `pseudo_pha2_lag`,`dev_rpt`.`pha2_duration` AS `pha2_duration`,concat(floor((`dev_rpt`.`pha2_duration` / 60)),':',round((`dev_rpt`.`pha2_duration` % 60),0)) AS `pseudo_pha2_duration`,`dev_rpt`.`pha3_id` AS `pha3_id`,`dev_rpt`.`pha3_nm` AS `pha3_nm`,`dev_rpt`.`pha3_by_id` AS `pha3_by_id`,`dev_rpt`.`pha3_by_nm` AS `pha3_by_nm`,`dev_rpt`.`pha3_lag` AS `pha3_lag`,concat(floor((`dev_rpt`.`pha3_lag` / 60)),':',round((`dev_rpt`.`pha3_lag` % 60),0)) AS `pseudo_pha3_lag`,`dev_rpt`.`pha3_duration` AS `pha3_duration`,concat(floor((`dev_rpt`.`pha3_duration` / 60)),':',round((`dev_rpt`.`pha3_duration` % 60),0)) AS `pseudo_pha3_duration`,`dev_rpt`.`pha4_id` AS `pha4_id`,`dev_rpt`.`pha4_nm` AS `pha4_nm`,`dev_rpt`.`pha4_by_id` AS `pha4_by_id`,`dev_rpt`.`pha4_by_nm` AS `pha4_by_nm`,`dev_rpt`.`pha4_lag` AS `pha4_lag`,concat(floor((`dev_rpt`.`pha4_lag` / 60)),':',round((`dev_rpt`.`pha4_lag` % 60),0)) AS `pseudo_pha4_lag`,`dev_rpt`.`pha4_duration` AS `pha4_duration`,concat(floor((`dev_rpt`.`pha4_duration` / 60)),':',round((`dev_rpt`.`pha4_duration` % 60),0)) AS `pseudo_pha4_duration`,`dev_rpt`.`pha5_id` AS `pha5_id`,`dev_rpt`.`pha5_nm` AS `pha5_nm`,`dev_rpt`.`pha5_by_id` AS `pha5_by_id`,`dev_rpt`.`pha5_by_nm` AS `pha5_by_nm`,`dev_rpt`.`pha5_lag` AS `pha5_lag`,concat(floor((`dev_rpt`.`pha5_lag` / 60)),':',round((`dev_rpt`.`pha5_lag` % 60),0)) AS `pseudo_pha5_lag`,`dev_rpt`.`pha5_duration` AS `pha5_duration`,concat(floor((`dev_rpt`.`pha5_duration` / 60)),':',round((`dev_rpt`.`pha5_duration` % 60),0)) AS `pseudo_pha5_duration`,`dev_rpt`.`updater` AS `updater`,`dev_rpt`.`updater_nm` AS `updater_nm`,convert(date_format(cast(`dev_rpt`.`last_updated` as char charset utf8),'%m-%d-%y %H:%i:%s') using latin1) AS `last_updated_formated`,`dev_rpt`.`pha_last_id` AS `pha_last_id`,`dev_rpt`.`pha_last_name` AS `pha_last_name`,`dev_rpt`.`pha_last_by_id` AS `pha_last_by_id`,`dev_rpt`.`pha_last_by_name` AS `pha_last_by_name`,`dev_rpt`.`pha_last_lag` AS `pha_last_lag`,`dev_rpt`.`pha_last_duration` AS `pha_last_duration`,`dev_rpt`.`assigned_to_ids` AS `assigned_to_ids`,concat(floor((`dev_rpt`.`pha_last_lag` / 60)),':',round((`dev_rpt`.`pha_last_lag` % 60),0)) AS `pseudo_pha_last_lag`,concat(floor((`dev_rpt`.`pha_last_duration` / 60)),':',round((`dev_rpt`.`pha_last_duration` % 60),0)) AS `pseudo_pha_last_duration` from `dev_rpt` order by `dev_rpt`.`priority_id`,`dev_rpt`.`pha_cur_duration` desc,`dev_rpt`.`pha_cur_lag` desc,`dev_rpt`.`tot_duration` desc,`dev_rpt`.`tot_lag` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_trng`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_trng`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_trng` AS select `a`.`iddev_trng` AS `iddev_trng`,`a`.`disp_order` AS `disp_order`,`a`.`train_nm` AS `train_nm`,`a`.`train_desc` AS `train_desc`,`a`.`duration` AS `duration`,`a`.`cnt` AS `cnt`,`a`.`practical` AS `practical`,`a`.`updater` AS `updater`,ifnull(`b`.`fullname`,'Admin') AS `updater_nm`,`a`.`last_updated` AS `last_updated`,ifnull(`a`.`last_updated`,'never') AS `last_updated_formatted`,concat(convert(coalesce(`a`.`last_updated`,'Never') using latin1),'  ',convert(coalesce(`b`.`fullname`,'Admin') using latin1)) AS `last_updated_by`,`a`.`del_dt` AS `del_dt`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt_formatted`,`a`.`del_by` AS `del_by`,ifnull(`c`.`fullname`,'Admin') AS `del_by_formatted`,`e`.`file_name` AS `del_by_file_name`,`a`.`del_day` AS `del_day`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `del_day_formatted`,`a`.`archv_by` AS `arch_by`,ifnull(`d`.`fullname`,'Admin') AS `arch_by_formatted`,`f`.`file_name` AS `arch_by_file_name`,`a`.`archv_dt` AS `arch_dt`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `arch_dt_formatted` from (((((`dev_trng` `a` left join `vw_emp` `b` on((`a`.`updater` = `b`.`emp_id`))) left join `vw_emp` `c` on((`a`.`del_dt` = `c`.`emp_id`))) left join `vw_emp` `d` on((`a`.`archv_by` = `d`.`emp_id`))) left join `storages` `e` on((`c`.`emp_id` = `e`.`emp_id`))) left join `storages` `f` on((`d`.`emp_id` = `f`.`emp_id`))) order by `a`.`disp_order` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dev_trng_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_dev_trng_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dev_trng_attach` AS select `a`.`iddev_trng_attach` AS `iddev_trng_attach`,`a`.`iddev_trng` AS `iddev_trng`,`a`.`disp_order` AS `disp_order`,`a`.`trng_desc` AS `trng_desc`,`a`.`duration` AS `duration`,`a`.`idstorage` AS `idstorage`,`a`.`cloud_link` AS `cloud_link`,`a`.`updater` AS `updater`,ifnull(`b`.`fullname`,'Admin') AS `updater_nm`,`a`.`last_updated` AS `last_updated`,ifnull(`a`.`last_updated`,'never') AS `last_updated_formatted`,concat(convert(coalesce(`a`.`last_updated`,'Never') using latin1),'  ',convert(coalesce(`b`.`fullname`,'Admin') using latin1)) AS `last_updated_by`,`a`.`del_dt` AS `del_dt`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt_formatted`,`a`.`del_by` AS `del_by`,ifnull(`c`.`fullname`,'Admin') AS `del_by_formatted`,`e`.`file_name` AS `del_by_file_name`,`a`.`del_day` AS `del_day`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `del_day_formatted`,`a`.`archv_by` AS `arch_by`,ifnull(`d`.`fullname`,'Admin') AS `arch_by_formatted`,`f`.`file_name` AS `arch_by_file_name`,`a`.`archv_dt` AS `arch_dt`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `arch_dt_formatted` from (((((`dev_trng_attach` `a` left join `vw_emp` `b` on((`a`.`updater` = `b`.`emp_id`))) left join `vw_emp` `c` on((`a`.`del_dt` = `c`.`emp_id`))) left join `vw_emp` `d` on((`a`.`archv_by` = `d`.`emp_id`))) left join `storages` `e` on((`c`.`emp_id` = `e`.`emp_id`))) left join `storages` `f` on((`d`.`emp_id` = `f`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dyn_emp_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_dyn_emp_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dyn_emp_attach` AS select `vw_emp_attach`.`emp_id` AS `emp_id`,group_concat(ifnull(`vw_emp_attach`.`file_name`,'') separator ' , ') AS `file_group` from `vw_emp_attach` group by `vw_emp_attach`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dyn_emp_contact`
--

/*!50001 DROP VIEW IF EXISTS `vw_dyn_emp_contact`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dyn_emp_contact` AS select `vw_emp_contact2`.`emp_id` AS `emp_id`,`vw_emp_contact2`.`employee_name` AS `employee_name`,`vw_emp_contact2`.`contacts` AS `contacts` from `vw_emp_contact2` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dyn_emp_tag`
--

/*!50001 DROP VIEW IF EXISTS `vw_dyn_emp_tag`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dyn_emp_tag` AS select `emp_tag`.`emp_id` AS `emp_id`,concat(group_concat((select `look_values`.`look_values` from `look_values` where (`look_values`.`look_values_id` = `emp_tag`.`emp_tags`) order by `look_values`.`look_display_id`) separator ' , ')) AS `tags` from `emp_tag` group by `emp_tag`.`emp_id` order by (select `look_values`.`look_display_id` from `look_values` where (`look_values`.`look_values_id` = `emp_tag`.`emp_tags`)),`emp_tag`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dyn_prosp_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_dyn_prosp_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dyn_prosp_attach` AS select `vw_sales_prosp_attach`.`prosp_consult_id` AS `prosp_consult_id`,group_concat(ifnull(`vw_sales_prosp_attach`.`file_name`,'') separator ' , ') AS `file_group` from `vw_sales_prosp_attach` group by `vw_sales_prosp_attach`.`prosp_consult_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_dyn_prosp_contact`
--

/*!50001 DROP VIEW IF EXISTS `vw_dyn_prosp_contact`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`jitenpatel`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_dyn_prosp_contact` AS select `vw_sales_prosp_contact`.`prosp_consult_id` AS `prosp_consult_id`,group_concat(ifnull(`vw_sales_prosp_contact`.`prosp_contact_type`,''),':',ifnull(`vw_sales_prosp_contact`.`contact_detail`,'') separator ' , ') AS `group_contact` from `vw_sales_prosp_contact` group by `vw_sales_prosp_contact`.`prosp_consult_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp` AS select `a`.`emp_id` AS `emp_id`,`a`.`firstname` AS `firstname`,`a`.`lastname` AS `lastname`,concat(`a`.`firstname`,' ',`a`.`lastname`) AS `fullname`,`a`.`nickname` AS `nickname`,`a`.`unique_id_type` AS `unique_id`,ifnull(`uid`.`emp_value`,'NA') AS `unique_id_type`,ifnull(`a`.`ssn`,'NO SSN') AS `ssn`,ifnull(`a`.`dob`,'NO DOB') AS `dob`,`a`.`gender` AS `gender_id`,ifnull(`g`.`emp_value`,'None') AS `gender`,`a`.`sto_limit` AS `sto_limit`,cast((((`a`.`sto_limit` / 1024) / 1024) / 1024) as decimal(10,2)) AS `sto_limit_format`,`s`.`file_name` AS `emp_file_name`,ifnull(`a`.`taxid`,'NO TAXID') AS `taxid`,`a`.`login_id` AS `login_id`,`l`.`isp` AS `isp`,`l`.`domain_name` AS `domain_name`,`l`.`country` AS `country`,`l`.`lastlogin` AS `lastlogin`,`l`.`logged_in` AS `logged_in`,`l`.`lastlogout` AS `lastlogout`,ifnull(concat(round(((unix_timestamp(now()) - unix_timestamp(`l`.`lastlogout_unformatted`)) / 3600),0),_utf8':',round((round(((unix_timestamp(now()) - unix_timestamp(`l`.`lastlogout_unformatted`)) % 3600),0) / 60),0)),'Live') AS `loggged_out`,`l`.`main_menu` AS `main_menu`,`l`.`sub_menu` AS `sub_menu`,`a`.`updater` AS `updater`,ifnull(concat(`u`.`firstname`,'  ',`u`.`lastname`),'Admin') AS `updater_nm`,`uf`.`file_name` AS `updater_file_name`,`a`.`last_updated` AS `last_updated`,concat(convert(date_format(`a`.`last_updated`,'%m-%d-%y %H:%i:%s %p') using latin1),' ') AS `last_updated_formatted`,`a`.`del_dt` AS `del_dt_unformatted`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,`a`.`del_by` AS `del_by_id`,ifnull(concat(`e_del_by`.`firstname`,' ',`e_del_by`.`lastname`),'Admin') AS `del_by`,`o_del_by`.`file_name` AS `del_by_file_name`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt_unformatted`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt`,`a`.`archv_by` AS `archv_by_id`,ifnull(concat(`e_archv_by`.`firstname`,' ',`e_archv_by`.`lastname`),'Admin') AS `archv_by`,`o_archv_by`.`file_name` AS `archv_by_file_name` from ((((((((((`emp` `a` left join `storages` `s` on((`a`.`idstorage` = `s`.`idstorage`))) left join `emp_lk_val` `g` on((`a`.`gender` = `g`.`idemp_lk_value`))) left join `emp_lk_val` `uid` on((`a`.`unique_id_type` = `uid`.`idemp_lk_value`))) left join `vw_all_users_login` `l` on((`a`.`login_id` = `l`.`login_id`))) left join `emp` `u` on((`a`.`updater` = `u`.`emp_id`))) left join `emp` `e_del_by` on((`a`.`del_by` = `e_del_by`.`emp_id`))) left join `emp` `e_archv_by` on((`a`.`archv_by` = `e_archv_by`.`emp_id`))) left join `storages` `o_del_by` on((`e_del_by`.`idstorage` = `o_del_by`.`idstorage`))) left join `storages` `o_archv_by` on((`e_archv_by`.`idstorage` = `o_archv_by`.`idstorage`))) left join `storages` `uf` on((`u`.`idstorage` = `uf`.`idstorage`))) order by `a`.`last_updated` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_access`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_access`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_access` AS select `a`.`access_id` AS `access_id`,`a`.`emp_id` AS `emp_id`,concat(`b`.`firstname`,_latin1' ',`b`.`lastname`) AS `emp_name`,`a`.`feature_id` AS `feature_id`,`c`.`feature_name` AS `feature_name`,`c`.`feature_desc` AS `feature_desc`,`c`.`disp_order` AS `disp_order`,`a`.`last_updated` AS `last_updated`,`a`.`updated_by` AS `updated_by`,`a`.`del_dt` AS `del_dt`,`a`.`del_by` AS `del_by`,`a`.`del_day` AS `del_day`,`a`.`archv_dt` AS `archv_dt`,`a`.`archv_by` AS `archv_by` from ((`emp_access` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) left join `feature` `c` on((`c`.`feature_id` = `a`.`feature_id`))) order by date_format(`a`.`last_updated`,_utf8'%Y-%m-%d %h:%i %p') desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_activity`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_activity`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_activity` AS select `a`.`idemp_activity` AS `idemp_activity`,`a`.`emp_id` AS `empd_id`,date_format(`a`.`call_recv_dt`,_utf8'%m.%d.%y') AS `call_recv_dt`,`a`.`emp_id` AS `emp_id`,(case when (`a`.`emp_id` <> 0) then concat_ws(_latin1' ',`b`.`firstname`,`b`.`lastname`) else 'Admin' end) AS `updater`,date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') AS `next_call_dt`,`a`.`call_note` AS `call_note`,date_format(`a`.`last_updated`,_utf8'%m.%d.%y %T') AS `last_updated` from (`emp_activity` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_add1`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_add1`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_add1` AS select `a`.`emp_add_id` AS `emp_add_id`,`a`.`emp_id` AS `emp_id`,date_format(`a`.`from_dt`,'%m-%d-%y') AS `from_dt`,date_format(`a`.`from_dt`,'%Y-%m-%d') AS `sort_from_dt`,date_format(`a`.`to_dt`,'%m-%d-%y') AS `to_dt`,convert((case when isnull(`a`.`to_dt`) then ceiling((((to_days(curdate()) - to_days(`a`.`from_dt`)) / 365.25) * 365.25)) else ceiling((((to_days(`a`.`to_dt`) - to_days(`a`.`from_dt`)) / 365.25) * 365.25)) end) using latin1) AS `no_days_lived`,convert((case when isnull(`a`.`to_dt`) then floor(((to_days(curdate()) - to_days(`a`.`from_dt`)) / 365.25)) else floor(((to_days(`a`.`to_dt`) - to_days(`a`.`from_dt`)) / 365.25)) end) using latin1) AS `no_years_lived`,date_format(`a`.`to_dt`,'%Y-%m-%d') AS `sort_to_dt`,`a`.`add_type` AS `add_type`,`a`.`house_apt_no` AS `house_apt_no`,`a`.`look_street_no_id` AS `look_street_no_id`,`b`.`look_street_no_id` AS `look_street_no_id2`,concat_ws(' ',`b`.`look_street_no`,' ',`b`.`street_name`,' ',(select `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `b`.`street_type`)),',','#',`a`.`house_apt_no`,'',`b`.`city_name`,' ',`b`.`state_name`,'  ',`b`.`zip_code`) AS `addresses` from (`emp_address` `a` left join `vw_addresses` `b` on((`a`.`look_street_no_id` = `b`.`look_street_no_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_add2`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_add2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_add2` AS select `vw_emp_add1`.`emp_id` AS `emp_id`,group_concat(`vw_emp_add1`.`addresses`,_latin1'(',_latin1'Years:',`vw_emp_add1`.`no_years_lived`,_latin1'',_latin1',',_latin1'Days:',`vw_emp_add1`.`no_days_lived`,_latin1')' separator ',') AS `addresses` from `vw_emp_add1` group by `vw_emp_add1`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_address`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_address`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_address` AS select `a`.`emp_add_id` AS `emp_add_id`,`a`.`emp_id` AS `emp_id`,`a`.`house_apt_no` AS `house_apt_no`,`a`.`house_apt_type` AS `house_apt_type`,`l`.`emp_value` AS `house_apt_type_nm`,`a`.`look_street_no_id` AS `look_street_no_id`,`b`.`look_street_no` AS `look_street_no`,`b`.`street_name` AS `street_name`,`b`.`street_type` AS `street_type`,`b`.`street_type_name` AS `street_type_name`,`b`.`zip_code` AS `zip_code`,`b`.`city_name` AS `city_name`,`b`.`state_name` AS `state_name`,`b`.`con_name` AS `con_name`,`b`.`addresses` AS `addresses`,`a`.`add_type` AS `add_type`,`v`.`emp_value` AS `add_type_nm`,`a`.`from_dt` AS `from_dt`,`a`.`to_dt` AS `to_dt`,(case when (`a`.`from_dt` <> _utf8'0000-00-00') then date_format(`a`.`from_dt`,_utf8'%m-%d-%y') else _utf8'' end) AS `from_dt_formatted`,(case when (`a`.`to_dt` <> _utf8'0000-00-00') then date_format(`a`.`to_dt`,_utf8'%m-%d-%y') else _utf8'' end) AS `to_dt_formatted`,`a`.`updater` AS `updater`,if(isnull(`a`.`updater`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updater_nm`,`s`.`file_name` AS `updater_file_name`,`a`.`last_updated` AS `last_updated`,concat(convert(date_format(`a`.`last_updated`,'%m-%d-%y %H:%i:%s %p') using latin1),' ') AS `format_last_updated` from (((((`emp_address` `a` left join `vw_look_addresses` `b` on((`a`.`look_street_no_id` = `b`.`look_street_no_id`))) left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) left join `emp_lk_val` `l` on((`a`.`house_apt_type` = `l`.`idemp_lk_value`))) left join `emp_lk_val` `v` on((`a`.`add_type` = `v`.`idemp_lk_value`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_attach` AS select `a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,date_format(`a`.`create_dt`,_utf8'%m-%d-%y') AS `create_dt`,(case when (`a`.`owner_id` = _latin1'') then 'Admin' when isnull(`a`.`owner_id`) then 'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updater`,`b`.`emp_id` AS `emp_id`,concat(`c`.`firstname`,_latin1' ',`c`.`lastname`) AS `emp_name` from (((`storages` `a` left join `emp_attach` `b` on((`a`.`idstorage` = `b`.`idstorage`))) left join `emp` `e` on((`a`.`owner_id` = `e`.`emp_id`))) left join `emp` `c` on((`b`.`emp_id` = `c`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_attachment`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_attachment`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_attachment` AS select `a`.`emp_legal_id` AS `emp_legal_id`,`a`.`doc_type` AS `doc_type`,`d`.`look_values` AS `doc_look_values`,`a`.`expire_dt` AS `expire_dt`,`b`.`emp_id` AS `emp_id`,`a`.`idstorage` AS `idstorage`,`a`.`updater` AS `updater`,`c`.`owner_id` AS `owner_id`,`c`.`file_name` AS `file_name`,`c`.`public` AS `public`,`c`.`self_view` AS `self_view`,`c`.`shared` AS `shared`,`c`.`updated_for_ref_id` AS `updated_for_ref_id`,`c`.`updated_for_ref_table` AS `updated_for_ref_table`,`a`.`last_updated` AS `last_updated` from (((`emp_legal` `a` left join `storages` `c` on((`a`.`idstorage` = `c`.`idstorage`))) left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) left join `look_values` `d` on((`a`.`doc_type` = `d`.`look_values_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_billing_details`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_billing_details`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_billing_details` AS select `c`.`companyname` AS `companyname`,`eep`.`bill_pay_rate` AS `bill_pay_rate`,`eb`.`engage_calc` AS `engage_calc`,`eb`.`engage_amt` AS `engage_amt`,`eb`.`engage_st_dt` AS `engage_st_dt`,`eb`.`engage_end_st` AS `engage_end_st`,`eb`.`limit_amt` AS `limit_amt`,`eb`.`engage_summary` AS `engage_summary`,`eb`.`engage_ref_id` AS `engage_ref_id` from ((((`engage` `e` left join `engage_entity` `ee` on((`e`.`engage_id` = `ee`.`engage_id`))) left join `engage_entity_po` `eep` on((`ee`.`idengage_entity` = `eep`.`idengage_entity`))) left join `engage_budget` `eb` on((`eb`.`idengage_entity_po` = `eep`.`idengage_entity_po`))) left join `company` `c` on((`c`.`comp_id` = `e`.`srv_client`))) where ((`eb`.`show_emp` = (select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where ((`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'yes_no'))) and (`look_values`.`look_values` = _latin1'Yes')))) and (`eb`.`engage_ref_table` = _latin1'Employee')) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_contact`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_contact`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_contact` AS select `a`.`emp_contact_id` AS `emp_contact_id`,`a`.`emp_id` AS `emp_id`,`a`.`contact_id` AS `contact_id`,`a`.`emp_contact_type` AS `emp_contact_type`,`c`.`emp_value` AS `contact_type`,`b`.`contact_detail` AS `contact_detail`,`a`.`summary` AS `summary`,`a`.`updater` AS `updater`,if(isnull(`a`.`updater`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updater_nm`,`s`.`file_name` AS `updater_file_name`,`a`.`last_updated` AS `last_updated`,concat(convert(date_format(`a`.`last_updated`,'%m-%d-%y %H:%i:%s %p') using latin1),' ') AS `format_last_updated` from ((((`emp_contact` `a` left join `contact_no` `b` on((`a`.`contact_id` = `b`.`contact_id`))) left join `emp_lk_val` `c` on((`a`.`emp_contact_type` = `c`.`idemp_lk_value`))) left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_contact1`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_contact1`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_contact1` AS select `a`.`emp_id` AS `emp_id`,concat(`a`.`firstname`,_latin1' ',`a`.`lastname`) AS `employee_name`,`b`.`emp_contact_id` AS `emp_contact_id`,(select `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `b`.`emp_contact_type`)) AS `contact_type`,`b`.`summary` AS `summary`,`c`.`contact_id` AS `contact_id`,`c`.`contact_detail` AS `contact_detail` from ((`emp` `a` left join `emp_contact` `b` on((`a`.`emp_id` = `b`.`emp_id`))) left join `contact_no` `c` on((`b`.`contact_id` = `c`.`contact_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_contact2`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_contact2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_contact2` AS select `vw_emp_contact1`.`emp_id` AS `emp_id`,`vw_emp_contact1`.`employee_name` AS `employee_name`,concat(`vw_emp_contact1`.`contact_type`,_latin1' \r\n                ',group_concat(distinct `vw_emp_contact1`.`contact_detail` separator ',\n                    ')) AS `contacts` from `vw_emp_contact1` group by `vw_emp_contact1`.`emp_id`,`vw_emp_contact1`.`contact_type` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_contact3`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_contact3`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_contact3` AS select `vw_emp_contact2`.`emp_id` AS `emp_id`,(select `storages`.`file_name` AS `img` from `storages` where (`storages`.`idstorage` = `emp`.`idstorage`)) AS `img`,`vw_emp_contact2`.`employee_name` AS `employee_name`,group_concat(distinct `vw_emp_contact2`.`contacts` separator ',') AS `contacts` from (`vw_emp_contact2` left join `emp` on((`vw_emp_contact2`.`emp_id` = `emp`.`emp_id`))) group by `vw_emp_contact2`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_contact4`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_contact4`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_contact4` AS select `a`.`emp_id` AS `emp_id`,`a`.`img` AS `img`,`a`.`employee_name` AS `employee_name`,`a`.`contacts` AS `contacts`,concat(_latin1'SSN:',`e`.`ssn`,_latin1' \r\n                ',_latin1'DOB:',convert((case when (`e`.`dob` <> _utf8'0000-00-00') then date_format(`e`.`dob`,_utf8'%m-%d-%y') else _utf8'' end) using latin1),_latin1' ',_latin1'GENDER:',`f`.`look_values`) AS `personel` from ((`vw_emp_contact3` `a` left join `emp` `e` on((`a`.`emp_id` = `e`.`emp_id`))) left join `look_values` `f` on((`e`.`gender` = `f`.`look_values_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_contact5`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_contact5`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_contact5` AS select `a`.`emp_id` AS `emp_id`,`a`.`img` AS `img`,`a`.`employee_name` AS `employee_name`,`a`.`contacts` AS `contacts`,`a`.`personel` AS `personel`,`b`.`addresses` AS `addresses` from (`vw_emp_contact4` `a` left join `vw_emp_add2` `b` on((`a`.`emp_id` = `b`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_contact6`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_contact6`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_contact6` AS select `a`.`emp_id` AS `emp_id`,`a`.`img` AS `img`,`a`.`employee_name` AS `employee_name`,`a`.`personel` AS `personel`,`a`.`contacts` AS `contacts`,`a`.`addresses` AS `addresses`,`b`.`companies` AS `companies`,`b`.`employment_days` AS `employment_days`,`c`.`consulting_companies` AS `consulting_companies`,`c`.`total` AS `consulting_days` from ((`vw_emp_contact5` `a` left join `vw_emp_st_end_dt13` `b` on((`a`.`emp_id` = `b`.`emp_id`))) left join `vw_emp_st_end_dt23` `c` on((`a`.`emp_id` = `c`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_contact6_bench`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_contact6_bench`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_contact6_bench` AS select `a`.`emp_id` AS `emp_id`,`a`.`img` AS `img`,`a`.`employee_name` AS `employee_name`,`a`.`personel` AS `personel`,`a`.`contacts` AS `contacts`,`a`.`addresses` AS `addresses`,`b`.`companies` AS `companies`,`b`.`employment_days` AS `employment_days`,`c`.`consulting_companies` AS `consulting_companies`,`c`.`total` AS `consulting_days` from ((`vw_emp_contact5` `a` left join `vw_emp_st_end_dt13` `b` on((`a`.`emp_id` = `b`.`emp_id`))) left join `vw_emp_st_end_dt23_bench` `c` on((`a`.`emp_id` = `c`.`emp_id`))) where (`c`.`emp_id` is not null) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_contact6_x`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_contact6_x`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_contact6_x` AS select `a`.`emp_id` AS `emp_id`,`a`.`img` AS `img`,`a`.`employee_name` AS `employee_name`,`a`.`personel` AS `personel`,`a`.`contacts` AS `contacts`,`a`.`addresses` AS `addresses`,`b`.`companies` AS `companies`,`b`.`employment_days` AS `employment_days`,`c`.`consulting_companies` AS `consulting_companies`,`c`.`total` AS `consulting_days` from ((`vw_emp_contact5` `a` left join `vw_emp_st_end_dt13` `b` on((`a`.`emp_id` = `b`.`emp_id`))) left join `vw_emp_st_end_dt23` `c` on((`a`.`emp_id` = `c`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_details`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_details`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_details` AS select `a`.`emp_id` AS `emp_id`,ifnull(`a`.`idstorage`,'') AS `idstorage`,`s`.`file_name` AS `file_name`,concat(`a`.`firstname`,' ',`a`.`lastname`) AS `personal_details`,concat('SSN:',ifnull(`a`.`ssn`,''),' ','DOB:',convert((case when (`a`.`dob` <> '0000-00-00') then date_format(`a`.`dob`,'%m-%d-%y') else '' end) using latin1),' ','Age:',convert((case when (`a`.`dob` <> '0000-00-00') then floor(((date_format(now(),'%Y%m%d') - date_format(`a`.`dob`,'%Y%m%d')) / 10000)) else '' end) using latin1),' ','year',',',convert((case when (`a`.`dob` <> '0000-00-00') then floor((((((sign((dayofmonth(now()) - dayofmonth(`a`.`dob`))) + 1) / 2) * (dayofmonth(now()) - dayofmonth(`a`.`dob`))) + (((sign((dayofmonth(now()) - dayofmonth(`a`.`dob`))) + 1) / 2) * (dayofmonth(now()) - dayofmonth(`a`.`dob`)))) + (((sign((dayofmonth(`a`.`dob`) - dayofmonth(now()))) + 1) / 2) * ((dayofmonth((str_to_date(date_format((`a`.`dob` + interval 1 month),'%Y-%m-01'),'%Y-%m-%d') - interval 1 day)) - dayofmonth(`a`.`dob`)) + dayofmonth(now()))))) else '' end) using latin1),'','days',',','Gender:',ifnull(`f`.`look_values`,''),' ','  ','TaxId:',ifnull(`a`.`taxid`,''),'Storage:',convert(ifnull(`a`.`sto_limit`,'') using latin1)) AS `other_details`,`c`.`contacts` AS `contacts`,concat((case when isnull(`a`.`last_updated`) then '' else convert(date_format(`a`.`last_updated`,'%m-%d-%y %H:%i:%s') using latin1) end),' ',(case when isnull(`a`.`updater`) then 'Admin' else concat(`e`.`firstname`,' ',`e`.`lastname`) end)) AS `mod_last_updated`,`b`.`addresses` AS `addresses`,`b`.`companies` AS `companies`,`b`.`employment_days` AS `employment_days`,`b`.`consulting_companies` AS `consulting_companies`,`b`.`consulting_days` AS `consulting_days` from ((((((`emp` `a` left join `look_values` `f` on((`a`.`gender` = `f`.`look_values_id`))) left join `storages` `s` on((`a`.`idstorage` = `s`.`idstorage`))) left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `all_users` `al` on((`a`.`updater` = `al`.`emp_id`))) left join `vw_emp_contact3` `c` on((`c`.`emp_id` = `a`.`emp_id`))) left join `vw_emp_contact6` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_exp_docs`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_exp_docs`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_exp_docs` AS select `a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,date_format(`a`.`create_dt`,_utf8'%m-%d-%y') AS `create_dt`,`a`.`owner_id` AS `owner_id`,`a`.`ext_type` AS `ext_type`,`a`.`public` AS `public`,`a`.`self_view` AS `self_view`,`a`.`shared` AS `shared`,`b`.`expire_dt` AS `expire_dt`,`b`.`emp_legal_id` AS `emp_legal_id`,`b`.`updater` AS `updater`,date_format(`b`.`expire_dt`,_utf8'%m-%d-%y') AS `mod_expiry`,`e`.`emp_id` AS `emp_id`,concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) AS `emp_name`,`c`.`look_values` AS `doc_type`,concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) AS `owner_name`,concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) AS `updater_name` from (((`storages` `a` left join `emp_legal` `b` on((`a`.`idstorage` = `b`.`idstorage`))) left join `emp` `e` on((`b`.`emp_id` = `e`.`emp_id`))) left join `look_values` `c` on((`b`.`doc_type` = `c`.`look_values_id`))) where (`b`.`expire_dt` is not null) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_extra_tags`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_extra_tags`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_extra_tags` AS select `emp_tag`.`idemp_tag` AS `idemp_tag`,`emp_tag`.`emp_id` AS `emp_id`,`emp_tag`.`emp_tags` AS `emp_tags` from `emp_tag` where (not(`emp_tag`.`emp_id` in (select `emp`.`emp_id` AS `emp_id` from `emp`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_extra_values_in_tags`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_extra_values_in_tags`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_extra_values_in_tags` AS select `emp_tag`.`idemp_tag` AS `idemp_tag`,`emp_tag`.`emp_id` AS `emp_id`,`emp_tag`.`emp_tags` AS `emp_tags` from `emp_tag` where (not(`emp_tag`.`emp_tags` in (select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where (`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section')))))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_legal`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_legal`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_legal` AS select `a`.`emp_legal_id` AS `emp_legal_id`,`a`.`emp_id` AS `emp_id`,concat(`p`.`firstname`,' ',`p`.`lastname`) AS `emp_name`,`a`.`doc_type` AS `doc_type`,`a`.`idstorage` AS `idstorage`,`g`.`file_name` AS `file_name`,`g`.`file_summary` AS `file_summary`,`g`.`file_size` AS `file_size`,(case when ((((`g`.`file_size` / 1024) / 1024) / 1024) > 1024) then convert(concat(cast(((((`g`.`file_size` / 1024) / 1024) / 1024) / 1024) as decimal(10,2)),' TB') using latin1) when (((`g`.`file_size` / 1024) / 1024) > 1024) then convert(concat(cast((((`g`.`file_size` / 1024) / 1024) / 1024) as decimal(10,2)),' GB') using latin1) when ((`g`.`file_size` / 1024) > 1024) then convert(concat(cast(((`g`.`file_size` / 1024) / 1024) as decimal(10,2)),' MB') using latin1) when (`g`.`file_size` > 1024) then convert(concat(cast((`g`.`file_size` / 1024) as decimal(10,2)),' KB') using latin1) when (`g`.`file_size` <= 1024) then concat(`g`.`file_size`,' B') end) AS `file_size_formatted`,`g`.`owner_id` AS `owner_id`,`g`.`create_dt` AS `create_dt`,if(isnull(`g`.`create_dt`),'No End Date',concat(convert(date_format(`g`.`create_dt`,'%m-%d-%y') using latin1),' ')) AS `create_dt_formatted`,`g`.`ext_type` AS `ext_type`,`g`.`public` AS `public`,`g`.`self_view` AS `self_view`,`g`.`shared` AS `shared`,`a`.`expire_dt` AS `expire_dt`,if(isnull(`a`.`expire_dt`),'No End Date',concat(convert(date_format(`a`.`expire_dt`,'%m-%d-%y') using latin1),' ')) AS `expire_dt_formatted`,`a`.`updater` AS `updater`,if((isnull(`a`.`updater`) or (`a`.`updater` = 0)),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updater_nm`,`s`.`file_name` AS `updater_file_name`,`a`.`last_updated` AS `last_updated`,concat(convert(date_format(`a`.`last_updated`,'%m-%d-%y %H:%i:%s %p') using latin1),' ') AS `last_updated_formatted` from ((((`emp_legal` `a` left join `emp` `p` on((`a`.`emp_id` = `p`.`emp_id`))) left join `storages` `g` on((`a`.`idstorage` = `g`.`idstorage`))) left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_legal_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_legal_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_legal_attach` AS select `a`.`emp_legal_id` AS `emp_legal_id`,`a`.`doc_type` AS `doc_type`,`d`.`look_values` AS `doc_look_values`,`a`.`expire_dt` AS `expire_dt`,`b`.`emp_id` AS `emp_id`,`a`.`idstorage` AS `idstorage`,`a`.`updater` AS `updater`,`c`.`owner_id` AS `owner_id`,`c`.`file_name` AS `file_name`,`c`.`public` AS `public`,`c`.`self_view` AS `self_view`,`c`.`shared` AS `shared`,`c`.`updated_for_ref_id` AS `updated_for_ref_id`,`c`.`updated_for_ref_table` AS `updated_for_ref_table`,`a`.`last_updated` AS `last_updated` from (((`emp_legal` `a` left join `storages` `c` on((`a`.`idstorage` = `c`.`idstorage`))) left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) left join `look_values` `d` on((`a`.`doc_type` = `d`.`look_values_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_load`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_load`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_load` AS select `a`.`emp_id` AS `emp_id`,`e`.`first_name` AS `firstname`,`e`.`last_name` AS `lastname`,`e`.`nick_name` AS `nickname`,ifnull(concat(`e`.`first_name`,' ',`e`.`last_name`,' (',ifnull(`e`.`nick_name`,'No Nickname'),')'),'No Details') AS `fullname`,`s`.`file_name` AS `emp_file_name`,`e`.`unique_id_type` AS `unique_id`,ifnull(`uid`.`emp_value`,'NA') AS `uniqueid_type`,ifnull(`e`.`ssn`,'NA') AS `ssn`,concat(ifnull(`uid`.`emp_value`,'NA'),' : ',ifnull(`e`.`ssn`,'NA')) AS `uniqueid`,`e`.`contacts` AS `contacts`,`e`.`addresses` AS `all_addresses`,`e`.`companies` AS `employment`,`e`.`emp_days` AS `emp_days`,concat(ifnull(`e`.`companies`,'NA'),' : ',ifnull(`e`.`emp_days`,'NA')) AS `emp_+_days`,`e`.`consulting_companies` AS `consulting`,`e`.`consulting_days` AS `consulting_days`,concat(ifnull(`e`.`consulting_companies`,'NA'),' : ',ifnull(`e`.`consulting_days`,'NA')) AS `consult_days`,`e`.`gender` AS `gender_id`,ifnull(`g`.`emp_value`,'NE') AS `gender`,ifnull(`e`.`dob`,'NE') AS `dob`,date_format(`e`.`dob`,'%m-%d-%y') AS `dob_format`,ifnull(concat(round(((unix_timestamp(now()) - unix_timestamp(`e`.`dob`)) / 31556736),0),_utf8':',round((round(((unix_timestamp(now()) - unix_timestamp(`e`.`dob`)) % 31556736),0) / 2630016),0),_utf8':',round((round(((unix_timestamp(now()) - unix_timestamp(`e`.`dob`)) % 31556736),0) / 86400),0)),'NE') AS `age`,`l`.`login_id` AS `login_id`,`l`.`isp` AS `isp`,`l`.`domain_name` AS `domain_name`,`l`.`country` AS `country`,`l`.`lastlogin` AS `lastlogin`,`l`.`logged_in` AS `logged_in`,`l`.`lastlogout` AS `lastlogout`,ifnull(concat(round(((unix_timestamp(now()) - unix_timestamp(`l`.`lastlogout_unformatted`)) / 3600),0),_utf8':',round((round(((unix_timestamp(now()) - unix_timestamp(`l`.`lastlogout_unformatted`)) % 3600),0) / 60),0)),'Live') AS `loggged_out`,`l`.`main_menu` AS `main_menu`,`l`.`sub_menu` AS `sub_menu`,`e`.`last_updated` AS `last_updated`,`e`.`updater` AS `updater_id`,ifnull(concat(`u`.`firstname`,'  ',`u`.`lastname`),'Admin') AS `updater`,`e`.`del_dt` AS `del_dt_unformatted`,date_format(`e`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,`e`.`del_by` AS `del_by_id`,ifnull(concat(`e_del_by`.`firstname`,' ',`e_del_by`.`lastname`),'Admin') AS `del_by`,`o_del_by`.`file_name` AS `del_by_file_name`,(to_days((date_format(`e`.`del_dt`,'%y-%m-%d') + interval `e`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`e`.`archv_dt` AS `archv_dt_unformatted`,date_format(`e`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt`,`e`.`archv_by` AS `archv_by_id`,ifnull(concat(`e_archv_by`.`firstname`,' ',`e_archv_by`.`lastname`),'Admin') AS `archv_by`,`o_archv_by`.`file_name` AS `archv_by_file_name`,sum(distinct (to_days(ifnull(`d`.`org_end_dt`,curdate())) - to_days(`d`.`org_start_dt`))) AS `total_days` from (((((((((((`emp` `a` left join `emp_load` `e` on((`a`.`emp_id` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) left join `emp_lk_val` `g` on((`e`.`gender` = `g`.`idemp_lk_value`))) left join `emp_lk_val` `uid` on((`e`.`unique_id_type` = `uid`.`idemp_lk_value`))) left join `vw_all_users_login` `l` on((`e`.`login_id` = `l`.`login_id`))) left join `emp` `u` on((`e`.`updater` = `u`.`emp_id`))) left join `emp` `e_del_by` on((`e`.`del_by` = `e_del_by`.`emp_id`))) left join `emp` `e_archv_by` on((`e`.`archv_by` = `e_archv_by`.`emp_id`))) left join `storages` `o_del_by` on((`e_del_by`.`idstorage` = `o_del_by`.`idstorage`))) left join `storages` `o_archv_by` on((`e_archv_by`.`idstorage` = `o_archv_by`.`idstorage`))) left join `vw_emp_org` `d` on((`d`.`emp_id` = `a`.`emp_id`))) group by `a`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_org`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_org`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_org` AS select `a`.`emp_org_id` AS `emp_org_id`,`a`.`emp_id` AS `emp_id`,`a`.`comp_id` AS `comp_id`,`b`.`companyname` AS `companyname`,`a`.`org_start_dt` AS `org_start_dt`,if(isnull(`a`.`org_start_dt`),'No Started',concat(convert(date_format(`a`.`org_start_dt`,'%m-%d-%y') using latin1),' ')) AS `org_start_dt_formatted`,`a`.`org_end_dt` AS `org_end_dt`,if(isnull(`a`.`org_end_dt`),'FullTime',concat(convert(date_format(`a`.`org_end_dt`,'%m-%d-%y') using latin1),' ')) AS `org_end_dt_formatted`,`a`.`days` AS `days`,(select timestampdiff(DAY,`a`.`org_start_dt`,ifnull(`a`.`org_end_dt`,curdate()))) AS `days_formatted`,concat(`b`.`companyname`,' From ',if(isnull(`a`.`org_start_dt`),'No Started',concat(convert(date_format(`a`.`org_start_dt`,'%m-%d-%y') using latin1),' ')),' To ',if(isnull(`a`.`org_end_dt`),'FullTime',concat(convert(date_format(`a`.`org_end_dt`,'%m-%d-%y') using latin1),'')),', Days: ',convert(ifnull(`a`.`days`,'Still Working') using latin1)) AS `company_formatted`,`a`.`emp_type` AS `emp_type`,`c`.`emp_value` AS `emp_type_nm`,`a`.`run_script` AS `run_script`,`a`.`updater` AS `updater`,ifnull(`a`.`updater`,'admin') AS `updater_formatted`,concat(`e`.`firstname`,' ',`e`.`lastname`) AS `updater_nm`,`s`.`file_name` AS `updater_file_name`,`a`.`last_updated` AS `last_updated`,concat(convert(date_format(`a`.`last_updated`,'%m-%d-%y %H:%i:%s %p') using latin1),' ') AS `format_last_updated` from ((((`emp_org` `a` left join `company` `b` on((`a`.`comp_id` = `b`.`comp_id`))) left join `emp_lk_val` `c` on((`a`.`emp_type` = `c`.`idemp_lk_value`))) left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) order by `a`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_org2`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_org2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_org2` AS select `a`.`emp_id` AS `emp_id`,group_concat(distinct `d`.`comp_id` separator ', ') AS `comp_id`,concat((select group_concat(distinct `d`.`company_formatted` separator '; ')),'  -|||-  total: ',ifnull(sum(distinct `d`.`days`),'still working'),' days') AS `companies_formatted` from ((((`vw_emp` `a` left join `vw_emp_contact` `b` on((`b`.`emp_id` = `a`.`emp_id`))) left join `vw_emp_address` `c` on((`c`.`emp_id` = `a`.`emp_id`))) left join `vw_emp_org` `d` on((`d`.`emp_id` = `a`.`emp_id`))) left join `vw_company` `e` on((`e`.`comp_id` = `d`.`comp_id`))) group by `a`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt1`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt1`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt1` AS select `b`.`emp_org_id` AS `emp_org_id`,`a`.`emp_id` AS `emp_id`,`a`.`gender` AS `gender`,`a`.`firstname` AS `firstname`,`a`.`lastname` AS `lastname`,`b`.`comp_id` AS `comp_id`,`c`.`companyname` AS `companyname`,date_format(`b`.`org_start_dt`,_utf8'%m-%d-%y') AS `org_start_dt`,date_format(`b`.`org_start_dt`,_utf8'%Y-%m-%d') AS `sort_org_start_dt`,(case when (`b`.`org_end_dt` is not null) then date_format(`b`.`org_end_dt`,_utf8'%m-%d-%y') end) AS `org_end_dt`,(case when (`b`.`org_end_dt` is not null) then date_format(`b`.`org_end_dt`,_utf8'%Y-%m-%d') end) AS `sort_org_end_dt`,(case when (`b`.`org_end_dt` is not null) then (to_days(`b`.`org_end_dt`) - to_days(`b`.`org_start_dt`)) else (to_days(curdate()) - to_days(`b`.`org_start_dt`)) end) AS `days`,if((`a`.`emp_id` is not null),_utf8'FullTime',NULL) AS `billable_type`,(case when (isnull(`b`.`org_start_dt`) and isnull(`b`.`org_end_dt`)) then _utf8'Freelancer' when (isnull(`b`.`org_end_dt`) and (`b`.`org_start_dt` is not null)) then _utf8'Employed' when (`b`.`org_end_dt` and `b`.`org_start_dt`) then _utf8'UnEmployed' else NULL end) AS `employment` from ((`emp` `a` left join `emp_org` `b` on((`a`.`emp_id` = `b`.`emp_id`))) left join `company` `c` on((`b`.`comp_id` = `c`.`comp_id`))) where (`b`.`emp_org_id` is not null) order by `a`.`emp_id`,`b`.`emp_org_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt11`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt11`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt11` AS select `vw_emp_st_end_dt1`.`emp_id` AS `emp_id`,`vw_emp_st_end_dt1`.`comp_id` AS `comp_id`,`vw_emp_st_end_dt1`.`org_start_dt` AS `org_start_dt`,(case when (`vw_emp_st_end_dt1`.`org_end_dt` is not null) then `vw_emp_st_end_dt1`.`org_end_dt` else _utf8'Current' end) AS `org_end_dt`,`vw_emp_st_end_dt1`.`days` AS `no_days` from `vw_emp_st_end_dt1` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt11_x`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt11_x`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt11_x` AS select `vw_emp_st_end_dt1`.`emp_id` AS `emp_id`,`vw_emp_st_end_dt1`.`comp_id` AS `comp_id`,`vw_emp_st_end_dt1`.`org_start_dt` AS `org_start_dt`,(case when (`vw_emp_st_end_dt1`.`org_end_dt` is not null) then `vw_emp_st_end_dt1`.`org_end_dt` else curdate() end) AS `org_end_dt`,(case when (`vw_emp_st_end_dt1`.`org_end_dt` is not null) then (to_days(`vw_emp_st_end_dt1`.`org_end_dt`) - to_days(`vw_emp_st_end_dt1`.`org_start_dt`)) else (to_days(curdate()) - to_days(`vw_emp_st_end_dt1`.`org_start_dt`)) end) AS `no_days` from `vw_emp_st_end_dt1` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt12`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt12`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt12` AS select `a`.`emp_id` AS `emp_id`,`a`.`comp_id` AS `comp_id`,cast(group_concat(concat(_utf8'FROM ',`a`.`org_start_dt`,_utf8' \r\n                        to ',`a`.`org_end_dt`,_utf8' =',`a`.`no_days`,_utf8' ') separator ',') as char(2000) charset utf8) AS `org_dates_days`,sum(`a`.`no_days`) AS `total` from (`vw_emp_st_end_dt11` `a` left join `company` `b` on((`a`.`comp_id` = `b`.`comp_id`))) group by `a`.`emp_id`,`a`.`comp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt12_x`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt12_x`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt12_x` AS select `a`.`emp_id` AS `emp_id`,`a`.`comp_id` AS `comp_id`,group_concat(concat('FROM ',`a`.`org_start_dt`,' \r\n                    to ',(case when (`a`.`org_end_dt` <> 'NULL') then `a`.`org_end_dt` else curdate() end),' =',(case when (`a`.`org_end_dt` <> 'NULL') then (to_days(`a`.`org_end_dt`) - to_days(`a`.`org_start_dt`)) else (to_days(curdate()) - to_days(`a`.`org_start_dt`)) end),' ') separator ',') AS `org_dates_days`,sum((to_days(`a`.`org_end_dt`) - to_days(`a`.`org_start_dt`))) AS `total` from (`vw_emp_st_end_dt11_x` `a` left join `company` `b` on((`a`.`comp_id` = `b`.`comp_id`))) group by `a`.`emp_id`,`a`.`comp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt13`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt13`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt13` AS select `a`.`emp_id` AS `emp_id`,cast(concat(group_concat(concat(convert(`company`.`companyname` using utf8),_utf8' \r\n                                ',`a`.`org_dates_days`) separator ','),concat(_utf8'Total=',sum(`a`.`total`))) as char(2000) charset utf8) AS `companies`,sum(`a`.`total`) AS `employment_days` from (`vw_emp_st_end_dt12` `a` left join `company` on((`a`.`comp_id` = `company`.`comp_id`))) group by `a`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt13_x`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt13_x`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt13_x` AS select `vw_emp_st_end_dt12`.`emp_id` AS `emp_id`,cast(concat(group_concat(concat(convert(`company`.`companyname` using utf8),_utf8' \r\n                                ',`vw_emp_st_end_dt12`.`org_dates_days`) separator ','),concat(_utf8'Total=',sum(`vw_emp_st_end_dt12`.`total`))) as char(2000) charset utf8) AS `companies`,sum(`vw_emp_st_end_dt12`.`total`) AS `employment_days` from (`vw_emp_st_end_dt12` left join `company` on((`vw_emp_st_end_dt12`.`comp_id` = `company`.`comp_id`))) group by `vw_emp_st_end_dt12`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt2`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt2` AS select `e`.`emp_id` AS `emp_id`,`e`.`gender` AS `gender`,`e`.`firstname` AS `firstname`,`e`.`lastname` AS `lastname`,`d`.`comp_id` AS `comp_id`,`d`.`companyname` AS `companyname`,date_format(`a`.`bill_start_dt`,_utf8'%m-%d-%y') AS `bill_start_dt`,date_format(`a`.`bill_start_dt`,_utf8'%Y-%m-%d') AS `sort_bill_start_dt`,(case when (`a`.`bill_end_dt` is not null) then date_format(`a`.`bill_end_dt`,_utf8'%m-%d-%y') end) AS `bill_end_dt`,(case when (`a`.`bill_end_dt` is not null) then date_format(`a`.`bill_end_dt`,_utf8'%Y-%m-%d') end) AS `sort_bill_end_dt`,(case when (`a`.`bill_end_dt` is not null) then (to_days(`a`.`bill_end_dt`) - to_days(`a`.`bill_start_dt`)) else (to_days(curdate()) - to_days(`a`.`bill_start_dt`)) end) AS `days`,if((`e`.`emp_id` is not null),_utf8'Consultant',NULL) AS `billable_type`,(case when (isnull(`a`.`bill_start_dt`) and isnull(`a`.`bill_end_dt`)) then _utf8'Freelancer' when (isnull(`a`.`bill_end_dt`) and (`a`.`bill_start_dt` is not null)) then _utf8'Employed' when (`a`.`bill_end_dt` and `a`.`bill_start_dt`) then _utf8'UnEmployed' else NULL end) AS `employment` from ((((`engage_entity_po` `a` left join `engage_entity` `b` on((`a`.`idengage_entity` = `b`.`idengage_entity`))) left join `engage` `c` on((`b`.`engage_id` = `c`.`engage_id`))) left join `company` `d` on((`c`.`srv_client` = `d`.`comp_id`))) left join `emp` `e` on((`b`.`engage_ref_id` = `e`.`emp_id`))) where (lower(`b`.`engage_ref_tab`) = _latin1'employee') order by `e`.`emp_id`,`d`.`comp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt21`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt21`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt21` AS select `a`.`emp_id` AS `emp_id`,`a`.`comp_id` AS `srv_client`,`a`.`bill_start_dt` AS `bill_start_dt`,(case when (cast(`a`.`bill_end_dt` as char charset binary) <> cast(_utf8'NULL' as char charset binary)) then `a`.`bill_end_dt` else _utf8'Current' end) AS `bill_end_dt`,`a`.`days` AS `consulting_days` from `vw_emp_st_end_dt2` `a` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt22`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt22`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt22` AS select `a`.`emp_id` AS `emp_id`,`a`.`srv_client` AS `srv_client`,cast(group_concat(concat(_utf8'From \r\n                        ',`a`.`bill_start_dt`,_utf8' ',_utf8' TO ',`a`.`bill_end_dt`,_utf8' = \r\n                        ',`a`.`consulting_days`) separator ',') as char(2000) charset utf8) AS `consulting_dates_days`,sum(`a`.`consulting_days`) AS `total` from `vw_emp_st_end_dt21` `a` group by `a`.`emp_id`,`a`.`srv_client` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt22_bench`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt22_bench`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt22_bench` AS select `a`.`emp_id` AS `emp_id`,`a`.`comp_id` AS `srv_client`,cast(group_concat(concat(_utf8'From \r\n                        ',`a`.`bill_start_dt`,_utf8' ',_utf8' TO ',`a`.`bill_end_dt`,_utf8' = \r\n                        ',`a`.`days`) separator ',') as char(2000) charset utf8) AS `consulting_dates_days`,sum(`a`.`days`) AS `total` from `vw_emp_st_end_dt2` `a` where ((`a`.`bill_start_dt` is not null) and (`a`.`bill_end_dt` is not null)) group by `a`.`emp_id`,`a`.`comp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt23`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt23`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt23` AS select `a`.`emp_id` AS `emp_id`,cast(concat(group_concat(concat(convert(`b`.`companyname` using utf8),_utf8' ',`a`.`consulting_dates_days`) separator ','),concat(_utf8'Total=',sum(`a`.`total`))) as char(2000) charset utf8) AS `consulting_companies`,sum(`a`.`total`) AS `total` from (`vw_emp_st_end_dt22` `a` left join `company` `b` on((`a`.`srv_client` = `b`.`comp_id`))) group by `a`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt23_bench`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt23_bench`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt23_bench` AS select `a`.`emp_id` AS `emp_id`,cast(concat(group_concat(concat(convert(`b`.`companyname` using utf8),_utf8' ',`a`.`consulting_dates_days`) separator ','),concat(_utf8'Total=',sum(`a`.`total`))) as char(2000) charset utf8) AS `consulting_companies`,sum(`a`.`total`) AS `total` from (`vw_emp_st_end_dt22_bench` `a` left join `company` `b` on((`a`.`srv_client` = `b`.`comp_id`))) group by `a`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt3`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt3`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt3` AS select `vw_emp_st_end_dt1`.`emp_id` AS `emp_id`,`vw_emp_st_end_dt1`.`gender` AS `gender`,`vw_emp_st_end_dt1`.`firstname` AS `firstname`,`vw_emp_st_end_dt1`.`lastname` AS `lastname`,concat(`vw_emp_st_end_dt1`.`firstname`,_latin1' \r\n                \r\n                \r\n                ',`vw_emp_st_end_dt1`.`lastname`) AS `fullname`,`vw_emp_st_end_dt1`.`comp_id` AS `comp_id`,`vw_emp_st_end_dt1`.`companyname` AS `companyname`,`vw_emp_st_end_dt1`.`org_start_dt` AS `start_dt`,`vw_emp_st_end_dt1`.`org_end_dt` AS `end_dt`,`vw_emp_st_end_dt1`.`sort_org_start_dt` AS `sort_start_dt`,`vw_emp_st_end_dt1`.`sort_org_end_dt` AS `sort_end_dt`,`vw_emp_st_end_dt1`.`days` AS `days`,`vw_emp_st_end_dt1`.`billable_type` AS `billable_type`,`vw_emp_st_end_dt1`.`employment` AS `employment` from `vw_emp_st_end_dt1` union select `vw_emp_st_end_dt2`.`emp_id` AS `emp_id`,`vw_emp_st_end_dt2`.`gender` AS `gender`,`vw_emp_st_end_dt2`.`firstname` AS `firstname`,`vw_emp_st_end_dt2`.`lastname` AS `lastname`,concat(`vw_emp_st_end_dt2`.`firstname`,_latin1' \r\n                ',`vw_emp_st_end_dt2`.`lastname`) AS `Fullname`,`vw_emp_st_end_dt2`.`comp_id` AS `comp_id`,`vw_emp_st_end_dt2`.`companyname` AS `companyname`,`vw_emp_st_end_dt2`.`bill_start_dt` AS `start_dt`,`vw_emp_st_end_dt2`.`bill_end_dt` AS `end_dt`,`vw_emp_st_end_dt2`.`sort_bill_start_dt` AS `sort_start_dt`,`vw_emp_st_end_dt2`.`sort_bill_end_dt` AS `sort_end_dt`,`vw_emp_st_end_dt2`.`days` AS `days`,`vw_emp_st_end_dt2`.`billable_type` AS `billable_type`,`vw_emp_st_end_dt2`.`employment` AS `employment` from `vw_emp_st_end_dt2` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt4`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt4`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt4` AS select `vw_emp_st_end_dt3`.`emp_id` AS `emp_id`,`vw_emp_st_end_dt3`.`gender` AS `gender`,`vw_emp_st_end_dt3`.`firstname` AS `firstname`,`vw_emp_st_end_dt3`.`lastname` AS `lastname`,`vw_emp_st_end_dt3`.`fullname` AS `fullname`,`vw_emp_st_end_dt3`.`comp_id` AS `comp_id`,`vw_emp_st_end_dt3`.`companyname` AS `companyname`,`vw_emp_st_end_dt3`.`start_dt` AS `start_dt`,`vw_emp_st_end_dt3`.`end_dt` AS `end_dt`,`vw_emp_st_end_dt3`.`sort_start_dt` AS `sort_start_dt`,`vw_emp_st_end_dt3`.`sort_end_dt` AS `sort_end_dt`,`vw_emp_st_end_dt3`.`billable_type` AS `billable_type`,(case when (isnull(`vw_emp_st_end_dt3`.`start_dt`) and isnull(`vw_emp_st_end_dt3`.`end_dt`)) then _utf8'Freelancer' when (isnull(`vw_emp_st_end_dt3`.`end_dt`) and (`vw_emp_st_end_dt3`.`start_dt` is not null)) then _utf8'Employed' when (`vw_emp_st_end_dt3`.`end_dt` and `vw_emp_st_end_dt3`.`start_dt`) then _utf8'UnEmployed' else NULL end) AS `employment`,(case when (isnull(`vw_emp_st_end_dt3`.`end_dt`) and (`vw_emp_st_end_dt3`.`start_dt` is not null)) then (to_days(now()) - to_days(`vw_emp_st_end_dt3`.`start_dt`)) else (to_days(`vw_emp_st_end_dt3`.`end_dt`) - to_days(`vw_emp_st_end_dt3`.`start_dt`)) end) AS `no_of_days`,(case when (isnull(`vw_emp_st_end_dt3`.`sort_start_dt`) and isnull(`vw_emp_st_end_dt3`.`sort_end_dt`)) then _utf8'Freelancer' when (isnull(`vw_emp_st_end_dt3`.`sort_end_dt`) and (`vw_emp_st_end_dt3`.`sort_start_dt` is not null)) then _utf8'Employed' when (`vw_emp_st_end_dt3`.`sort_end_dt` and `vw_emp_st_end_dt3`.`sort_start_dt`) then _utf8'UnEmployed' else NULL end) AS `sort_employment`,(case when (isnull(`vw_emp_st_end_dt3`.`sort_end_dt`) and (`vw_emp_st_end_dt3`.`sort_start_dt` is not null)) then (to_days(now()) - to_days(`vw_emp_st_end_dt3`.`sort_start_dt`)) else (to_days(`vw_emp_st_end_dt3`.`sort_end_dt`) - to_days(`vw_emp_st_end_dt3`.`sort_start_dt`)) end) AS `sort_no_of_days`,`vw_emp_st_end_dt3`.`days` AS `routed_days`,`vw_emp_st_end_dt3`.`employment` AS `routed_employment` from `vw_emp_st_end_dt3` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_st_end_dt_11_new`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_st_end_dt_11_new`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_st_end_dt_11_new` AS select `b`.`emp_id` AS `emp_id`,`b`.`org_start_dt` AS `org_start_dt`,`b`.`org_end_dt` AS `org_end_dt`,`b`.`no_days` AS `no_days` from (`vw_emp_st_end_dt11` `b` left join `company` on((`b`.`comp_id` = `company`.`comp_id`))) group by `b`.`emp_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_tag_extra_1`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_tag_extra_1`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_tag_extra_1` AS select `emp_tag`.`idemp_tag` AS `idemp_tag`,`emp_tag`.`emp_id` AS `emp_id`,`emp_tag`.`emp_tags` AS `emp_tags` from `emp_tag` where (not(`emp_tag`.`emp_id` in (select `emp`.`emp_id` AS `emp_id` from `emp`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_tag_extra_2`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_tag_extra_2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_tag_extra_2` AS select `emp_tag`.`idemp_tag` AS `idemp_tag`,`emp_tag`.`emp_id` AS `emp_id`,`emp_tag`.`emp_tags` AS `emp_tags` from `emp_tag` where (not(`emp_tag`.`emp_tags` in (select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where (`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section')))))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_emp_tag_extra_3`
--

/*!50001 DROP VIEW IF EXISTS `vw_emp_tag_extra_3`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_emp_tag_extra_3` AS select `emp_tag`.`idemp_tag` AS `idemp_tag`,`emp_tag`.`emp_id` AS `emp_id`,`emp_tag`.`emp_tags` AS `emp_tags` from `emp_tag` where (not(`emp_tag`.`emp_id` in (select `emp`.`emp_id` AS `emp_id` from `emp`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_empend`
--

/*!50001 DROP VIEW IF EXISTS `vw_empend`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_empend` AS select year(`emp_org`.`org_end_dt`) AS `year`,month(`emp_org`.`org_end_dt`) AS `month`,count(`emp_org`.`emp_id`) AS `cnt` from `emp_org` group by year(`emp_org`.`org_end_dt`),month(`emp_org`.`org_end_dt`) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_employee`
--

/*!50001 DROP VIEW IF EXISTS `vw_employee`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_employee` AS select `E`.`emp_id` AS `emp_id`,`E`.`firstname` AS `firstname`,`E`.`lastname` AS `lastname`,`E`.`ssn` AS `ssn`,`E`.`dob` AS `dob`,`E`.`gender` AS `gender`,`EO`.`org_start_dt` AS `sdate`,`EO`.`org_end_dt` AS `edate`,(case when (isnull(`EO`.`org_end_dt`) or (`EO`.`org_end_dt` = _latin1'')) then (to_days(now()) - to_days(`EO`.`org_start_dt`)) else (to_days(`EO`.`org_end_dt`) - to_days(`EO`.`org_start_dt`)) end) AS `noOfDays`,`EO`.`comp_id` AS `comp_id` from (`emp` `E` join `emp_org` `EO` on((`E`.`emp_id` = `EO`.`emp_id`))) where ((`EO`.`org_start_dt` <> _latin1'') and (`EO`.`org_start_dt` <> _latin1'')) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_empstart`
--

/*!50001 DROP VIEW IF EXISTS `vw_empstart`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_empstart` AS select year(`emp_org`.`org_start_dt`) AS `year`,month(`emp_org`.`org_start_dt`) AS `month`,count(`emp_org`.`emp_id`) AS `cnt` from `emp_org` group by year(`emp_org`.`org_start_dt`),month(`emp_org`.`org_start_dt`) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_engage`
--

/*!50001 DROP VIEW IF EXISTS `vw_engage`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_engage` AS select `E`.`engage_id` AS `engage_id`,`EC`.`comp_id` AS `comp_id`,`EC`.`idengage_comp` AS `idengage_comp`,`C`.`companyname` AS `companyname`,`E`.`srv_st_dt` AS `srv_st_dt`,date_format(`E`.`srv_st_dt`,_utf8'%m-%d-%y') AS `formatted_srv_st_dt`,`E`.`srv_e_dt` AS `srv_e_dt`,date_format(`E`.`srv_e_dt`,_utf8'%m-%d-%y') AS `formatted_srv_e_dt`,`LV`.`look_values` AS `sr_frequency`,`LV2`.`look_values` AS `srv_paytype`,`E`.`eg_sumry` AS `eg_sumry` from ((((`engage_comp` `EC` left join `engage` `E` on((`EC`.`engage_id` = `E`.`engage_id`))) left join `company` `C` on((`EC`.`comp_id` = `C`.`comp_id`))) left join `look_values` `LV` on((`E`.`sr_frequency` = `LV`.`look_values_id`))) left join `look_values` `LV2` on((`E`.`srv_paytype` = `LV2`.`look_values_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_engage_budget`
--

/*!50001 DROP VIEW IF EXISTS `vw_engage_budget`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_engage_budget` AS select `EB`.`idengage_entity_po` AS `idengage_entity_po`,group_concat(distinct (case when (`EB`.`engage_ref_table` = _latin1'Employee') then concat(_latin1'E:',`EMP`.`lastname`,_latin1' ',`EMP`.`firstname`) else concat(_latin1'C:',`C`.`companyname`) end) separator ',') AS `budget_contact` from ((`engage_budget` `EB` left join `emp` `EMP` on((`EMP`.`emp_id` = `EB`.`engage_ref_id`))) left join `company` `C` on((`C`.`comp_id` = `EB`.`engage_ref_id`))) group by `EB`.`idengage_entity_po` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_engage_details`
--

/*!50001 DROP VIEW IF EXISTS `vw_engage_details`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_engage_details` AS select `a`.`engage_id` AS `engage_id`,`a`.`srv_st_dt` AS `srv_st_dt`,`a`.`srv_e_dt` AS `srv_e_dt`,`a`.`sr_frequency` AS `sr_frequency`,`a`.`srv_paytype` AS `srv_paytype`,`a`.`srv_amt` AS `srv_amount`,`a`.`eg_sumry` AS `eg_sumry`,`a`.`srv_client` AS `srv_client`,`a`.`srv_vendor` AS `comp_id`,date_format(`a`.`srv_st_dt`,_utf8'%m-%d-%y') AS `mod_srv_st_dt`,date_format(`a`.`srv_st_dt`,_utf8'%m.%d.%y') AS `mod_srv_st_dt1`,date_format(`a`.`srv_e_dt`,_utf8'%m-%d-%y') AS `mod_srv_e_dt`,date_format(`a`.`srv_e_dt`,_utf8'%m.%d.%y') AS `mod_srv_e_dt1`,`lv`.`look_values` AS `frequency`,`lvp`.`look_values` AS `paytype`,`t`.`engage_doc_id` AS `engage_doc_id`,`a`.`last_updated` AS `last_updated`,`c`.`companyname` AS `srv_client_name`,`cc`.`companyname` AS `companyname`,(case when (`a`.`updated_by` = _utf8'0') then 'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updated_by`,concat(`lv`.`look_values`,_latin1'-',`lvp`.`look_values`) AS `freqypaytype`,concat(convert(date_format(`a`.`last_updated`,_utf8'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',(case when (`a`.`updated_by` = _utf8'0') then 'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end)) AS `last_updter`,concat(convert(date_format(`a`.`last_updated`,_utf8'%m.%d.%y %H:%i:%s') using latin1),_latin1' ',(case when (`a`.`updated_by` = _utf8'0') then 'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end)) AS `last_updter1` from ((((((`engage` `a` left join `look_values` `lv` on((`a`.`sr_frequency` = `lv`.`look_values_id`))) left join `look_values` `lvp` on((`a`.`srv_paytype` = `lvp`.`look_values_id`))) left join `emp` `e` on((`a`.`updated_by` = `e`.`emp_id`))) left join `vw_contracts_attach` `t` on((`t`.`engage_id` = `a`.`engage_id`))) left join `company` `c` on((`a`.`srv_client` = `c`.`comp_id`))) left join `company` `cc` on((`a`.`srv_vendor` = `cc`.`comp_id`))) where ((`lv`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'bill.detail.bill.cycle'))) and (`lvp`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'contract_pay_type')))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_engage_inv`
--

/*!50001 DROP VIEW IF EXISTS `vw_engage_inv`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_engage_inv` AS select `a`.`idengage_inv` AS `idengage_inv`,`a`.`idengage_entity_po` AS `idengage_entity_po`,`a`.`display` AS `display`,`a`.`idengage_add_con` AS `idengage_add_con`,`a`.`last_updated` AS `last_updated`,`c`.`comp_contact_no_id` AS `comp_contact_no_id`,`d`.`emp_contact_id` AS `emp_contact_id`,`e`.`contact_id` AS `contact_id`,`e`.`emp_contact_type` AS `emp_contact_type`,`e`.`emp_id` AS `emp_id`,concat(`h`.`firstname`,_latin1' ',`h`.`lastname`) AS `employee`,concat(`g`.`look_values`,_latin1'->',`f`.`contact_detail`) AS `contact_detail` from ((((((`engage_inv` `a` left join `engage_add_con` `c` on((`a`.`idengage_add_con` = `c`.`idengage_add_con`))) left join `comp_contact_no` `d` on((`c`.`comp_contact_no_id` = `d`.`comp_contact_no_id`))) left join `emp_contact` `e` on((`e`.`emp_contact_id` = `d`.`emp_contact_id`))) left join `emp` `h` on((`h`.`emp_id` = `e`.`emp_id`))) left join `contact_no` `f` on((`e`.`contact_id` = `f`.`contact_id`))) left join `look_values` `g` on((`g`.`look_values_id` = `e`.`emp_contact_type`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_engage_inv_gp`
--

/*!50001 DROP VIEW IF EXISTS `vw_engage_inv_gp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_engage_inv_gp` AS select `vw_engage_inv`.`idengage_inv` AS `idengage_inv`,`vw_engage_inv`.`idengage_entity_po` AS `idengage_entity_po`,`vw_engage_inv`.`display` AS `display`,`vw_engage_inv`.`idengage_add_con` AS `idengage_add_con`,`vw_engage_inv`.`last_updated` AS `last_updated`,`vw_engage_inv`.`comp_contact_no_id` AS `comp_contact_no_id`,`vw_engage_inv`.`emp_contact_id` AS `emp_contact_id`,`vw_engage_inv`.`contact_id` AS `contact_id`,`vw_engage_inv`.`emp_contact_type` AS `emp_contact_type`,`vw_engage_inv`.`emp_id` AS `emp_id`,`vw_engage_inv`.`employee` AS `employee`,`vw_engage_inv`.`contact_detail` AS `contact_detail` from `vw_engage_inv` where `vw_engage_inv`.`last_updated` in (select max(`vw_engage_inv`.`last_updated`) AS `MAX(last_updated)` from `vw_engage_inv` group by `vw_engage_inv`.`idengage_entity_po`) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_engage_po_inv`
--

/*!50001 DROP VIEW IF EXISTS `vw_engage_po_inv`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_engage_po_inv` AS select `a`.`idengage_entity_po` AS `idengage_entity_po`,`a`.`idengage_entity` AS `idengage_entity`,`b`.`engage_id` AS `engage_id`,`c`.`srv_client` AS `srv_client`,`d`.`idengage_comp` AS `idengage_comp`,`e`.`idengage_add` AS `idengage_add`,`f`.`comp_contact_no_id` AS `comp_contact_no_id`,`f`.`idengage_add_con` AS `idengage_add_con`,`g`.`emp_contact_id` AS `emp_contact_id`,`h`.`contact_id` AS `contact_id`,`h`.`emp_contact_type` AS `emp_contact_type`,`h`.`emp_id` AS `emp_id`,concat(`i`.`firstname`,_latin1' ',`i`.`lastname`) AS `employee`,concat(`k`.`look_values`,_latin1'->',`j`.`contact_detail`) AS `contact_detail` from ((((((((((`engage_entity_po` `a` left join `engage_entity` `b` on((`a`.`idengage_entity` = `b`.`idengage_entity`))) left join `engage` `c` on((`c`.`engage_id` = `b`.`engage_id`))) left join `engage_comp` `d` on(((`d`.`comp_id` = `c`.`srv_client`) and (`d`.`engage_id` = `b`.`engage_id`)))) left join `engage_add` `e` on((`e`.`idengage_comp` = `d`.`idengage_comp`))) left join `engage_add_con` `f` on((`f`.`idengage_add` = `e`.`idengage_add`))) left join `comp_contact_no` `g` on((`g`.`comp_contact_no_id` = `f`.`comp_contact_no_id`))) left join `emp_contact` `h` on((`h`.`emp_contact_id` = `g`.`emp_contact_id`))) left join `emp` `i` on((`i`.`emp_id` = `h`.`emp_id`))) left join `contact_no` `j` on((`j`.`contact_id` = `h`.`contact_id`))) left join `look_values` `k` on((`k`.`look_values_id` = `h`.`emp_contact_type`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_engage_tree`
--

/*!50001 DROP VIEW IF EXISTS `vw_engage_tree`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_engage_tree` AS select group_concat(`C`.`companyname` separator ' ->') AS `comp_name`,`ET`.`idengage_entity_po` AS `idengage_entity_po` from (`engage_tree` `ET` left join `company` `C` on((`ET`.`comp_id` = `C`.`comp_id`))) group by `ET`.`idengage_entity_po` order by `ET`.`engage_tree_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_feature`
--

/*!50001 DROP VIEW IF EXISTS `vw_feature`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_feature` AS select `a`.`feature_no` AS `feature_no`,`a`.`feature_id` AS `feature_id`,`a`.`feature_name` AS `feature_name`,`a`.`feature_desc` AS `feature_desc`,`a`.`disp_order` AS `disp_order`,count(`c`.`feature_id`) AS `assigned`,count(`b`.`feature_id`) AS `groups` from ((`feature` `a` left join `feature_grp_list` `b` on((`a`.`feature_id` = `b`.`feature_id`))) left join `emp_access` `c` on((`a`.`feature_id` = `c`.`feature_id`))) group by `a`.`feature_id` order by `a`.`disp_order` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_feature_grp`
--

/*!50001 DROP VIEW IF EXISTS `vw_feature_grp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_feature_grp` AS select `feature_grp_list`.`idfeature_grp_list` AS `idfeature_grp_list`,`feature_grp_list`.`idfeature_grp` AS `idfeature_grp`,`feature_grp_list`.`feature_id` AS `feature_id`,`feature_grp_list`.`disp_order` AS `disp_order` from `feature_grp_list` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_feature_grp_load`
--

/*!50001 DROP VIEW IF EXISTS `vw_feature_grp_load`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_feature_grp_load` AS select `a`.`idfeature_grp` AS `idfeature_grp`,`b`.`idfeature_grp_load` AS `idfeature_grp_load`,`b`.`group_name` AS `group_name`,`b`.`group_desc` AS `group_desc`,`b`.`idfeature_grp_list` AS `idfeature_grp_list`,`b`.`feature_id` AS `feature_id`,`b`.`feature_nm` AS `feature_nm`,`b`.`updater` AS `updater`,`b`.`updater_nm` AS `updater_nm`,`b`.`last_updated` AS `last_updated` from (`feature_grp` `a` left join `feature_grp_load` `b` on((`a`.`idfeature_grp` = `b`.`idfeature_grp`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_festival`
--

/*!50001 DROP VIEW IF EXISTS `vw_festival`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_festival` AS select `a`.`idfestival` AS `idfestival`,`a`.`look_values_id` AS `look_values_id`,`a`.`comp_id` AS `comp_id`,`a`.`festival_yr` AS `festival_yr`,date_format(`a`.`festival_day`,_utf8'%m-%d-%y') AS `festival_day`,dayname(`a`.`festival_day`) AS `day`,`a`.`festival_name` AS `festival_name`,`a`.`festival_type` AS `festival_type`,`a`.`last_updated` AS `last_updated`,`a`.`updated_by` AS `updated_by`,concat(convert(date_format(`a`.`last_updated`,_utf8'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',(case when (`a`.`updated_by` = _utf8'0') then 'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end)) AS `mod_last_updated` from (`festival` `a` left join `emp` `e` on((`e`.`emp_id` = `a`.`updated_by`))) order by `a`.`festival_yr`,`a`.`festival_day` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_festival_company`
--

/*!50001 DROP VIEW IF EXISTS `vw_festival_company`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_festival_company` AS select `a`.`idfestival` AS `idfestival`,`a`.`look_values_id` AS `look_values_id`,`c`.`comp_id` AS `comp_id`,`c`.`companyname` AS `companyname`,`a`.`festival_yr` AS `festival_yr`,date_format(`a`.`festival_day`,_utf8'%m-%d-%y') AS `festival_day`,dayname(`a`.`festival_day`) AS `day`,`a`.`festival_name` AS `festival_name`,`a`.`festival_type` AS `festival_type`,`a`.`last_updated` AS `last_updated`,`a`.`updated_by` AS `updated_by`,concat(convert(date_format(`a`.`last_updated`,_utf8'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',(case when (`a`.`updated_by` = _utf8'0') then 'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end)) AS `mod_last_updated` from ((`festival` `a` left join `emp` `e` on((`e`.`emp_id` = `a`.`updated_by`))) left join `company` `c` on((`c`.`comp_id` = `a`.`comp_id`))) order by `a`.`festival_yr`,`a`.`festival_day` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_hours`
--

/*!50001 DROP VIEW IF EXISTS `vw_hours`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_hours` AS select `a`.`hour_id` AS `hour_id`,`a`.`emp_id` AS `emp_id`,concat(`b`.`firstname`,' ',`b`.`lastname`) AS `employee`,`a`.`comp_id` AS `comp_id`,`a`.`inv_num` AS `inv_num`,`a`.`hoursdate` AS `sort_hoursdate`,`a`.`timecard_id` AS `timecard_id`,`a`.`hoursday` AS `hoursday`,`a`.`totaltime` AS `totaltime`,`a`.`totaltime` AS `total_mm`,`a`.`hrs_type` AS `hrs_type`,ifnull(`l`.`lk_value`,'None') AS `hrs_type_val`,`a`.`iddev_apps` AS `iddev_apps`,date_format(`a`.`hoursdate`,'%m-%d-%y') AS `hoursdate`,date_format(`a`.`hoursdate`,'%Y') AS `hoursyear`,date_format(`a`.`hoursdate`,'%m') AS `hoursmonth`,date_format(`a`.`starttime`,'%m-%d-%y %H:%i:%s') AS `starttime`,date_format(`a`.`endtime`,'%m-%d-%y %H:%i:%s') AS `endtime`,date_format(`a`.`enter_dt`,'%Y-%m-%d') AS `enter_dt`,date_format(`a`.`approve_dt`,'%m-%d-%y') AS `approve_dt`,ifnull(`g`.`app_name`,'No Project') AS `app_name`,`a`.`dev_est` AS `dev_est`,ifnull(`a`.`dev_est`,'No Work Or') AS `dev_est_id1`,ifnull(`h`.`dev_est_smry`,'No Work Desc') AS `dev_est_smry`,`a`.`dev_est_reqs` AS `dev_est_reqs`,ifnull(`a`.`dev_est_reqs`,'No Req') AS `dev_est_reqs1`,ifnull(`i`.`req_desc`,'No Req Desc') AS `req_desc`,`i`.`req_type` AS `req_type`,ifnull(`j`.`look_value`,'No Category') AS `category`,`a`.`expected_hrs` AS `expected_hrs`,`c`.`companyname` AS `companyname`,`b`.`emp_id` AS `update_by_id`,ifnull(concat(`b`.`firstname`,' ',`b`.`lastname`),'Admin') AS `update_by`,`d`.`emp_id` AS `enterby`,concat(convert(date_format(`a`.`enter_dt`,'%m-%d-%y') using latin1),' ',ifnull(concat(`d`.`firstname`,' ',`d`.`lastname`),'Admin')) AS `last_updated`,ifnull(`d`.`emp_id`,'Admin') AS `entered_by`,ifnull(concat(`d`.`firstname`,' ',`d`.`lastname`),'Admin') AS `entered_by_nm`,`e`.`emp_id` AS `approve_by`,ifnull(concat(`e`.`firstname`,' ',`e`.`lastname`),'No Approvee') AS `approve_by_name`,`e`.`firstname` AS `approved_name`,`f`.`emp_id` AS `approver`,ifnull(concat(`f`.`firstname`,' ',`f`.`lastname`),'No Approver') AS `approver_by_name`,`k`.`emp_id` AS `process_by`,ifnull(concat(`k`.`firstname`,' ',`k`.`lastname`),'Not Processed') AS `process_by_name`,date_format(`a`.`process_dt`,'%m-%d-%y') AS `process_dt`,`a`.`summary` AS `summary` from (((((((((((`hours` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) left join `company` `c` on((`a`.`comp_id` = `c`.`comp_id`))) left join `emp` `d` on((`a`.`enterby` = `d`.`emp_id`))) left join `emp` `e` on((`a`.`approve_by` = `e`.`emp_id`))) left join `emp` `f` on((`a`.`approver` = `f`.`emp_id`))) left join `emp` `k` on((`a`.`process_by` = `k`.`emp_id`))) left join `dev_apps` `g` on((`a`.`iddev_apps` = `g`.`iddev_apps`))) left join `dev_est` `h` on((`a`.`dev_est` = `h`.`iddev_est`))) left join `dev_est_reqs` `i` on((`a`.`dev_est_reqs` = `i`.`iddev_est_reqs`))) left join `dev_look_value` `j` on((`i`.`req_type` = `j`.`iddev_look_value`))) left join `hours_lk_val` `l` on((`a`.`hrs_type` = `l`.`idhours_lk_val`))) order by `a`.`enter_dt` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_hr_meeting`
--

/*!50001 DROP VIEW IF EXISTS `vw_hr_meeting`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_hr_meeting` AS select `a`.`idhr_meeting` AS `idhr_meeting`,`a`.`st_tm_est` AS `st_tm_est`,`a`.`e_tm_est` AS `e_tm_est`,ifnull(concat('From',' ',time_format(`a`.`st_tm_est`,'%h:%i %p'),' ','To',' ',time_format(`a`.`e_tm_est`,'%h:%i %p')),'None') AS `est_meeting_time`,`a`.`st_tm_ist` AS `st_tm_ist`,`a`.`e_tm_ist` AS `e_tm_ist`,ifnull(concat('From',' ',time_format(`a`.`st_tm_ist`,'%h:%i %p'),' ','To',' ',time_format(`a`.`e_tm_ist`,'%h:%i %p')),'None') AS `ist_meeting_time`,`a`.`description` AS `description`,`a`.`attendances` AS `attendants`,`a`.`scrum_master` AS `scrum_master`,ifnull(time_format(`a`.`last_updated`,'%h:%i %p'),'Never') AS `last_updated`,ifnull(concat(`c`.`firstname`,' ',`c`.`lastname`),'Admin') AS `updater` from (`hr_meeting` `a` left join `emp` `c` on((`a`.`updater` = `c`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immi_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_immi_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immi_attach` AS select `a`.`idimmi_attach` AS `idimmi_attach`,`b`.`status_id` AS `status_id`,`b`.`rec_status` AS `rec_status`,`f`.`look_values` AS `status`,`b`.`receipt_id` AS `receipt_id`,`a`.`idstorage` AS `idstorage`,`a`.`updater` AS `updater`,`c`.`owner_id` AS `owner_id`,`c`.`file_name` AS `file_name`,`c`.`public` AS `public`,`c`.`self_view` AS `self_view`,`c`.`shared` AS `shared`,`c`.`emp_id` AS `emp_id`,`c`.`updated_for_ref_id` AS `updated_for_ref_id`,`c`.`updated_for_ref_table` AS `updated_for_ref_table` from (((`immi_attach` `a` left join `storages` `c` on((`a`.`idstorage` = `c`.`idstorage`))) left join `immi_status` `b` on((`b`.`status_id` = `a`.`status_id`))) left join `look_values` `f` on((`b`.`rec_status` = `f`.`look_values_id`))) order by `a`.`idimmi_attach` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immi_lk_wrk_flow`
--

/*!50001 DROP VIEW IF EXISTS `vw_immi_lk_wrk_flow`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immi_lk_wrk_flow` AS select `a`.`idimmi_lk_wrk_flow` AS `idimmi_lk_wrk_flow`,`a`.`id_wrk_flow` AS `id_wrk_flow`,`a`.`id_wrk_flow_parent` AS `id_wrk_flow_parent`,`a`.`look_restart` AS `look_restart`,ifnull(concat(`c`.`firstname`,' ',`c`.`lastname`),'Admin') AS `updater`,`a`.`last_updated` AS `last_updated`,`b`.`immi_value` AS `immi_value` from ((`immi_lk_wrk_flow` `a` left join `immi_lk_val` `b` on((`a`.`id_wrk_flow` = `b`.`idimmi_lk_val`))) left join `emp` `c` on((`a`.`updater` = `c`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immi_qry`
--

/*!50001 DROP VIEW IF EXISTS `vw_immi_qry`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immi_qry` AS select `immi_qry`.`idimmi_qry` AS `idimmi_qry`,`immi_qry`.`immi_desc` AS `immi_desc`,`immi_qry`.`immi_desc_detail` AS `immi_desc_detail`,`immi_qry`.`last_updated` AS `last_updated`,date_format(`immi_qry`.`last_updated`,_utf8'%m-%d-%y') AS `last_updated_formatted`,date_format(`immi_qry`.`last_updated`,_utf8'%Y') AS `immi_year`,date_format(`immi_qry`.`last_updated`,_utf8'%m') AS `immi_month`,`immi_qry`.`updated_by` AS `updated_by`,ifnull(`u`.`fullname`,'Admin') AS `updater`,`u`.`emp_file_name` AS `updater_file_name`,`immi_qry`.`del_dt` AS `del_dt`,date_format(`immi_qry`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt_formatted`,`immi_qry`.`del_by` AS `del_by_id`,ifnull(`e_del_by`.`fullname`,'Admin') AS `del_by`,`e_del_by`.`emp_file_name` AS `del_by_file_name`,(to_days((date_format(`immi_qry`.`del_dt`,'%y-%m-%d') + interval `immi_qry`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day` from ((`immi_qry` left join `vw_emp` `u` on((`u`.`emp_id` = `immi_qry`.`updated_by`))) left join `vw_emp` `e_del_by` on((`immi_qry`.`del_by` = `e_del_by`.`emp_id`))) order by `immi_qry`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immi_receipt_qry`
--

/*!50001 DROP VIEW IF EXISTS `vw_immi_receipt_qry`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immi_receipt_qry` AS select `immi_receipt_qry`.`idimmi_receipt_qry` AS `idimmi_receipt_qry`,`immi_receipt_qry`.`immi_receipts` AS `immi_receipts`,`a`.`comp_id` AS `comp_id`,`a`.`company` AS `company`,`a`.`receipt_type` AS `receipt_type`,`a`.`receipt_no` AS `receipt_no`,`a`.`immi_ref_tab` AS `immi_ref_tab`,`a`.`immi_ref_id` AS `immi_ref_id`,`a`.`name` AS `name`,`a`.`typst` AS `typst`,`a`.`filed_dt` AS `filed_dt`,`a`.`filed_dt_formatted` AS `filed_dt_formatted`,`a`.`filed_dt_m` AS `filed_dt_m`,`a`.`filed_dt_y` AS `filed_dt_y`,`a`.`ad_title` AS `ad_title`,`a`.`ad` AS `ad`,`a`.`imi_source` AS `imi_source`,`a`.`immi_source_nm` AS `immi_source_nm`,`a`.`combo` AS `combo`,`a`.`from_dt` AS `from_dt`,`a`.`from_dt_formatted` AS `from_dt_formatted`,`a`.`to_dt` AS `to_dt`,`a`.`to_dt_formatted` AS `to_dt_formatted`,`a`.`valid_days` AS `valid_days`,`a`.`expire_dt` AS `expire_dt`,`a`.`expire_dt_formatted` AS `expire_dt_formatted`,`a`.`validity` AS `validity`,`a`.`look_street_no_id` AS `look_street_no_id`,`a`.`addresses` AS `addresses`,`a`.`suite_no` AS `suite_no`,`a`.`stat_st_dt_formatted` AS `stat_st_dt_formatted`,`a`.`stat_e_dt_formatted` AS `stat_e_dt_formatted`,`a`.`no_days` AS `no_days`,`a`.`status` AS `status`,`a`.`immi_summary` AS `immi_summary`,`immi_receipt_qry`.`due_dt` AS `due_dt`,date_format(`immi_receipt_qry`.`due_dt`,'%m-%d-%y') AS `due_dt_formatted`,date_format(`immi_receipt_qry`.`due_dt`,'%m-%Y') AS `due_dt1`,`immi_receipt_qry`.`qry_stat` AS `qry_stat`,`immi_receipt_qry`.`last_updated` AS `last_updated`,date_format(`immi_receipt_qry`.`last_updated`,'%m-%d-%y ') AS `last_updated_formatted`,date_format(`immi_receipt_qry`.`last_updated`,'%Y') AS `receipt_qry_year`,date_format(`immi_receipt_qry`.`last_updated`,'%m') AS `receipt_qry_month`,`immi_receipt_qry`.`updated_by` AS `updated_by`,ifnull(`u`.`fullname`,'Admin') AS `updater`,`u`.`emp_file_name` AS `updater_file_name`,`a`.`del_dt` AS `del_dt`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt_formatted`,`immi_receipt_qry`.`del_by` AS `del_by_id`,ifnull(`e_del_by`.`fullname`,'Admin') AS `del_by`,`e_del_by`.`emp_file_name` AS `del_by_file_name`,(to_days((date_format(`immi_receipt_qry`.`del_dt`,'%y-%m-%d') + interval `immi_receipt_qry`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`immi_receipt_qry`.`archv_dt` AS `archv_dt`,date_format(`immi_receipt_qry`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt_formatted`,`immi_receipt_qry`.`archv_by` AS `archv_by_id`,ifnull(`e_archv_by`.`fullname`,'Admin') AS `archv_by`,`e_archv_by`.`emp_file_name` AS `archv_by_file_name` from ((((`immi_receipt_qry` left join `vw_immi_receipts` `a` on((`immi_receipt_qry`.`immi_receipts` = `a`.`receipt_id`))) left join `vw_emp` `u` on((`u`.`emp_id` = `immi_receipt_qry`.`updated_by`))) left join `vw_emp` `e_del_by` on((`immi_receipt_qry`.`del_by` = `e_del_by`.`emp_id`))) left join `vw_emp` `e_archv_by` on((`immi_receipt_qry`.`archv_by` = `e_archv_by`.`emp_id`))) order by `immi_receipt_qry`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immi_receipt_qry_list`
--

/*!50001 DROP VIEW IF EXISTS `vw_immi_receipt_qry_list`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immi_receipt_qry_list` AS select `immi_receipt_qry_list`.`idimmi_receipt_qry_list` AS `idimmi_receipt_qry_list`,`immi_receipt_qry_list`.`idimmi_receipt_qry` AS `idimmi_receipt_qry`,`immi_receipt_qry_list`.`idimmi_qry` AS `idimmi_qry`,`immi_receipt_qry_list`.`immi_receipts` AS `immi_receipts`,`a`.`company` AS `company`,`a`.`company_logo` AS `company_logo`,`a`.`receipt_type` AS `receipt_type`,`a`.`receipt_no` AS `receipt_no`,`a`.`immi_ref_id` AS `immi_ref_id`,`a`.`immi_ref_tab` AS `immi_ref_tab`,`a`.`name` AS `name`,`a`.`typst` AS `typst`,`a`.`filed_dt_formatted` AS `filed_dt_formatted`,`a`.`imi_source` AS `imi_source`,`a`.`immi_source_nm` AS `immi_source_nm`,`a`.`combo` AS `combo`,`a`.`expire_dt_formatted` AS `expire_dt_formatted`,`a`.`validity` AS `validity`,`a`.`salary_type` AS `salary_type`,`a`.`salary_type_nm` AS `salary_type_nm`,`a`.`salary_amt` AS `salary_amt`,`a`.`rec_status` AS `rec_status`,`a`.`status` AS `status`,`g`.`immi_desc` AS `immi_desc`,date_format(`immi_receipt_qry_list`.`start_dt`,_utf8'%m-%d-%y ') AS `start_dt`,date_format(`immi_receipt_qry_list`.`end_dt`,_utf8'%m-%d-%y ') AS `end_dt`,date_format(`immi_receipt_qry_list`.`due_dt`,_utf8'%m-%d-%y ') AS `due_dt`,(case when (`immi_receipt_qry_list`.`end_dt` <> _utf8'0000-00-00') then (to_days(`immi_receipt_qry_list`.`end_dt`) - to_days(`immi_receipt_qry_list`.`start_dt`)) else (to_days(curdate()) - to_days(`immi_receipt_qry_list`.`start_dt`)) end) AS `no_days`,`c`.`file_name` AS `file_name`,`immi_receipt_qry_list`.`idstorage` AS `idstorage`,`immi_receipt_qry_list`.`last_updated` AS `last_updated`,date_format(`immi_receipt_qry_list`.`last_updated`,_utf8'%m-%d-%y %H:%i:%s') AS `last_updated_formatted`,`immi_receipt_qry_list`.`updated_by` AS `updated_by`,ifnull(`e`.`fullname`,'Admin') AS `updated_nm` from ((((`immi_receipt_qry_list` left join `vw_immi_receipts` `a` on((`a`.`receipt_id` = `immi_receipt_qry_list`.`immi_receipts`))) left join `vw_immi_qry` `g` on((`g`.`idimmi_qry` = `immi_receipt_qry_list`.`idimmi_qry`))) left join `vw_emp` `e` on((`e`.`emp_id` = `immi_receipt_qry_list`.`updated_by`))) left join `storages` `c` on((`immi_receipt_qry_list`.`idstorage` = `c`.`idstorage`))) order by date_format(`immi_receipt_qry_list`.`last_updated`,_utf8'%m-%d-%y ') desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immi_receipt_qry_list_rpt`
--

/*!50001 DROP VIEW IF EXISTS `vw_immi_receipt_qry_list_rpt`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immi_receipt_qry_list_rpt` AS select `a`.`idimmi_receipt_qry` AS `idimmi_receipt_qry`,`a`.`idimmi_qry` AS `idimmi_qry`,`a`.`immi_receipts` AS `immi_receipts`,`a`.`immi_desc` AS `immi_desc`,count(`a`.`immi_receipts`) AS `immi_receiptscount`,`a`.`updated_by` AS `updated_by`,`a`.`updated_nm` AS `updated_nm`,`a`.`last_updated` AS `last_updated`,`a`.`last_updated_formatted` AS `last_updated_formatted`,date_format(`a`.`last_updated`,_utf8'%Y') AS `receipt_qry_year`,date_format(`a`.`last_updated`,_utf8'%m') AS `receipt_qry_month` from (`vw_immi_receipt_qry_list` `a` left join `vw_emp` `e` on((`e`.`emp_id` = `a`.`updated_by`))) group by `a`.`idimmi_qry` order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immi_receipts`
--

/*!50001 DROP VIEW IF EXISTS `vw_immi_receipts`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immi_receipts` AS select `a`.`receipt_id` AS `receipt_id`,`a`.`comp_id` AS `comp_id`,ifnull(`m`.`companyname`,'No Comp') AS `company`,`m`.`storage_file_name` AS `company_logo`,`a`.`receipt_type` AS `receipt_type`,`a`.`receipt_no` AS `receipt_no`,`a`.`immi_ref_id` AS `immi_ref_id`,`a`.`immi_ref_tab` AS `immi_ref_tab`,(case when (`a`.`immi_ref_tab` = _latin1'Consultant') then ifnull(concat(`k`.`prosp_first_name`,_latin1' ',`k`.`prosp_last_name`),'No Consult') when (`a`.`immi_ref_tab` = _latin1'Employee') then ifnull(concat(`j`.`firstname`,_latin1' ',`j`.`lastname`),'Admin') end) AS `name`,concat_ws(_latin1',',`a`.`receipt_type`,`i`.`immi_value`,`m`.`companyname`) AS `typst`,`a`.`filed_dt` AS `filed_dt`,date_format(`a`.`filed_dt`,_utf8'%m-%d-%y') AS `filed_dt_formatted`,date_format(`a`.`filed_dt`,_utf8'%m') AS `filed_dt_m`,date_format(`a`.`filed_dt`,_utf8'%Y') AS `filed_dt_y`,`a`.`ad_title` AS `ad_title`,ifnull(`b`.`immi_value`,'No Ad') AS `ad`,`a`.`immi_source` AS `imi_source`,ifnull(`c`.`immi_value`,'None') AS `immi_source_nm`,`a`.`occ_code` AS `occ_code`,ifnull(`d`.`immi_value`,'None') AS `occ_code_nm`,`a`.`skill_level` AS `skill_level`,ifnull(`e`.`immi_value`,'None') AS `skill_level_nm`,concat_ws(_latin1'-',(case when (`d`.`immi_value` <> _latin1'') then concat(_latin1'(',`b`.`immi_value`,_latin1'-',`d`.`immi_value`,_latin1')') end),(case when (`e`.`immi_value` <> _latin1'') then concat(_latin1'(',`e`.`immi_value`,_latin1')') end),(case when (`f`.`immi_value` <> _latin1'') then concat(_latin1'(',`f`.`immi_value`,_latin1')') end),(case when (`g`.`immi_value` <> _latin1'') then concat(_latin1'(',`g`.`immi_value`,_latin1')') end),(case when (`h`.`immi_value` <> _latin1'') then concat(_latin1'(',`h`.`immi_value`,_latin1')') end),(case when (`a`.`salary_amt` <> _latin1'') then concat(_latin1'(',`a`.`salary_amt`,_latin1')') end)) AS `combo`,`a`.`from_dt` AS `from_dt`,date_format(`a`.`from_dt`,_utf8'%m-%d-%y') AS `from_dt_formatted`,`a`.`to_dt` AS `to_dt`,date_format(`a`.`to_dt`,_utf8'%m-%d-%y') AS `to_dt_formatted`,`a`.`valid_days` AS `valid_days`,if((`a`.`expire_dt` = _utf8'0000-00-00'),_utf8'',date_format(`a`.`expire_dt`,_utf8'%Y-%m-%d')) AS `expire_dt`,if((`a`.`expire_dt` = _utf8'0000-00-00'),_utf8'',date_format(`a`.`expire_dt`,_utf8'%m-%d-%y')) AS `expire_dt_formatted`,date_format(`a`.`expire_dt`,_utf8'%m-%Y') AS `expire_dt_new`,(to_days(`a`.`expire_dt`) - to_days(now())) AS `expire_diff`,concat_ws(_utf8' To ',date_format(`a`.`from_dt`,_utf8'%m-%d-%y'),date_format(`a`.`to_dt`,_utf8'%m-%d-%y')) AS `validity`,`a`.`education` AS `education`,ifnull(`f`.`immi_value`,'None') AS `education_nm`,`a`.`exp_years` AS `exp_years`,ifnull(`g`.`immi_value`,'None') AS `exp_years_nm`,`a`.`salary_type` AS `salary_type`,ifnull(`h`.`immi_value`,'None') AS `salary_type_nm`,`a`.`salary_amt` AS `salary_amt`,`a`.`look_street_no_id` AS `look_street_no_id`,ifnull(`jj`.`addresses`,'No Add') AS `addresses`,`a`.`suite_no` AS `suite_no`,`a`.`rec_status` AS `rec_status`,ifnull(`i`.`immi_value`,'None') AS `status`,`a`.`stat_st_dt` AS `stat_st_dt`,date_format(`a`.`stat_st_dt`,_utf8'%m-%d-%y') AS `stat_st_dt_formatted`,`a`.`stat_e_dt` AS `stat_e_dt`,date_format(`a`.`stat_e_dt`,_utf8'%m-%d-%y') AS `stat_e_dt_formatted`,`a`.`no_days` AS `no_days`,`a`.`immi_summary` AS `immi_summary`,`a`.`idlook_stat_order` AS `idlook_stat_order`,`l`.`immi_value` AS `idlook_stat_order_nm`,`a`.`last_updated` AS `last_updated`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated_formatted`,`a`.`emp_id` AS `updater_id`,ifnull(`u`.`fullname`,'Admin') AS `updater`,`u`.`emp_file_name` AS `updater_file_name`,`a`.`del_dt` AS `del_dt`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt_formatted`,`a`.`del_by` AS `del_by_id`,ifnull(`e_del_by`.`fullname`,'Admin') AS `del_by`,`e_del_by`.`emp_file_name` AS `del_by_file_name`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt_formatted`,`a`.`archv_by` AS `archv_by_id`,ifnull(`e_archv_by`.`fullname`,'Admin') AS `archv_by`,`e_archv_by`.`emp_file_name` AS `archv_by_file_name` from ((((((((((((((((`immi_receipts` `a` left join `immi_lk_val` `b` on((`a`.`ad_title` = `b`.`idimmi_lk_val`))) left join `immi_lk_val` `c` on((`a`.`immi_source` = `c`.`idimmi_lk_val`))) left join `immi_lk_val` `d` on((`a`.`occ_code` = `d`.`idimmi_lk_val`))) left join `immi_lk_val` `e` on((`a`.`skill_level` = `e`.`idimmi_lk_val`))) left join `immi_lk_val` `f` on((`a`.`education` = `f`.`idimmi_lk_val`))) left join `immi_lk_val` `g` on((`a`.`exp_years` = `g`.`idimmi_lk_val`))) left join `immi_lk_val` `h` on((`a`.`salary_type` = `h`.`idimmi_lk_val`))) left join `immi_lk_val` `i` on((`a`.`rec_status` = `i`.`idimmi_lk_val`))) left join `immi_lk_val` `l` on((`a`.`idlook_stat_order` = `l`.`idimmi_lk_val`))) left join `vw_look_addresses` `jj` on((`a`.`look_street_no_id` = `jj`.`look_street_no_id`))) left join `emp` `j` on((`a`.`immi_ref_id` = `j`.`emp_id`))) left join `prosp_consult` `k` on((`a`.`immi_ref_id` = `k`.`prosp_consult_id`))) left join `vw_emp` `u` on((`a`.`emp_id` = `u`.`emp_id`))) left join `vw_company` `m` on((`a`.`comp_id` = `m`.`comp_id`))) left join `vw_emp` `e_del_by` on((`a`.`del_by` = `e_del_by`.`emp_id`))) left join `vw_emp` `e_archv_by` on((`a`.`archv_by` = `e_archv_by`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immi_recpt_qry_list_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_immi_recpt_qry_list_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immi_recpt_qry_list_attach` AS select `a`.`idimmi_recpt_qry_list_attach` AS `idimmi_recpt_qry_list_attach`,`b`.`idimmi_receipt_qry_list` AS `idimmi_receipt_qry_list`,`b`.`immi_receipts` AS `immi_receipts`,`b`.`idimmi_qry` AS `idimmi_qry`,`f`.`immi_desc` AS `immi_desc`,`b`.`idimmi_receipt_qry` AS `idimmi_receipt_qry`,`a`.`idstorage` AS `idstorage`,`a`.`updater` AS `updater`,`c`.`owner_id` AS `owner_id`,`c`.`file_name` AS `file_name`,`c`.`public` AS `public`,`c`.`self_view` AS `self_view`,`c`.`shared` AS `shared`,`c`.`emp_id` AS `emp_id`,`c`.`updated_for_ref_id` AS `updated_for_ref_id`,`c`.`updated_for_ref_table` AS `updated_for_ref_table`,`a`.`last_updated` AS `last_updated` from (((`immi_recpt_qry_list_attach` `a` left join `storages` `c` on((`a`.`idstorage` = `c`.`idstorage`))) left join `immi_receipt_qry_list` `b` on((`b`.`idimmi_receipt_qry_list` = `a`.`idimmi_receipt_qry_list`))) left join `immi_qry` `f` on((`b`.`idimmi_qry` = `f`.`idimmi_qry`))) order by `a`.`idimmi_recpt_qry_list_attach` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immi_status`
--

/*!50001 DROP VIEW IF EXISTS `vw_immi_status`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immi_status` AS select `a`.`status_id` AS `status_id`,`a`.`receipt_id` AS `receipt_id`,`a`.`rec_status` AS `rec_status_id`,`b`.`immi_value` AS `rec_status_nm`,`a`.`stat_dt_dt` AS `stat_dt_dt`,date_format(`a`.`stat_dt_dt`,_utf8'%m-%d-%y') AS `stat_st_dt_formatted`,`a`.`stat_e_dt` AS `stat_e_dt`,date_format(`a`.`stat_e_dt`,_utf8'%m-%d-%y') AS `stat_e_dt_formatted`,`a`.`no_days` AS `no_days`,`a`.`idlook_stat_order` AS `idlook_stat_order`,`l`.`immi_value` AS `idlook_stat_order_nm`,`a`.`last_updated` AS `last_updated`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated_formatted`,`a`.`updater` AS `updater`,ifnull(`u`.`fullname`,'Admin') AS `updater_nm`,`u`.`emp_file_name` AS `updater_file_name`,`a`.`del_dt` AS `del_dt`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt_formatted`,`a`.`del_by` AS `del_by_id`,ifnull(`e_del_by`.`fullname`,'Admin') AS `del_by`,`e_del_by`.`emp_file_name` AS `del_by_file_name`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt_formatted`,`a`.`archv_by` AS `archv_by_id`,ifnull(`e_archv_by`.`fullname`,'Admin') AS `archv_by`,`e_archv_by`.`emp_file_name` AS `archv_by_file_name` from (((((`immi_status` `a` left join `immi_lk_val` `b` on((`a`.`rec_status` = `b`.`idimmi_lk_val`))) left join `immi_lk_val` `l` on((`a`.`idlook_stat_order` = `l`.`idimmi_lk_val`))) left join `vw_emp` `u` on((`a`.`updater` = `u`.`emp_id`))) left join `vw_emp` `e_del_by` on((`a`.`del_by` = `e_del_by`.`emp_id`))) left join `vw_emp` `e_archv_by` on((`a`.`archv_by` = `e_archv_by`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immi_status_steps`
--

/*!50001 DROP VIEW IF EXISTS `vw_immi_status_steps`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immi_status_steps` AS select `a`.`idimmi_status_steps` AS `idimmi_status_steps`,`a`.`immi_status_id` AS `immi_status_id`,`a`.`receipt_id` AS `receipt_id`,`b`.`rec_status` AS `rec_status_id`,`c`.`immi_value` AS `rec_status`,`a`.`immi_steps_detail` AS `immi_steps_detail`,`a`.`last_updated` AS `last_updated`,`a`.`updater` AS `updater_id`,ifnull(`u`.`fullname`,'Admin') AS `updater`,`u`.`emp_file_name` AS `updater_file_name` from (((`immi_status_steps` `a` left join `immi_status` `b` on((`a`.`immi_status_id` = `b`.`status_id`))) left join `immi_lk_val` `c` on((`b`.`rec_status` = `c`.`idimmi_lk_val`))) left join `vw_emp` `u` on((`a`.`updater` = `u`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_immisource_del`
--

/*!50001 DROP VIEW IF EXISTS `vw_immisource_del`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_immisource_del` AS select `look_values`.`look_values_id` AS `look_values_id`,`look_values`.`look_table` AS `look_table`,`look_values`.`look_values` AS `look_values`,`look_values`.`look_value_desc` AS `look_value_desc`,`look_values`.`look_value_code` AS `look_value_code`,`look_values`.`look_display_id` AS `look_display_id`,`look_values`.`look_sub_value_id` AS `look_sub_value_id` from `look_values` where `look_values`.`look_sub_value_id` in (select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where (`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'immi_receipts')))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_inv`
--

/*!50001 DROP VIEW IF EXISTS `vw_inv`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_inv` AS select `inv`.`inv_num` AS `inv_num`,`inv`.`comp_id` AS `comp_id`,`co`.`companyname` AS `companyname`,`inv`.`idstorage` AS `idstorage`,`inv`.`comp_add_ref_id` AS `comp_add_ref_id`,`lstrno`.`addresses` AS `comp_addresses`,`inv`.`inv_phone` AS `inv_phone`,`inv`.`comp_add_suite_no` AS `comp_add_suite_no`,`inv`.`inv_email` AS `inv_email`,`inv`.`invoice_no` AS `invoice_no`,`inv`.`from_dt` AS `from_dt`,date_format(`inv`.`from_dt`,'%m-%d-%y') AS `from_dt_formatted`,`inv`.`to_dt` AS `to_dt`,date_format(`inv`.`to_dt`,'%m-%d-%y') AS `to_dt_formatted`,`inv`.`billed_dt` AS `billed_dt`,date_format(`inv`.`billed_dt`,'%m-%d-%y') AS `billed_dt_formatted`,`inv`.`due_dt` AS `due_dt`,date_format(`inv`.`due_dt`,'%m-%d-%y') AS `due_dt_formatted`,`inv`.`summary` AS `summary`,`inv`.`inv_to_ref_id` AS `inv_to_ref_id`,`inv`.`inv_to_ref_table` AS `inv_to_ref_table`,(case when (`inv`.`inv_to_ref_table` = 'Company') then concat(`c`.`companyname`) when (`inv`.`inv_to_ref_table` = 'Employee') then (case when isnull(`inv`.`inv_to_ref_id`) then 'Admin' else concat(`em`.`firstname`,_latin1' ',`em`.`lastname`) end) end) AS `inv_ref_id_name`,(case when (`inv`.`inv_to_ref_table` = 'Company') then concat(`c`.`companyname`) when (`inv`.`inv_to_ref_table` = 'Employee') then (case when isnull(`inv`.`inv_to_ref_id`) then 'Admin' else concat(`em`.`firstname`,_latin1' ',`em`.`lastname`) end) end) AS `bill_to`,`inv`.`inv_add_ref_id` AS `inv_add_ref_id`,`lstr`.`addresses` AS `client _addresses`,`inv`.`inv_add_suite_no` AS `inv_add_suite_no`,`inv`.`amt_sub` AS `amt_sub`,`inv`.`amt_tax` AS `amt_tax`,`inv`.`amt_tol` AS `amt_tol`,`inv`.`amt_paid` AS `amt_paid`,`inv`.`updatedby` AS `updatedby`,`inv`.`lastupdated` AS `lastupdated`,(select group_concat(`inv_atten`.`inv_attn_name`,_latin1' : ',`inv_atten`.`inv_attn_contact`,_latin1' : ',`inv_atten`.`inv__attn_display`,' <br> ' separator ',') AS `contact_detail` from `inv_atten` where (`inv_atten`.`inv_num` = `inv`.`inv_num`) group by `inv_atten`.`inv_num`) AS `contact_detail`,concat(convert(date_format(`inv`.`lastupdated`,'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',(case when (isnull(`inv`.`updatedby`) or (`inv`.`updatedby` = '0')) then 'Admin' else concat(`e`.`firstname`,_latin1'<br>',`e`.`lastname`) end)) AS `last_updated` from ((((((`inv` left join `emp` `em` on((`inv`.`inv_to_ref_id` = `em`.`emp_id`))) left join `company` `co` on((`inv`.`comp_id` = `co`.`comp_id`))) left join `company` `c` on((`inv`.`inv_to_ref_id` = `c`.`comp_id`))) left join `emp` `e` on((`inv`.`updatedby` = `e`.`emp_id`))) left join `vw_addresses2` `lstrno` on((`inv`.`comp_add_ref_id` = `lstrno`.`look_street_no_id`))) left join `vw_addresses2` `lstr` on((`inv`.`inv_add_ref_id` = `lstr`.`look_street_no_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_inv_engage`
--

/*!50001 DROP VIEW IF EXISTS `vw_inv_engage`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_inv_engage` AS select `a`.`idengage_inv` AS `idengage_inv`,`a`.`idengage_entity_po` AS `idengage_entity_po`,`a`.`display` AS `display`,`a`.`idengage_add_con` AS `idengage_add_con`,`a`.`last_updated` AS `last_updated`,`c`.`comp_contact_no_id` AS `comp_contact_no_id`,`d`.`emp_contact_id` AS `emp_contact_id`,`e`.`contact_id` AS `contact_id`,`e`.`emp_contact_type` AS `emp_contact_type`,`e`.`emp_id` AS `emp_id`,concat(`h`.`firstname`,_latin1' ',`h`.`lastname`) AS `employee`,concat(`g`.`look_values`,_latin1'->',`f`.`contact_detail`) AS `contact_detail` from ((((((`engage_inv` `a` left join `engage_add_con` `c` on((`a`.`idengage_add_con` = `c`.`idengage_add_con`))) left join `comp_contact_no` `d` on((`c`.`comp_contact_no_id` = `d`.`comp_contact_no_id`))) left join `emp_contact` `e` on((`e`.`emp_contact_id` = `d`.`emp_contact_id`))) left join `emp` `h` on((`h`.`emp_id` = `e`.`emp_id`))) left join `contact_no` `f` on((`e`.`contact_id` = `f`.`contact_id`))) left join `look_values` `g` on((`g`.`look_values_id` = `e`.`emp_contact_type`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_inv_engage_gp`
--

/*!50001 DROP VIEW IF EXISTS `vw_inv_engage_gp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_inv_engage_gp` AS select `vw_engage_inv`.`idengage_inv` AS `idengage_inv`,`vw_engage_inv`.`idengage_entity_po` AS `idengage_entity_po`,`vw_engage_inv`.`display` AS `display`,`vw_engage_inv`.`idengage_add_con` AS `idengage_add_con`,`vw_engage_inv`.`last_updated` AS `last_updated`,`vw_engage_inv`.`comp_contact_no_id` AS `comp_contact_no_id`,`vw_engage_inv`.`emp_contact_id` AS `emp_contact_id`,`vw_engage_inv`.`contact_id` AS `contact_id`,`vw_engage_inv`.`emp_contact_type` AS `emp_contact_type`,`vw_engage_inv`.`emp_id` AS `emp_id`,`vw_engage_inv`.`employee` AS `employee`,`vw_engage_inv`.`contact_detail` AS `contact_detail` from `vw_engage_inv` where `vw_engage_inv`.`last_updated` in (select max(`vw_engage_inv`.`last_updated`) AS `MAX(last_updated)` from `vw_engage_inv` group by `vw_engage_inv`.`idengage_entity_po`) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_inv_engage_po`
--

/*!50001 DROP VIEW IF EXISTS `vw_inv_engage_po`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_inv_engage_po` AS select `a`.`idengage_entity_po` AS `idengage_entity_po`,`a`.`idengage_entity` AS `idengage_entity`,`b`.`engage_id` AS `engage_id`,`c`.`srv_client` AS `srv_client`,`d`.`idengage_comp` AS `idengage_comp`,`e`.`idengage_add` AS `idengage_add`,`f`.`comp_contact_no_id` AS `comp_contact_no_id`,`f`.`idengage_add_con` AS `idengage_add_con`,`g`.`emp_contact_id` AS `emp_contact_id`,`h`.`contact_id` AS `contact_id`,`h`.`emp_contact_type` AS `emp_contact_type`,`h`.`emp_id` AS `emp_id`,concat(`i`.`firstname`,_latin1' ',`i`.`lastname`) AS `employee`,concat(`k`.`look_values`,_latin1'->',`j`.`contact_detail`) AS `contact_detail` from ((((((((((`engage_entity_po` `a` left join `engage_entity` `b` on((`a`.`idengage_entity` = `b`.`idengage_entity`))) left join `engage` `c` on((`c`.`engage_id` = `b`.`engage_id`))) left join `engage_comp` `d` on(((`d`.`comp_id` = `c`.`srv_client`) and (`d`.`engage_id` = `b`.`engage_id`)))) left join `engage_add` `e` on((`e`.`idengage_comp` = `d`.`idengage_comp`))) left join `engage_add_con` `f` on((`f`.`idengage_add` = `e`.`idengage_add`))) left join `comp_contact_no` `g` on((`g`.`comp_contact_no_id` = `f`.`comp_contact_no_id`))) left join `emp_contact` `h` on((`h`.`emp_contact_id` = `g`.`emp_contact_id`))) left join `emp` `i` on((`i`.`emp_id` = `h`.`emp_id`))) left join `contact_no` `j` on((`j`.`contact_id` = `h`.`contact_id`))) left join `look_values` `k` on((`k`.`look_values_id` = `h`.`emp_contact_type`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_inv_po`
--

/*!50001 DROP VIEW IF EXISTS `vw_inv_po`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_inv_po` AS select `x`.`con_srv_st_dt` AS `con_srv_st_dt`,`x`.`con_srv_e_dt` AS `con_srv_e_dt`,`x`.`mod_bill_start_dt1` AS `mod_bill_start_dt1`,`x`.`mod_bill_end_dt1` AS `mod_bill_end_dt1`,`x`.`client_address` AS `client_address`,`x`.`vendor_address` AS `vendor_address`,`x`.`engage_ref_id_name` AS `engage_ref_id_name`,`x`.`engage_ref_tab` AS `engage_ref_tab`,`x`.`comp_emp_detail` AS `comp_emp_detail`,`y`.`idengage_inv` AS `idengage_inv`,`x`.`idengage_entity_po` AS `idengage_entity_po`,`y`.`idengage_add_con` AS `idengage_add_con`,`y`.`comp_contact_no_id` AS `comp_contact_no_id`,`y`.`emp_contact_id` AS `emp_contact_id`,`y`.`contact_id` AS `contact_id`,`y`.`emp_contact_type` AS `emp_contact_type`,`y`.`contact_detail` AS `contact_detail`,`y`.`last_updated` AS `last_updated` from (`vw_contracts_po` `x` left join `vw_inv_engage_gp` `y` on((`x`.`idengage_entity_po` = `y`.`idengage_entity_po`))) group by `x`.`idengage_entity_po` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_load_contracts`
--

/*!50001 DROP VIEW IF EXISTS `vw_load_contracts`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_load_contracts` AS select `b`.`idload_contracts` AS `idload_contracts`,`b`.`engage_id` AS `engage_id`,`b`.`srv_st_dt` AS `srv_st_dt`,`b`.`srv_e_dt` AS `srv_e_dt`,`b`.`eng_tentitive_en_dt` AS `eng_tentitive_en_dt`,`b`.`sr_frequency` AS `sr_frequency`,`b`.`srv_paytype` AS `srv_paytype`,`b`.`srv_amount` AS `srv_amount`,`b`.`eg_sumry` AS `eg_sumry`,`b`.`cloud_drive` AS `cloud_drive`,`b`.`srv_client` AS `srv_client`,`b`.`comp_id` AS `comp_id`,`b`.`mod_srv_st_dt` AS `mod_srv_st_dt`,`b`.`mod_srv_st_dt1` AS `mod_srv_st_dt1`,`b`.`mod_srv_e_dt` AS `mod_srv_e_dt`,`b`.`mod_srv_e_dt1` AS `mod_srv_e_dt1`,`b`.`mod_eng_tentitive_en_dt` AS `mod_eng_tentitive_en_dt`,`b`.`mod_eng_tentitive_en_dt1` AS `mod_eng_tentitive_en_dt1`,`b`.`eng_tentitive_en_dt_filter` AS `eng_tentitive_en_dt_filter`,`b`.`frequency` AS `frequency`,`b`.`paytype` AS `paytype`,`b`.`engage_doc_id` AS `engage_doc_id`,`b`.`last_updated` AS `last_updated`,`b`.`srv_client_name` AS `srv_client_name`,`b`.`companyname` AS `companyname`,`b`.`updated_by` AS `updated_by`,`b`.`freqypaytype` AS `freqypaytype`,`b`.`last_updter` AS `last_updter`,`b`.`last_updter1` AS `last_updter1`,`b`.`idengage_comp` AS `idengage_comp`,`b`.`client_address` AS `client_address`,`b`.`vendor_address` AS `vendor_address` from (`engage` `a` left join `load_contracts` `b` on((`a`.`engage_id` = `b`.`engage_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_log_global`
--

/*!50001 DROP VIEW IF EXISTS `vw_log_global`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_log_global` AS select concat(convert(date_format(`log_global`.`last_update`,_utf8'%m-%d-%y %H:%i:%s') using latin1),_latin1'- ',`log_global`.`updater`) AS `last_updated`,`log_global`.`last_update` AS `last_update`,`log_global`.`table_update` AS `table_update`,`log_global`.`updater` AS `updater`,concat(`log_global`.`table_update`,_latin1'- ',`log_global`.`actions`,_latin1'- ',`log_global`.`table_id`) AS `tabledetails`,`log_global`.`col1` AS `col1`,`log_global`.`col2` AS `col2`,`log_global`.`col3` AS `col3`,`log_global`.`col4` AS `col4`,`log_global`.`col5` AS `col5`,`log_global`.`col6` AS `col6`,`log_global`.`idglb_log` AS `idglb_log` from `log_global` order by `log_global`.`last_update` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_look_addresses`
--

/*!50001 DROP VIEW IF EXISTS `vw_look_addresses`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_look_addresses` AS select `a`.`country_id` AS `country_id`,ifnull(`a`.`con_name`,'No Country') AS `con_name`,`b`.`state_id` AS `state_id`,ifnull(`b`.`state_name`,'No State') AS `state_name`,`b`.`state_full_name` AS `state_full_name`,`c`.`city_id` AS `city_id`,ifnull(`c`.`city_name`,'No City') AS `city_name`,ifnull(`d`.`postal_id`,'No Postal Id') AS `postal_id`,ifnull(`d`.`zip_code`,'No Zip Code') AS `zip_code`,`e`.`look_street_id` AS `look_street_id`,ifnull(`e`.`street_name`,'No Street Name') AS `street_name`,`f`.`look_street_no_id` AS `look_street_no_id`,ifnull(`f`.`look_street_no`,'No Street') AS `look_street_no`,ifnull(`e`.`street_type`,'No Street Type') AS `street_type`,ifnull(`g`.`feature_value`,'No Street Type') AS `street_type_name`,concat(ifnull(`e`.`street_name`,'No Street Name'),' ',ifnull(`g`.`feature_value`,'No Street Type')) AS `street_name_type`,concat(ifnull(`f`.`look_street_no`,'No Street '),' ',ifnull(`e`.`street_name`,'No Street, '),' ',ifnull(`g`.`feature_value`,'No Street Type'),', ',ifnull(`c`.`city_name`,'No City, '),', ',ifnull(`b`.`state_name`,'No State, '),' ',ifnull(`d`.`zip_code`,'No Zip Code, '),' ','(',ifnull(`a`.`con_name`,'No Country'),')') AS `addresses` from ((((((`look_country` `a` left join `look_state` `b` on((`a`.`country_id` = `b`.`country_id`))) left join `look_city` `c` on((`b`.`state_id` = `c`.`state_id`))) left join `look_postal` `d` on((`c`.`city_id` = `d`.`city_id`))) left join `look_street` `e` on((`d`.`postal_id` = `e`.`postal_id`))) left join `look_street_no` `f` on((`e`.`look_street_id` = `f`.`look_street_id`))) left join `feature_lk_val` `g` on((`e`.`street_type` = `g`.`idfeature_lk_val`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_look_bank_rec`
--

/*!50001 DROP VIEW IF EXISTS `vw_look_bank_rec`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_look_bank_rec` AS select `a`.`look_values_id` AS `value_id1`,`a`.`look_values` AS `value1`,`b`.`look_values_id` AS `value_id2`,`b`.`look_values` AS `value2`,`b`.`look_sub_value_id` AS `sub_value_id1`,`c`.`look_values_id` AS `value_id3`,`c`.`look_values` AS `value3`,`c`.`look_sub_value_id` AS `sub_value_id2` from (`look_values` `c` left join (`look_values` `b` left join `look_values` `a` on((`a`.`look_values_id` = `b`.`look_sub_value_id`))) on((`b`.`look_values_id` = `c`.`look_sub_value_id`))) where (`a`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'bank_record'))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_manage_emp`
--

/*!50001 DROP VIEW IF EXISTS `vw_manage_emp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_manage_emp` AS select `V`.`emp_id` AS `emp_id`,`V`.`firstname` AS `firstname`,`V`.`lastname` AS `lastname`,`V`.`ssn` AS `ssn`,`V`.`dob` AS `dob`,`V`.`gender` AS `gender`,`V`.`sdate` AS `sdate`,`V`.`edate` AS `edate`,`V`.`noOfDays` AS `noOfDays`,`A`.`feature_id` AS `feature_id`,`V`.`comp_id` AS `comp_id` from (`vw_employee` `V` left join `emp_access` `A` on((`A`.`emp_id` = `V`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_manage_employee`
--

/*!50001 DROP VIEW IF EXISTS `vw_manage_employee`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_manage_employee` AS select `E`.`emp_id` AS `emp_id`,`E`.`firstname` AS `firstname`,`E`.`lastname` AS `lastname`,`E`.`ssn` AS `ssn`,`E`.`dob` AS `dob`,`E`.`gender` AS `gender`,`EO`.`org_start_dt` AS `sdate`,`EO`.`org_end_dt` AS `edate`,(case when (isnull(`EO`.`org_end_dt`) or (`EO`.`org_end_dt` = _latin1'')) then (to_days(now()) - to_days(`EO`.`org_start_dt`)) else (to_days(`EO`.`org_end_dt`) - to_days(`EO`.`org_start_dt`)) end) AS `noOfDays`,`EO`.`comp_id` AS `comp_id` from (`emp` `E` join `emp_org` `EO` on((`E`.`emp_id` = `EO`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_mkt_assist`
--

/*!50001 DROP VIEW IF EXISTS `vw_mkt_assist`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_mkt_assist` AS select `a`.`idmkt_assist` AS `idmkt_assist`,`a`.`idmkt_open` AS `idmkt_open`,`a`.`assist_ref_table` AS `assist_ref_table`,(case when (`a`.`assist_ref_table` = 'Employee') then (case when (`a`.`assist_ref_id` <> 0) then concat_ws(_latin1' ',`e`.`firstname`,`e`.`lastname`) else 'Admin' end) when (`a`.`assist_ref_table` = 'Consultant') then concat(`c`.`prosp_first_name`,`c`.`prosp_last_name`) end) AS `Name`,`a`.`assist_ref_id` AS `assist_ref_id`,`d`.`mkt_value` AS `prosp_status`,`a`.`assist_status` AS `prosp_status_id`,date_format(`a`.`stat_st_dt`,'%m-%d-%y') AS `stat_st_dt`,date_format(`a`.`stat_st_dt`,'%Y') AS `mkt_year`,date_format(`a`.`stat_st_dt`,'%m') AS `mkt_month`,date_format(`a`.`stat_st_dt`,'%Y-%m-%d') AS `stat_st_dt2`,date_format(`a`.`stat_e_dt`,'%m-%d-%y') AS `stat_e_dt`,date_format(`a`.`stat_e_dt`,'%Y-%m-%d') AS `stat_e_dt2`,if((`a`.`stat_e_dt` <> '0000-00-00'),`a`.`no_days`,(to_days(curdate()) - to_days(`a`.`stat_st_dt`))) AS `no_days`,`b`.`compname` AS `compname`,`b`.`client_name` AS `client_name`,`a`.`assist_rate` AS `assist_rate`,`a`.`summary` AS `summary`,`b`.`location` AS `location`,`b`.`contact_info` AS `contact_info`,`b`.`open_details` AS `open_details`,`a`.`last_updated` AS `last_updated`,`a`.`updated_by` AS `updated_by`,concat(if(isnull(`a`.`updated_by`),'Admin',concat(`g`.`firstname`,' ',`g`.`lastname`))) AS `updator`,concat(convert(date_format(`a`.`last_updated`,'%m-%d-%y %H:%i:%s') using latin1),_latin1'<br>',if(isnull(`a`.`updated_by`),'Admin',concat(`f`.`firstname`,_latin1'<br>',`f`.`lastname`))) AS `mod_last_updated` from ((((((`mkt_assist` `a` left join `vw_mkt_open` `b` on((`a`.`idmkt_open` = `b`.`idmkt_open`))) left join `emp` `e` on((`e`.`emp_id` = `a`.`assist_ref_id`))) left join `prosp_consult` `c` on((`c`.`prosp_consult_id` = `a`.`assist_ref_id`))) left join `mkt_lk_val` `d` on((`d`.`idmkt_lk_val` = `a`.`assist_status`))) left join `emp` `g` on((`a`.`updated_by` = `g`.`emp_id`))) left join `emp` `f` on((`a`.`updated_by` = `f`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_mkt_assist_status`
--

/*!50001 DROP VIEW IF EXISTS `vw_mkt_assist_status`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_mkt_assist_status` AS select `a`.`idmkt_assist_status` AS `idmkt_assist_status`,`a`.`idmkt_assist` AS `idmkt_assist`,`a`.`assist_status` AS `assist_status`,date_format(`a`.`stat_st_dt`,_utf8'%m-%d-%y') AS `stat_st_dt`,(case when (`a`.`stat_e_dt` <> _utf8'0000-00-00') then date_format(`a`.`stat_e_dt`,_utf8'%m-%d-%y') else _utf8'' end) AS `stat_e_dt`,(case when (`a`.`stat_e_dt` <> _utf8'0000-00-00') then `a`.`no_days` else (to_days(curdate()) - to_days(`a`.`stat_st_dt`)) end) AS `no_days`,`a`.`last_updated` AS `last_updated`,`a`.`updated_by` AS `updated_by`,`b`.`mkt_value` AS `status`,concat(convert(date_format(`a`.`last_updated`,_utf8'%m-%d-%y %H:%i:%s') using latin1),_latin1'\n                                                                                ',if(isnull((`a`.`updated_by` = '0')),'Admin',concat(`f`.`firstname`,'',`f`.`lastname`))) AS `mod_last_updated` from ((`mkt_assist_status` `a` left join `mkt_lk_val` `b` on((`a`.`assist_status` = `b`.`idmkt_lk_val`))) left join `emp` `f` on((`a`.`updated_by` = `f`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_mkt_assist_status_steps`
--

/*!50001 DROP VIEW IF EXISTS `vw_mkt_assist_status_steps`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_mkt_assist_status_steps` AS select `a`.`idmkt_assist_status_steps` AS `idmkt_assist_status_steps`,`a`.`idmkt_assist` AS `idmkt_assist`,`a`.`idmkt_assist_status` AS `idmkt_assist_status`,`b`.`assist_status` AS `assist_status_id`,`c`.`mkt_value` AS `status`,`a`.`mkt_steps_detail` AS `mkt_steps_details`,`a`.`last_updated` AS `last_updated`,`a`.`updater` AS `updated_by`,concat(convert(date_format(`a`.`last_updated`,_utf8'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',ifnull(concat(`f`.`firstname`,'',`f`.`lastname`),'Admin')) AS `mod_last_updated` from (((`mkt_assist_status_steps` `a` left join `mkt_assist_status` `b` on((`a`.`idmkt_assist_status` = `b`.`idmkt_assist_status`))) left join `mkt_lk_val` `c` on((`b`.`assist_status` = `c`.`idmkt_lk_val`))) left join `emp` `f` on((`a`.`updater` = `f`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_mkt_company`
--

/*!50001 DROP VIEW IF EXISTS `vw_mkt_company`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_mkt_company` AS select `mkt_company`.`idmkt_company` AS `idmkt_company`,`mkt_company`.`companyname` AS `companyname`,`mkt_company`.`company_info` AS `company_info`,`mkt_company`.`comp_website` AS `comp_website`,`mkt_company`.`comp_phone` AS `comp_phone`,`mkt_company`.`req_type` AS `req_type`,`l`.`mkt_value` AS `req_type_name`,`mkt_company`.`track` AS `track`,`mkt_company`.`block` AS `block`,`g`.`mkt_value` AS `block_name`,`f`.`mkt_value` AS `track_name`,date_format(`mkt_company`.`block_dt`,'%m-%d-%y') AS `block_dt`,`mkt_company`.`block_dt` AS `sort_block_dt`,date_format(`mkt_company`.`block_dt`,'%m-%Y') AS `block_dt_new`,`mkt_company`.`acc_mgr` AS `acc_mgr`,(case when isnull(`mkt_company`.`acc_mgr`) then 'Admin' else concat(`ff`.`firstname`,_latin1'',`ff`.`lastname`) end) AS `acc_mgr_name`,`mkt_company`.`comp_email` AS `comp_email`,`mkt_company`.`updated_by` AS `updated_by`,date_format(`mkt_company`.`last_updated`,'%m-%d-%y') AS `mod_last_updated`,date_format(`mkt_company`.`last_updated`,'%m') AS `mkt_month`,date_format(`mkt_company`.`last_updated`,'%Y') AS `mkt_year`,concat(convert(date_format(`mkt_company`.`last_updated`,'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',if(isnull(`mkt_company`.`updated_by`),'Admin',concat(`e`.`firstname`,'',`e`.`lastname`))) AS `last_updated` from (((((`mkt_company` left join `emp` `e` on((`mkt_company`.`updated_by` = `e`.`emp_id`))) left join `emp` `ff` on((`mkt_company`.`acc_mgr` = `ff`.`emp_id`))) left join `mkt_lk_val` `l` on((`mkt_company`.`req_type` = `l`.`idmkt_lk_val`))) left join `mkt_lk_val` `f` on((`mkt_company`.`track` = `f`.`idmkt_lk_val`))) left join `mkt_lk_val` `g` on((`mkt_company`.`block` = `g`.`idmkt_lk_val`))) order by `mkt_company`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_mkt_lk_wrk_flow`
--

/*!50001 DROP VIEW IF EXISTS `vw_mkt_lk_wrk_flow`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_mkt_lk_wrk_flow` AS select `a`.`idmkt_wrk_flow` AS `idmkt_wrk_flow`,`a`.`id_wrk_flow` AS `id_wrk_flow`,`a`.`id_wrk_flow_parent` AS `id_wrk_flow_parent`,ifnull(concat(`c`.`firstname`,' ',`c`.`lastname`),'Admin') AS `updater`,`a`.`last_updated` AS `last_updated`,`b`.`mkt_value` AS `mkt_value` from ((`mkt_lk_wrk_flow` `a` left join `mkt_lk_val` `b` on((`a`.`id_wrk_flow` = `b`.`idmkt_lk_val`))) left join `emp` `c` on((`a`.`updater` = `c`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_mkt_open`
--

/*!50001 DROP VIEW IF EXISTS `vw_mkt_open`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_mkt_open` AS select `a`.`idmkt_open` AS `idmkt_open`,`b`.`companyname` AS `compname`,`c`.`companyname` AS `client_name`,`a`.`req_source` AS `req_source`,`u`.`mkt_value` AS `req_source_nm`,concat(`d`.`city_name`,_latin1',',`e`.`state_name`) AS `location`,`e`.`state_id` AS `state_id`,`e`.`state_name` AS `state_name`,`d`.`city_id` AS `city_id`,`d`.`city_name` AS `city_name`,`a`.`contact_info` AS `contact_info`,`a`.`req_type` AS `req_type`,`l`.`mkt_value` AS `req_type_name`,`a`.`track` AS `track`,`t`.`mkt_value` AS `track_name`,concat(`f`.`firstname`,_latin1' ',`f`.`lastname`) AS `acc_mgr`,(case when (`a`.`close_dt` <> '0000-00-00') then (to_days(`a`.`close_dt`) - to_days(`a`.`open_dt`)) else (to_days(curdate()) - to_days(`a`.`open_dt`)) end) AS `no_days`,`a`.`open_details` AS `open_details`,date_format(`a`.`open_dt`,'%m-%d-%y') AS `open_dt`,`a`.`open_dt` AS `open_dt1`,date_format(`a`.`close_dt`,'%m-%d-%y') AS `close_dt`,`a`.`close_dt` AS `close_dt1`,(case when ((isnull(`a`.`close_dt`) or (`a`.`close_dt` = '00-00-00')) and (`a`.`open_dt` is not null)) then 'Open' when ((`a`.`open_dt` is not null) and (`a`.`close_dt` is not null)) then 'Close' else NULL end) AS `Pstate`,`a`.`last_updated` AS `last_updated`,`a`.`updated_by` AS `updated_by`,concat(convert(date_format(`a`.`last_updated`,'%m-%d-%y %H:%i:%s') using latin1),_latin1' ',if(isnull(`a`.`updated_by`),'Admin',concat(`g`.`firstname`,_latin1'',`g`.`lastname`))) AS `mod_last_updated`,`a`.`summary` AS `summary`,year(`a`.`open_dt`) AS `open_dt_y`,year(`a`.`close_dt`) AS `close_dt_y` from (((((((((`mkt_open` `a` left join `mkt_company` `b` on((`a`.`compname` = `b`.`idmkt_company`))) left join `mkt_company` `c` on((`a`.`client_name` = `c`.`idmkt_company`))) left join `look_city` `d` on((`a`.`location` = `d`.`city_id`))) left join `look_state` `e` on((`d`.`state_id` = `e`.`state_id`))) left join `emp` `f` on((`a`.`acc_mgr` = `f`.`emp_id`))) left join `mkt_lk_val` `l` on((`a`.`req_type` = `l`.`idmkt_lk_val`))) left join `emp` `g` on((`a`.`updated_by` = `g`.`emp_id`))) left join `mkt_lk_val` `t` on((`a`.`track` = `t`.`idmkt_lk_val`))) left join `mkt_lk_val` `u` on((`a`.`req_source` = `u`.`idmkt_lk_val`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_mod_hoursx`
--

/*!50001 DROP VIEW IF EXISTS `vw_mod_hoursx`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_mod_hoursx` AS select `hours`.`emp_id` AS `emp_id`,`hours`.`comp_id` AS `comp_id`,year(`hours`.`hoursdate`) AS `yr_hours`,monthname(`hours`.`hoursdate`) AS `mon_name`,sum(`hours`.`totaltime`) AS `mon_hrs`,sum(if(isnull(`hours`.`timecard_id`),`hours`.`totaltime`,0)) AS `WithoutTimeSheet`,sum(if(isnull(`hours`.`inv_num`),`hours`.`totaltime`,0)) AS `UnInvoice_hours`,sum(if(isnull(`hours`.`approve_by`),`hours`.`totaltime`,0)) AS `Unaproved_hours`,sum(if((`hours`.`hrs_type` = _latin1'B'),`hours`.`totaltime`,0)) AS `billable_hrs`,sum(if((`hours`.`hrs_type` = _latin1'N'),`hours`.`totaltime`,0)) AS `non_billable_hrs` from `hours` group by `hours`.`emp_id`,`hours`.`comp_id`,monthname(`hours`.`hoursdate`),year(`hours`.`hoursdate`) having (sum(`hours`.`totaltime`) > 0) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_mon_emp`
--

/*!50001 DROP VIEW IF EXISTS `vw_mon_emp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_mon_emp` AS select (case when isnull(`vw_mon_emp_sub`.`st_year`) then `vw_mon_emp_sub`.`ed_year` else `vw_mon_emp_sub`.`st_year` end) AS `year`,(case when isnull(`vw_mon_emp_sub`.`st_month`) then `vw_mon_emp_sub`.`ed_month` else `vw_mon_emp_sub`.`st_month` end) AS `month`,(case when isnull(`vw_mon_emp_sub`.`started`) then 0 else `vw_mon_emp_sub`.`started` end) AS `started`,(case when isnull(`vw_mon_emp_sub`.`ended`) then 0 else `vw_mon_emp_sub`.`ended` end) AS `ended` from `vw_mon_emp_sub` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_mon_emp_sub`
--

/*!50001 DROP VIEW IF EXISTS `vw_mon_emp_sub`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_mon_emp_sub` AS select `sd`.`year` AS `st_year`,`sd`.`month` AS `st_month`,`sd`.`cnt` AS `started`,`ed`.`year` AS `ed_year`,`ed`.`month` AS `ed_month`,`ed`.`cnt` AS `ended` from (`vw_empstart` `sd` left join `vw_empend` `ed` on(((`sd`.`year` = `ed`.`year`) and (`sd`.`month` = `ed`.`month`)))) union select `sd`.`year` AS `year`,`sd`.`month` AS `month`,`sd`.`cnt` AS `cnt`,`ed`.`year` AS `year`,`ed`.`month` AS `month`,`ed`.`cnt` AS `cnt` from (`vw_empend` `ed` left join `vw_empstart` `sd` on(((`sd`.`year` = `ed`.`year`) and (`sd`.`month` = `ed`.`month`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_net_ser`
--

/*!50001 DROP VIEW IF EXISTS `vw_net_ser`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_net_ser` AS select `a`.`idnet_ser` AS `idnet_ser`,`a`.`hostnm` AS `hostnm`,`a`.`dep_usr` AS `dep_usr`,`a`.`host_conf` AS `host_conf`,`a`.`hosted` AS `hosted`,`a`.`hostdm` AS `hostdm`,`a`.`host_type` AS `host_type`,`a`.`host_mst` AS `host_mst`,`a`.`ip_lan` AS `ip_lan`,`a`.`ip_wan` AS `ip_wan`,`a`.`ip_usr` AS `ip_usr`,`a`.`gateway` AS `gateway`,`a`.`updater` AS `updater`,`a`.`updated_on` AS `updated_on`,`b`.`hostnm` AS `mst_hostnm`,`b`.`hostdm` AS `mst_hostdm`,`b`.`ip_lan` AS `mst_ip_lan`,`b`.`ip_wan` AS `mst_ip_wan` from (`net_ser` `a` left join `net_ser` `b` on((`a`.`host_mst` = `b`.`hostnm`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_net_ser_clone`
--

/*!50001 DROP VIEW IF EXISTS `vw_net_ser_clone`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_net_ser_clone` AS select `a`.`idnet_clone` AS `idnet_clone`,`a`.`idnet_ser` AS `idnet_ser`,`b`.`hostnm` AS `hostnm`,`b`.`hostdm` AS `hostdm`,`b`.`host_mst` AS `host_mst`,`b`.`ip_lan` AS `ip_lan`,`b`.`ip_wan` AS `ip_wan`,`b`.`ip_usr` AS `ip_usr`,`b`.`gateway` AS `gateway`,`a`.`mst_app` AS `mst_app`,`a`.`cloned_app` AS `cloned_app`,`a`.`code_bk` AS `code_bk`,`a`.`db_bk` AS `db_bk`,`a`.`valid_days` AS `valid_days`,`a`.`validity` AS `validity`,`a`.`alert_days` AS `alert_days`,`a`.`app_url` AS `app_url`,`a`.`deleted_on` AS `deleted_on`,`a`.`updater` AS `updater`,`a`.`updated_on` AS `updated_on` from (`net_ser_clone` `a` left join `net_ser` `b` on((`a`.`idnet_ser` = `b`.`idnet_ser`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_newengage`
--

/*!50001 DROP VIEW IF EXISTS `vw_newengage`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_newengage` AS select `a`.`engage_id` AS `engage_id`,`a`.`srv_st_dt` AS `srv_st_dt`,`a`.`srv_e_dt` AS `srv_e_dt`,`a`.`sr_frequency` AS `sr_frequency`,`a`.`srv_paytype` AS `srv_paytype`,`a`.`eg_sumry` AS `eg_sumry`,`a`.`srv_client` AS `srv_client`,`b`.`comp_id` AS `comp_id`,`c`.`companyname` AS `companyname` from ((`engage` `a` left join `engage_comp` `b` on(((`a`.`engage_id` = `b`.`engage_id`) and (`a`.`srv_client` <> `b`.`comp_id`)))) left join `company` `c` on((`c`.`comp_id` = `b`.`comp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_po_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_po_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_po_attach` AS select `a`.`idengage_entity_po_doc` AS `idengage_entity_po_doc`,`a`.`doc_type` AS `doc_type`,`d`.`look_values` AS `doc_look_values`,`a`.`expire_dt` AS `expire_dt`,date_format(`a`.`expire_dt`,_utf8'%m-%d-%y') AS `mod_expire_dt`,`b`.`idengage_entity_po` AS `idengage_entity_po`,`a`.`idstorage` AS `idstorage`,`c`.`owner_id` AS `owner_id`,`c`.`file_name` AS `file_name`,`c`.`public` AS `public`,`c`.`self_view` AS `self_view`,`c`.`shared` AS `shared`,`c`.`emp_id` AS `emp_id`,`c`.`updated_for_ref_id` AS `updated_for_ref_id`,`c`.`updated_for_ref_table` AS `updated_for_ref_table` from (((`engage_entity_po_doc` `a` left join `storages` `c` on((`a`.`idstorage` = `c`.`idstorage`))) left join `engage_entity_po` `b` on((`a`.`idengage_entity_po` = `b`.`idengage_entity_po`))) left join `look_values` `d` on((`a`.`doc_type` = `d`.`look_values_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_activity`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_activity`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_activity` AS select (case when (`pa`.`emp_id` <> 0) then concat_ws(_latin1' ',`e`.`firstname`,`e`.`lastname`) else 'Admin' end) AS `name`,`pa`.`prosp_activity_id` AS `prosp_activity_id`,`pa`.`prosp_consult_id` AS `prosp_consult_id`,`pa`.`call_recv_dt` AS `call_recv_dt`,`pa`.`emp_id` AS `emp_id`,`pa`.`next_call_dt` AS `next_call_dt`,`pa`.`call_note` AS `call_note`,`pa`.`last_update` AS `last_update` from (`prosp_activity` `pa` left join `emp` `e` on((`e`.`emp_id` = `pa`.`emp_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_consult`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_consult`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_consult` AS select `a`.`prosp_consult_id` AS `prosp_consult_id`,`a`.`prosp_first_name` AS `prosp_first_name`,`a`.`prosp_last_name` AS `prosp_last_name`,concat(`a`.`prosp_first_name`,' ',`a`.`prosp_last_name`) AS `prosp_fullname`,`a`.`prosp_level` AS `prosp_level_id`,ifnull(`pl`.`prosp_value`,'None') AS `prosp_level`,`a`.`prosp_summary` AS `prosp_summary`,ifnull(`a`.`dob`,'NO DOB') AS `dob`,ifnull(`a`.`ssn`,'NO SSN') AS `ssn`,ifnull(`a`.`taxid`,'NO TAXID') AS `taxid`,`a`.`gender` AS `gender_id`,ifnull(`g`.`emp_value`,'None') AS `gender`,`a`.`emp` AS `updater_id`,ifnull(`u`.`fullname`,'Admin') AS `updater`,`a`.`emp_assigned_id` AS `emp_assigned_id`,`a`.`call_recv_dt` AS `call_recv_dt_unformatted`,date_format(`a`.`call_recv_dt`,'%m-%d-%y %h:%i %p') AS `call_recv_dt`,`a`.`next_call_dt` AS `next_call_dt_unformatted`,date_format(`a`.`next_call_dt`,'%m-%d-%y %h:%i %p') AS `next_call_dt`,`a`.`call_note` AS `call_note`,`a`.`last_updated` AS `last_updated_unformatted`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated`,`a`.`attachment` AS `attachment`,`a`.`del_dt` AS `del_dt_unformatted`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,`a`.`del_by` AS `del_by_id`,ifnull(`e_del_by`.`fullname`,'Admin') AS `del_by`,`e_del_by`.`emp_file_name` AS `del_by_file_name`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt_unformatted`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt`,`a`.`archv_by` AS `archv_by_id`,ifnull(`e_archv_by`.`fullname`,'Admin') AS `archv_by`,`e_archv_by`.`emp_file_name` AS `archv_by_file_name` from (((((`prosp_consult` `a` left join `emp_lk_val` `g` on((`a`.`gender` = `g`.`idemp_lk_value`))) left join `prosp_lk_val` `pl` on((`a`.`prosp_level` = `pl`.`idprosp_lk_val`))) left join `vw_emp` `u` on((`a`.`emp` = `u`.`emp_id`))) left join `vw_emp` `e_del_by` on((`a`.`del_by` = `e_del_by`.`emp_id`))) left join `vw_emp` `e_archv_by` on((`a`.`archv_by` = `e_archv_by`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_consult_activity`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_consult_activity`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_consult_activity` AS select `a`.`prosp_consult_id` AS `prosp_consult_id`,`a`.`prosp_first_name` AS `prosp_first_name`,`a`.`prosp_last_name` AS `prosp_last_name`,`a`.`prosp_level` AS `prosp_level`,`a`.`prosp_summary` AS `prosp_summary`,`b`.`prosp_activity_id` AS `prosp_activity_id`,`b`.`call_recv_dt` AS `call_recv_dt`,`b`.`emp_id` AS `emp_id`,`b`.`next_call_dt` AS `next_call_dt`,`b`.`call_note` AS `call_note`,`b`.`last_update` AS `last_update` from (`prosp_consult` `a` left join `prosp_activity` `b` on((`a`.`prosp_consult_id` = `b`.`prosp_consult_id`))) group by `a`.`prosp_consult_id` order by `a`.`prosp_consult_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_corp`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_corp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_corp` AS select `a`.`idprosp_corp` AS `idprosp_corp`,`a`.`prosp_corp_type` AS `prosp_corp_type`,ifnull(`d`.`prosp_value`,'No Val') AS `prosp_corp_type_name`,`a`.`corp_entity_name` AS `corp_entity_name`,`a`.`corp_source` AS `corp_source`,`e`.`prosp_value` AS `corp_source_nm`,`a`.`corp_level` AS `corp_level`,`g`.`prosp_value` AS `corp_level_nm`,`a`.`response` AS `response`,`r`.`prosp_value` AS `response_nm`,`a`.`corp_contacts` AS `corp_contacts`,`a`.`corp_address` AS `corp_address`,ifnull(`a`.`register_yr`,'No Val') AS `register_yr`,ifnull(`a`.`register_state`,'None') AS `register_state`,`a`.`start_dt` AS `start_dt`,date_format(`a`.`start_dt`,'%m-%d-%y') AS `start_dt_formatted`,`a`.`end_dt` AS `end_dt`,date_format(`a`.`end_dt`,'%m-%d-%y') AS `end_dt_formatted`,(case when isnull(`a`.`end_dt`) then round(((unix_timestamp(now()) - unix_timestamp(`a`.`start_dt`)) / 86400),0) else round(((unix_timestamp(`a`.`end_dt`) - unix_timestamp(`a`.`start_dt`)) / 86400),0) end) AS `lead_time`,if(isnull(`a`.`end_dt`),concat(round(((unix_timestamp(now()) - unix_timestamp(`a`.`start_dt`)) / 86400),0),_utf8':',round((round(((unix_timestamp(now()) - unix_timestamp(`a`.`start_dt`)) % 86400),0) / 3600),0)),concat(floor((`a`.`st_end_tm` / 3600)),_utf8':',round((`a`.`st_end_tm` % 3600),0))) AS `pseudo_leads_time`,`a`.`acc_mgr` AS `acc_mgr`,ifnull(concat(`f`.`firstname`,' ',`f`.`lastname`),'Admin') AS `acc_mgr_name`,`f_by`.`file_name` AS `acc_mgr_file_name`,`a`.`topic_discussed` AS `topic_discussed`,`a`.`topic_count` AS `topic_count`,`a`.`about_corp` AS `about_corp`,`a`.`access_name` AS `access_name`,`a`.`tentative_en_dt` AS `tentative_en_dt`,date_format(`a`.`tentative_en_dt`,'%m-%d-%y') AS `tentative_en_dt_formatted`,`a`.`remind` AS `remind`,`a`.`vm_count` AS `vm_count`,`a`.`last_updated` AS `last_updated`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated_formatted`,`a`.`updated_by` AS `updated_by`,ifnull(concat(`u`.`firstname`,' ',`u`.`lastname`),'Admin') AS `updated_by_nm`,`u_by`.`file_name` AS `updater_file_name`,`a`.`del_dt` AS `del_dt`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt_formatted`,`a`.`del_by` AS `del_by_id`,ifnull(concat(`e_del_by`.`firstname`,' ',`e_del_by`.`lastname`),'Admin') AS `del_by`,`o_del_by`.`file_name` AS `del_by_file_name`,`a`.`del_day` AS `del_day`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt_formatted`,`a`.`archv_by` AS `archv_by_id`,ifnull(concat(`e_arch_by`.`firstname`,' ',`e_arch_by`.`lastname`),'Admin') AS `arch_by`,`o_arch_by`.`file_name` AS `arch_by_file_name` from ((((((((((((`prosp_corp` `a` left join `prosp_lk_val` `d` on((`a`.`prosp_corp_type` = `d`.`idprosp_lk_val`))) left join `prosp_lk_val` `e` on((`a`.`corp_source` = `e`.`idprosp_lk_val`))) left join `emp` `f` on((`a`.`acc_mgr` = `f`.`emp_id`))) left join `prosp_lk_val` `g` on((`a`.`corp_level` = `g`.`idprosp_lk_val`))) left join `storages` `f_by` on((`f`.`idstorage` = `f_by`.`idstorage`))) left join `prosp_lk_val` `r` on((`a`.`response` = `r`.`idprosp_lk_val`))) left join `emp` `u` on((`u`.`emp_id` = `a`.`updated_by`))) left join `storages` `u_by` on((`u`.`idstorage` = `u_by`.`idstorage`))) left join `emp` `e_del_by` on((`a`.`del_dt` = `e_del_by`.`emp_id`))) left join `emp` `e_arch_by` on((`a`.`archv_by` = `e_arch_by`.`emp_id`))) left join `storages` `o_del_by` on((`e_del_by`.`idstorage` = `o_del_by`.`idstorage`))) left join `storages` `o_arch_by` on((`e_arch_by`.`idstorage` = `o_arch_by`.`idstorage`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_corp_activity`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_corp_activity`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_corp_activity` AS select `a`.`idprosp_corp_activity` AS `idprosp_corp_activity`,`a`.`idprosp_corp` AS `idprosp_corp`,`a`.`topic_disussed` AS `topic_disussed`,`a`.`corp_level` AS `corp_level`,`g`.`prosp_value` AS `corp_level_nm`,`a`.`response` AS `response`,`r`.`prosp_value` AS `response_nm`,`a`.`start_dt` AS `start_dt`,date_format(`a`.`start_dt`,'%m-%d-%y') AS `start_dt_formatted`,`a`.`acc_mgr` AS `acc_mgr`,ifnull(`f`.`fullname`,'Admin') AS `acc_mgr_name`,`a`.`end_dt` AS `end_dt`,date_format(`a`.`end_dt`,'%m-%d-%y') AS `end_dt_formatted`,`a`.`updated_by` AS `updated_by`,ifnull(`b`.`fullname`,'Admin') AS `updater`,`b`.`emp_file_name` AS `updater_file_name`,`a`.`last_updated` AS `last_updated`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated_formatted`,`a`.`del_dt` AS `del_dt`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt_formatted`,`a`.`del_by` AS `del_by_id`,ifnull(`e_del_by`.`fullname`,'Admin') AS `del_by`,`e_del_by`.`emp_file_name` AS `del_by_file_name`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt_formatted`,`a`.`archv_by` AS `archv_by_id`,ifnull(`e_archv_by`.`fullname`,'Admin') AS `archv_by`,`e_archv_by`.`emp_file_name` AS `archv_by_file_name` from ((((((`prosp_corp_activity` `a` left join `vw_emp` `b` on((`b`.`emp_id` = `a`.`updated_by`))) left join `prosp_lk_val` `r` on((`a`.`response` = `r`.`idprosp_lk_val`))) left join `prosp_lk_val` `g` on((`a`.`corp_level` = `g`.`idprosp_lk_val`))) left join `vw_emp` `f` on((`a`.`acc_mgr` = `f`.`emp_id`))) left join `vw_emp` `e_del_by` on((`a`.`del_by` = `e_del_by`.`emp_id`))) left join `vw_emp` `e_archv_by` on((`a`.`archv_by` = `e_archv_by`.`emp_id`))) order by `a`.`idprosp_corp` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_corp_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_corp_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_corp_attach` AS select `a`.`idprosp_corp_attach` AS `idprosp_corp_attach`,`a`.`idprosp_corp` AS `idprosp_corp`,`a`.`idstorage` AS `idstorage`,`c`.`owner_id` AS `owner_id`,`c`.`owner_name` AS `owner_name`,`c`.`file_name` AS `file_name`,`c`.`public` AS `public`,`c`.`self_view` AS `self_view`,`c`.`shared` AS `shared`,`c`.`emp_id` AS `emp_id`,`c`.`emp_name` AS `emp_name`,`a`.`updater` AS `updater`,ifnull(`b`.`fullname`,'Admin') AS `updated_by`,`b`.`emp_file_name` AS `updater_file_name`,`a`.`last_updated` AS `last_updated`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated_formatted` from ((`prosp_corp_attach` `a` left join `vw_emp` `b` on((`b`.`emp_id` = `a`.`updater`))) left join `vw_storages` `c` on((`a`.`idstorage` = `c`.`idstorage`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_corp_inc`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_corp_inc`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_corp_inc` AS select `a`.`idprosp_corp_inc` AS `idprosp_corp_inc`,`a`.`idprosp_lk_val` AS `idprosp_lk_val`,`c`.`prosp_value` AS `prosp_value`,`a`.`emp_id` AS `emp_id`,ifnull(concat(`b`.`firstname`,' ',`b`.`lastname`),'Admin') AS `emp_name`,`b_by`.`file_name` AS `emp_file_name`,`a`.`inc_frm` AS `inc_frm`,date_format(`a`.`inc_frm`,'%m-%d-%y %h:%i %p') AS `inc_frm_formatted`,`a`.`inc_to` AS `inc_to`,date_format(`a`.`inc_to`,'%m-%d-%y %h:%i %p') AS `inc_to_formatted`,`a`.`inc_amt` AS `inc_amt`,`a`.`approver_id` AS `approver_id`,ifnull(concat(`d`.`firstname`,' ',`d`.`lastname`),'Admin') AS `approver_name`,`d_by`.`file_name` AS `approver_file_name`,`a`.`last_updated` AS `last_updated_unformatted`,date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p') AS `last_updated`,`a`.`updater` AS `updater`,ifnull(concat(`e`.`firstname`,' ',`e`.`lastname`),'Admin') AS `updater_nm`,`u_by`.`file_name` AS `updater_file_name`,`a`.`del_dt` AS `del_dt`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt_formatted`,`a`.`del_by` AS `del_by_id`,ifnull(concat(`e_del_by`.`firstname`,' ',`e_del_by`.`lastname`),'Admin') AS `del_by`,`o_del_by`.`file_name` AS `del_by_file_name`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt_formatted`,`a`.`archv_by` AS `archv_by_id`,ifnull(concat(`e_arch_by`.`firstname`,' ',`e_arch_by`.`lastname`),'Admin') AS `arch_by`,`o_arch_by`.`file_name` AS `arch_by_file_name` from (((((((((((`prosp_corp_inc` `a` left join `emp` `b` on((`b`.`emp_id` = `a`.`emp_id`))) left join `storages` `b_by` on((`b`.`idstorage` = `b_by`.`idstorage`))) left join `prosp_lk_val` `c` on((`a`.`idprosp_lk_val` = `c`.`idprosp_lk_val`))) left join `emp` `d` on((`d`.`emp_id` = `a`.`approver_id`))) left join `storages` `d_by` on((`d`.`idstorage` = `d_by`.`idstorage`))) left join `emp` `e` on((`e`.`emp_id` = `a`.`updater`))) left join `storages` `u_by` on((`e`.`idstorage` = `u_by`.`idstorage`))) left join `emp` `e_del_by` on((`a`.`del_dt` = `e_del_by`.`emp_id`))) left join `emp` `e_arch_by` on((`a`.`archv_by` = `e_arch_by`.`emp_id`))) left join `storages` `o_del_by` on((`e_del_by`.`idstorage` = `o_del_by`.`idstorage`))) left join `storages` `o_arch_by` on((`e_arch_by`.`idstorage` = `o_arch_by`.`idstorage`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_extra_tags`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_extra_tags`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_extra_tags` AS select `prosp_tag`.`prosp_tag_id` AS `prosp_tag_id`,`prosp_tag`.`prosp_consult_id` AS `prosp_consult_id`,`prosp_tag`.`prosp_tags` AS `prosp_tags` from `prosp_tag` where (not(`prosp_tag`.`prosp_consult_id` in (select `prosp_consult`.`prosp_consult_id` AS `prosp_consult_id` from `prosp_consult`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_extra_values_in_tags`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_extra_values_in_tags`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_extra_values_in_tags` AS select `prosp_tag`.`prosp_tag_id` AS `prosp_tag_id`,`prosp_tag`.`prosp_consult_id` AS `prosp_consult_id`,`prosp_tag`.`prosp_tags` AS `prosp_tags` from `prosp_tag` where (not(`prosp_tag`.`prosp_tags` in (select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where (`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section')))))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_initiate`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_initiate`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_initiate` AS select `b`.`idprosp_refund1` AS `idprosp_refund1`,`b`.`ref_for_id` AS `payee_id`,`b`.`ref_for_table` AS `payee_from`,(case when (`b`.`ref_for_table` = _latin1'consult') then concat(`e`.`prosp_first_name`,_latin1' ',`e`.`prosp_last_name`) else concat(`d`.`firstname`,_latin1' ',`d`.`lastname`) end) AS `payee`,`b`.`total_paid` AS `total_paid`,`b`.`total_refund` AS `total_refund`,`b`.`cleared` AS `cleared`,`a`.`idprosp_refund2` AS `idprosp_refund2`,`a`.`paid_amt` AS `paid_amt`,`a`.`refund_amt` AS `refund_amt`,`a`.`pay_for` AS `purpose`,`a`.`pay_dt` AS `pay_dt`,`a`.`pay_smry` AS `pay_smry`,`a`.`selection` AS `selection`,`c`.`idprosp_refund_details` AS `refund_details`,`c`.`refund_type` AS `refund_type`,`c`.`refund_amt` AS `refund_phases`,`c`.`ref_for_id` AS `ref_for_id`,`c`.`ref_for_table` AS `ref_for_table`,(case when (`c`.`ref_for_table` = _latin1'consult') then concat(`e`.`prosp_first_name`,_latin1' ',`e`.`prosp_last_name`) else concat(`d`.`firstname`,_latin1' ',`d`.`lastname`) end) AS `refunded_to`,`c`.`refund_dt` AS `refund_dt`,`c`.`refund_smry` AS `refund_smry`,`c`.`display` AS `display` from ((((`prosp_refund2` `a` left join `prosp_refund1` `b` on((`a`.`idprosp_refund1` = `b`.`idprosp_refund1`))) left join `prosp_refund_detail` `c` on((`a`.`idprosp_refund2` = `c`.`idprosp_refund2`))) left join `emp` `d` on((`b`.`ref_for_id` = `d`.`emp_id`))) left join `prosp_consult` `e` on((`b`.`ref_for_id` = `e`.`prosp_consult_id`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_lk_val`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_lk_val`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_lk_val` AS select `a`.`idprosp_lk_val` AS `idprosp_lk_val`,`a`.`idprosp_lk` AS `idprosp_lk`,`b`.`prosp_name` AS `prosp_name`,`a`.`prosp_value` AS `prosp_value`,`a`.`disp_order` AS `disp_order`,`a`.`updater` AS `updater`,ifnull(`u`.`fullname`,'Admin') AS `updater_nm`,`u`.`emp_file_name` AS `updater_file_name`,`a`.`last_updated` AS `last_updated`,ifnull(date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p'),'Never') AS `last_updated_formatted`,`a`.`del_dt` AS `del_dt`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt_formatted`,`a`.`del_by` AS `del_by_id`,ifnull(`e_del_by`.`fullname`,'Admin') AS `del_by`,`e_del_by`.`emp_file_name` AS `del_by_file_name`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt_formatted`,`a`.`archv_by` AS `archv_by_id`,ifnull(`e_archv_by`.`fullname`,'Admin') AS `archv_by`,`e_archv_by`.`emp_file_name` AS `archv_by_file_name` from ((((`prosp_lk_val` `a` left join `prosp_lk` `b` on((`a`.`idprosp_lk` = `b`.`idprosp_lk`))) left join `vw_emp` `u` on((`a`.`updater` = `u`.`emp_id`))) left join `vw_emp` `e_del_by` on((`a`.`del_by` = `e_del_by`.`emp_id`))) left join `vw_emp` `e_archv_by` on((`a`.`archv_by` = `e_archv_by`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_multi_date`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_multi_date`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_multi_date` AS select `prosp_activity`.`prosp_activity_id` AS `prosp_activity_id`,`prosp_activity`.`prosp_consult_id` AS `prosp_consult_id`,`prosp_activity`.`last_update` AS `last_update`,count(`prosp_activity`.`last_update`) AS `cnt` from `prosp_activity` group by `prosp_activity`.`last_update`,`prosp_activity`.`prosp_consult_id` having (`cnt` > 1) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_tag_extra_1`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_tag_extra_1`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_tag_extra_1` AS select `prosp_tag`.`prosp_tag_id` AS `prosp_tag_id`,`prosp_tag`.`prosp_consult_id` AS `prosp_consult_id`,`prosp_tag`.`prosp_tags` AS `prosp_tags` from `prosp_tag` where (not(`prosp_tag`.`prosp_consult_id` in (select `prosp_consult`.`prosp_consult_id` AS `prosp_consult_id` from `prosp_consult`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_tag_extra_2`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_tag_extra_2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_tag_extra_2` AS select `prosp_tag`.`prosp_tag_id` AS `prosp_tag_id`,`prosp_tag`.`prosp_consult_id` AS `prosp_consult_id`,`prosp_tag`.`prosp_tags` AS `prosp_tags` from `prosp_tag` where (not(`prosp_tag`.`prosp_tags` in (select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where (`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section')))))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_prosp_tag_extra_3`
--

/*!50001 DROP VIEW IF EXISTS `vw_prosp_tag_extra_3`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_prosp_tag_extra_3` AS select `prosp_tag`.`prosp_tag_id` AS `prosp_tag_id`,`prosp_tag`.`prosp_consult_id` AS `prosp_consult_id`,`prosp_tag`.`prosp_tags` AS `prosp_tags` from `prosp_tag` where (not(`prosp_tag`.`prosp_consult_id` in (select `prosp_consult`.`prosp_consult_id` AS `prosp_consult_id` from `prosp_consult`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_rpt_all_data_process_2`
--

/*!50001 DROP VIEW IF EXISTS `vw_rpt_all_data_process_2`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_rpt_all_data_process_2` AS select `vw_dev_est_reqs_status`.`iddev_est_reqs` AS `iddev_est_reqs`,count(0) AS `status_count`,group_concat(ifnull(`vw_dev_est_reqs_status`.`status`,_latin1' ') order by `vw_dev_est_reqs_status`.`iddev_est_reqs_status` ASC separator '-->') AS `status_list`,substring_index(substring_index(group_concat(`vw_dev_est_reqs_status`.`assigned_to` separator ','),_latin1',',1),_latin1',',-(1)) AS `req_developer`,if(((length(group_concat(`vw_dev_est_reqs_status`.`assigned_to` separator ',')) - length(replace(group_concat(`vw_dev_est_reqs_status`.`assigned_to` separator ','),_latin1',',_latin1''))) >= 1),substring_index(substring_index(group_concat(`vw_dev_est_reqs_status`.`assigned_to` separator ','),_latin1',',2),_latin1',',-(1)),NULL) AS `rpt_req_analyst` from `vw_dev_est_reqs_status` group by `vw_dev_est_reqs_status`.`iddev_est_reqs` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_rpt_bill_ts_cycle`
--

/*!50001 DROP VIEW IF EXISTS `vw_rpt_bill_ts_cycle`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_rpt_bill_ts_cycle` AS select `a`.`idrpt_bill_ts_cycle` AS `idrpt_bill_ts_cycle`,`a`.`idengage_entity_po` AS `idengage_entity_po`,`a`.`cycle_for` AS `cycle_for`,`a`.`cycle_type` AS `cycle_type`,`l`.`look_values` AS `frequency`,`et`.`engage_ref_tab` AS `engage_ref_tab`,`et`.`engage_ref_id` AS `engage_ref_id`,`ep`.`summary` AS `summary`,`ep`.`idengage_entity` AS `idengage_entity`,(case when (`et`.`engage_ref_tab` = _latin1'Company') then concat(`c`.`companyname`) when (`et`.`engage_ref_tab` = _latin1'Employee') then (case when isnull(`et`.`engage_ref_id`) then 'Admin' else concat(`em`.`firstname`,_latin1' ',`em`.`lastname`) end) end) AS `engage_ref_id_name`,substring_index(`a`.`expect_bill_hr`,'.',1) AS `expect_bill_hr`,substring_index(`a`.`expect_unbill_hr`,'.',1) AS `expect_unbill_hr`,substring_index(`a`.`expect_total_hr`,'.',1) AS `expect_total_hr`,`ep`.`bill_pay_rate` AS `bill_pay_rate`,`a`.`expect_bill_amt` AS `expect_bill_amt`,`a`.`bill_hr` AS `bill_hr`,`a`.`unbill_hr` AS `unbill_hr`,`a`.`bill_total_hr` AS `bill_total_hr`,`a`.`bill_amt` AS `bill_amt`,`a`.`diff_bill_hr` AS `diff_bill_hr`,`a`.`diff_unbill_hr` AS `diff_unbill_hr`,`a`.`diff_total_hr` AS `diff_total_hr`,`a`.`diff_bill_amt` AS `diff_bill_amt`,date_format(`a`.`cycle_st_dt`,'%m.%d.%y') AS `cycle_st_dt`,date_format(`a`.`cycle_st_dt`,'%m-%d-%y') AS `cycle_st_dt0`,`a`.`cycle_st_dt` AS `cycle_st_dt1`,date_format(`a`.`cycle_end_dt`,'%m.%d.%y') AS `cycle_end_dt`,date_format(`a`.`cycle_end_dt`,'%m-%d-%y') AS `cycle_end_dt0`,`a`.`cycle_end_dt` AS `cycle_end_dt1`,date_format(`a`.`due_dt`,'%m.%d.%y') AS `due_dt`,date_format(`a`.`due_dt`,'%m-%d-%y') AS `due_dt0`,`a`.`due_dt` AS `due_dt1`,`a`.`display` AS `display`,`a`.`invoiced` AS `invoiced`,`a`.`approved` AS `approved`,`a`.`timecard` AS `timecard`,`a`.`last_updated` AS `last_updated`,(case when (`a`.`cycle_for` = _latin1'BI') then date_format(`ep`.`bill_last_run`,'%m.%d.%y') else date_format(`ep`.`ts_last_run`,'%m.%d.%y') end) AS `last_run`,(case when (`a`.`cycle_for` = _latin1'BI') then `ep`.`bill_last_run` else `ep`.`ts_last_run` end) AS `last_run2`,`a`.`updated_by` AS `updated_by`,`ep`.`allow_inv` AS `allow_inv`,concat(convert(date_format(`a`.`last_updated`,'%m.%d.%y %H:%i:%s') using latin1),_latin1' ',(case when isnull(`a`.`updated_by`) then 'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end)) AS `mod_last_updated`,`a`.`srv_client` AS `srv_client`,`m`.`companyname` AS `srv_client_name`,`a`.`emp_id` AS `emp_id` from (((((((`rpt_bill_ts_cycle` `a` left join `emp` `e` on((`e`.`emp_id` = `a`.`updated_by`))) left join `engage_entity_po` `ep` on((`ep`.`idengage_entity_po` = `a`.`idengage_entity_po`))) left join `engage_entity` `et` on((`et`.`idengage_entity` = `ep`.`idengage_entity`))) left join `company` `c` on((`et`.`engage_ref_id` = `c`.`comp_id`))) left join `emp` `em` on((`et`.`engage_ref_id` = `em`.`emp_id`))) left join `look_values` `l` on((`l`.`look_values_id` = `a`.`cycle_type`))) left join `company` `m` on((`m`.`comp_id` = `a`.`srv_client`))) order by `a`.`due_dt` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_rpt_dev_status_lag_time`
--

/*!50001 DROP VIEW IF EXISTS `vw_rpt_dev_status_lag_time`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_rpt_dev_status_lag_time` AS select `dev_est_reqs_status`.`iddev_est_reqs` AS `iddev_est_reqs`,sum(`dev_est_reqs_status`.`lag_time`) AS `lag_time` from `dev_est_reqs_status` where (`dev_est_reqs_status`.`iddev_est_reqs` = `dev_est_reqs_status`.`iddev_est_reqs`) group by `dev_est_reqs_status`.`iddev_est_reqs` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_sale_current_location`
--

/*!50001 DROP VIEW IF EXISTS `vw_sale_current_location`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_sale_current_location` AS select `p`.`prosp_consult_id` AS `prosp_consult_id`,sum((case `p`.`prosp_tags` when _utf8'690' then `p`.`prosp_tags` else 0 end)) AS `Current Location_USA`,sum((case `p`.`prosp_tags` when _utf8'258' then `p`.`prosp_tags` else 0 end)) AS `Current Location_india`,sum((case `p`.`prosp_tags` when _utf8'1028' then `p`.`prosp_tags` else 0 end)) AS `Current Location_UK`,sum((case `p`.`prosp_tags` when _utf8'1034' then `p`.`prosp_tags` else 0 end)) AS `Current Location_ENG`,if(((`p`.`prosp_tags` = 690) or (`p`.`prosp_tags` = 258) or (`p`.`prosp_tags` = 1028) or (`p`.`prosp_tags` = 1034)),0,1) AS `Missing_current_location` from `prosp_tag` `p` group by `p`.`prosp_consult_id` order by `p`.`prosp_consult_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_sale_shr`
--

/*!50001 DROP VIEW IF EXISTS `vw_sale_shr`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`jitenpatel`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_sale_shr` AS (select `c`.`look_values_id` AS `look_values_id`,`c`.`look_table` AS `look_table`,`c`.`look_values` AS `look_values`,`c`.`look_display_id` AS `look_display_id`,`c`.`look_sub_value_id` AS `look_sub_value_id`,(select distinct `look_values`.`look_values` AS `look_values` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_title`,(select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `group_display_id`,(select distinct `look_values`.`look_value_code` AS `look_value_code` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_code`,(select distinct `look_values`.`look_value_desc` AS `look_value_desc` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)) AS `look_value_desc` from `look_values` `c` where ((`c`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'sales.section'))) and (`c`.`look_sub_value_id` > 0)) order by (select distinct `look_values`.`look_display_id` AS `look_display_id` from `look_values` where (`look_values`.`look_values_id` = `c`.`look_sub_value_id`)),`c`.`look_display_id`) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_sales_consult_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_sales_consult_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_sales_consult_attach` AS select `a`.`idprosp_attach` AS `idprosp_attach`,`b`.`prosp_consult_id` AS `prosp_consult_id`,`a`.`idstorage` AS `idstorage`,`c`.`owner_id` AS `owner_id`,`c`.`file_name` AS `file_name`,`c`.`public` AS `public`,`c`.`self_view` AS `self_view`,`c`.`shared` AS `shared`,`c`.`emp_id` AS `emp_id`,`c`.`updated_for_ref_id` AS `updated_for_ref_id`,(case when (`c`.`owner_id` = _latin1'') then 'Admin' when isnull(`c`.`owner_id`) then 'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updater`,`c`.`updated_for_ref_table` AS `updated_for_ref_table`,`a`.`last_updated` AS `last_updated` from (((`prosp_attach` `a` left join `storages` `c` on((`a`.`idstorage` = `c`.`idstorage`))) left join `emp` `e` on((`c`.`owner_id` = `e`.`emp_id`))) left join `prosp_consult` `b` on((`a`.`prosp_consult_id` = `b`.`prosp_consult_id`))) order by `b`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_sales_prosp_activity`
--

/*!50001 DROP VIEW IF EXISTS `vw_sales_prosp_activity`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`jitenpatel`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_sales_prosp_activity` AS (select `a`.`prosp_activity_id` AS `prosp_activity_id`,`a`.`prosp_consult_id` AS `prosp_consult_id`,date_format(`a`.`call_recv_dt`,_utf8'%m.%d.%y') AS `call_recv_dt`,`a`.`emp_id` AS `emp_id`,(case when (`a`.`emp_id` <> 0) then concat_ws(_latin1' ',`b`.`firstname`,`b`.`lastname`) else 'Admin' end) AS `updater`,date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') AS `next_call_dt`,`a`.`call_note` AS `call_note`,date_format(`a`.`last_update`,_utf8'%m.%d.%y %T') AS `last_update` from (`prosp_activity` `a` left join `emp` `b` on((`a`.`emp_id` = `b`.`emp_id`))) order by date_format(`a`.`next_call_dt`,_utf8'%m.%d.%y') desc) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_sales_prosp_attach`
--

/*!50001 DROP VIEW IF EXISTS `vw_sales_prosp_attach`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`jitenpatel`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_sales_prosp_attach` AS (select `a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,date_format(`a`.`create_dt`,_utf8'%m-%d-%y') AS `create_dt`,(case when (`a`.`owner_id` = _latin1'') then 'Admin' when isnull(`a`.`owner_id`) then 'Admin' else concat(`e`.`firstname`,_latin1' ',`e`.`lastname`) end) AS `updater`,`b`.`prosp_consult_id` AS `prosp_consult_id`,concat(`c`.`prosp_first_name`,_latin1' ',`c`.`prosp_last_name`) AS `prsp_consult_name` from (((`storages` `a` left join `prosp_attach` `b` on((`a`.`idstorage` = `b`.`idstorage`))) left join `emp` `e` on((`a`.`owner_id` = `e`.`emp_id`))) left join `prosp_consult` `c` on((`b`.`prosp_consult_id` = `c`.`prosp_consult_id`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_sales_prosp_contact`
--

/*!50001 DROP VIEW IF EXISTS `vw_sales_prosp_contact`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`jitenpatel`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_sales_prosp_contact` AS (select `a`.`prosp_contact_id` AS `prosp_contact_id`,`a`.`prosp_consult_id` AS `prosp_consult_id`,`a`.`contact_id` AS `contact_id`,`a`.`prosp_contact_type` AS `prosp_contact_type`,(select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where ((`look_values`.`look_values` = `a`.`prosp_contact_type`) and (select `look_values`.`look_table` AS `look_table` from `look_values` where (`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'contact.type'))) limit 1)) limit 1) AS `prosp_contact_type_id`,`a`.`summary` AS `summary`,`b`.`contact_detail` AS `contact_detail` from (`prosp_contact` `a` left join `contact_no` `b` on((`a`.`contact_id` = `b`.`contact_id`)))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_show_emp`
--

/*!50001 DROP VIEW IF EXISTS `vw_show_emp`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_show_emp` AS select `c`.`companyname` AS `companyname`,`eep`.`bill_pay_rate` AS `bill_pay_rate`,`eb`.`engage_calc` AS `engage_calc`,`eb`.`engage_amt` AS `engage_amt`,`eb`.`engage_st_dt` AS `engage_st_dt`,`eb`.`engage_end_st` AS `engage_end_st`,`eb`.`limit_amt` AS `limit_amt`,`eb`.`engage_summary` AS `engage_summary`,`eb`.`engage_ref_id` AS `engage_ref_id` from ((((`engage` `e` left join `engage_entity` `ee` on((`e`.`engage_id` = `ee`.`engage_id`))) left join `engage_entity_po` `eep` on((`ee`.`idengage_entity` = `eep`.`idengage_entity`))) left join `engage_budget` `eb` on((`eb`.`idengage_entity_po` = `eep`.`idengage_entity_po`))) left join `company` `c` on((`c`.`comp_id` = `e`.`srv_client`))) where (`eb`.`show_emp` = (select `look_values`.`look_values_id` AS `look_values_id` from `look_values` where ((`look_values`.`look_table` = (select `look_table`.`look_table_id` AS `look_table_id` from `look_table` where (`look_table`.`table_name` = _latin1'yes_no'))) and (`look_values`.`look_values` = _latin1'Yes')))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_storage_lk_tag`
--

/*!50001 DROP VIEW IF EXISTS `vw_storage_lk_tag`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_storage_lk_tag` AS select `a`.`idstorage_lk_tag` AS `idstorage_lk_tag`,`a`.`lk_tag` AS `lk_tag`,`a`.`lk_tag_desc` AS `lk_tag_desc`,`a`.`lk_disp_id` AS `lk_disp_id`,`a`.`lk_parent_tag_id` AS `lk_parent_tag_id`,`a`.`updater` AS `updater`,if(isnull(`a`.`updater`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)) AS `updater_fmt`,`s`.`file_name` AS `updater_file_name`,`a`.`last_updated` AS `last_updated`,if(isnull(`a`.`last_updated`),'Never',date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p')) AS `last_updated_fmt`,concat(if(isnull(`a`.`updater`),'Admin',concat(`e`.`firstname`,' ',`e`.`lastname`)),' ',convert(if(isnull(`a`.`last_updated`),'Never',date_format(`a`.`last_updated`,'%m-%d-%y %h:%i %p')) using latin1)) AS `last_updated_by` from ((`storage_lk_tag` `a` left join `emp` `e` on((`a`.`updater` = `e`.`emp_id`))) left join `storages` `s` on((`e`.`idstorage` = `s`.`idstorage`))) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_storages`
--

/*!50001 DROP VIEW IF EXISTS `vw_storages`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_storages` AS select `a`.`idstorage` AS `idstorage`,`a`.`file_name` AS `file_name`,`a`.`file_size` AS `file_size`,`a`.`owner_id` AS `owner_id`,ifnull(concat(`o`.`firstname`,'  ',`o`.`lastname`),'Admin') AS `owner_name`,`a`.`create_dt` AS `create_dt_unformatted`,date_format(`a`.`create_dt`,'%m-%d-%y %h:%i %p') AS `create_dt`,`a`.`ext_type` AS `ext_type`,`a`.`public` AS `public`,`a`.`self_view` AS `self_view`,`a`.`shared` AS `shared`,`a`.`file_summary` AS `file_summary`,`a`.`updated_for_ref_id` AS `updated_for_ref_id`,(case when (`a`.`updated_for_ref_table` = 'Employee') then ifnull(`e`.`fullname`,'Admin') when (`a`.`updated_for_ref_table` = 'Consultant') then `c`.`prosp_fullname` else 'NO Ref' end) AS `updated_for_ref_name`,`a`.`last_updated` AS `last_updated`,`a`.`emp_id` AS `emp_id`,ifnull(`u`.`fullname`,'Admin') AS `emp_name`,`a`.`del_dt` AS `del_dt_unformatted`,date_format(`a`.`del_dt`,'%m-%d-%y %h:%i %p') AS `del_dt`,`a`.`del_by` AS `del_by_id`,ifnull(`e_del_by`.`fullname`,'Admin') AS `del_by`,`e_del_by`.`emp_file_name` AS `del_by_file_name`,(to_days((date_format(`a`.`del_dt`,'%y-%m-%d') + interval `a`.`del_day` day)) - to_days(date_format(now(),'%y-%m-%d'))) AS `virtual_del_day`,`a`.`archv_dt` AS `archv_dt_unformatted`,date_format(`a`.`archv_dt`,'%m-%d-%y %h:%i %p') AS `archv_dt`,`a`.`archv_by` AS `archv_by_id`,ifnull(`e_archv_by`.`fullname`,'Admin') AS `archv_by`,`e_archv_by`.`emp_file_name` AS `archv_by_file_name` from ((((((`storages` `a` left join `vw_emp` `o` on((`a`.`owner_id` = `o`.`emp_id`))) left join `vw_emp` `e` on((`a`.`updated_for_ref_id` = `e`.`emp_id`))) left join `vw_prosp_consult` `c` on((`a`.`updated_for_ref_id` = `c`.`prosp_consult_id`))) left join `vw_emp` `u` on((`a`.`emp_id` = `u`.`emp_id`))) left join `vw_emp` `e_del_by` on((`a`.`del_by` = `e_del_by`.`emp_id`))) left join `vw_emp` `e_archv_by` on((`a`.`archv_by` = `e_archv_by`.`emp_id`))) order by `a`.`last_updated` desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `vw_timesheet`
--

/*!50001 DROP VIEW IF EXISTS `vw_timesheet`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`aerion`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `vw_timesheet` AS select `a`.`timecard_id` AS `timecard_id`,`a`.`emp_id` AS `emp_id`,`a`.`comp_id` AS `comp_id`,date_format(`a`.`timefrom_dt`,_utf8'%m-%d-%y') AS `timefrom_dt1`,`a`.`timefrom_dt` AS `timefrom_dt`,date_format(`a`.`timeto_dt`,_utf8'%m-%d-%y') AS `timeto_dt1`,`a`.`timeto_dt` AS `timeto_dt`,`a`.`bill_hrs` AS `bill_hrs`,`a`.`unbill_hrs` AS `unbill_hrs`,`a`.`total_hrs` AS `total_hrs`,`a`.`validate_dt` AS `validate_dt`,date_format(`a`.`validate_dt`,_utf8'%m-%d-%y') AS `validate_dt1`,(case when isnull(`a`.`validate_by`) then 'Admin' else concat(`f`.`firstname`,_latin1' ',`f`.`lastname`) end) AS `validate_by`,`a`.`updated_by` AS `updated_by`,(case when isnull(`a`.`updated_by`) then 'Admin' else concat(`m`.`firstname`,_latin1' ',`m`.`lastname`) end) AS `updated_by_name`,`a`.`summary` AS `summary`,`a`.`idstorage` AS `idstorage`,`d`.`file_name` AS `filename`,`b`.`companyname` AS `companyname`,concat(`c`.`firstname`,_latin1' ',`c`.`lastname`) AS `fullname`,date_format(`a`.`last_updated`,_utf8'%m-%d-%y') AS `last_updated`,`a`.`last_updated` AS `last_updated_o` from (((((`hours_time` `a` left join `company` `b` on((`a`.`comp_id` = `b`.`comp_id`))) left join `emp` `c` on((`a`.`emp_id` = `c`.`emp_id`))) left join `emp` `f` on((`a`.`validate_by` = `f`.`emp_id`))) left join `emp` `m` on((`a`.`updated_by` = `m`.`emp_id`))) left join `storages` `d` on((`a`.`idstorage` = `d`.`idstorage`))) order by concat(convert(ifnull(concat(substr(`a`.`last_updated`,6,2),_utf8'-',substr(`a`.`last_updated`,9,2),_utf8'-',substr(`a`.`last_updated`,3,2)),_utf8'') using latin1),' ',ifnull((select concat(`emp`.`firstname`,_latin1' ',`emp`.`lastname`) AS `concat(firstname,' ',lastname)` from `emp` where (`emp`.`emp_id` = `a`.`updated_by`)),_latin1'')) desc */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2020-07-22 20:27:51