-- http://www.phpmyadmin.net
--




--
-- Database: `solimaq_dev`
--
USE `webcorp_crm`;

DELIMITER $$
--
-- Procedures
--
DROP PROCEDURE IF EXISTS `pa_user`$$
CREATE DEFINER=`webcorp_crm`@`%` PROCEDURE `pa_user`(
 in numb int(5),
 in name varchar(30),
 in ip varchar(30),
 in user_name varchar(255),
 in email varchar(100),
 in about text
 )
begin
	case numb
    when 1 then 
    insert into bitacora (name,ip,msg,date)
    values(name,ip,concat("se registro el usuario ",user_name,' con un correo ',email,' y una descripcion ',about),now()) ;
    when 2 then
    insert into bitacora (name,ip,msg,date)
    values(name,ip,concat("se borró el ",user_name),now()) ;
    when 3 then
    insert into bitacora (name,ip,msg,date)
    values(name,ip,concat("se registro el usuario ",user_name,' con un correo ',email,' y una descripcion ',about),now()) ;
    end case;
    
 end$$

DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `access`
--

CREATE TABLE IF NOT EXISTS `access` (
  `id_group` int(11) NOT NULL,
  `id_module` int(11) NOT NULL,
  ` is_cat` tinyint(1) NOT NULL,
  `create_a` tinyint(1) NOT NULL,
  `read_a` tinyint(1) NOT NULL,
  `update_a` tinyint(1) NOT NULL,
  `delete_a` tinyint(1) NOT NULL,
  KEY `id_group` (`id_group`),
  KEY `id_module` (`id_module`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `bitacora`
--

CREATE TABLE IF NOT EXISTS `bitacora` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) DEFAULT NULL,
  `ip` varchar(50) DEFAULT NULL,
  `msg` text,
  `date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ;

-- --------------------------------------------------------

--
-- Table structure for table `business`
--

CREATE TABLE IF NOT EXISTS `business` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `business_name` varchar(50) NOT NULL,
  `address` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=27 ;

-- --------------------------------------------------------

--
-- Table structure for table `buys_x_proveedor`
--

CREATE TABLE IF NOT EXISTS `buys_x_proveedor` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pro_x_product` int(11) NOT NULL,
  `price` float NOT NULL,
  `porcent` float NOT NULL,
  `user_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=76 ;

-- --------------------------------------------------------

--
-- Table structure for table `cat_files`
--

CREATE TABLE IF NOT EXISTS `cat_files` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name_file` varchar(100) NOT NULL,
  `type_id` int(11) NOT NULL,
  `business_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;

-- --------------------------------------------------------

--
-- Table structure for table `cat_payments`
--

CREATE TABLE IF NOT EXISTS `cat_payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;

-- --------------------------------------------------------

--
-- Table structure for table `cat_products`
--

CREATE TABLE IF NOT EXISTS `cat_products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `type` varchar(100) NOT NULL,
  `model` varchar(100) NOT NULL,
  `ability` varchar(100) NOT NULL,
  `description` text NOT NULL,
  `media_path` varchar(255) NOT NULL,
  `su_price` double NOT NULL,
  `delivery_time` varchar(60) NOT NULL,
  `c_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `link_youtube` varchar(200) NOT NULL,
  `business_id` int(11) NOT NULL,
  `deleted_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=32 ;

-- --------------------------------------------------------

--
-- Table structure for table `cat_sales_stages`
--

CREATE TABLE IF NOT EXISTS `cat_sales_stages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `description` varchar(500) DEFAULT NULL,
  `position` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;

-- --------------------------------------------------------

--
-- Table structure for table `clients_data`
--

CREATE TABLE IF NOT EXISTS `clients_data` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `rfc` varchar(20) DEFAULT NULL,
  `phone` int(10) NOT NULL,
  `mobile` varchar(100) DEFAULT NULL,
  `adress_country` varchar(255) DEFAULT NULL,
  `adress_city` varchar(255) DEFAULT NULL,
  `adress_county` varchar(255) DEFAULT NULL,
  `adress_street` varchar(255) DEFAULT NULL,
  `adress_postal_code` varchar(255) DEFAULT NULL,
  `adress_number` varchar(255) DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user-client_idx` (`id_user`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

-- --------------------------------------------------------

--
-- Table structure for table `contracts`
--

CREATE TABLE IF NOT EXISTS `contracts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_user` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `rfc` varchar(100) DEFAULT NULL,
  `description` varchar(200) DEFAULT NULL,
  `wyswyg` text,
  PRIMARY KEY (`id`),
  KEY `id_user` (`id_user`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ;

-- --------------------------------------------------------

--
-- Table structure for table `cotization`
--

CREATE TABLE IF NOT EXISTS `cotization` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_user_vendor` int(11) NOT NULL,
  `id_user_client` int(11) NOT NULL,
  `global_percent` double NOT NULL,
  `c_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `name_data_contact` varchar(50) DEFAULT NULL,
  `email_data_contact` varchar(100) DEFAULT NULL,
  `phone_data_contact` varchar(100) DEFAULT NULL,
  `movil_data_contact` varchar(100) DEFAULT NULL,
  `calle` varchar(100) DEFAULT NULL,
  `interior` varchar(100) DEFAULT NULL,
  `exterior` varchar(100) DEFAULT NULL,
  `colonia` varchar(100) DEFAULT NULL,
  `localidad` varchar(100) DEFAULT NULL,
  `estado` varchar(100) DEFAULT NULL,
  `municipio` varchar(100) DEFAULT NULL,
  `postal` varchar(100) DEFAULT NULL,
  `referencia` varchar(100) DEFAULT NULL,
  `country` varchar(100) DEFAULT NULL,
  `show_cotization` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `ID` (`id`),
  KEY `id_user_vendor` (`id_user_vendor`),
  KEY `id_user_client` (`id_user_client`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;

-- --------------------------------------------------------

--
-- Table structure for table `cotization_x_products`
--

CREATE TABLE IF NOT EXISTS `cotization_x_products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_cat_products` int(11) NOT NULL,
  `id_cotization` int(11) NOT NULL,
  `price` double NOT NULL DEFAULT '0',
  `percent` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id_cat_products` (`id_cat_products`),
  KEY `id_cotization` (`id_cotization`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=108 ;

-- --------------------------------------------------------

--
-- Table structure for table `data_venta`
--

CREATE TABLE IF NOT EXISTS `data_venta` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tipo_persona` varchar(80) NOT NULL,
  `rfc` varchar(13) NOT NULL,
  `correo` varchar(250) NOT NULL,
  `telefono_fijo` int(10) NOT NULL,
  `telefono_movil` int(10) NOT NULL,
  `dom_entrega` varchar(200) NOT NULL,
  `dom_facturacion` varchar(200) NOT NULL,
  `rep_legal` varchar(150) NOT NULL,
  `num_acta_constitutiva` varchar(80) NOT NULL,
  `Fecha` datetime NOT NULL,
  `nombre` varchar(100) NOT NULL,
  `notorio_puplico` varchar(100) NOT NULL,
  `id_data_clients` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;

-- --------------------------------------------------------

--
-- Table structure for table `employs_data`
--

CREATE TABLE IF NOT EXISTS `employs_data` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `salary` double DEFAULT NULL,
  `job_description` varchar(45) DEFAULT NULL,
  `phone` varchar(100) DEFAULT NULL,
  `movil` varchar(100) DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `employ-user_idx` (`id_user`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;

-- --------------------------------------------------------

--
-- Table structure for table `file_patments`
--

CREATE TABLE IF NOT EXISTS `file_patments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `payments_id` int(11) NOT NULL,
  `path` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

-- --------------------------------------------------------

--
-- Table structure for table `files_sales`
--

CREATE TABLE IF NOT EXISTS `files_sales` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sales_id` int(11) NOT NULL,
  `path` varchar(200) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=32 ;

-- --------------------------------------------------------

--
-- Table structure for table `group_modules`
--

CREATE TABLE IF NOT EXISTS `group_modules` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `description` varchar(255) NOT NULL,
  `icon` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;

-- --------------------------------------------------------

--
-- Table structure for table `groups`
--

CREATE TABLE IF NOT EXISTS `groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `description` varchar(500) NOT NULL,
  `active` smallint(6) NOT NULL DEFAULT '0',
  `c_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=48 ;

-- --------------------------------------------------------

--
-- Table structure for table `marketing_campaigns`
--

CREATE TABLE IF NOT EXISTS `marketing_campaigns` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` text NOT NULL,
  `budget` double NOT NULL,
  `date_start` datetime NOT NULL,
  `date_end` datetime NOT NULL,
  `channel` varchar(255) NOT NULL,
  `leads` double NOT NULL,
  `id_producto` int(11) NOT NULL,
  `status` int(11) NOT NULL,
  `id_create_user` int(11) NOT NULL,
  `id_asigned_user` int(11) NOT NULL,
  `c_date` datetime NOT NULL,
  `u_date` datetime NOT NULL,
  `d_date` datetime NOT NULL,
  `total_cost` double DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `id_producto` (`id_producto`,`id_create_user`,`id_asigned_user`),
  KEY `fk_user_create` (`id_create_user`),
  KEY `fk_user_asigned` (`id_asigned_user`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=31 ;

-- --------------------------------------------------------

--
-- Table structure for table `modules`
--

CREATE TABLE IF NOT EXISTS `modules` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_group_module` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `controller` varchar(255) NOT NULL,
  `active` tinyint(1) NOT NULL,
  `phase` int(11) NOT NULL,
  `show_in_menu` tinyint(1) NOT NULL DEFAULT '0',
  `parent` varchar(80) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `id_group_module` (`id_group_module`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=160 ;

-- --------------------------------------------------------

--
-- Table structure for table `notifications`
--

CREATE TABLE IF NOT EXISTS `notifications` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_type` int(11) NOT NULL,
  `state` tinyint(1) NOT NULL,
  `id_user_emisor` int(11) DEFAULT NULL,
  `id_user_receptor` int(11) DEFAULT NULL,
  `date` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_user_receiver` (`id_user_emisor`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;

-- --------------------------------------------------------

--
-- Table structure for table `payments`
--

CREATE TABLE IF NOT EXISTS `payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_sales` int(11) DEFAULT NULL,
  `amount` double DEFAULT NULL,
  `status` varchar(255) DEFAULT NULL,
  `c_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `id_cat_payments` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `payment-cat-payment_idx` (`id_cat_payments`),
  KEY `payment-sales_idx` (`id_sales`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=18 ;

-- --------------------------------------------------------

--
-- Table structure for table `proveedor`
--

CREATE TABLE IF NOT EXISTS `proveedor` (
  `id_proveedor` int(11) NOT NULL AUTO_INCREMENT,
  `contact` varchar(100) NOT NULL,
  `phone` int(10) NOT NULL,
  `embark` varchar(100) NOT NULL,
  `bank` varchar(200) NOT NULL,
  `name_proveedor` varchar(100) DEFAULT NULL,
  `p_address_country` varchar(255) DEFAULT NULL,
  `p_address_city` varchar(255) DEFAULT NULL,
  `p_address_county` varchar(255) DEFAULT NULL,
  `p_address_street` varchar(255) DEFAULT NULL,
  `p_address_postal_code` varchar(255) DEFAULT NULL,
  `p_address_number` varchar(255) DEFAULT NULL,
  `rfc` varchar(100) DEFAULT NULL,
  `description_proveedor` text,
  `c_date` datetime DEFAULT NULL,
  `business_id` int(11) NOT NULL,
  PRIMARY KEY (`id_proveedor`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=58 ;

-- --------------------------------------------------------

--
-- Table structure for table `proveedor_x_products`
--

CREATE TABLE IF NOT EXISTS `proveedor_x_products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_product` int(11) NOT NULL,
  `id_proveedor` int(11) NOT NULL,
  `supplier_price` double NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id_product` (`id_product`),
  KEY `id_proveedor` (`id_proveedor`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ;

-- --------------------------------------------------------

--
-- Table structure for table `sale_product_activity`
--

CREATE TABLE IF NOT EXISTS `sale_product_activity` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_cotization_x_products` int(11) DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `description` varchar(5000) DEFAULT NULL,
  `id_stage` int(11) DEFAULT NULL,
  `c_date` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `cotization-c_x_p_idx` (`id_cotization_x_products`),
  KEY `spa-users_idx` (`id_user`),
  KEY `spa-stage_idx` (`id_stage`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `sales`
--

CREATE TABLE IF NOT EXISTS `sales` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_cotizacion` int(11) DEFAULT NULL,
  `id_user_vendor` int(11) DEFAULT NULL,
  `subtotal` double DEFAULT NULL,
  `tax` double DEFAULT NULL,
  `c_date` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `sales-user_idx` (`id_cotizacion`),
  KEY `sales-user_idx1` (`id_user_vendor`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=37 ;

-- --------------------------------------------------------

--
-- Table structure for table `selected_button`
--

CREATE TABLE IF NOT EXISTS `selected_button` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name_table` varchar(100) DEFAULT NULL,
  `column_name` varchar(100) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;

-- --------------------------------------------------------

--
-- Table structure for table `type_files`
--

CREATE TABLE IF NOT EXISTS `type_files` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type_file` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;

-- --------------------------------------------------------

--
-- Table structure for table `type_of_notification`
--

CREATE TABLE IF NOT EXISTS `type_of_notification` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Tipo` varchar(50) NOT NULL,
  `Mensaje` varchar(80) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

