· 9 years ago · Sep 13, 2017, 01:46 PM
1-- phpMyAdmin SQL Dump
2-- version 4.5.2
3-- http://www.phpmyadmin.net
4--
5-- Host: localhost
6-- Generation Time: Sep 13, 2017 at 03:43
7-- Server version: 10.1.19-MariaDB
8-- PHP Version: 7.0.9
9
10SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11SET time_zone = "+00:00";
12
13
14/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
15/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
16/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
17/*!40101 SET NAMES utf8mb4 */;
18
19--
20-- Database: `crm_db`
21--
22
23DELIMITER $$
24--
25-- Procedures
26--
27CREATE DEFINER=`root`@`localhost` PROCEDURE `build_email_list` (INOUT `email_list` VARCHAR(4000)) BEGIN
28
29 DECLARE v_finished INTEGER DEFAULT 0;
30 DECLARE v_email varchar(100) DEFAULT "";
31
32 DEClARE email_cursor CURSOR FOR
33 SELECT invoice_id FROM crm_invoices;
34
35 DECLARE CONTINUE HANDLER
36 FOR NOT FOUND SET v_finished = 1;
37
38 OPEN email_cursor;
39
40 get_email: LOOP
41
42 FETCH email_cursor INTO v_email;
43
44 IF v_finished = 1 THEN
45 LEAVE get_email;
46 END IF;
47
48 SET email_list = CONCAT(v_email,";",email_list);
49
50 END LOOP get_email;
51
52 CLOSE email_cursor;
53
54END$$
55
56CREATE DEFINER=`root`@`localhost` PROCEDURE `coba` () NO SQL
57BEGIN
58SET @date_param = (SELECT DATE_FORMAT(CURDATE(), "%m%y"));
59SET @inv_code = (SELECT invoice_code FROM crm_invoice_details WHERE invoice_code LIKE CONCAT('%',@date_param,'%') ORDER BY invoice_detail_id DESC LIMIT 1);
60
61IF @inv_code IS null THEN
62 SET @new_inv_code = CONCAT('INV-', @date_param, '00001');
63ELSE
64 SET @new_numb_code = (SELECT SUBSTRING_INDEX(@inv_code, '-', -1));
65 SET @new_code = @new_numb_code + 1;
66 SET @sub_code = substring(@new_code, -5);
67 SET @new_inv_code = CONCAT('INV-', @date_param, @sub_code);
68END IF;
69
70SELECT @new_inv_code;
71END$$
72
73CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_campaign_insert` (IN `name` VARCHAR(100), IN `description` TEXT, IN `start_date` DATE, IN `end_date` DATE, IN `status` ENUM('0','1'), IN `number` INT, IN `percentage_response` DOUBLE, IN `budget_cost_currency` ENUM('1','2'), IN `budget_cost` DOUBLE, IN `actual_cost_currency` ENUM('1','2'), IN `actual_cost` DOUBLE, IN `expected_revenue_currency` ENUM('1','2'), IN `expected_revenue` DOUBLE, IN `u_created` VARCHAR(100), IN `date_created` DATETIME, OUT `c_id` INT, OUT `sukses` INT) NO SQL
74BEGIN
75
76DECLARE exit handler for sqlexception
77 BEGIN
78 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
79 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
80SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
81SELECT @full_error;
82 SET sukses=0;
83 ROLLBACK;
84END;
85
86DECLARE exit handler for sqlwarning
87 BEGIN
88 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
89 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
90SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
91SELECT @full_error;
92 SET sukses=0;
93 ROLLBACK;
94END;
95 drop temporary table if exists temp_cursor_table;
96 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT product_id AS p_id FROM crm_products where product_id in(', product_list ,') )');
97 prepare pst from @temp;
98 execute pst;
99 drop prepare pst;
100
101 INSERT INTO `crm_campaigns`(`campaign_name`, `campaign_description`, `campaign_start_date`, `campaign_end_date`, `campaign_status`, `campaign_number`, `campaign_percentage_response`, `campaign_budget_cost_currency`, `campaign_budget_cost`, `campaign_actual_cost_currency`, `campaign_actual_cost`, `campaign_expected_revenue_currency`, `campaign_expected_revenue`, `user_created`, `user_created_date`) VALUES (name, description, start_date, end_date, status, number, percentage_response, budget_cost_currency, budget_cost, actual_cost_currency, actual_cost, expected_revenue_currency, expected_revenue, u_created, date_created);
102 SET c_id = LAST_INSERT_ID();
103 SET sukses = 1;
104COMMIT;
105END$$
106
107CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_company_insert` (IN `code` VARCHAR(50), IN `name` VARCHAR(200), IN `parent` INT, IN `office_phone` VARCHAR(30), IN `industry` INT, IN `email` VARCHAR(100), IN `fax` VARCHAR(30), IN `employee` INT, IN `revenue` DOUBLE, IN `website` VARCHAR(100), IN `address1` VARCHAR(255), IN `address2` VARCHAR(255), IN `city` VARCHAR(100), IN `state` VARCHAR(100), IN `zip_code` VARCHAR(10), IN `country` VARCHAR(50), IN `billing_address1` VARCHAR(255), IN `billing_address2` VARCHAR(255), IN `billing_city` VARCHAR(100), IN `billing_state` VARCHAR(100), IN `billing_zip_code` VARCHAR(10), IN `billing_country` VARCHAR(50), IN `right_permission` ENUM('1','2','3'), IN `u_created` VARCHAR(100), IN `date_created` DATETIME, IN `groups` INT, IN `customer` ENUM('0','1'), IN `user_list` VARCHAR(300), OUT `sukses` INT, OUT `company_id` INT) NO SQL
108BEGIN
109
110DECLARE exit handler for sqlexception
111 BEGIN
112 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
113 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
114SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
115SELECT @full_error;
116 SET sukses=0;
117 ROLLBACK;
118END;
119
120DECLARE exit handler for sqlwarning
121 BEGIN
122 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
123 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
124SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
125SELECT @full_error;
126 SET sukses=0;
127 ROLLBACK;
128END;
129 drop temporary table if exists temp_cursor_table;
130 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id AS u_id FROM crm_users where user_id in(', user_list ,') )');
131 prepare pst from @temp;
132 execute pst;
133 drop prepare pst;
134
135 INSERT INTO `crm_companies`(`customer_code`, `company_name`, `company_parent`, `company_office_phone`, `company_industry`, `company_email`, `company_fax`, `company_employee`, `company_revenue`, `company_website`, `company_address1`, `company_address2`, `company_city`, `company_state`, `company_zip_code`, `company_country`, `company_billing_address1`, `company_billing_address2`, `company_billing_city`, `company_billing_state`, `company_billing_zip_code`, `company_billing_country`, `company_right_permission`, `user_created`, `user_created_date`, `company_groups`, `company_customer`) VALUES
136(code, name, parent, office_phone, industry, email, fax, employee, revenue, website, address1, address2, city, state, zip_code, country, billing_address1, billing_address2, billing_city, billing_state, billing_zip_code, billing_country, right_permission, u_created, date_created, groups, customer);
137SET @l_id = LAST_INSERT_ID();
138SET company_id = LAST_INSERT_ID();
139INSERT INTO `crm_users_companies`(`company_id`,`user_id`)
140 SELECT @l_id,u_id from temp_cursor_table;
141 drop temporary table if exists temp_cursor_table;
142 SET sukses = 1;
143COMMIT;
144END$$
145
146CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_company_meeting_delete` (IN `meet_id` INT, OUT `sukses` INT) NO SQL
147BEGIN
148
149
150DECLARE exit handler for sqlexception
151 BEGIN
152 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
153 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
154SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
155SELECT @full_error;
156 SET sukses=0;
157 ROLLBACK;
158END;
159
160DECLARE exit handler for sqlwarning
161 BEGIN
162 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
163 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
164SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
165SELECT @full_error;
166 SET sukses=0;
167 ROLLBACK;
168END;
169
170START TRANSACTION;
171 DELETE FROM company_meeting_users WHERE company_meeting_id = meet_id;
172 DELETE FROM company_meeting WHERE company_meeting_id = meet_id;
173 SET sukses = 1;
174COMMIT;
175END$$
176
177CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_company_meeting_insert` (IN `l_id` INT, IN `name` VARCHAR(100), IN `location` VARCHAR(255), IN `start_date` DATETIME, IN `end_date` DATETIME, IN `description` TEXT, IN `date` DATETIME, IN `user` VARCHAR(100), IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
178BEGIN
179
180DECLARE exit handler for sqlexception
181 BEGIN
182 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
183 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
184SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
185SELECT @full_error;
186 SET sukses=0;
187 ROLLBACK;
188END;
189
190DECLARE exit handler for sqlwarning
191 BEGIN
192 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
193 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
194SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
195SELECT @full_error;
196 SET sukses=0;
197 ROLLBACK;
198END;
199 drop temporary table if exists temp_cursor_table;
200 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id FROM crm_users where user_id in(', user_list ,') )');
201 prepare pst from @temp;
202 execute pst;
203 drop prepare pst;
204INSERT INTO `company_meeting`(`company_id`, `company_meeting_name`, `company_meeting_location`, `company_meeting_start_date`, `company_meeting_end_date`, `company_meeting_description`, `company_meeting_date`, `company_meeting_user`) VALUES (l_id,name,location,start_date,end_date,description,date,user);
205 SET @meet_id = LAST_INSERT_ID();
206INSERT INTO `company_meeting_users`(`company_meeting_id`,`company_user_id`)
207 SELECT @meet_id,user_id from temp_cursor_table;
208 drop temporary table if exists temp_cursor_table;
209 set sukses=1;
210COMMIT;
211END$$
212
213CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_company_meeting_update` (IN `meet_id` INT, IN `l_id` INT, IN `name` VARCHAR(100), IN `location` VARCHAR(255), IN `start_date` DATETIME, IN `end_date` DATETIME, IN `description` TEXT, IN `date` DATETIME, IN `user` VARCHAR(100), IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
214BEGIN
215
216DECLARE exit handler for sqlexception
217 BEGIN
218 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
219 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
220SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
221SELECT @full_error;
222 SET sukses=0;
223 ROLLBACK;
224END;
225
226DECLARE exit handler for sqlwarning
227 BEGIN
228 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
229 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
230SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
231SELECT @full_error;
232 SET sukses=0;
233 ROLLBACK;
234END;
235 drop temporary table if exists temp_cursor_table;
236 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id FROM crm_users where user_id in(', user_list ,') )');
237 prepare pst from @temp;
238 execute pst;
239 drop prepare pst;
240UPDATE `company_meeting` SET
241`company_meeting_name`=name,
242`company_meeting_location`=location,
243`company_meeting_start_date`=start_date,
244`company_meeting_end_date`=end_date,
245`company_meeting_description`=description,
246`company_meeting_date`=date,
247`company_meeting_user`=user,
248`company_id`=l_id
249WHERE `company_meeting_id`=meet_id;
250delete from company_meeting_users where company_meeting_id=meet_id;
251REPLACE INTO `company_meeting_users`(`company_meeting_id`,`company_user_id`)
252 SELECT meet_id,user_id from temp_cursor_table;
253 drop temporary table if exists temp_cursor_table;
254set sukses=1;
255COMMIT;
256END$$
257
258CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_company_update` (IN `c_id` INT, IN `code` VARCHAR(50), IN `name` VARCHAR(200), IN `parent` INT, IN `office_phone` VARCHAR(30), IN `industry` INT, IN `email` VARCHAR(100), IN `fax` VARCHAR(30), IN `employee` INT, IN `revenue` DOUBLE, IN `website` VARCHAR(100), IN `address1` VARCHAR(255), IN `address2` VARCHAR(255), IN `city` VARCHAR(100), IN `state` VARCHAR(100), IN `zip_code` VARCHAR(10), IN `country` VARCHAR(50), IN `billing_address1` VARCHAR(255), IN `billing_address2` VARCHAR(255), IN `billing_city` VARCHAR(100), IN `billing_state` VARCHAR(100), IN `billing_zip_code` VARCHAR(10), IN `billing_country` VARCHAR(50), IN `right_permission` ENUM('1','2','3'), IN `groups` INT, IN `customer` ENUM('0','1'), IN `u_modified` VARCHAR(100), IN `date_modified` DATETIME, IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
259BEGIN
260
261DECLARE exit handler for sqlexception
262 BEGIN
263 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
264 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
265SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
266SELECT @full_error;
267 SET sukses=0;
268 ROLLBACK;
269END;
270
271DECLARE exit handler for sqlwarning
272 BEGIN
273 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
274 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
275SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
276SELECT @full_error;
277 SET sukses=0;
278 ROLLBACK;
279END;
280 drop temporary table if exists temp_cursor_table;
281 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id AS u_id FROM crm_users where user_id in(', user_list ,') )');
282 prepare pst from @temp;
283 execute pst;
284 drop prepare pst;
285UPDATE `crm_companies` SET
286 `customer_code`=code,
287 `company_name`=name,
288 `company_parent`=parent,
289 `company_office_phone`=office_phone,
290 `company_industry`=industry,
291 `company_email`=email,
292 `company_fax`=fax,
293 `company_employee`=employee,
294 `company_revenue`=revenue,
295 `company_website`=website,
296 `company_address1`=address1,
297 `company_address2`=address2,
298 `company_city`=city,
299 `company_state`=state,
300 `company_zip_code`=zip_code,
301 `company_country`=country,
302 `company_billing_address1`=billing_address1,
303 `company_billing_address2`=billing_address2,
304 `company_billing_city`=billing_city,
305 `company_billing_state`=billing_state,
306 `company_billing_zip_code`=billing_zip_code,
307 `company_billing_country`=billing_country,
308 `company_right_permission`=right_permission,
309 `user_modified`=u_modified,
310 `user_modified_date`=date_modified,
311 `company_groups`=groups,
312 `company_customer`=customer
313WHERE `company_id`=c_id;
314delete from crm_users_companies where company_id=c_id;
315REPLACE INTO `crm_users_companies`(`company_id`,`user_id`)
316 SELECT c_id,u_id from temp_cursor_table;
317 drop temporary table if exists temp_cursor_table;
318 SET sukses = 1;
319COMMIT;
320END$$
321
322CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_contact_insert` (IN `salutation` ENUM('1','2','3'), IN `first_name` VARCHAR(100), IN `last_name` VARCHAR(100), IN `job_title` VARCHAR(100), IN `company` VARCHAR(100), IN `department` VARCHAR(100), IN `email` VARCHAR(100), IN `office_phone` VARCHAR(30), IN `mobile_phone` VARCHAR(30), IN `industry` INT, IN `address1` VARCHAR(255), IN `address2` VARCHAR(255), IN `city` VARCHAR(100), IN `state` VARCHAR(100), IN `zip_code` VARCHAR(10), IN `country` VARCHAR(50), IN `sources` INT, IN `photo` VARCHAR(100), IN `comp_id` INT, IN `right_permission` ENUM('1','2','3'), IN `groups` INT, IN `user_list` VARCHAR(300), OUT `sukses` INT, OUT `contact_id` INT) NO SQL
323BEGIN
324
325DECLARE exit handler for sqlexception
326 BEGIN
327 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
328 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
329SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
330SELECT @full_error;
331 SET sukses=0;
332 ROLLBACK;
333END;
334
335DECLARE exit handler for sqlwarning
336 BEGIN
337 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
338 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
339SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
340SELECT @full_error;
341 SET sukses=0;
342 ROLLBACK;
343END;
344 drop temporary table if exists temp_cursor_table;
345 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id AS u_id FROM crm_users where user_id in(', user_list ,') )');
346 prepare pst from @temp;
347 execute pst;
348 drop prepare pst;
349
350 INSERT INTO `crm_peoples`(`people_salutation`, `people_first_name`, `people_last_name`, `people_job_title`, `people_company`, `people_department`, `people_email`, `people_office_phone`, `people_mobile_phone`, `people_industry`, `people_address1`, `people_address2`, `people_city`, `people_state`, `people_zip_code`, `people_country`, `people_source`, `people_photo`, `people_status`) VALUES (salutation, first_name, last_name, job_title, company, department, email, office_phone, mobile_phone, industry, address1, address2, city, state, zip_code, country, sources, photo, '2');
351 SET @p_id = LAST_INSERT_ID();
352INSERT INTO `crm_contacts`(`people_id`, `contact_right_permission`, `contact_groups`, `company_id`) VALUES (@p_id, right_permission, groups, comp_id);
353SET @l_id = LAST_INSERT_ID();
354INSERT INTO `crm_users_contacts`(`contact_id`,`user_id`)
355 SELECT @l_id,u_id from temp_cursor_table;
356 SET contact_id = @l_id;
357 drop temporary table if exists temp_cursor_table;
358 SET sukses = 1;
359COMMIT;
360END$$
361
362CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_contact_meeting_delete` (IN `meet_id` INT, OUT `sukses` INT) NO SQL
363BEGIN
364
365
366DECLARE exit handler for sqlexception
367 BEGIN
368 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
369 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
370SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
371SELECT @full_error;
372 SET sukses=0;
373 ROLLBACK;
374END;
375
376DECLARE exit handler for sqlwarning
377 BEGIN
378 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
379 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
380SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
381SELECT @full_error;
382 SET sukses=0;
383 ROLLBACK;
384END;
385
386START TRANSACTION;
387 DELETE FROM contact_meeting_users WHERE contact_meeting_id = meet_id;
388 DELETE FROM contact_meeting WHERE contact_meeting_id = meet_id;
389 SET sukses = 1;
390COMMIT;
391END$$
392
393CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_contact_meeting_insert` (IN `l_id` INT, IN `name` VARCHAR(100), IN `location` VARCHAR(255), IN `start_date` DATETIME, IN `end_date` DATETIME, IN `description` TEXT, IN `date` DATETIME, IN `user` VARCHAR(100), IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
394BEGIN
395
396DECLARE exit handler for sqlexception
397 BEGIN
398 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
399 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
400SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
401SELECT @full_error;
402 SET sukses=0;
403 ROLLBACK;
404END;
405
406DECLARE exit handler for sqlwarning
407 BEGIN
408 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
409 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
410SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
411SELECT @full_error;
412 SET sukses=0;
413 ROLLBACK;
414END;
415 drop temporary table if exists temp_cursor_table;
416 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id FROM crm_users where user_id in(', user_list ,') )');
417 prepare pst from @temp;
418 execute pst;
419 drop prepare pst;
420INSERT INTO `contact_meeting`(`contact_id`, `contact_meeting_name`, `contact_meeting_location`, `contact_meeting_start_date`, `contact_meeting_end_date`, `contact_meeting_description`, `contact_meeting_date`, `contact_meeting_user`) VALUES (l_id,name,location,start_date,end_date,description,date,user);
421 SET @meet_id = LAST_INSERT_ID();
422INSERT INTO `contact_meeting_users`(`contact_meeting_id`,`contact_user_id`)
423 SELECT @meet_id,user_id from temp_cursor_table;
424 drop temporary table if exists temp_cursor_table;
425 set sukses=1;
426COMMIT;
427END$$
428
429CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_contact_meeting_update` (IN `meet_id` INT, IN `l_id` INT, IN `name` VARCHAR(100), IN `location` VARCHAR(255), IN `start_date` DATETIME, IN `end_date` DATETIME, IN `description` TEXT, IN `date` DATETIME, IN `user` VARCHAR(100), IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
430BEGIN
431
432DECLARE exit handler for sqlexception
433 BEGIN
434 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
435 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
436SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
437SELECT @full_error;
438 SET sukses=0;
439 ROLLBACK;
440END;
441
442DECLARE exit handler for sqlwarning
443 BEGIN
444 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
445 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
446SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
447SELECT @full_error;
448 SET sukses=0;
449 ROLLBACK;
450END;
451 drop temporary table if exists temp_cursor_table;
452 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id FROM crm_users where user_id in(', user_list ,') )');
453 prepare pst from @temp;
454 execute pst;
455 drop prepare pst;
456UPDATE `contact_meeting` SET
457`contact_meeting_name`=name,
458`contact_meeting_location`=location,
459`contact_meeting_start_date`=start_date,
460`contact_meeting_end_date`=end_date,
461`contact_meeting_description`=description,
462`contact_meeting_date`=date,
463`contact_meeting_user`=user,
464`contact_id`=l_id
465WHERE `contact_meeting_id`=meet_id;
466delete from contact_meeting_users where contact_meeting_id=meet_id;
467REPLACE INTO `contact_meeting_users`(`contact_meeting_id`,`contact_user_id`)
468 SELECT meet_id,user_id from temp_cursor_table;
469 drop temporary table if exists temp_cursor_table;
470set sukses=1;
471COMMIT;
472END$$
473
474CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_contact_update` (IN `l_id` INT, IN `salutation` ENUM('1','2','3'), IN `first_name` VARCHAR(100), IN `last_name` VARCHAR(100), IN `job_title` VARCHAR(100), IN `company` VARCHAR(100), IN `department` VARCHAR(100), IN `email` VARCHAR(100), IN `office_phone` VARCHAR(30), IN `mobile_phone` VARCHAR(30), IN `industry` INT, IN `address1` VARCHAR(255), IN `address2` VARCHAR(255), IN `city` VARCHAR(100), IN `state` VARCHAR(100), IN `zip_code` VARCHAR(10), IN `country` VARCHAR(50), IN `sources` INT, IN `photo` VARCHAR(100), IN `comp_id` INT, IN `right_permission` ENUM('1','2','3'), IN `groups` INT, IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
475BEGIN
476
477DECLARE exit handler for sqlexception
478 BEGIN
479 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
480 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
481SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
482SELECT @full_error;
483 SET sukses=0;
484 ROLLBACK;
485END;
486
487DECLARE exit handler for sqlwarning
488 BEGIN
489 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
490 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
491SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
492SELECT @full_error;
493 SET sukses=0;
494 ROLLBACK;
495END;
496 drop temporary table if exists temp_cursor_table;
497 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id AS u_id FROM crm_users where user_id in(', user_list ,') )');
498 prepare pst from @temp;
499 execute pst;
500 drop prepare pst;
501 UPDATE `crm_peoples` a JOIN crm_contacts b ON a.people_id=b.people_id
502SET
503a.people_salutation=salutation,
504a.people_first_name=first_name,
505a.people_last_name=last_name,
506a.people_job_title=job_title,
507a.people_company=company,
508a.people_department=department,
509a.people_email=email,
510a.people_office_phone=office_phone,
511a.people_mobile_phone=mobile_phone,
512a.people_industry=industry,
513a.people_address1=address1,
514a.people_address2=address2,
515a.people_city=city,
516a.people_state=state,
517a.people_zip_code=zip_code,
518a.people_country=country,
519a.people_source=sources,
520a.people_photo=photo,
521b.contact_right_permission=right_permission,
522b.contact_groups=groups,
523b.company_id=comp_id
524WHERE b.contact_id = l_id;
525delete from crm_users_contacts where contact_id = l_id;
526REPLACE INTO `crm_users_contacts`(`contact_id`,`user_id`)
527 SELECT l_id,u_id from temp_cursor_table;
528 drop temporary table if exists temp_cursor_table;
529 SET sukses = 1;
530COMMIT;
531END$$
532
533CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_convert_lead` (IN `l_id` INT, IN `comp_id` INT, IN `skip` ENUM('0','1'), IN `c_code` VARCHAR(50), IN `c_parent` INT, IN `c_office_phone` VARCHAR(30), IN `c_industry` INT, IN `c_email` VARCHAR(100), IN `c_fax` VARCHAR(30), IN `c_employee` INT, IN `c_revenue` DOUBLE, IN `c_website` VARCHAR(100), IN `c_address1` VARCHAR(255), IN `c_address2` VARCHAR(255), IN `c_city` VARCHAR(100), IN `c_state` VARCHAR(100), IN `c_zip_code` VARCHAR(10), IN `c_country` VARCHAR(50), IN `c_billing_address1` VARCHAR(255), IN `c_billing_address2` VARCHAR(255), IN `c_billing_city` VARCHAR(100), IN `c_billing_state` VARCHAR(100), IN `c_billing_zip_code` VARCHAR(10), IN `c_billing_country` VARCHAR(50), IN `c_right_permission` ENUM('1','2','3'), IN `c_u_created` VARCHAR(100), IN `c_date_created` DATETIME, IN `c_groups` INT, IN `c_customer` ENUM('0','1'), IN `o_code` VARCHAR(100), IN `o_name` VARCHAR(45), IN `o_stage_id` INT, IN `o_amount` DOUBLE, IN `o_expected_closing_date` DATETIME, IN `o_service` ENUM('1','2'), IN `o_campaign_id` INT, IN `product_list` VARCHAR(300), OUT `sukses` INT) NO SQL
534BEGIN
535
536DECLARE exit handler for sqlexception
537 BEGIN
538 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
539 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
540SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
541SELECT @full_error;
542 SET sukses=0;
543 ROLLBACK;
544END;
545
546DECLARE continue handler for not found set sukses = 0;
547DECLARE exit handler for sqlwarning
548 BEGIN
549 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
550 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
551SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
552SELECT @full_error;
553 SET sukses=0;
554 ROLLBACK;
555END;
556SELECT a.lead_status,b.people_company into @l_status, @company from crm_leads a JOIN crm_peoples b ON a.people_id=b.people_id WHERE a.lead_id=l_id;
557IF comp_id is null THEN
558 SET @comp_id = null;
559ELSE
560SET @comp_id = comp_id;
561END IF;
562IF @l_status= 1 THEN
563 IF @comp_id IS null THEN
564 INSERT INTO `crm_companies`(`customer_code`, `company_name`, `company_parent`, `company_office_phone`, `company_industry`,`company_email`, `company_fax`, `company_employee`, `company_revenue`, `company_website`, `company_address1`, `company_address2`, `company_city`, `company_state`, `company_zip_code`, `company_country`, `company_billing_address1`, `company_billing_address2`, `company_billing_city`, `company_billing_state`, `company_billing_zip_code`, `company_billing_country`, `company_right_permission`, `user_created`, `user_created_date`, `company_groups`, `company_customer`) VALUES
565(c_code, @company, c_parent, c_office_phone, c_industry, c_email, c_fax, c_employee, c_revenue, c_website, c_address1, c_address2, c_city, c_state, c_zip_code, c_country, c_billing_address1, c_billing_address2, c_billing_city, c_billing_state, c_billing_zip_code, c_billing_country, c_right_permission, c_u_created, c_date_created, c_groups, c_customer);
566 set @comp_id = LAST_INSERT_ID();
567 insert into crm_users_companies(company_id, user_id)
568 SELECT @comp_id, user_id from crm_users_leads
569 where lead_id = l_id;
570 END IF;
571 insert into crm_contacts(company_id,people_id,contact_right_permission,contact_groups)
572 SELECT @comp_id,people_id,lead_right_permission,lead_groups from crm_leads where lead_id = l_id;
573 set @c_id = LAST_INSERT_ID();
574 UPDATE crm_leads set lead_status = '2'
575 where lead_id = l_id;
576 insert into crm_users_contacts(contact_id, user_id)
577 SELECT @c_id, user_id from crm_users_leads
578 where lead_id = l_id;
579 IF skip='0' THEN
580 drop temporary table if exists temp_cursor_table;
581 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT product_id AS p_id FROM crm_products where product_id in(', product_list ,') )');
582 prepare pst from @temp;
583 execute pst;
584 drop prepare pst;
585 INSERT INTO `crm_opportunities`(`opportunity_code`,`opportunity_name`, `opportunity_stage_id`, `company_id`, `opportunity_amount`, `opportunity_expected_closing_date`, `opportunity_service`, `opportunity_campaign_id`) VALUES (o_code, o_name, o_stage_id, @comp_id, o_amount, o_expected_closing_date, o_service, o_campaign_id);
586 SET @o_id = LAST_INSERT_ID();
587 INSERT INTO crm_opportunities_contacts(opportunity_id,contact_id) VALUES (@o_id,@c_id);
588 INSERT INTO `crm_opportunities_products`(`opportunity_id`, `product_id`)
589 SELECT @o_id,p_id from temp_cursor_table;
590 drop temporary table if exists temp_cursor_table;
591
592 END IF;
593END if;
594 SET sukses = 1;
595COMMIT;
596END$$
597
598CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_lead_delete` (IN `l_id` INT, OUT `sukses` INT) NO SQL
599BEGIN
600
601DECLARE exit handler for sqlexception
602 BEGIN
603 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
604 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
605SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
606SELECT @full_error;
607 SET sukses=0;
608 ROLLBACK;
609END;
610
611DECLARE exit handler for sqlwarning
612 BEGIN
613 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
614 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
615SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
616SELECT @full_error;
617 SET sukses=0;
618 ROLLBACK;
619END;
620delete from crm_users_leads where lead_id = l_id;
621DELETE crm_peoples, crm_leads
622FROM crm_peoples
623INNER JOIN crm_leads ON crm_peoples.people_id=crm_leads.people_id
624WHERE crm_leads.lead_id=l_id;
625 SET sukses = 1;
626COMMIT;
627END$$
628
629CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_lead_insert` (IN `salutation` ENUM('1','2','3'), IN `first_name` VARCHAR(100), IN `last_name` VARCHAR(100), IN `job_title` VARCHAR(100), IN `company` VARCHAR(100), IN `department` VARCHAR(100), IN `email` VARCHAR(100), IN `office_phone` VARCHAR(30), IN `mobile_phone` VARCHAR(30), IN `industry` INT, IN `address1` VARCHAR(255), IN `address2` VARCHAR(255), IN `city` VARCHAR(100), IN `state` VARCHAR(100), IN `zip_code` VARCHAR(10), IN `country` VARCHAR(50), IN `sources` INT, IN `photo` VARCHAR(100), IN `stat` ENUM('1','2'), IN `label` INT, IN `right_permission` ENUM('1','2','3'), IN `groups` INT, IN `u_created` VARCHAR(100), IN `date_created` DATETIME, IN `user_list` VARCHAR(300), OUT `sukses` INT, OUT `l_id` INT) NO SQL
630BEGIN
631
632DECLARE exit handler for sqlexception
633 BEGIN
634 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
635 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
636SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
637SELECT @full_error;
638 SET sukses=0;
639 ROLLBACK;
640END;
641
642DECLARE exit handler for sqlwarning
643 BEGIN
644 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
645 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
646SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
647SELECT @full_error;
648 SET sukses=0;
649 ROLLBACK;
650END;
651 drop temporary table if exists temp_cursor_table;
652 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id AS u_id FROM crm_users where user_id in(', user_list ,') )');
653 prepare pst from @temp;
654 execute pst;
655 drop prepare pst;
656
657 INSERT INTO `crm_peoples`(`people_salutation`, `people_first_name`, `people_last_name`, `people_job_title`, `people_company`, `people_department`, `people_email`, `people_office_phone`, `people_mobile_phone`, `people_industry`, `people_address1`, `people_address2`, `people_city`, `people_state`, `people_zip_code`, `people_country`, `people_source`, `people_photo`, `people_status`) VALUES (salutation, first_name, last_name, job_title, company, department, email, office_phone, mobile_phone, industry, address1, address2, city, state, zip_code, country, sources, photo, stat);
658 SET @p_id = LAST_INSERT_ID();
659INSERT INTO `crm_leads`(`lead_label`, `people_id`, `lead_right_permission`, `lead_groups`, `user_created`, `user_created_date`) VALUES (label, @p_id, right_permission, groups, u_created, date_created);
660SET l_id = LAST_INSERT_ID();
661INSERT INTO `crm_users_leads`(`lead_id`,`user_id`)
662 SELECT l_id,u_id from temp_cursor_table;
663 drop temporary table if exists temp_cursor_table;
664 SET sukses = 1;
665COMMIT;
666END$$
667
668CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_lead_meeting_delete` (IN `meet_id` INT, OUT `sukses` INT) NO SQL
669BEGIN
670
671
672DECLARE exit handler for sqlexception
673 BEGIN
674 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
675 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
676SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
677SELECT @full_error;
678 SET sukses=0;
679 ROLLBACK;
680END;
681
682DECLARE exit handler for sqlwarning
683 BEGIN
684 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
685 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
686SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
687SELECT @full_error;
688 SET sukses=0;
689 ROLLBACK;
690END;
691
692START TRANSACTION;
693 DELETE FROM lead_meeting_users WHERE lead_meeting_id = meet_id;
694 DELETE FROM lead_meeting WHERE lead_meeting_id = meet_id;
695 SET sukses = 1;
696COMMIT;
697END$$
698
699CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_lead_meeting_insert` (IN `l_id` INT, IN `name` VARCHAR(100), IN `location` VARCHAR(255), IN `start_date` DATETIME, IN `end_date` DATETIME, IN `description` TEXT, IN `date` DATETIME, IN `user` VARCHAR(100), IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
700BEGIN
701
702DECLARE exit handler for sqlexception
703 BEGIN
704 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
705 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
706SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
707SELECT @full_error;
708 SET sukses=0;
709 ROLLBACK;
710END;
711
712DECLARE exit handler for sqlwarning
713 BEGIN
714 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
715 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
716SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
717SELECT @full_error;
718 SET sukses=0;
719 ROLLBACK;
720END;
721 drop temporary table if exists temp_cursor_table;
722 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id FROM crm_users where user_id in(', user_list ,') )');
723 prepare pst from @temp;
724 execute pst;
725 drop prepare pst;
726INSERT INTO `lead_meeting`(`lead_id`, `lead_meeting_name`, `lead_meeting_location`, `lead_meeting_start_date`, `lead_meeting_end_date`, `lead_meeting_description`, `lead_meeting_date`, `lead_meeting_user`) VALUES (l_id,name,location,start_date,end_date,description,date,user);
727 SET @meet_id = LAST_INSERT_ID();
728INSERT INTO `lead_meeting_users`(`lead_meeting_id`,`lead_user_id`)
729 SELECT @meet_id,user_id from temp_cursor_table;
730 drop temporary table if exists temp_cursor_table;
731 set sukses=1;
732COMMIT;
733END$$
734
735CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_lead_meeting_update` (IN `meet_id` INT, IN `l_id` INT, IN `name` VARCHAR(100), IN `location` VARCHAR(255), IN `start_date` DATETIME, IN `end_date` DATETIME, IN `description` TEXT, IN `date` DATETIME, IN `user` VARCHAR(100), IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
736BEGIN
737
738DECLARE exit handler for sqlexception
739 BEGIN
740 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
741 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
742SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
743SELECT @full_error;
744 SET sukses=0;
745 ROLLBACK;
746END;
747
748DECLARE exit handler for sqlwarning
749 BEGIN
750 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
751 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
752SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
753SELECT @full_error;
754 SET sukses=0;
755 ROLLBACK;
756END;
757 drop temporary table if exists temp_cursor_table;
758 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id FROM crm_users where user_id in(', user_list ,') )');
759 prepare pst from @temp;
760 execute pst;
761 drop prepare pst;
762UPDATE `lead_meeting` SET
763`lead_meeting_name`=name,
764`lead_meeting_location`=location,
765`lead_meeting_start_date`=start_date,
766`lead_meeting_end_date`=end_date,
767`lead_meeting_description`=description,
768`lead_meeting_date`=date,
769`lead_meeting_user`=user,
770`lead_id`=l_id
771WHERE `lead_meeting_id`=meet_id;
772delete from lead_meeting_users where lead_meeting_id=meet_id;
773REPLACE INTO `lead_meeting_users`(`lead_meeting_id`,`lead_user_id`)
774 SELECT meet_id,user_id from temp_cursor_table;
775 drop temporary table if exists temp_cursor_table;
776set sukses=1;
777COMMIT;
778END$$
779
780CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_lead_update` (IN `l_id` INT, IN `salutation` ENUM('1','2','3'), IN `first_name` VARCHAR(100), IN `last_name` VARCHAR(100), IN `job_title` VARCHAR(100), IN `company` VARCHAR(100), IN `department` VARCHAR(100), IN `email` VARCHAR(100), IN `office_phone` VARCHAR(30), IN `mobile_phone` VARCHAR(30), IN `industry` INT, IN `address1` VARCHAR(255), IN `address2` VARCHAR(255), IN `city` VARCHAR(100), IN `state` VARCHAR(100), IN `zip_code` VARCHAR(10), IN `country` VARCHAR(50), IN `sources` INT, IN `photo` VARCHAR(100), IN `status_p` ENUM('1','2'), IN `status_l` ENUM('1','2','3'), IN `label` INT, IN `right_permission` ENUM('1','2','3'), IN `groups` INT, IN `u_modified` VARCHAR(100), IN `date_modified` DATETIME, IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
781BEGIN
782
783DECLARE exit handler for sqlexception
784 BEGIN
785 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
786 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
787SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
788SELECT @full_error;
789 SET sukses=0;
790 ROLLBACK;
791END;
792
793DECLARE exit handler for sqlwarning
794 BEGIN
795 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
796 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
797SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
798SELECT @full_error;
799 SET sukses=0;
800 ROLLBACK;
801END;
802 drop temporary table if exists temp_cursor_table;
803 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id AS u_id FROM crm_users where user_id in(', user_list ,') )');
804 prepare pst from @temp;
805 execute pst;
806 drop prepare pst;
807 UPDATE `crm_peoples` a JOIN crm_leads b ON a.people_id=b.people_id
808SET
809a.people_salutation=salutation,
810a.people_first_name=first_name,
811a.people_last_name=last_name,
812a.people_job_title=job_title,
813a.people_company=company,
814a.people_department=department,
815a.people_email=email,
816a.people_office_phone=office_phone,
817a.people_mobile_phone=mobile_phone,
818a.people_industry=industry,
819a.people_address1=address1,
820a.people_address2=address2,
821a.people_city=city,
822a.people_state=state,
823a.people_zip_code=zip_code,
824a.people_country=country,
825a.people_source=sources,
826a.people_photo=photo,
827a.people_status = status_p,
828b.lead_label=label,
829b.lead_right_permission=right_permission,
830b.lead_groups=groups,
831b.lead_status=status_l,
832b.user_modified=u_modified,
833b.user_modified_date=date_modified
834WHERE b.lead_id = l_id;
835delete from crm_users_leads where lead_id = l_id;
836REPLACE INTO `crm_users_leads`(`lead_id`,`user_id`)
837 SELECT l_id,u_id from temp_cursor_table;
838 drop temporary table if exists temp_cursor_table;
839 SET sukses = 1;
840COMMIT;
841END$$
842
843CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_opportunity_insert` (IN `code` VARCHAR(100), IN `name` VARCHAR(45), IN `stage_id` INT, IN `comp_id` INT, IN `amount` DOUBLE, IN `expected_closing_date` DATETIME, IN `service` ENUM('1','2'), IN `campaign_id` INT, IN `product_list` VARCHAR(300), IN `contact_list` VARCHAR(300), OUT `sukses` INT) NO SQL
844BEGIN
845
846DECLARE exit handler for sqlexception
847 BEGIN
848 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
849 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
850SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
851SELECT @full_error;
852 SET sukses=0;
853 ROLLBACK;
854END;
855
856DECLARE exit handler for sqlwarning
857 BEGIN
858 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
859 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
860SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
861SELECT @full_error;
862 SET sukses=0;
863 ROLLBACK;
864END;
865 drop temporary table if exists temp_cursor_table;
866 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT product_id AS p_id FROM crm_products where product_id in(', product_list ,') )');
867 prepare pst from @temp;
868 execute pst;
869 drop prepare pst;
870 drop temporary table if exists temp_contact;
871 set @temp1 = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_contact AS (SELECT contact_id AS c_id FROM crm_contacts where contact_id in(', contact_list ,') )');
872 prepare pst from @temp1;
873 execute pst;
874 drop prepare pst;
875
876 INSERT INTO `crm_opportunities`(`opportunity_code`, `opportunity_name`, `opportunity_stage_id`, `company_id`, `opportunity_amount`, `opportunity_expected_closing_date`, `opportunity_service`, `opportunity_campaign_id`) VALUES (code, name, stage_id, comp_id, amount, expected_closing_date, service, campaign_id);
877SET @o_id = LAST_INSERT_ID();
878INSERT INTO crm_opportunities_contacts(opportunity_id,contact_id)
879 SELECT @o_id,c_id from temp_contact;
880INSERT INTO `crm_opportunities_products`(`opportunity_id`, `product_id`)
881 SELECT @o_id,p_id from temp_cursor_table;
882 drop temporary table if exists temp_cursor_table;
883 drop temporary table if exists temp_contact;
884 SET sukses = 1;
885COMMIT;
886END$$
887
888CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_opportunity_meeting_delete` (IN `meet_id` INT, OUT `sukses` INT) NO SQL
889BEGIN
890
891
892DECLARE exit handler for sqlexception
893 BEGIN
894 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
895 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
896SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
897SELECT @full_error;
898 SET sukses=0;
899 ROLLBACK;
900END;
901
902DECLARE exit handler for sqlwarning
903 BEGIN
904 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
905 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
906SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
907SELECT @full_error;
908 SET sukses=0;
909 ROLLBACK;
910END;
911
912START TRANSACTION;
913 DELETE FROM opportunity_meeting_users WHERE opportunity_meeting_id = meet_id;
914 DELETE FROM opportunity_meeting WHERE opportunity_meeting_id = meet_id;
915 SET sukses = 1;
916COMMIT;
917END$$
918
919CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_opportunity_meeting_insert` (IN `o_id` INT, IN `name` VARCHAR(100), IN `location` VARCHAR(255), IN `start_date` DATETIME, IN `end_date` DATETIME, IN `description` TEXT, IN `date` DATETIME, IN `user` VARCHAR(100), IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
920BEGIN
921
922DECLARE exit handler for sqlexception
923 BEGIN
924 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
925 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
926SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
927SELECT @full_error;
928 SET sukses=0;
929 ROLLBACK;
930END;
931
932DECLARE exit handler for sqlwarning
933 BEGIN
934 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
935 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
936SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
937SELECT @full_error;
938 SET sukses=0;
939 ROLLBACK;
940END;
941 drop temporary table if exists temp_cursor_table;
942 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id FROM crm_users where user_id in(', user_list ,') )');
943 prepare pst from @temp;
944 execute pst;
945 drop prepare pst;
946INSERT INTO `opportunity_meeting`(`opportunity_id`, `opportunity_meeting_name`, `opportunity_meeting_location`, `opportunity_meeting_start_date`, `opportunity_meeting_end_date`, `opportunity_meeting_description`, `opportunity_meeting_date`, `opportunity_meeting_user`) VALUES (o_id,name,location,start_date,end_date,description,date,user);
947 SET @meet_id = LAST_INSERT_ID();
948INSERT INTO `opportunity_meeting_users`(`opportunity_meeting_id`,`opportunity_user_id`)
949 SELECT @meet_id,user_id from temp_cursor_table;
950 drop temporary table if exists temp_cursor_table;
951 set sukses=1;
952COMMIT;
953END$$
954
955CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_opportunity_meeting_update` (IN `meet_id` INT, IN `o_id` INT, IN `name` VARCHAR(100), IN `location` VARCHAR(255), IN `start_date` DATETIME, IN `end_date` DATETIME, IN `description` TEXT, IN `date` DATETIME, IN `user` VARCHAR(100), IN `user_list` VARCHAR(300), OUT `sukses` INT) NO SQL
956BEGIN
957
958DECLARE exit handler for sqlexception
959 BEGIN
960 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
961 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
962SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
963SELECT @full_error;
964 SET sukses=0;
965 ROLLBACK;
966END;
967
968DECLARE exit handler for sqlwarning
969 BEGIN
970 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
971 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
972SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
973SELECT @full_error;
974 SET sukses=0;
975 ROLLBACK;
976END;
977 drop temporary table if exists temp_cursor_table;
978 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT user_id FROM crm_users where user_id in(', user_list ,') )');
979 prepare pst from @temp;
980 execute pst;
981 drop prepare pst;
982UPDATE `opportunity_meeting` SET
983`opportunity_meeting_name`=name,
984`opportunity_meeting_location`=location,
985`opportunity_meeting_start_date`=start_date,
986`opportunity_meeting_end_date`=end_date,
987`opportunity_meeting_description`=description,
988`opportunity_meeting_date`=date,
989`opportunity_meeting_user`=user,
990`opportunity_id`=o_id
991WHERE `opportunity_meeting_id`=meet_id;
992delete from opportunity_meeting_users where opportunity_meeting_id=meet_id;
993REPLACE INTO `opportunity_meeting_users`(`opportunity_meeting_id`,`opportunity_user_id`)
994 SELECT meet_id,user_id from temp_cursor_table;
995 drop temporary table if exists temp_cursor_table;
996set sukses=1;
997COMMIT;
998END$$
999
1000CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_opportunity_update` (IN `o_id` INT, IN `name` VARCHAR(45), IN `stage_id` INT, IN `comp_id` INT, IN `amount` DOUBLE, IN `expected_closing_date` DATETIME, IN `service` ENUM('1','2'), IN `campaign_id` INT, IN `product_list` VARCHAR(300), IN `contact_list` VARCHAR(300), OUT `sukses` INT) NO SQL
1001BEGIN
1002
1003DECLARE exit handler for sqlexception
1004 BEGIN
1005 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
1006 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
1007SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
1008SELECT @full_error;
1009 SET sukses=0;
1010 ROLLBACK;
1011END;
1012
1013DECLARE exit handler for sqlwarning
1014 BEGIN
1015 GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
1016 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
1017SET @full_error = CONCAT("Warning ", @errno, " (", @sqlstate, "): ", @text);
1018SELECT @full_error;
1019 SET sukses=0;
1020 ROLLBACK;
1021END;
1022 drop temporary table if exists temp_cursor_table;
1023 set @temp = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_cursor_table AS (SELECT product_id AS p_id FROM crm_products where product_id in(', product_list ,') )');
1024 prepare pst from @temp;
1025 execute pst;
1026 drop prepare pst;
1027 drop temporary table if exists temp_contact;
1028 set @temp1 = concat('CREATE TEMPORARY TABLE IF NOT EXISTS temp_contact AS (SELECT contact_id AS c_id FROM crm_contacts where contact_id in(', contact_list ,') )');
1029 prepare pst from @temp1;
1030 execute pst;
1031 drop prepare pst;
1032UPDATE `crm_opportunities` SET
1033`opportunity_name`=name,
1034`opportunity_stage_id`=stage_id,
1035`company_id`=comp_id,
1036`opportunity_amount`=amount,
1037`opportunity_expected_closing_date`=expected_closing_date,
1038`opportunity_service`=service,
1039`opportunity_campaign_id`=campaign_id
1040WHERE `opportunity_id`=o_id;
1041delete from crm_opportunities_products where opportunity_id = o_id;
1042REPLACE INTO `crm_opportunities_products`(`opportunity_id`, `product_id`)
1043 SELECT o_id,p_id from temp_cursor_table;
1044REPLACE INTO crm_opportunities_contacts(opportunity_id,contact_id)
1045 SELECT o_id,c_id from temp_contact;
1046 drop temporary table if exists temp_cursor_table;
1047 drop temporary table if exists temp_contact;
1048 SET sukses = 1;
1049COMMIT;
1050END$$
1051
1052CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_recuring_invoice` () BEGIN
1053
1054 DECLARE v_finished INTEGER DEFAULT 0;
1055 DECLARE inv_id INTEGER DEFAULT 0;
1056 DECLARE inv_repeat_type VARCHAR(5) DEFAULT "";
1057 DECLARE next_date DATE;
1058 DECLARE next_date_2 DATE;
1059 DECLARE inv_disc_type VARCHAR(2) DEFAULT "";
1060 DECLARE inv_disc_value DOUBLE DEFAULT 0;
1061 DECLARE inv_tax_percentage INTEGER DEFAULT 0;
1062 DECLARE inv_adj DOUBLE DEFAULT 0;
1063 DECLARE inv_type VARCHAR(2) DEFAULT "";
1064 DECLARE inv_cycle INTEGER DEFAULT 0;
1065 DECLARE inv_code VARCHAR(20);
1066 DECLARE repeat_inv INTEGER DEFAULT 0;
1067
1068 DEClARE invoice_cursor CURSOR FOR
1069 SELECT
1070 a.invoice_id,
1071 a.next_invoice_date,
1072 a.repeat_invoice,
1073 b.invoice_repeat_type,
1074 c.invoice_discount_type,
1075 c.invoice_discount_value,
1076 c.invoice_tax_percentage,
1077 c.invoice_adjustment,
1078 c.invoice_type,
1079 c.invoice_cycle
1080 FROM
1081 invoice_control a
1082 LEFT JOIN
1083 crm_invoices b ON a.invoice_id = b.invoice_id
1084 LEFT JOIN
1085 crm_invoice_details c ON b.invoice_id = c.invoice_id
1086 WHERE
1087 a.next_invoice_date = CURDATE() AND (b.invoice_end_date > NOW() OR b.invoice_expired = '1') AND b.invoice_type = '2' AND a.repeat_invoice > 0;
1088
1089 DECLARE CONTINUE HANDLER
1090 FOR NOT FOUND SET v_finished = 1;
1091
1092 OPEN invoice_cursor;
1093
1094 get_invoice: LOOP
1095
1096 FETCH invoice_cursor INTO inv_id, next_date, repeat_inv, inv_repeat_type, inv_disc_type, inv_disc_value, inv_tax_percentage, inv_adj, inv_type, inv_cycle;
1097 SET @invoice_id = inv_id;
1098
1099 SET @inv_detail_id = (SELECT invoice_detail_id FROM crm_invoice_details WHERE invoice_id = @invoice_id ORDER BY invoice_detail_id DESC LIMIT 1);
1100
1101 SET @n_inv = repeat_inv - 1;
1102
1103 IF v_finished = 1 THEN
1104 LEAVE get_invoice;
1105 END IF;
1106
1107 SET inv_code = make_inv_code();
1108
1109 IF inv_repeat_type = '1' THEN
1110 SET next_date_2 = TIMESTAMPADD(DAY, 1, next_date);
1111 ELSEIF inv_repeat_type = '2' THEN
1112 SET next_date_2 = TIMESTAMPADD(WEEK, 1, next_date);
1113 ELSE
1114 SET next_date_2 = TIMESTAMPADD(MONTH, 1, next_date);
1115 END IF;
1116
1117INSERT INTO crm_invoice_details(`invoice_code`,`invoice_id`,`invoice_date`,`invoice_due_date`,`invoice_discount_type`,`invoice_discount_value`,`invoice_tax_percentage`,`invoice_adjustment`,`invoice_type`,`invoice_cycle`) VALUES (inv_code, inv_id, NOW(), null, inv_disc_type, inv_disc_value, inv_tax_percentage, inv_adj, inv_type, inv_cycle);
1118
1119SET @l_id = LAST_INSERT_ID();
1120
1121INSERT INTO crm_invoices_products(`invoice_detail_id`,`product_id`,`qty`, `price`, `is_campaign`) SELECT @l_id, product_id, qty, price, is_campaign FROM crm_invoices_products WHERE invoice_detail_id = @inv_detail_id;
1122
1123 UPDATE invoice_control SET next_invoice_date = next_date_2, repeat_invoice = @n_inv WHERE invoice_id = @invoice_id;
1124
1125 END LOOP get_invoice;
1126
1127 CLOSE invoice_cursor;
1128END$$
1129
1130--
1131-- Functions
1132--
1133CREATE DEFINER=`root`@`localhost` FUNCTION `make_inv_code` () RETURNS VARCHAR(20) CHARSET latin1 BEGIN
1134SET
1135 @date_param =(
1136 SELECT DATE_FORMAT
1137 (CURDATE(),
1138 "%m%y")) ;
1139 SET
1140 @inv_code =(
1141 SELECT
1142 invoice_code
1143 FROM
1144 crm_invoice_details
1145 WHERE
1146 invoice_code LIKE CONCAT('%',
1147 @date_param,
1148 '%')
1149 ORDER BY
1150 invoice_detail_id DESC
1151 LIMIT 1
1152 ) ; IF @inv_code IS NULL THEN
1153SET
1154 @new_inv_code = CONCAT('INV-',
1155 @date_param,
1156 '00001') ; ELSE
1157SET
1158 @new_numb_code =(
1159 SELECT SUBSTRING_INDEX
1160 (@inv_code,
1161 '-',
1162 -1)
1163) ;
1164SET
1165 @new_code = @new_numb_code + 1 ;
1166SET
1167 @sub_code = SUBSTRING(@new_code,
1168 -5) ;
1169SET
1170 @new_inv_code = CONCAT('INV-',
1171 @date_param,
1172 @sub_code) ;
1173END IF ;
1174RETURN
1175 @new_inv_code ;
1176END$$
1177
1178DELIMITER ;
1179
1180-- --------------------------------------------------------
1181
1182--
1183-- Table structure for table `coba`
1184--
1185
1186CREATE TABLE `coba` (
1187 `id` int(11) NOT NULL,
1188 `code` varchar(110) NOT NULL,
1189 `date` date NOT NULL
1190) ENGINE=InnoDB DEFAULT CHARSET=latin1;
1191
1192--
1193-- Dumping data for table `coba`
1194--
1195
1196INSERT INTO `coba` (`id`, `code`, `date`) VALUES
1197(1, 'INV-091700001', '2017-09-08'),
1198(2, 'INV-091700001', '2017-09-14');
1199
1200-- --------------------------------------------------------
1201
1202--
1203-- Table structure for table `company_calls`
1204--
1205
1206CREATE TABLE `company_calls` (
1207 `company_call_id` int(11) NOT NULL,
1208 `company_call_title` varchar(100) DEFAULT NULL,
1209 `company_call_duration` int(11) DEFAULT NULL,
1210 `company_call_time` enum('1','2','3') DEFAULT '1' COMMENT '1= Second\n2= Minutes\n3=Hour\n',
1211 `company_call_notes` text,
1212 `company_call_date` datetime NOT NULL,
1213 `company_call_user` varchar(100) NOT NULL,
1214 `company_id` int(11) NOT NULL
1215) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1216
1217-- --------------------------------------------------------
1218
1219--
1220-- Table structure for table `company_files`
1221--
1222
1223CREATE TABLE `company_files` (
1224 `company_files_id` int(11) NOT NULL,
1225 `company_file_subject` varchar(100) DEFAULT NULL,
1226 `company_file_to` varchar(100) NOT NULL,
1227 `company_file_cc` varchar(100) DEFAULT NULL,
1228 `company_file_description` text,
1229 `company_file_name` varchar(100) NOT NULL,
1230 `company_file_date` datetime NOT NULL,
1231 `company_file_user` varchar(100) NOT NULL,
1232 `company_id` int(11) NOT NULL
1233) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1234
1235-- --------------------------------------------------------
1236
1237--
1238-- Table structure for table `company_meeting`
1239--
1240
1241CREATE TABLE `company_meeting` (
1242 `company_meeting_id` int(11) NOT NULL,
1243 `company_meeting_name` varchar(100) DEFAULT NULL,
1244 `company_meeting_location` varchar(255) DEFAULT NULL,
1245 `company_meeting_start_date` datetime DEFAULT NULL,
1246 `company_meeting_end_date` datetime DEFAULT NULL,
1247 `company_meeting_description` text,
1248 `company_meeting_date` datetime NOT NULL,
1249 `company_meeting_user` varchar(100) NOT NULL,
1250 `company_id` int(11) NOT NULL
1251) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1252
1253-- --------------------------------------------------------
1254
1255--
1256-- Table structure for table `company_meeting_users`
1257--
1258
1259CREATE TABLE `company_meeting_users` (
1260 `company_meeting_id` int(11) NOT NULL,
1261 `company_user_id` int(11) NOT NULL
1262) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1263
1264-- --------------------------------------------------------
1265
1266--
1267-- Table structure for table `company_notes`
1268--
1269
1270CREATE TABLE `company_notes` (
1271 `company_note_id` int(11) NOT NULL,
1272 `company_note_name` varchar(100) NOT NULL,
1273 `company_note_description` text,
1274 `company_note_date` datetime DEFAULT NULL,
1275 `company_note_user` varchar(100) DEFAULT NULL,
1276 `company_id` int(11) NOT NULL
1277) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1278
1279--
1280-- Dumping data for table `company_notes`
1281--
1282
1283INSERT INTO `company_notes` (`company_note_id`, `company_note_name`, `company_note_description`, `company_note_date`, `company_note_user`, `company_id`) VALUES
1284(1, 'tes', '<p><span style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; letter-spacing: normal;">and the emergence of Chichén Itzá altered the political spectrum in the Yucatán peninsula and began eroding the dominance of Coba. Beginning around 900 or 1000 AD</span><br></p>', '2017-08-29 06:01:08', 'adiputra', 1);
1285
1286-- --------------------------------------------------------
1287
1288--
1289-- Table structure for table `company_tasks`
1290--
1291
1292CREATE TABLE `company_tasks` (
1293 `company_task_id` int(11) NOT NULL,
1294 `company_task_name` varchar(100) NOT NULL,
1295 `company_task_description` varchar(45) DEFAULT NULL,
1296 `company_task_status` int(11) DEFAULT NULL,
1297 `company_task_due_date` datetime DEFAULT NULL,
1298 `company_task_date` datetime NOT NULL,
1299 `company_task_user` varchar(100) NOT NULL,
1300 `company_id` int(11) NOT NULL
1301) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1302
1303--
1304-- Dumping data for table `company_tasks`
1305--
1306
1307INSERT INTO `company_tasks` (`company_task_id`, `company_task_name`, `company_task_description`, `company_task_status`, `company_task_due_date`, `company_task_date`, `company_task_user`, `company_id`) VALUES
1308(1, 'tes 1', 'company', 30, '2017-08-29 00:00:00', '2017-08-29 06:00:56', 'adiputra', 1);
1309
1310-- --------------------------------------------------------
1311
1312--
1313-- Table structure for table `contact_calls`
1314--
1315
1316CREATE TABLE `contact_calls` (
1317 `contact_call_id` int(11) NOT NULL,
1318 `contact_call_title` varchar(100) DEFAULT NULL,
1319 `contact_call_duration` int(11) DEFAULT NULL,
1320 `contact_call_time` enum('1','2','3') DEFAULT '1' COMMENT '1= Second\n2= Minutes\n3=Hour\n',
1321 `contact_call_notes` text,
1322 `contact_call_date` datetime NOT NULL,
1323 `contact_call_user` varchar(100) NOT NULL,
1324 `contact_id` int(11) NOT NULL
1325) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1326
1327--
1328-- Dumping data for table `contact_calls`
1329--
1330
1331INSERT INTO `contact_calls` (`contact_call_id`, `contact_call_title`, `contact_call_duration`, `contact_call_time`, `contact_call_notes`, `contact_call_date`, `contact_call_user`, `contact_id`) VALUES
1332(1, 'call log', 3, '2', 'disini', '2017-08-29 04:23:14', 'adiputra', 1),
1333(2, 'new call', 30, '1', 'ini adalah sesuatu yang berharga', '2017-08-29 05:59:31', 'adiputra', 1);
1334
1335-- --------------------------------------------------------
1336
1337--
1338-- Table structure for table `contact_files`
1339--
1340
1341CREATE TABLE `contact_files` (
1342 `contact_files_id` int(11) NOT NULL,
1343 `contact_file_subject` varchar(100) DEFAULT NULL,
1344 `contact_file_to` varchar(100) NOT NULL,
1345 `contact_file_cc` varchar(100) DEFAULT NULL,
1346 `contact_file_description` text,
1347 `contact_file_name` varchar(100) NOT NULL,
1348 `contact_file_date` datetime NOT NULL,
1349 `contact_file_user` varchar(100) NOT NULL,
1350 `contact_id` int(11) NOT NULL
1351) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1352
1353--
1354-- Dumping data for table `contact_files`
1355--
1356
1357INSERT INTO `contact_files` (`contact_files_id`, `contact_file_subject`, `contact_file_to`, `contact_file_cc`, `contact_file_description`, `contact_file_name`, `contact_file_date`, `contact_file_user`, `contact_id`) VALUES
1358(1, 'new file', 'faisnasrullah@yahoo.com', 'adiputra@gmail.com,muh.aliusman@yahoo.co.id', 'dasdas', 'd61fb677-7221-43bc-9877-631981ceb120.pdf', '2017-08-29 05:56:56', 'adiputra', 1);
1359
1360-- --------------------------------------------------------
1361
1362--
1363-- Table structure for table `contact_meeting`
1364--
1365
1366CREATE TABLE `contact_meeting` (
1367 `contact_meeting_id` int(11) NOT NULL,
1368 `contact_meeting_name` varchar(100) DEFAULT NULL,
1369 `contact_meeting_location` varchar(255) DEFAULT NULL,
1370 `contact_meeting_start_date` datetime DEFAULT NULL,
1371 `contact_meeting_end_date` datetime DEFAULT NULL,
1372 `contact_meeting_description` text,
1373 `contact_meeting_date` datetime NOT NULL,
1374 `contact_meeting_user` varchar(100) NOT NULL,
1375 `contact_id` int(11) NOT NULL
1376) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1377
1378--
1379-- Dumping data for table `contact_meeting`
1380--
1381
1382INSERT INTO `contact_meeting` (`contact_meeting_id`, `contact_meeting_name`, `contact_meeting_location`, `contact_meeting_start_date`, `contact_meeting_end_date`, `contact_meeting_description`, `contact_meeting_date`, `contact_meeting_user`, `contact_id`) VALUES
1383(1, 'coba', 'jakrta', '2017-08-29 00:00:00', '2017-08-29 00:00:00', 'coba aja', '2017-08-29 05:59:53', 'adiputra', 1);
1384
1385-- --------------------------------------------------------
1386
1387--
1388-- Table structure for table `contact_meeting_users`
1389--
1390
1391CREATE TABLE `contact_meeting_users` (
1392 `contact_meeting_id` int(11) NOT NULL,
1393 `contact_user_id` int(11) NOT NULL
1394) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1395
1396--
1397-- Dumping data for table `contact_meeting_users`
1398--
1399
1400INSERT INTO `contact_meeting_users` (`contact_meeting_id`, `contact_user_id`) VALUES
1401(1, 18);
1402
1403-- --------------------------------------------------------
1404
1405--
1406-- Table structure for table `contact_notes`
1407--
1408
1409CREATE TABLE `contact_notes` (
1410 `contact_note_id` int(11) NOT NULL,
1411 `contact_note_name` varchar(100) NOT NULL,
1412 `contact_note_description` text,
1413 `contact_note_date` datetime DEFAULT NULL,
1414 `contact_note_user` varchar(100) DEFAULT NULL,
1415 `contact_id` int(11) NOT NULL
1416) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1417
1418-- --------------------------------------------------------
1419
1420--
1421-- Table structure for table `contact_tasks`
1422--
1423
1424CREATE TABLE `contact_tasks` (
1425 `contact_task_id` int(11) NOT NULL,
1426 `contact_task_name` varchar(100) NOT NULL,
1427 `contact_task_description` varchar(45) DEFAULT NULL,
1428 `contact_task_status` int(11) DEFAULT NULL,
1429 `contact_task_due_date` datetime DEFAULT NULL,
1430 `contact_task_date` datetime NOT NULL,
1431 `contact_task_user` varchar(100) NOT NULL,
1432 `contact_id` int(11) NOT NULL
1433) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1434
1435--
1436-- Dumping data for table `contact_tasks`
1437--
1438
1439INSERT INTO `contact_tasks` (`contact_task_id`, `contact_task_name`, `contact_task_description`, `contact_task_status`, `contact_task_due_date`, `contact_task_date`, `contact_task_user`, `contact_id`) VALUES
1440(1, 'new task', '12345678', 90, '2017-08-29 00:00:00', '2017-08-29 05:56:26', 'adiputra', 1);
1441
1442-- --------------------------------------------------------
1443
1444--
1445-- Table structure for table `crm_campaigns`
1446--
1447
1448CREATE TABLE `crm_campaigns` (
1449 `campaign_id` int(11) NOT NULL,
1450 `campaign_name` varchar(100) NOT NULL,
1451 `campaign_description` text,
1452 `campaign_start_date` date DEFAULT NULL,
1453 `campaign_end_date` date DEFAULT NULL,
1454 `campaign_status` enum('0','1') DEFAULT '0' COMMENT '0=Non aktif\n1= Aktif\n\n',
1455 `campaign_number` int(11) DEFAULT NULL,
1456 `campaign_percentage_response` double DEFAULT NULL,
1457 `campaign_budget_cost_currency` enum('1','2') DEFAULT NULL COMMENT '1= USD\n2 = IDR ',
1458 `campaign_budget_cost` double DEFAULT NULL,
1459 `campaign_actual_cost_currency` enum('1','2') DEFAULT NULL COMMENT '1= USD\n2 = IDR ',
1460 `campaign_actual_cost` double DEFAULT NULL,
1461 `campaign_expected_revenue_currency` enum('1','2') DEFAULT NULL COMMENT '1= USD\n2 = IDR ',
1462 `campaign_expected_revenue` double DEFAULT NULL,
1463 `user_created` varchar(100) DEFAULT NULL,
1464 `user_created_date` datetime DEFAULT NULL,
1465 `user_modified` varchar(100) DEFAULT NULL,
1466 `user_modified_date` datetime DEFAULT NULL
1467) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1468
1469--
1470-- Dumping data for table `crm_campaigns`
1471--
1472
1473INSERT INTO `crm_campaigns` (`campaign_id`, `campaign_name`, `campaign_description`, `campaign_start_date`, `campaign_end_date`, `campaign_status`, `campaign_number`, `campaign_percentage_response`, `campaign_budget_cost_currency`, `campaign_budget_cost`, `campaign_actual_cost_currency`, `campaign_actual_cost`, `campaign_expected_revenue_currency`, `campaign_expected_revenue`, `user_created`, `user_created_date`, `user_modified`, `user_modified_date`) VALUES
1474(1, 'Promo Hari Raya', 'Diskon untuk beberapa produk', '2017-08-28', '2017-08-29', '1', 400, 100, '1', 60000000, '1', 50000000, '1', 100000000, 'parinussa', '2017-08-28 16:59:04', NULL, NULL),
1475(2, 'Promo Liburan', 'deskripsi', '2017-08-29', '2017-09-04', '1', 70, 70, '1', 50000000, '1', 40000000, '1', 70000000, 'adiputra', '2017-08-29 08:25:29', NULL, NULL),
1476(4, 'SDYOC', 'sdyoc 25 %', '2017-09-03', '2017-09-12', '1', 50, 84, '1', 70000000, '1', 80000000, '1', 84000000, 'parinussa', '2017-09-06 03:50:57', NULL, '2017-09-06 04:15:10'),
1477(5, 'Sibling', 'discount 20% for sibling', '2017-09-06', '2017-09-07', '1', 70, 50, '1', 40000000, '1', 30000000, '1', 50000000, 'parinussa', '2017-09-06 04:14:32', NULL, NULL);
1478
1479-- --------------------------------------------------------
1480
1481--
1482-- Table structure for table `crm_companies`
1483--
1484
1485CREATE TABLE `crm_companies` (
1486 `company_id` int(11) NOT NULL,
1487 `customer_code` varchar(50) DEFAULT NULL,
1488 `company_name` varchar(200) DEFAULT NULL,
1489 `company_parent` int(11) DEFAULT NULL,
1490 `company_office_phone` varchar(30) DEFAULT NULL,
1491 `company_industry` int(11) NOT NULL,
1492 `company_email` varchar(100) DEFAULT NULL,
1493 `company_fax` varchar(30) DEFAULT NULL,
1494 `company_employee` int(11) DEFAULT NULL,
1495 `company_revenue` double DEFAULT NULL,
1496 `company_website` varchar(100) DEFAULT NULL,
1497 `company_address1` varchar(255) DEFAULT NULL,
1498 `company_address2` varchar(255) DEFAULT NULL,
1499 `company_city` varchar(100) DEFAULT NULL,
1500 `company_state` varchar(100) DEFAULT NULL,
1501 `company_zip_code` varchar(10) DEFAULT NULL,
1502 `company_country` varchar(50) DEFAULT NULL,
1503 `company_billing_address1` varchar(255) DEFAULT NULL,
1504 `company_billing_address2` varchar(255) DEFAULT NULL,
1505 `company_billing_city` varchar(100) DEFAULT NULL,
1506 `company_billing_state` varchar(100) DEFAULT NULL,
1507 `company_billing_zip_code` varchar(10) DEFAULT NULL,
1508 `company_billing_country` varchar(50) DEFAULT NULL,
1509 `company_right_permission` enum('1','2','3') DEFAULT '1' COMMENT '1=owner2=group23=everyone',
1510 `user_created` varchar(100) DEFAULT NULL,
1511 `user_created_date` datetime DEFAULT NULL,
1512 `user_modified` varchar(100) DEFAULT NULL,
1513 `user_modified_date` datetime DEFAULT NULL,
1514 `company_groups` int(11) DEFAULT NULL,
1515 `company_customer` enum('0','1') DEFAULT '0' COMMENT '0=Not Customer\n1=Customer\n'
1516) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1517
1518--
1519-- Dumping data for table `crm_companies`
1520--
1521
1522INSERT INTO `crm_companies` (`company_id`, `customer_code`, `company_name`, `company_parent`, `company_office_phone`, `company_industry`, `company_email`, `company_fax`, `company_employee`, `company_revenue`, `company_website`, `company_address1`, `company_address2`, `company_city`, `company_state`, `company_zip_code`, `company_country`, `company_billing_address1`, `company_billing_address2`, `company_billing_city`, `company_billing_state`, `company_billing_zip_code`, `company_billing_country`, `company_right_permission`, `user_created`, `user_created_date`, `user_modified`, `user_modified_date`, `company_groups`, `company_customer`) VALUES
1523(1, '123456', 'Bangsa Cerdas', 2, '03748374', 5, 'company@yahoo.com', '082562562', 40, 500000000, 'company.com', 'jl. kelapa puyuh raya', NULL, 'kelpa gading', 'jakarta utara', '784374', 'indonesia', 'jl. kelapa molek', NULL, 'kelapa gading', 'Jakarta Utara', '3232', 'indonesia', '1', NULL, NULL, 'adiputra', '2017-08-29 06:03:45', NULL, '1'),
1524(2, NULL, 'PT. Maju Bersama', NULL, NULL, 6, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, NULL, '0'),
1525(3, 'CST-091723458', 'Republicofkoders', NULL, NULL, 5, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, NULL, '0'),
1526(4, NULL, 'bangsa cerdas', NULL, NULL, 5, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, NULL, '0'),
1527(5, NULL, 'Sharp Indonesia', NULL, '0864376437', 3, 'sharp@indonesia.com', '09273927399', 67, 900000000, 'sharp@yahoo.com', 'jakarta', 'jakarta', 'jakarta', 'jakarta', 'jakarta', 'jakarta', 'jakarta', 'jakarta', 'jakarta', 'jakarta', 'jakarta', 'jakarta', '1', 'adiputra', '2017-08-29 06:04:57', NULL, NULL, NULL, '1'),
1528(6, NULL, 'Net Zap', NULL, NULL, 6, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, NULL, '0'),
1529(7, 'CST-091723459', 'PT. Maju Mundur', NULL, NULL, 5, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, NULL, '0');
1530
1531-- --------------------------------------------------------
1532
1533--
1534-- Table structure for table `crm_companies_products`
1535--
1536
1537CREATE TABLE `crm_companies_products` (
1538 `company_id` int(11) NOT NULL,
1539 `product_id` int(11) NOT NULL,
1540 `product_price` double NOT NULL,
1541 `status` enum('0','1') NOT NULL
1542) ENGINE=InnoDB DEFAULT CHARSET=latin1;
1543
1544--
1545-- Dumping data for table `crm_companies_products`
1546--
1547
1548INSERT INTO `crm_companies_products` (`company_id`, `product_id`, `product_price`, `status`) VALUES
1549(3, 7, 9000000, '1'),
1550(3, 8, 3000000, '1'),
1551(7, 9, 1500000, '1'),
1552(7, 10, 15000000, '1');
1553
1554-- --------------------------------------------------------
1555
1556--
1557-- Table structure for table `crm_contacts`
1558--
1559
1560CREATE TABLE `crm_contacts` (
1561 `contact_id` int(11) NOT NULL,
1562 `company_id` int(11) NOT NULL,
1563 `people_id` int(11) NOT NULL,
1564 `contact_right_permission` enum('1','2','3') DEFAULT NULL,
1565 `contact_groups` int(11) DEFAULT NULL
1566) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1567
1568--
1569-- Dumping data for table `crm_contacts`
1570--
1571
1572INSERT INTO `crm_contacts` (`contact_id`, `company_id`, `people_id`, `contact_right_permission`, `contact_groups`) VALUES
1573(1, 1, 1, '1', NULL),
1574(2, 2, 3, '2', 4),
1575(3, 3, 4, '2', 4),
1576(4, 4, 5, '1', NULL),
1577(5, 1, 6, '1', NULL),
1578(6, 1, 8, '1', NULL),
1579(7, 2, 7, '1', NULL),
1580(8, 6, 9, '2', 7),
1581(9, 7, 11, '1', NULL);
1582
1583-- --------------------------------------------------------
1584
1585--
1586-- Table structure for table `crm_groups`
1587--
1588
1589CREATE TABLE `crm_groups` (
1590 `group_id` int(11) NOT NULL,
1591 `group_name` varchar(100) NOT NULL,
1592 `group_status` enum('0','1') DEFAULT '1' COMMENT '0= Non Aktif\n1= Aktif\n',
1593 `user_created` varchar(100) DEFAULT NULL,
1594 `user_created_date` datetime DEFAULT NULL,
1595 `user_modified` varchar(45) DEFAULT NULL,
1596 `user_modified_date` datetime DEFAULT NULL
1597) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1598
1599--
1600-- Dumping data for table `crm_groups`
1601--
1602
1603INSERT INTO `crm_groups` (`group_id`, `group_name`, `group_status`, `user_created`, `user_created_date`, `user_modified`, `user_modified_date`) VALUES
1604(3, 'Marketing', '1', 'admin', '2017-08-23 00:00:00', NULL, NULL),
1605(4, 'Developer', '1', 'admin', '2017-08-23 00:00:00', NULL, NULL),
1606(5, 'Designer', '1', 'admin', '2017-08-23 00:00:00', NULL, NULL),
1607(6, 'Managemen', '1', 'muhaliusman', '2017-08-23 16:33:30', NULL, NULL),
1608(7, 'Sales Canvas', '1', 'muhaliusman', '2017-08-29 07:25:34', NULL, NULL);
1609
1610-- --------------------------------------------------------
1611
1612--
1613-- Table structure for table `crm_industry`
1614--
1615
1616CREATE TABLE `crm_industry` (
1617 `industry_id` int(11) NOT NULL,
1618 `industry_name` varchar(100) NOT NULL,
1619 `user_created` varchar(100) DEFAULT NULL,
1620 `user_created_date` datetime DEFAULT NULL,
1621 `user_modified` varchar(100) DEFAULT NULL,
1622 `user_modified_date` datetime DEFAULT NULL
1623) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1624
1625--
1626-- Dumping data for table `crm_industry`
1627--
1628
1629INSERT INTO `crm_industry` (`industry_id`, `industry_name`, `user_created`, `user_created_date`, `user_modified`, `user_modified_date`) VALUES
1630(3, 'Manufacture', 'muhaliusman', '2017-08-25 04:06:27', NULL, '2017-09-12 06:41:45'),
1631(4, 'Consumer Good', 'muhaliusman', '2017-08-25 04:06:36', NULL, NULL),
1632(5, 'Development Center', 'muhaliusman', '2017-08-25 04:06:46', NULL, NULL),
1633(6, 'Education', 'muhaliusman', '2017-08-25 04:06:53', NULL, NULL),
1634(7, 'Services', 'muhaliusman', '2017-08-25 04:07:25', NULL, NULL);
1635
1636-- --------------------------------------------------------
1637
1638--
1639-- Table structure for table `crm_invoices`
1640--
1641
1642CREATE TABLE `crm_invoices` (
1643 `invoice_id` int(11) NOT NULL,
1644 `company_id` int(11) NOT NULL,
1645 `invoice_ref` varchar(45) DEFAULT NULL,
1646 `invoice_profile` varchar(100) DEFAULT NULL,
1647 `invoice_type` enum('1','2') NOT NULL COMMENT '1=One Time\n2=Recurring\n',
1648 `invoice_start_date` datetime DEFAULT NULL,
1649 `invoice_end_date` datetime DEFAULT NULL COMMENT ' ',
1650 `invoice_repeat_value` int(11) DEFAULT NULL,
1651 `invoice_repeat_type` enum('1','2','3') DEFAULT NULL COMMENT '1 =Day\n2= week\n3=Month\n',
1652 `invoice_expired` enum('0','1') DEFAULT NULL COMMENT '0=expired\n1=never expired\n',
1653 `term_id` int(11) NOT NULL
1654) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1655
1656--
1657-- Dumping data for table `crm_invoices`
1658--
1659
1660INSERT INTO `crm_invoices` (`invoice_id`, `company_id`, `invoice_ref`, `invoice_profile`, `invoice_type`, `invoice_start_date`, `invoice_end_date`, `invoice_repeat_value`, `invoice_repeat_type`, `invoice_expired`, `term_id`) VALUES
1661(1, 3, 'OPR-081700001', '-', '2', '2017-09-01 00:00:00', '2017-12-21 00:00:00', 4, '1', '0', 1),
1662(2, 3, 'OPR-081700001', '-', '2', '2017-09-06 00:00:00', NULL, 8, '2', '1', 1),
1663(3, 1, 'OPR-081700003', '-', '1', NULL, NULL, NULL, '1', '1', 1),
1664(4, 1, 'OPR-081700003', '-', '1', NULL, NULL, NULL, '1', '1', 1),
1665(5, 1, 'OPR-081700003', '-', '1', NULL, NULL, NULL, '1', '1', 1),
1666(6, 1, 'OPR-081700003', '-', '1', NULL, NULL, NULL, '1', '1', 1),
1667(7, 1, 'OPR-081700003', '-', '1', NULL, NULL, NULL, '1', '1', 1),
1668(8, 1, 'OPR-081700003', '-', '1', NULL, NULL, NULL, '1', '1', 1),
1669(9, 1, 'OPR-081700003', '-', '1', NULL, NULL, NULL, '1', '1', 1),
1670(10, 1, 'OPR-081700003', '-', '1', NULL, NULL, NULL, '1', '1', 1),
1671(11, 2, NULL, '-', '1', NULL, NULL, NULL, '1', '1', 1);
1672
1673-- --------------------------------------------------------
1674
1675--
1676-- Table structure for table `crm_invoices_products`
1677--
1678
1679CREATE TABLE `crm_invoices_products` (
1680 `invoice_detail_id` int(11) NOT NULL,
1681 `product_id` int(11) NOT NULL,
1682 `qty` int(11) DEFAULT NULL,
1683 `price` double DEFAULT NULL,
1684 `is_campaign` enum('0','1') NOT NULL
1685) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1686
1687--
1688-- Dumping data for table `crm_invoices_products`
1689--
1690
1691INSERT INTO `crm_invoices_products` (`invoice_detail_id`, `product_id`, `qty`, `price`, `is_campaign`) VALUES
1692(1, 7, 1, 10000, '0'),
1693(2, 7, 1, 9000000, '0'),
1694(2, 8, 1, 3000000, '0'),
1695(12, 7, 1, 10000, '0'),
1696(13, 7, 1, 9000000, '0'),
1697(13, 8, 1, 3000000, '0');
1698
1699-- --------------------------------------------------------
1700
1701--
1702-- Table structure for table `crm_invoice_details`
1703--
1704
1705CREATE TABLE `crm_invoice_details` (
1706 `invoice_detail_id` int(11) NOT NULL,
1707 `invoice_code` varchar(50) NOT NULL,
1708 `invoice_id` int(11) NOT NULL,
1709 `invoice_date` datetime NOT NULL,
1710 `invoice_due_date` datetime DEFAULT NULL,
1711 `invoice_discount_type` enum('1','2') DEFAULT '1' COMMENT '1=Percentage2=Value',
1712 `invoice_discount_value` double DEFAULT NULL,
1713 `invoice_tax_percentage` double DEFAULT NULL,
1714 `invoice_adjustment` double DEFAULT NULL,
1715 `invoice_type` enum('1','2') DEFAULT NULL COMMENT '1=One time\n2=recurring\n',
1716 `invoice_cycle` int(11) DEFAULT '1'
1717) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1718
1719--
1720-- Dumping data for table `crm_invoice_details`
1721--
1722
1723INSERT INTO `crm_invoice_details` (`invoice_detail_id`, `invoice_code`, `invoice_id`, `invoice_date`, `invoice_due_date`, `invoice_discount_type`, `invoice_discount_value`, `invoice_tax_percentage`, `invoice_adjustment`, `invoice_type`, `invoice_cycle`) VALUES
1724(1, 'INV-081700001', 1, '2017-08-29 06:15:02', '2017-09-28 00:00:00', '1', 5, 4, 109, '1', 1),
1725(2, 'INV-081700002', 2, '2017-08-29 06:15:20', '2017-09-28 00:00:00', '1', 5, 4, 109, '1', 1),
1726(3, 'INV-081700003', 11, '2017-08-29 06:15:49', '2017-09-28 00:00:00', '1', 100, 1, 1, '1', 1),
1727(12, 'INV-091700001', 1, '2017-09-07 02:59:40', NULL, '1', 5, 4, 109, '1', 1),
1728(13, 'INV-091700002', 2, '2017-09-07 02:59:40', NULL, '1', 5, 4, 109, '1', 1);
1729
1730-- --------------------------------------------------------
1731
1732--
1733-- Table structure for table `crm_leads`
1734--
1735
1736CREATE TABLE `crm_leads` (
1737 `lead_id` int(11) NOT NULL,
1738 `lead_label` int(11) NOT NULL,
1739 `people_id` int(11) NOT NULL,
1740 `lead_right_permission` enum('1','2','3') DEFAULT NULL COMMENT '1=owner\n2=group2\n3=everyone\n\n',
1741 `lead_groups` int(11) DEFAULT NULL,
1742 `lead_status` enum('1','2','3') NOT NULL DEFAULT '1' COMMENT '1= Lead\n2 = Convert\n3 =Junk\n',
1743 `user_created` varchar(100) DEFAULT NULL,
1744 `user_created_date` datetime DEFAULT NULL,
1745 `user_modified` varchar(100) DEFAULT NULL,
1746 `user_modified_date` datetime DEFAULT NULL
1747) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1748
1749--
1750-- Dumping data for table `crm_leads`
1751--
1752
1753INSERT INTO `crm_leads` (`lead_id`, `lead_label`, `people_id`, `lead_right_permission`, `lead_groups`, `lead_status`, `user_created`, `user_created_date`, `user_modified`, `user_modified_date`) VALUES
1754(1, 4, 1, '1', NULL, '2', 'parinussa', '2017-08-28 14:12:54', NULL, NULL),
1755(3, 4, 3, '2', 4, '2', 'parinussa', '2017-08-28 16:19:06', NULL, NULL),
1756(4, 4, 4, '2', 4, '2', 'parinussa', '2017-08-28 16:40:02', NULL, NULL),
1757(5, 4, 5, '1', NULL, '2', 'parinussa', '2017-08-28 17:01:29', NULL, NULL),
1758(6, 5, 7, '1', NULL, '2', 'adiputra', '2017-08-29 04:05:54', NULL, NULL),
1759(7, 4, 9, '2', 7, '2', 'adiputra', '2017-08-29 07:33:03', NULL, NULL),
1760(8, 4, 10, '1', NULL, '1', 'ardiansyah', '2017-08-29 08:04:42', NULL, NULL),
1761(9, 4, 11, '1', NULL, '2', 'parinussa', '2017-09-06 03:05:46', NULL, NULL);
1762
1763-- --------------------------------------------------------
1764
1765--
1766-- Table structure for table `crm_lead_label`
1767--
1768
1769CREATE TABLE `crm_lead_label` (
1770 `lead_label_id` int(11) NOT NULL,
1771 `lead_label_name` varchar(100) NOT NULL,
1772 `lead_label_status_score` int(11) NOT NULL COMMENT '0-100'
1773) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1774
1775--
1776-- Dumping data for table `crm_lead_label`
1777--
1778
1779INSERT INTO `crm_lead_label` (`lead_label_id`, `lead_label_name`, `lead_label_status_score`) VALUES
1780(4, 'New', 0),
1781(5, 'Negotiating', 50),
1782(6, 'Interest', 80),
1783(7, 'Deal', 100),
1784(8, 'Pikir-pikir', 30);
1785
1786-- --------------------------------------------------------
1787
1788--
1789-- Table structure for table `crm_modules`
1790--
1791
1792CREATE TABLE `crm_modules` (
1793 `module_id` int(11) NOT NULL,
1794 `module_name` varchar(100) NOT NULL,
1795 `module_route` varchar(225) NOT NULL,
1796 `module_order` int(11) DEFAULT NULL
1797) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1798
1799--
1800-- Dumping data for table `crm_modules`
1801--
1802
1803INSERT INTO `crm_modules` (`module_id`, `module_name`, `module_route`, `module_order`) VALUES
1804(1, 'Leads', 'leads', NULL),
1805(2, 'Contacts', 'contacts', NULL),
1806(3, 'Companies', 'companies', NULL),
1807(4, 'Opportunities', 'opportunities', NULL),
1808(5, 'Products', 'products', NULL),
1809(6, 'Campaigns', 'campaigns', NULL),
1810(8, 'invoices', 'invoices', NULL),
1811(9, 'recurring invoices', 'recurring-invoices', NULL),
1812(10, 'customer', 'customers', NULL),
1813(11, 'payments', 'payments', NULL);
1814
1815-- --------------------------------------------------------
1816
1817--
1818-- Table structure for table `crm_news`
1819--
1820
1821CREATE TABLE `crm_news` (
1822 `news_id` int(11) NOT NULL,
1823 `news_title` varchar(150) NOT NULL,
1824 `news_description` text NOT NULL,
1825 `news_date` datetime NOT NULL
1826) ENGINE=InnoDB DEFAULT CHARSET=latin1;
1827
1828--
1829-- Dumping data for table `crm_news`
1830--
1831
1832INSERT INTO `crm_news` (`news_id`, `news_title`, `news_description`, `news_date`) VALUES
1833(1, 'News Baru', '<p style="-webkit-tap-highlight-color: transparent; margin-top: 1.5em; margin-bottom: 1.5em; color: rgb(104, 119, 137); font-size: 1.1875em; font-family: "Mercury SSm A", "Mercury SSm B", Georgia, Times, "Times New Roman", "Microsoft YaHei New", "Microsoft Yahei", ????, ??, SimSun, STXihei, ????, serif; line-height: 1.5; animation: fadeInLorem 1000ms linear; letter-spacing: normal;">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc pulvinar sapien et ligula. Leo duis ut diam quam. Amet risus nullam eget felis eget. Arcu odio ut sem nulla pharetra. Donec ultrices tincidunt arcu non sodales neque sodales ut etiam. Pharetra convallis posuere morbi leo urna molestie at elementum. Mi eget mauris pharetra et. Mollis nunc sed id semper risus in. Eget mi proin sed libero. Pellentesque adipiscing commodo elit at. Magna fringilla urna porttitor rhoncus dolor purus non enim. Morbi blandit cursus risus at ultrices mi tempus imperdiet nulla. Volutpat blandit aliquam etiam erat velit scelerisque in dictum non. Ultrices tincidunt arcu non sodales.</p><p style="-webkit-tap-highlight-color: transparent; margin-top: 1.5em; margin-bottom: 1.5em; color: rgb(104, 119, 137); font-size: 1.1875em; font-family: "Mercury SSm A", "Mercury SSm B", Georgia, Times, "Times New Roman", "Microsoft YaHei New", "Microsoft Yahei", ????, ??, SimSun, STXihei, ????, serif; line-height: 1.5; animation: fadeInLorem 1000ms linear; letter-spacing: normal;">Leo urna molestie at elementum eu facilisis sed odio. Consectetur adipiscing elit duis tristique sollicitudin. Sapien et ligula ullamcorper malesuada. Interdum posuere lorem ipsum dolor sit amet consectetur. Imperdiet massa tincidunt nunc pulvinar sapien et ligula ullamcorper. Enim eu turpis egestas pretium aenean pharetra. Viverra suspendisse potenti nullam ac. Quis imperdiet massa tincidunt nunc pulvinar. Ultrices mi tempus imperdiet nulla malesuada pellentesque. Varius morbi enim nunc faucibus a pellentesque sit amet porttitor. Enim ut sem viverra aliquet eget sit amet. Erat nam at lectus urna duis convallis convallis tellus id.</p><p style="-webkit-tap-highlight-color: transparent; margin-top: 1.5em; margin-bottom: 1.5em; color: rgb(104, 119, 137); font-size: 1.1875em; font-family: "Mercury SSm A", "Mercury SSm B", Georgia, Times, "Times New Roman", "Microsoft YaHei New", "Microsoft Yahei", ????, ??, SimSun, STXihei, ????, serif; line-height: 1.5; animation: fadeInLorem 1000ms linear; letter-spacing: normal;">Tellus mauris a diam maecenas sed enim ut sem. Amet mauris commodo quis imperdiet. Sit amet aliquam id diam maecenas ultricies mi. Tempor nec feugiat nisl pretium fusce id velit ut tortor. Eget arcu dictum varius duis. Pretium fusce id velit ut. Porttitor lacus luctus accumsan tortor posuere ac ut. Amet nisl purus in mollis nunc sed id semper risus. Pellentesque massa placerat duis ultricies. Integer vitae justo eget magna fermentum iaculis eu non. Adipiscing diam donec adipiscing tristique risus nec feugiat. Consequat id porta nibh venenatis cras sed. Est ante in nibh mauris cursus mattis molestie a iaculis. Nibh tellus molestie nunc non blandit massa. Urna neque viverra justo nec ultrices. Sed odio morbi quis commodo odio. Morbi tristique senectus et netus et malesuada fames. Condimentum mattis pellentesque id nibh tortor id aliquet lectus. Placerat orci nulla pellentesque dignissim enim sit amet venenatis.</p>', '2017-09-12 08:58:24');
1834
1835-- --------------------------------------------------------
1836
1837--
1838-- Table structure for table `crm_opportunities`
1839--
1840
1841CREATE TABLE `crm_opportunities` (
1842 `opportunity_id` int(11) NOT NULL,
1843 `opportunity_code` varchar(100) DEFAULT NULL,
1844 `opportunity_name` varchar(45) DEFAULT NULL,
1845 `opportunity_stage_id` int(11) NOT NULL,
1846 `company_id` int(11) NOT NULL,
1847 `opportunity_amount` double DEFAULT NULL,
1848 `opportunity_expected_closing_date` datetime DEFAULT NULL,
1849 `opportunity_closing_date` datetime DEFAULT NULL,
1850 `opportunity_service` enum('1','2') DEFAULT NULL COMMENT '1= Product\n2=Campaign\n',
1851 `opportunity_campaign_id` int(11) DEFAULT NULL
1852) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1853
1854--
1855-- Dumping data for table `crm_opportunities`
1856--
1857
1858INSERT INTO `crm_opportunities` (`opportunity_id`, `opportunity_code`, `opportunity_name`, `opportunity_stage_id`, `company_id`, `opportunity_amount`, `opportunity_expected_closing_date`, `opportunity_closing_date`, `opportunity_service`, `opportunity_campaign_id`) VALUES
1859(1, 'OPR-081700001', 'Opportunity 1', 6, 3, 17000000, '2017-08-22 00:00:00', NULL, '1', NULL),
1860(2, 'OPR-081700002', 'opportunity 3', 4, 4, 8000000, '2017-08-29 00:00:00', NULL, '2', 1),
1861(3, 'OPR-081700003', 'Opportunity 23', 5, 1, 6000000, '2017-08-22 00:00:00', NULL, '1', NULL),
1862(4, 'OPR-081700004', 'opportunity 6', 4, 2, 17000000, '2017-08-08 00:00:00', NULL, '1', 1),
1863(5, 'OPR-081700005', 'Opportunity 9', 6, 6, 7000000, '2017-08-30 00:00:00', NULL, '2', 2),
1864(6, 'OPR-091700006', 'New Opportunity', 5, 3, 4000000, '2017-09-15 00:00:00', NULL, '1', NULL),
1865(7, 'OPR-091700007', 'coba habis closing', 6, 7, 16500000, '2017-09-18 00:00:00', NULL, '2', 4);
1866
1867-- --------------------------------------------------------
1868
1869--
1870-- Table structure for table `crm_opportunities_contacts`
1871--
1872
1873CREATE TABLE `crm_opportunities_contacts` (
1874 `opportunity_id` int(11) NOT NULL,
1875 `contact_id` int(11) NOT NULL
1876) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1877
1878--
1879-- Dumping data for table `crm_opportunities_contacts`
1880--
1881
1882INSERT INTO `crm_opportunities_contacts` (`opportunity_id`, `contact_id`) VALUES
1883(1, 3),
1884(2, 4),
1885(3, 5),
1886(4, 7),
1887(5, 8),
1888(6, 3),
1889(7, 9);
1890
1891-- --------------------------------------------------------
1892
1893--
1894-- Table structure for table `crm_opportunities_products`
1895--
1896
1897CREATE TABLE `crm_opportunities_products` (
1898 `opportunity_id` int(11) NOT NULL,
1899 `product_id` int(11) NOT NULL
1900) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1901
1902--
1903-- Dumping data for table `crm_opportunities_products`
1904--
1905
1906INSERT INTO `crm_opportunities_products` (`opportunity_id`, `product_id`) VALUES
1907(1, 7),
1908(1, 8),
1909(2, 6),
1910(3, 7),
1911(3, 8),
1912(4, 7),
1913(4, 9),
1914(5, 12),
1915(6, 7),
1916(7, 9),
1917(7, 10);
1918
1919-- --------------------------------------------------------
1920
1921--
1922-- Table structure for table `crm_opportunity_stage`
1923--
1924
1925CREATE TABLE `crm_opportunity_stage` (
1926 `opportunity_stage_id` int(11) NOT NULL,
1927 `opportunity_stage_name` varchar(100) DEFAULT NULL,
1928 `opportunity_stage_status_score` int(11) NOT NULL
1929) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1930
1931--
1932-- Dumping data for table `crm_opportunity_stage`
1933--
1934
1935INSERT INTO `crm_opportunity_stage` (`opportunity_stage_id`, `opportunity_stage_name`, `opportunity_stage_status_score`) VALUES
1936(4, 'Negotiating', 30),
1937(5, 'New', 0),
1938(6, 'Close Won', 100);
1939
1940-- --------------------------------------------------------
1941
1942--
1943-- Table structure for table `crm_payment`
1944--
1945
1946CREATE TABLE `crm_payment` (
1947 `payment_id` int(11) NOT NULL,
1948 `payment_code` varchar(100) NOT NULL,
1949 `invoice_detail_id` int(11) DEFAULT NULL,
1950 `payment_amount_received` double NOT NULL,
1951 `payment_bank_charge` double DEFAULT NULL,
1952 `payment_method_id` int(11) DEFAULT NULL,
1953 `payment_date` datetime NOT NULL,
1954 `payment_ref` varchar(200) DEFAULT NULL,
1955 `payment_notes` varchar(200) DEFAULT NULL,
1956 `payment_file` varchar(200) DEFAULT NULL
1957) ENGINE=InnoDB DEFAULT CHARSET=latin1;
1958
1959-- --------------------------------------------------------
1960
1961--
1962-- Table structure for table `crm_payment_methods`
1963--
1964
1965CREATE TABLE `crm_payment_methods` (
1966 `payment_method_id` int(11) NOT NULL,
1967 `payment_method_name` varchar(200) NOT NULL
1968) ENGINE=InnoDB DEFAULT CHARSET=latin1;
1969
1970-- --------------------------------------------------------
1971
1972--
1973-- Table structure for table `crm_peoples`
1974--
1975
1976CREATE TABLE `crm_peoples` (
1977 `people_id` int(11) NOT NULL,
1978 `people_salutation` enum('1','2','3') DEFAULT NULL,
1979 `people_first_name` varchar(100) NOT NULL,
1980 `people_last_name` varchar(100) DEFAULT NULL,
1981 `people_job_title` varchar(100) DEFAULT NULL,
1982 `people_company` varchar(100) DEFAULT NULL,
1983 `people_department` varchar(100) DEFAULT NULL,
1984 `people_email` varchar(100) DEFAULT NULL,
1985 `people_office_phone` varchar(30) DEFAULT NULL,
1986 `people_mobile_phone` varchar(30) DEFAULT NULL,
1987 `people_industry` int(11) DEFAULT NULL,
1988 `people_address1` varchar(255) DEFAULT NULL,
1989 `people_address2` varchar(255) DEFAULT NULL,
1990 `people_city` varchar(100) DEFAULT NULL,
1991 `people_state` varchar(100) DEFAULT NULL,
1992 `people_zip_code` varchar(10) DEFAULT NULL,
1993 `people_country` varchar(50) DEFAULT NULL,
1994 `people_source` int(11) NOT NULL,
1995 `people_photo` varchar(100) DEFAULT NULL,
1996 `people_status` enum('1','2') NOT NULL COMMENT '1=Lead\n2=Customer\n'
1997) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1998
1999--
2000-- Dumping data for table `crm_peoples`
2001--
2002
2003INSERT INTO `crm_peoples` (`people_id`, `people_salutation`, `people_first_name`, `people_last_name`, `people_job_title`, `people_company`, `people_department`, `people_email`, `people_office_phone`, `people_mobile_phone`, `people_industry`, `people_address1`, `people_address2`, `people_city`, `people_state`, `people_zip_code`, `people_country`, `people_source`, `people_photo`, `people_status`) VALUES
2004(1, '2', 'Fais', 'Nasrullahh', 'Manager', 'Bangsa Cerdas', 'Development', 'faisnasrullah@yahoo.com', '022-1232323', '08564009283', 5, 'Jl. Puyuh Raya Blok, E4 No.1', 'Kelapa Gading', 'Jakarta Utara', 'DKI Jakarta', '45343', 'Indonesia', 5, NULL, '1'),
2005(3, '2', 'Yusuf', 'Basori', 'Kepala Bagian', 'PT. Maju Bersama', 'Production', 'yusuf@majubersama.com', '022-329323', '085637444', 6, 'Jl. Kelapa molek 5 No.2', 'Kelapa Gading', 'Jakarta Utara', 'DKI Jakarta', '373748', 'Indonesia', 4, NULL, '1'),
2006(4, '2', 'Adi', 'Putra Putri', NULL, 'Republicofkoders', NULL, 'adi@yahoo.com', '0323232323', '08647837483', 5, 'kelapa gading', NULL, NULL, NULL, NULL, NULL, 3, NULL, '1'),
2007(5, '2', 'Fais', 'Ajah', 'programmer', 'bangsa cerdas', 'developer', 'fais@gmail.com', '02332323', '088788444', 5, 'kelapa gading', NULL, NULL, NULL, NULL, NULL, 4, NULL, '1'),
2008(6, '1', 'John', 'Doe', 'Manager', 'Bangsa Cerdas', 'Developers', 'johndoe@example.com', '0822-345678', '0818834933', 6, 'Jl. Kelapa Puyuh No 2', 'Kelapa Gading', 'Jakarta utara', 'DKI Jakarta', '323232', 'Indonesia', 4, NULL, '2'),
2009(7, '2', 'Wahyu', 'Nugroho', 'Manger', 'PT. Maju Bersama', 'Production', 'wahyu@majubersama.com', '022-8373733', '08562737292', 7, 'Jl. Kelapa Molek 5', NULL, 'Kelapa Gading', 'Jakarta Utara', NULL, NULL, 4, NULL, '1'),
2010(8, '1', 'Contact', 'Convert', 'Manager', 'Bangsa Cerdas', 'Development', 'contact@yahoo.com', '022-1232323', '08536363636', 5, 'Jl. Puyuh Raya Blok, E4 No.1', 'Kelapa Gading', 'Jakarta Utara', 'DKI Jakarta', '45343', 'Indonesia', 5, NULL, '2'),
2011(9, '2', 'Tohir', 'Mutohir', 'Mnager', 'Net Zap', NULL, 'tohir@gmail.com', '0220384784', '0864848444', 6, 'Jl. Kelapa Molek 5', 'Kelapa Gading', 'Jakarta Utara', 'Jakarta', NULL, NULL, 3, NULL, '1'),
2012(10, '1', 'Widi', 'Jenny', 'Mnager', 'Net Zap', NULL, 'widi@yahoo.com', '0220384784', '0864848444', 6, 'Jl. Kelapa Molek 5', 'Kelapa Gading', 'Jakarta Utara', 'Jakarta', NULL, NULL, 3, NULL, '1'),
2013(11, '2', 'Herbert', 'Gay Lord', 'Kepala Bagian', 'PT. Maju Mundur', 'Produksi', 'herbertgay@majumundur.com', '022-23323', '081232323', 5, 'Jl. Puyuh Raya, blk z2 no.1', 'Kelapa Gading', 'Jakarta Utara', 'DKI Jakarta', '51325', 'Indonesia', 5, NULL, '1');
2014
2015-- --------------------------------------------------------
2016
2017--
2018-- Table structure for table `crm_products`
2019--
2020
2021CREATE TABLE `crm_products` (
2022 `product_id` int(11) NOT NULL,
2023 `product_name` varchar(100) DEFAULT NULL,
2024 `product_category_id` int(11) DEFAULT NULL,
2025 `product_description` text,
2026 `product_type` enum('1','2','3') NOT NULL COMMENT '1=Product\n2=Services\n3=Subscription\n',
2027 `product_price_frequency` enum('1','2','3') DEFAULT NULL COMMENT '1=One Time\n2=Monthly\n3=Annually ',
2028 `product_price` double NOT NULL DEFAULT '0',
2029 `product_status` enum('0','1') NOT NULL DEFAULT '1' COMMENT '0=Non Aktif\n1=Aktif\n',
2030 `user_created` varchar(100) DEFAULT NULL,
2031 `user_created_date` datetime DEFAULT NULL,
2032 `user_modified` varchar(100) DEFAULT NULL,
2033 `user_modified_date` datetime DEFAULT NULL
2034) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2035
2036--
2037-- Dumping data for table `crm_products`
2038--
2039
2040INSERT INTO `crm_products` (`product_id`, `product_name`, `product_category_id`, `product_description`, `product_type`, `product_price_frequency`, `product_price`, `product_status`, `user_created`, `user_created_date`, `user_modified`, `user_modified_date`) VALUES
2041(6, 'Back End Course, With PHP', 6, 'pembelajaran membahas tentang bagaimana membuat sebuah program menggunakan PHP', '2', '1', 4000000, '1', 'parinussa', '2017-08-25 04:21:47', 'parinussa', '2017-09-06 05:36:01'),
2042(7, 'Angular 4 Course', 7, 'Belajar tentang angular 4', '2', '1', 9000000, '1', 'parinussa', '2017-08-25 04:23:07', NULL, NULL),
2043(8, 'Animation With Macromedia 8', 9, 'Belajar membuat animasi', '2', '1', 3000000, '1', 'parinussa', '2017-08-25 04:23:45', NULL, NULL),
2044(9, 'Crash Course', 7, 'Belajar membuat tampilan web dalam waktu 5 hari', '2', '1', 2000000, '1', 'parinussa', '2017-08-25 04:24:23', NULL, NULL),
2045(10, 'Full Stack Web Dev', 5, 'belajar membuat web. mulai dari tampilan depan hingga bagian back end menggunakan PHP', '2', '1', 20000000, '1', 'parinussa', '2017-08-25 04:25:22', NULL, NULL),
2046(11, 'Ionic', 7, 'belajar membuat mobile Apps hybrid menggunakan ionic', '2', '1', 15000000, '1', 'parinussa', '2017-08-25 04:26:06', NULL, NULL),
2047(12, 'Junior coder Kmy', 9, 'game and apps', '2', '1', 8000000, '1', 'ardiansyah', '2017-08-29 08:07:36', 'adiputra', '2017-08-29 08:49:22'),
2048(13, 'Junior Koder Pik', 5, 'junior koder', '1', '2', 9000000, '1', 'adiputra', '2017-08-29 08:49:50', NULL, NULL),
2049(14, 'Junior Koder', 5, 'Kelas koding untuk anak di bawah 13 tahun', '2', '1', 9000000, '1', 'parinussa', '2017-09-06 03:16:44', 'parinussa', '2017-09-06 03:40:15');
2050
2051-- --------------------------------------------------------
2052
2053--
2054-- Table structure for table `crm_products_campaigns`
2055--
2056
2057CREATE TABLE `crm_products_campaigns` (
2058 `product_id` int(11) NOT NULL,
2059 `campaign_id` int(11) NOT NULL,
2060 `discount_type` enum('1','2') DEFAULT NULL COMMENT '1=Percentage\n2=Fixed',
2061 `amount` double DEFAULT NULL
2062) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2063
2064--
2065-- Dumping data for table `crm_products_campaigns`
2066--
2067
2068INSERT INTO `crm_products_campaigns` (`product_id`, `campaign_id`, `discount_type`, `amount`) VALUES
2069(6, 1, '1', 50),
2070(9, 1, '2', 500000),
2071(9, 4, '1', 25),
2072(10, 4, '1', 25),
2073(12, 2, '1', 50),
2074(14, 5, '1', 20);
2075
2076-- --------------------------------------------------------
2077
2078--
2079-- Table structure for table `crm_product_categories`
2080--
2081
2082CREATE TABLE `crm_product_categories` (
2083 `category_id` int(11) NOT NULL,
2084 `category_name` varchar(100) NOT NULL,
2085 `category_status` enum('0','1') DEFAULT '1' COMMENT '0=non aktif\n1=aktif',
2086 `user_created` varchar(100) DEFAULT NULL,
2087 `user_created_date` datetime DEFAULT NULL,
2088 `user_modified` varchar(100) DEFAULT NULL,
2089 `user_modified_date` datetime DEFAULT NULL
2090) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2091
2092--
2093-- Dumping data for table `crm_product_categories`
2094--
2095
2096INSERT INTO `crm_product_categories` (`category_id`, `category_name`, `category_status`, `user_created`, `user_created_date`, `user_modified`, `user_modified_date`) VALUES
2097(5, 'Full Stack', '1', 'parinussa', '2017-08-25 04:20:53', NULL, NULL),
2098(6, 'Back End Dev', '1', 'parinussa', '2017-08-25 04:21:09', NULL, NULL),
2099(7, 'Front End Dev', '1', 'parinussa', '2017-08-25 04:21:17', NULL, NULL),
2100(8, 'Design', '1', 'parinussa', '2017-08-25 04:21:24', NULL, NULL),
2101(9, 'Animation', '1', 'parinussa', '2017-08-25 04:21:32', NULL, NULL);
2102
2103-- --------------------------------------------------------
2104
2105--
2106-- Table structure for table `crm_roles`
2107--
2108
2109CREATE TABLE `crm_roles` (
2110 `role_id` int(11) NOT NULL COMMENT 'User Administrator Hard Code All access module',
2111 `role_name` varchar(100) DEFAULT NULL,
2112 `status` enum('0','1') DEFAULT NULL,
2113 `user_created` varchar(100) DEFAULT NULL,
2114 `user_created_date` datetime DEFAULT NULL,
2115 `user_modified` varchar(100) DEFAULT NULL,
2116 `user_modified_date` datetime DEFAULT NULL
2117) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2118
2119--
2120-- Dumping data for table `crm_roles`
2121--
2122
2123INSERT INTO `crm_roles` (`role_id`, `role_name`, `status`, `user_created`, `user_created_date`, `user_modified`, `user_modified_date`) VALUES
2124(1, 'Administrator', '1', 'admin', '2017-08-23 00:00:00', NULL, NULL),
2125(2, 'Marketing', '1', 'admin', '2017-08-23 00:00:00', NULL, NULL),
2126(3, 'Supervisor', '1', 'admin', '2017-08-23 00:00:00', NULL, NULL),
2127(4, 'CEO', '1', 'admin', '2017-08-23 00:00:00', NULL, NULL),
2128(7, 'Developer', '1', 'muhaliusman', '2017-08-23 16:28:40', NULL, NULL);
2129
2130-- --------------------------------------------------------
2131
2132--
2133-- Table structure for table `crm_roles_modules`
2134--
2135
2136CREATE TABLE `crm_roles_modules` (
2137 `crm_roles_role_id` int(11) NOT NULL,
2138 `crm_modules_module_id` int(11) NOT NULL
2139) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2140
2141--
2142-- Dumping data for table `crm_roles_modules`
2143--
2144
2145INSERT INTO `crm_roles_modules` (`crm_roles_role_id`, `crm_modules_module_id`) VALUES
2146(4, 1),
2147(4, 2),
2148(4, 3),
2149(4, 4),
2150(4, 5),
2151(4, 6),
2152(4, 8),
2153(4, 9),
2154(7, 1),
2155(7, 2),
2156(7, 3),
2157(7, 4),
2158(7, 5),
2159(7, 6),
2160(7, 8),
2161(7, 9),
2162(7, 10);
2163
2164-- --------------------------------------------------------
2165
2166--
2167-- Table structure for table `crm_setup_company`
2168--
2169
2170CREATE TABLE `crm_setup_company` (
2171 `company_id` int(11) NOT NULL,
2172 `company_name` varchar(225) NOT NULL,
2173 `company_email` varchar(225) DEFAULT NULL,
2174 `company_address1` varchar(225) NOT NULL,
2175 `company_address2` varchar(100) DEFAULT NULL,
2176 `company_city` varchar(225) NOT NULL,
2177 `company_state` varchar(225) NOT NULL,
2178 `company_zip_code` varchar(50) NOT NULL,
2179 `company_country` varchar(225) NOT NULL,
2180 `company_phone` varchar(50) DEFAULT NULL,
2181 `company_logo` varchar(100) DEFAULT NULL,
2182 `company_fax` varchar(50) DEFAULT NULL,
2183 `company_website` varchar(100) DEFAULT NULL,
2184 `company_initial_setting` enum('0','1') DEFAULT '0'
2185) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2186
2187--
2188-- Dumping data for table `crm_setup_company`
2189--
2190
2191INSERT INTO `crm_setup_company` (`company_id`, `company_name`, `company_email`, `company_address1`, `company_address2`, `company_city`, `company_state`, `company_zip_code`, `company_country`, `company_phone`, `company_logo`, `company_fax`, `company_website`, `company_initial_setting`) VALUES
2192(5, 'Republic Of Koders', 'official@republicofkoders.com', 'Jl. Puyuh Raya Blok Z2 No.1', 'Kelapa Gading', 'Jakarta Utara', 'DKI Jakarta', '277374', 'Indonesia', '627366373', NULL, '628363399', 'republicofkoders.com', '1');
2193
2194-- --------------------------------------------------------
2195
2196--
2197-- Table structure for table `crm_source`
2198--
2199
2200CREATE TABLE `crm_source` (
2201 `source_id` int(11) NOT NULL,
2202 `source_name` varchar(100) NOT NULL,
2203 `user_created` varchar(100) DEFAULT NULL,
2204 `user_created_date` datetime DEFAULT NULL,
2205 `user_modified` varchar(100) DEFAULT NULL,
2206 `user_modified_date` datetime DEFAULT NULL
2207) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2208
2209--
2210-- Dumping data for table `crm_source`
2211--
2212
2213INSERT INTO `crm_source` (`source_id`, `source_name`, `user_created`, `user_created_date`, `user_modified`, `user_modified_date`) VALUES
2214(3, 'Facebook', 'muhaliusman', '2017-08-25 04:07:37', NULL, NULL),
2215(4, 'Koran', 'muhaliusman', '2017-08-25 04:07:44', NULL, NULL),
2216(5, 'Television', 'muhaliusman', '2017-08-25 04:07:53', NULL, NULL),
2217(6, 'Exhibition', 'muhaliusman', '2017-08-25 04:08:15', NULL, NULL);
2218
2219-- --------------------------------------------------------
2220
2221--
2222-- Table structure for table `crm_terms`
2223--
2224
2225CREATE TABLE `crm_terms` (
2226 `term_id` int(11) NOT NULL,
2227 `term_description` varchar(100) NOT NULL,
2228 `term_day` int(11) NOT NULL,
2229 `term_default` enum('0','1') DEFAULT '0' COMMENT '0=Not Default\n1=Default'
2230) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2231
2232--
2233-- Dumping data for table `crm_terms`
2234--
2235
2236INSERT INTO `crm_terms` (`term_id`, `term_description`, `term_day`, `term_default`) VALUES
2237(1, '1 Week', 7, '1'),
2238(2, '1 Month', 30, '0');
2239
2240-- --------------------------------------------------------
2241
2242--
2243-- Table structure for table `crm_users`
2244--
2245
2246CREATE TABLE `crm_users` (
2247 `user_id` int(11) NOT NULL,
2248 `user_first_name` varchar(100) NOT NULL,
2249 `user_last_name` varchar(100) DEFAULT NULL,
2250 `user_job_title` varchar(50) DEFAULT NULL,
2251 `user_password` varchar(100) NOT NULL,
2252 `user_mobile` varchar(30) NOT NULL,
2253 `user_username` varchar(100) NOT NULL,
2254 `user_department` varchar(100) DEFAULT NULL,
2255 `user_email` varchar(100) NOT NULL,
2256 `user_photo` varchar(100) DEFAULT NULL,
2257 `user_status` enum('0','1') DEFAULT '1' COMMENT '0=Non-Aktif 1=Aktif',
2258 `user_group_id` int(11) NOT NULL,
2259 `user_manager_id` int(11) DEFAULT NULL,
2260 `user_role_id` int(11) NOT NULL,
2261 `user_created` varchar(100) DEFAULT NULL,
2262 `user_created_date` datetime DEFAULT NULL,
2263 `user_modified` varchar(100) DEFAULT NULL,
2264 `user_modified_date` datetime DEFAULT NULL
2265) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2266
2267--
2268-- Dumping data for table `crm_users`
2269--
2270
2271INSERT INTO `crm_users` (`user_id`, `user_first_name`, `user_last_name`, `user_job_title`, `user_password`, `user_mobile`, `user_username`, `user_department`, `user_email`, `user_photo`, `user_status`, `user_group_id`, `user_manager_id`, `user_role_id`, `user_created`, `user_created_date`, `user_modified`, `user_modified_date`) VALUES
2272(17, 'Muhammad', 'Ali Usman', 'admin', '$2a$06$YMLm1h/c/n198STzo1O8Y.2rKBzRgBYm.iOdX6rFIk1Tt.sKJlzwi', '085717647462', 'muhaliusman', 'Administrator', 'muh.aliusman@yahoo.co.id', NULL, '1', 3, NULL, 1, 'admin', '2017-08-23 00:00:00', NULL, NULL),
2273(18, 'Noval', 'Parinussa', 'Senior Programmer', '$2a$10$2Cn479SFX80weNkwlyrWA.wy78ldTIalxyy1ql5S9TLtaYAb9d0ty', '0856008793888', 'parinussa', 'Product Development', 'parinussa@gmail.com', NULL, '1', 4, NULL, 7, 'muhaliusman', '2017-08-23 16:30:05', 'muhaliusman', '2017-08-23 16:34:06'),
2274(19, 'Adi', 'Putra', 'Software Enginer', '$2a$10$2Cn479SFX80weNkwlyrWA.wy78ldTIalxyy1ql5S9TLtaYAb9d0ty', '08590023889', 'adiputra', 'Product Development', 'adiputra@gmail.com', NULL, '1', 4, NULL, 7, 'muhaliusman', '2017-08-23 16:31:04', 'muhaliusman', '2017-08-23 16:34:00'),
2275(20, 'Yusuf', 'Basori', 'Database Administrator', '$2a$10$2Cn479SFX80weNkwlyrWA.wy78ldTIalxyy1ql5S9TLtaYAb9d0ty', '087363536664', 'yusufbasori', 'Product Development', 'basori@gmail.com', NULL, '1', 4, NULL, 7, 'muhaliusman', '2017-08-23 16:32:07', 'muhaliusman', '2017-08-23 16:33:53'),
2276(21, 'Jupiter', 'Zhuo', 'CEO', '$2a$10$2Cn479SFX80weNkwlyrWA.wy78ldTIalxyy1ql5S9TLtaYAb9d0ty', '0862752722', 'jupiter', 'Course', 'jupiter@gmail.com', NULL, '1', 6, NULL, 4, 'muhaliusman', '2017-08-23 16:33:13', 'muhaliusman', '2017-08-23 16:33:45'),
2277(22, 'Ardi', 'Putra', 'Manager', '$2a$10$7QE8JDV6QLOcY29kC4FYG.a5RefbQJxcoex4TLPMZFY5PaDOLCjlW', '0856748878787', 'ardiansyah', 'Sales', 'ardi@yahoo.com', NULL, '1', 7, NULL, 7, 'muhaliusman', '2017-08-29 07:27:08', NULL, NULL);
2278
2279-- --------------------------------------------------------
2280
2281--
2282-- Table structure for table `crm_users_companies`
2283--
2284
2285CREATE TABLE `crm_users_companies` (
2286 `company_id` int(11) NOT NULL,
2287 `user_id` int(11) NOT NULL
2288) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2289
2290--
2291-- Dumping data for table `crm_users_companies`
2292--
2293
2294INSERT INTO `crm_users_companies` (`company_id`, `user_id`) VALUES
2295(1, 19),
2296(2, 18),
2297(3, 18),
2298(4, 18),
2299(5, 19),
2300(6, 19),
2301(7, 18),
2302(7, 20);
2303
2304-- --------------------------------------------------------
2305
2306--
2307-- Table structure for table `crm_users_contacts`
2308--
2309
2310CREATE TABLE `crm_users_contacts` (
2311 `contact_id` int(11) NOT NULL,
2312 `user_id` int(11) NOT NULL
2313) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2314
2315--
2316-- Dumping data for table `crm_users_contacts`
2317--
2318
2319INSERT INTO `crm_users_contacts` (`contact_id`, `user_id`) VALUES
2320(1, 18),
2321(1, 19),
2322(2, 18),
2323(3, 18),
2324(4, 18),
2325(5, 18),
2326(5, 19),
2327(6, 19),
2328(6, 20),
2329(7, 18),
2330(7, 19),
2331(8, 19),
2332(9, 18),
2333(9, 20);
2334
2335-- --------------------------------------------------------
2336
2337--
2338-- Table structure for table `crm_users_leads`
2339--
2340
2341CREATE TABLE `crm_users_leads` (
2342 `lead_id` int(11) NOT NULL,
2343 `user_id` int(11) NOT NULL
2344) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2345
2346--
2347-- Dumping data for table `crm_users_leads`
2348--
2349
2350INSERT INTO `crm_users_leads` (`lead_id`, `user_id`) VALUES
2351(1, 18),
2352(1, 19),
2353(3, 18),
2354(4, 18),
2355(5, 18),
2356(6, 18),
2357(6, 19),
2358(7, 19),
2359(8, 22),
2360(9, 18),
2361(9, 20);
2362
2363-- --------------------------------------------------------
2364
2365--
2366-- Table structure for table `invoice_control`
2367--
2368
2369CREATE TABLE `invoice_control` (
2370 `invoice_id` int(11) NOT NULL,
2371 `next_invoice_date` date NOT NULL,
2372 `repeat_invoice` int(11) NOT NULL
2373) ENGINE=InnoDB DEFAULT CHARSET=latin1;
2374
2375--
2376-- Dumping data for table `invoice_control`
2377--
2378
2379INSERT INTO `invoice_control` (`invoice_id`, `next_invoice_date`, `repeat_invoice`) VALUES
2380(1, '2017-09-08', 2),
2381(2, '2017-09-14', 2);
2382
2383-- --------------------------------------------------------
2384
2385--
2386-- Table structure for table `lead_calls`
2387--
2388
2389CREATE TABLE `lead_calls` (
2390 `lead_call_id` int(11) NOT NULL,
2391 `lead_call_title` varchar(100) DEFAULT NULL,
2392 `lead_call_duration` int(11) DEFAULT NULL,
2393 `lead_call_time` enum('1','2','3') DEFAULT '1' COMMENT '1= Second\n2= Minutes\n3=Hour\n',
2394 `lead_call_notes` text,
2395 `lead_call_date` datetime NOT NULL,
2396 `lead_call_user` varchar(100) NOT NULL,
2397 `lead_id` int(11) NOT NULL
2398) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2399
2400--
2401-- Dumping data for table `lead_calls`
2402--
2403
2404INSERT INTO `lead_calls` (`lead_call_id`, `lead_call_title`, `lead_call_duration`, `lead_call_time`, `lead_call_notes`, `lead_call_date`, `lead_call_user`, `lead_id`) VALUES
2405(1, 'paggilan baru', 3, '2', 'panggilan baru', '2017-08-29 04:28:11', 'adiputra', 6),
2406(2, 'enw', 50, '1', 'dasdasd', '2017-08-29 04:39:05', 'adiputra', 6),
2407(3, 'panggilan baru', 20, '2', 'panggilan hari ini', '2017-08-29 04:39:31', 'adiputra', 6),
2408(4, 'sdaas', 45, '1', 'adasdasd', '2017-08-29 04:41:21', 'adiputra', 6),
2409(5, 'call', 5, '2', 'note', '2017-08-29 08:01:40', 'adiputra', 7);
2410
2411-- --------------------------------------------------------
2412
2413--
2414-- Table structure for table `lead_files`
2415--
2416
2417CREATE TABLE `lead_files` (
2418 `lead_files_id` int(11) NOT NULL,
2419 `lead_file_subject` varchar(100) DEFAULT NULL,
2420 `lead_file_to` varchar(100) NOT NULL,
2421 `lead_file_cc` varchar(100) DEFAULT NULL,
2422 `lead_file_description` text,
2423 `lead_file_name` varchar(100) NOT NULL,
2424 `lead_file_date` datetime NOT NULL,
2425 `lead_file_user` varchar(100) NOT NULL,
2426 `lead_id` int(11) NOT NULL
2427) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2428
2429--
2430-- Dumping data for table `lead_files`
2431--
2432
2433INSERT INTO `lead_files` (`lead_files_id`, `lead_file_subject`, `lead_file_to`, `lead_file_cc`, `lead_file_description`, `lead_file_name`, `lead_file_date`, `lead_file_user`, `lead_id`) VALUES
2434(1, 'ini', 'wahyu@majubersama.com', 'adiputra@gmail.com,basori@gmail.com', 'ini file baru', '2addfdd3-6704-431f-86de-a18139310266.pdf', '2017-08-29 04:26:38', 'adiputra', 6),
2435(2, 'New file 2', 'wahyu@majubersama.com', 'adiputra@gmail.com', 'e of Chichén Itzá altered the political spectrum in the Yucatán peninsula and began eroding the dominance of Coba. Beginning around 900 or 1000 AD, Coba must have begun', 'f1d6bcbd-6ceb-404e-8448-e6364f6e8360.pdf', '2017-08-29 04:31:45', 'adiputra', 6),
2436(3, 'new file again', 'wahyu@majubersama.com', 'adiputra@gmail.com,,basori@gmail.com', 'ini baru lagi evidenced by the new buildings dating to the time 1200-1500 AD, now built in the typical Eastern coastal style. However, power centers and trading routes had moved to the coast,', '01c54204-323a-44b5-8079-8ad200671c25.pdf', '2017-08-29 04:32:17', 'adiputra', 6),
2437(4, 'new file', 'wahyu@majubersama.com', 'adiputra@gmail.com,,parinussa@gmail.com', 'forcing cities like Coba into a secondary status, although somewhat more successful than its more ephemeral enemy Chichén Itzá. The greatest of the Coba kings was King Goon.', '643738aa-dfa1-4714-bf2b-7eb95c7ac59a.pdf', '2017-08-29 04:32:56', 'adiputra', 6),
2438(5, 'subject', 'tohir@gmail.com', 'adiputra@gmail.com,parinussa@gmail.com', 'deskripsi file', '50eb20c1-3b8a-4d8a-8fc6-dc10973596a0.pdf', '2017-08-29 07:47:29', 'adiputra', 7);
2439
2440-- --------------------------------------------------------
2441
2442--
2443-- Table structure for table `lead_meeting`
2444--
2445
2446CREATE TABLE `lead_meeting` (
2447 `lead_meeting_id` int(11) NOT NULL,
2448 `lead_meeting_name` varchar(100) DEFAULT NULL,
2449 `lead_meeting_location` varchar(255) DEFAULT NULL,
2450 `lead_meeting_start_date` datetime DEFAULT NULL,
2451 `lead_meeting_end_date` datetime DEFAULT NULL,
2452 `lead_meeting_description` text,
2453 `lead_meeting_date` datetime NOT NULL,
2454 `lead_meeting_user` varchar(100) NOT NULL,
2455 `lead_id` int(11) NOT NULL
2456) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2457
2458--
2459-- Dumping data for table `lead_meeting`
2460--
2461
2462INSERT INTO `lead_meeting` (`lead_meeting_id`, `lead_meeting_name`, `lead_meeting_location`, `lead_meeting_start_date`, `lead_meeting_end_date`, `lead_meeting_description`, `lead_meeting_date`, `lead_meeting_user`, `lead_id`) VALUES
2463(1, 'CRM', 'KN', '2017-08-29 00:00:00', '2017-08-29 00:00:00', 'membahas project kn', '2017-08-29 04:29:00', 'adiputra', 6),
2464(2, 'meeting', 'kemayoran', '2017-08-29 00:00:00', '2017-08-29 00:00:00', 'meeting', '2017-08-29 08:00:10', 'adiputra', 7),
2465(3, 'meeting 2', 'kelapa gading', '2017-08-31 00:00:00', '2017-08-31 00:00:00', 'meeting kelapa gading', '2017-08-29 08:00:54', 'adiputra', 7);
2466
2467-- --------------------------------------------------------
2468
2469--
2470-- Table structure for table `lead_meeting_users`
2471--
2472
2473CREATE TABLE `lead_meeting_users` (
2474 `lead_meeting_id` int(11) NOT NULL,
2475 `lead_user_id` int(11) NOT NULL
2476) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2477
2478--
2479-- Dumping data for table `lead_meeting_users`
2480--
2481
2482INSERT INTO `lead_meeting_users` (`lead_meeting_id`, `lead_user_id`) VALUES
2483(1, 18),
2484(1, 21),
2485(2, 18),
2486(3, 18);
2487
2488-- --------------------------------------------------------
2489
2490--
2491-- Table structure for table `lead_notes`
2492--
2493
2494CREATE TABLE `lead_notes` (
2495 `lead_note_id` int(11) NOT NULL,
2496 `lead_note_name` varchar(100) NOT NULL,
2497 `lead_note_description` text,
2498 `lead_note_date` datetime NOT NULL,
2499 `lead_note_user` varchar(100) NOT NULL,
2500 `lead_id` int(11) NOT NULL
2501) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2502
2503--
2504-- Dumping data for table `lead_notes`
2505--
2506
2507INSERT INTO `lead_notes` (`lead_note_id`, `lead_note_name`, `lead_note_description`, `lead_note_date`, `lead_note_user`, `lead_id`) VALUES
2508(1, 'Note Pertama', '<p>ini adalah descripsi note pertama</p>', '2017-08-28 16:34:17', 'parinussa', 3),
2509(3, 'Note baru lgi', '<span style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; letter-spacing: normal;">oubled faced features that were found around the majority of the household clusters. These were often linked to the platforms that led to the sacbeobs. A lot of features found tended to connect to something or lead to something but the other end was left open-ended. Coba has many features that are platforms or on platforms. The last major linear </span>', '2017-08-29 04:30:46', 'adiputra', 6),
2510(4, 'coba lagi', '<span style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; letter-spacing: normal;">by the new buildings dating to the time 1200-1500 AD, now built in the typical Eastern coastal style. However, power centers and trading routes had moved to the coast,</span>', '2017-08-29 04:31:07', 'adiputra', 6),
2511(5, 'note', '<p>contoh note</p>', '2017-08-29 07:46:28', 'adiputra', 7);
2512
2513-- --------------------------------------------------------
2514
2515--
2516-- Table structure for table `lead_tasks`
2517--
2518
2519CREATE TABLE `lead_tasks` (
2520 `lead_task_id` int(11) NOT NULL,
2521 `lead_task_name` varchar(100) NOT NULL,
2522 `lead_task_description` varchar(45) DEFAULT NULL,
2523 `lead_task_status` int(11) DEFAULT NULL,
2524 `lead_task_due_date` datetime DEFAULT NULL,
2525 `lead_task_date` datetime NOT NULL,
2526 `lead_task_user` varchar(100) NOT NULL,
2527 `lead_id` int(11) NOT NULL
2528) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2529
2530--
2531-- Dumping data for table `lead_tasks`
2532--
2533
2534INSERT INTO `lead_tasks` (`lead_task_id`, `lead_task_name`, `lead_task_description`, `lead_task_status`, `lead_task_due_date`, `lead_task_date`, `lead_task_user`, `lead_id`) VALUES
2535(1, 'Task Pertama', 'Ini task pertama untuk di follow up', 100, '2017-08-28 00:00:00', '2017-08-28 16:30:45', 'parinussa', 3),
2536(2, 'Task Kedua', 'Ini Task Kedua', 30, '2017-08-28 00:00:00', '2017-08-28 16:31:14', 'parinussa', 3),
2537(3, 'Task Ketiga', 'Ini isi task Ketiga', 40, '2017-08-28 00:00:00', '2017-08-28 16:31:40', 'parinussa', 3),
2538(4, 'Task Keempat', 'ini task keempat', 60, '2017-08-28 00:00:00', '2017-08-28 16:32:57', 'parinussa', 3),
2539(5, 'Task Kelima', 'ini task kelima', 20, '2017-08-28 00:00:00', '2017-08-28 16:33:24', 'parinussa', 3),
2540(6, 'task keenam', 'ini task keenam', 30, '2017-08-28 00:00:00', '2017-08-28 16:33:48', 'parinussa', 3),
2541(7, 'new task', 'this is new task', 50, '2017-08-29 00:00:00', '2017-08-29 04:35:13', 'adiputra', 6),
2542(8, 'new task again', 'this is new task again', 40, '2017-08-29 00:00:00', '2017-08-29 04:35:32', 'adiputra', 6),
2543(9, 'new task 2', 'a lengthy power struggle with Chichén Itzá, w', 40, '2017-08-29 00:00:00', '2017-08-29 04:35:55', 'adiputra', 6),
2544(10, 'New Task 3', 'new task again', 70, '2017-08-29 00:00:00', '2017-08-29 04:36:12', 'adiputra', 6),
2545(11, 'New Task 5', 'This is new task 5', 70, '2017-08-29 00:00:00', '2017-08-29 04:36:34', 'adiputra', 6),
2546(12, 'Folloe up', 'deskripsi', 60, '2017-08-29 00:00:00', '2017-08-29 07:43:58', 'adiputra', 7),
2547(13, 'task baru', 'deskripsi', 40, '2017-08-29 00:00:00', '2017-08-29 07:44:21', 'adiputra', 7);
2548
2549-- --------------------------------------------------------
2550
2551--
2552-- Table structure for table `opportunity_calls`
2553--
2554
2555CREATE TABLE `opportunity_calls` (
2556 `opportunity_call_id` int(11) NOT NULL,
2557 `opportunity_call_title` varchar(100) DEFAULT NULL,
2558 `opportunity_call_duration` int(11) DEFAULT NULL,
2559 `opportunity_call_time` enum('1','2','3') DEFAULT '1' COMMENT '1= Second\n2= Minutes\n3=Hour\n',
2560 `opportunity_call_notes` text,
2561 `opportunity_call_date` datetime NOT NULL,
2562 `opportunity_call_user` varchar(100) NOT NULL,
2563 `opportunity_id` int(11) NOT NULL
2564) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2565
2566-- --------------------------------------------------------
2567
2568--
2569-- Table structure for table `opportunity_files`
2570--
2571
2572CREATE TABLE `opportunity_files` (
2573 `opportunity_files_id` int(11) NOT NULL,
2574 `opportunity_file_subject` varchar(100) DEFAULT NULL,
2575 `opportunity_file_to` varchar(100) NOT NULL,
2576 `opportunity_file_cc` varchar(100) DEFAULT NULL,
2577 `opportunity_file_description` text,
2578 `opportunity_file_name` varchar(100) NOT NULL,
2579 `opportunity_file_date` datetime NOT NULL,
2580 `opportunity_file_user` varchar(100) NOT NULL,
2581 `opportunity_id` int(11) NOT NULL
2582) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2583
2584-- --------------------------------------------------------
2585
2586--
2587-- Table structure for table `opportunity_meeting`
2588--
2589
2590CREATE TABLE `opportunity_meeting` (
2591 `opportunity_meeting_id` int(11) NOT NULL,
2592 `opportunity_meeting_name` varchar(100) DEFAULT NULL,
2593 `opportunity_meeting_location` varchar(255) DEFAULT NULL,
2594 `opportunity_meeting_start_date` datetime DEFAULT NULL,
2595 `opportunity_meeting_end_date` datetime DEFAULT NULL,
2596 `opportunity_meeting_description` text,
2597 `opportunity_meeting_date` datetime NOT NULL,
2598 `opportunity_meeting_user` varchar(100) NOT NULL,
2599 `opportunity_id` int(11) NOT NULL
2600) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2601
2602-- --------------------------------------------------------
2603
2604--
2605-- Table structure for table `opportunity_meeting_users`
2606--
2607
2608CREATE TABLE `opportunity_meeting_users` (
2609 `opportunity_meeting_id` int(11) NOT NULL,
2610 `opportunity_user_id` int(11) NOT NULL
2611) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2612
2613-- --------------------------------------------------------
2614
2615--
2616-- Table structure for table `opportunity_notes`
2617--
2618
2619CREATE TABLE `opportunity_notes` (
2620 `opportunity_note_id` int(11) NOT NULL,
2621 `opportunity_note_name` varchar(100) NOT NULL,
2622 `opportunity_note_description` text,
2623 `opportunity_note_date` datetime DEFAULT NULL,
2624 `opportunity_note_user` varchar(100) DEFAULT NULL,
2625 `opportunity_id` int(11) NOT NULL
2626) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2627
2628-- --------------------------------------------------------
2629
2630--
2631-- Table structure for table `opportunity_tasks`
2632--
2633
2634CREATE TABLE `opportunity_tasks` (
2635 `opportunity_task_id` int(11) NOT NULL,
2636 `opportunity_task_name` varchar(100) NOT NULL,
2637 `opportunity_task_description` varchar(45) DEFAULT NULL,
2638 `opportunity_task_status` int(11) DEFAULT NULL,
2639 `opportunity_task_due_date` datetime DEFAULT NULL,
2640 `opportunity_task_date` datetime NOT NULL,
2641 `opportunity_task_user` varchar(100) NOT NULL,
2642 `opportunity_id` int(11) NOT NULL
2643) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2644
2645--
2646-- Indexes for dumped tables
2647--
2648
2649--
2650-- Indexes for table `coba`
2651--
2652ALTER TABLE `coba`
2653 ADD PRIMARY KEY (`id`);
2654
2655--
2656-- Indexes for table `company_calls`
2657--
2658ALTER TABLE `company_calls`
2659 ADD PRIMARY KEY (`company_call_id`),
2660 ADD KEY `fk_company_calls_crm_company1_idx` (`company_id`);
2661
2662--
2663-- Indexes for table `company_files`
2664--
2665ALTER TABLE `company_files`
2666 ADD PRIMARY KEY (`company_files_id`),
2667 ADD KEY `fk_company_files_crm_company1_idx` (`company_id`);
2668
2669--
2670-- Indexes for table `company_meeting`
2671--
2672ALTER TABLE `company_meeting`
2673 ADD PRIMARY KEY (`company_meeting_id`),
2674 ADD KEY `fk_company_meeting_crm_company1_idx` (`company_id`);
2675
2676--
2677-- Indexes for table `company_meeting_users`
2678--
2679ALTER TABLE `company_meeting_users`
2680 ADD PRIMARY KEY (`company_meeting_id`,`company_user_id`),
2681 ADD KEY `fk_company_meeting_has_crm_users_crm_users1_idx` (`company_user_id`),
2682 ADD KEY `fk_company_meeting_has_crm_users_company_meeting1_idx` (`company_meeting_id`);
2683
2684--
2685-- Indexes for table `company_notes`
2686--
2687ALTER TABLE `company_notes`
2688 ADD PRIMARY KEY (`company_note_id`),
2689 ADD KEY `fk_company_notes_crm_company1_idx` (`company_id`);
2690
2691--
2692-- Indexes for table `company_tasks`
2693--
2694ALTER TABLE `company_tasks`
2695 ADD PRIMARY KEY (`company_task_id`),
2696 ADD KEY `fk_company_tasks_crm_company1_idx` (`company_id`);
2697
2698--
2699-- Indexes for table `contact_calls`
2700--
2701ALTER TABLE `contact_calls`
2702 ADD PRIMARY KEY (`contact_call_id`),
2703 ADD KEY `fk_customer_calls_crm_customers1_idx` (`contact_id`);
2704
2705--
2706-- Indexes for table `contact_files`
2707--
2708ALTER TABLE `contact_files`
2709 ADD PRIMARY KEY (`contact_files_id`),
2710 ADD KEY `fk_customer_files_copy1_crm_customers1_idx` (`contact_id`);
2711
2712--
2713-- Indexes for table `contact_meeting`
2714--
2715ALTER TABLE `contact_meeting`
2716 ADD PRIMARY KEY (`contact_meeting_id`),
2717 ADD KEY `fk_customer_meeting_crm_customers1_idx` (`contact_id`);
2718
2719--
2720-- Indexes for table `contact_meeting_users`
2721--
2722ALTER TABLE `contact_meeting_users`
2723 ADD PRIMARY KEY (`contact_meeting_id`,`contact_user_id`),
2724 ADD KEY `fk_contact_meeting_has_crm_users_crm_users1_idx` (`contact_user_id`),
2725 ADD KEY `fk_contact_meeting_has_crm_users_contact_meeting1_idx` (`contact_meeting_id`);
2726
2727--
2728-- Indexes for table `contact_notes`
2729--
2730ALTER TABLE `contact_notes`
2731 ADD PRIMARY KEY (`contact_note_id`),
2732 ADD KEY `fk_customer_notes_crm_customers1_idx` (`contact_id`);
2733
2734--
2735-- Indexes for table `contact_tasks`
2736--
2737ALTER TABLE `contact_tasks`
2738 ADD PRIMARY KEY (`contact_task_id`),
2739 ADD KEY `fk_customer_tasks_crm_customers1_idx` (`contact_id`);
2740
2741--
2742-- Indexes for table `crm_campaigns`
2743--
2744ALTER TABLE `crm_campaigns`
2745 ADD PRIMARY KEY (`campaign_id`);
2746
2747--
2748-- Indexes for table `crm_companies`
2749--
2750ALTER TABLE `crm_companies`
2751 ADD PRIMARY KEY (`company_id`),
2752 ADD KEY `fk_crm_company_crm_industry1_idx` (`company_industry`),
2753 ADD KEY `fk_crm_company_crm_groups1_idx` (`company_groups`),
2754 ADD KEY `fk_crm_companies_crm_companies1_idx` (`company_parent`);
2755
2756--
2757-- Indexes for table `crm_companies_products`
2758--
2759ALTER TABLE `crm_companies_products`
2760 ADD KEY `company_id` (`company_id`),
2761 ADD KEY `product_id` (`product_id`);
2762
2763--
2764-- Indexes for table `crm_contacts`
2765--
2766ALTER TABLE `crm_contacts`
2767 ADD PRIMARY KEY (`contact_id`),
2768 ADD KEY `fk_crm_customer_crm_company1_idx` (`company_id`),
2769 ADD KEY `fk_crm_customer_crm_groups1_idx` (`contact_groups`),
2770 ADD KEY `fk_crm_customer_peoples1_idx` (`contact_id`),
2771 ADD KEY `fk_crm_contacts_crm_peoples1_idx` (`people_id`);
2772
2773--
2774-- Indexes for table `crm_groups`
2775--
2776ALTER TABLE `crm_groups`
2777 ADD PRIMARY KEY (`group_id`);
2778
2779--
2780-- Indexes for table `crm_industry`
2781--
2782ALTER TABLE `crm_industry`
2783 ADD PRIMARY KEY (`industry_id`);
2784
2785--
2786-- Indexes for table `crm_invoices`
2787--
2788ALTER TABLE `crm_invoices`
2789 ADD PRIMARY KEY (`invoice_id`),
2790 ADD KEY `fk_crm_invoices_crm_terms1_idx` (`term_id`),
2791 ADD KEY `fk_crm_invoices_crm_companies1_idx` (`company_id`);
2792
2793--
2794-- Indexes for table `crm_invoices_products`
2795--
2796ALTER TABLE `crm_invoices_products`
2797 ADD PRIMARY KEY (`invoice_detail_id`,`product_id`),
2798 ADD KEY `fk_crm_invoice_details_has_crm_products_crm_products1_idx` (`product_id`),
2799 ADD KEY `fk_crm_invoice_details_has_crm_products_crm_invoice_details_idx` (`invoice_detail_id`),
2800 ADD KEY `invoice_detail_id` (`invoice_detail_id`);
2801
2802--
2803-- Indexes for table `crm_invoice_details`
2804--
2805ALTER TABLE `crm_invoice_details`
2806 ADD PRIMARY KEY (`invoice_detail_id`),
2807 ADD KEY `fk_crm_invoice_details_crm_invoices1_idx` (`invoice_id`);
2808
2809--
2810-- Indexes for table `crm_leads`
2811--
2812ALTER TABLE `crm_leads`
2813 ADD PRIMARY KEY (`lead_id`),
2814 ADD KEY `fk_crm_leads_crm_lead_status1_idx` (`lead_label`),
2815 ADD KEY `fk_crm_leads_crm_groups1_idx` (`lead_groups`),
2816 ADD KEY `fk_crm_leads_crm_peoples1_idx` (`people_id`);
2817
2818--
2819-- Indexes for table `crm_lead_label`
2820--
2821ALTER TABLE `crm_lead_label`
2822 ADD PRIMARY KEY (`lead_label_id`);
2823
2824--
2825-- Indexes for table `crm_modules`
2826--
2827ALTER TABLE `crm_modules`
2828 ADD PRIMARY KEY (`module_id`);
2829
2830--
2831-- Indexes for table `crm_news`
2832--
2833ALTER TABLE `crm_news`
2834 ADD PRIMARY KEY (`news_id`);
2835
2836--
2837-- Indexes for table `crm_opportunities`
2838--
2839ALTER TABLE `crm_opportunities`
2840 ADD PRIMARY KEY (`opportunity_id`),
2841 ADD KEY `fk_crm_opportunities_crm_opportunity_stage1_idx` (`opportunity_stage_id`),
2842 ADD KEY `fk_crm_opportunities_crm_companies1_idx` (`company_id`),
2843 ADD KEY `fk_crm_opportunities_crm_campaigns1_idx` (`opportunity_campaign_id`);
2844
2845--
2846-- Indexes for table `crm_opportunities_contacts`
2847--
2848ALTER TABLE `crm_opportunities_contacts`
2849 ADD PRIMARY KEY (`opportunity_id`,`contact_id`),
2850 ADD KEY `fk_crm_opportunities_has_crm_contacts_crm_contacts1_idx` (`contact_id`),
2851 ADD KEY `fk_crm_opportunities_has_crm_contacts_crm_opportunities1_idx` (`opportunity_id`);
2852
2853--
2854-- Indexes for table `crm_opportunities_products`
2855--
2856ALTER TABLE `crm_opportunities_products`
2857 ADD PRIMARY KEY (`opportunity_id`,`product_id`),
2858 ADD KEY `fk_crm_opportunities_has_crm_products_crm_products1_idx` (`product_id`),
2859 ADD KEY `fk_crm_opportunities_has_crm_products_crm_opportunities1_idx` (`opportunity_id`);
2860
2861--
2862-- Indexes for table `crm_opportunity_stage`
2863--
2864ALTER TABLE `crm_opportunity_stage`
2865 ADD PRIMARY KEY (`opportunity_stage_id`);
2866
2867--
2868-- Indexes for table `crm_payment`
2869--
2870ALTER TABLE `crm_payment`
2871 ADD PRIMARY KEY (`payment_id`),
2872 ADD KEY `invoice_id` (`invoice_detail_id`),
2873 ADD KEY `payment_method_id` (`payment_method_id`);
2874
2875--
2876-- Indexes for table `crm_payment_methods`
2877--
2878ALTER TABLE `crm_payment_methods`
2879 ADD PRIMARY KEY (`payment_method_id`);
2880
2881--
2882-- Indexes for table `crm_peoples`
2883--
2884ALTER TABLE `crm_peoples`
2885 ADD PRIMARY KEY (`people_id`),
2886 ADD KEY `fk_peoples_crm_industry1_idx` (`people_industry`),
2887 ADD KEY `fk_peoples_crm_source1_idx` (`people_source`);
2888
2889--
2890-- Indexes for table `crm_products`
2891--
2892ALTER TABLE `crm_products`
2893 ADD PRIMARY KEY (`product_id`),
2894 ADD KEY `crm_products_crm_product_categories_category_id_fk` (`product_category_id`);
2895
2896--
2897-- Indexes for table `crm_products_campaigns`
2898--
2899ALTER TABLE `crm_products_campaigns`
2900 ADD PRIMARY KEY (`product_id`,`campaign_id`),
2901 ADD KEY `fk_crm_products_has_crm_campaigns_crm_campaigns1_idx` (`campaign_id`),
2902 ADD KEY `fk_crm_products_has_crm_campaigns_crm_products1_idx` (`product_id`);
2903
2904--
2905-- Indexes for table `crm_product_categories`
2906--
2907ALTER TABLE `crm_product_categories`
2908 ADD PRIMARY KEY (`category_id`);
2909
2910--
2911-- Indexes for table `crm_roles`
2912--
2913ALTER TABLE `crm_roles`
2914 ADD PRIMARY KEY (`role_id`);
2915
2916--
2917-- Indexes for table `crm_roles_modules`
2918--
2919ALTER TABLE `crm_roles_modules`
2920 ADD PRIMARY KEY (`crm_roles_role_id`,`crm_modules_module_id`),
2921 ADD KEY `fk_crm_roles_has_crm_modules_crm_modules1_idx` (`crm_modules_module_id`),
2922 ADD KEY `fk_crm_roles_has_crm_modules_crm_roles1_idx` (`crm_roles_role_id`);
2923
2924--
2925-- Indexes for table `crm_setup_company`
2926--
2927ALTER TABLE `crm_setup_company`
2928 ADD PRIMARY KEY (`company_id`);
2929
2930--
2931-- Indexes for table `crm_source`
2932--
2933ALTER TABLE `crm_source`
2934 ADD PRIMARY KEY (`source_id`);
2935
2936--
2937-- Indexes for table `crm_terms`
2938--
2939ALTER TABLE `crm_terms`
2940 ADD PRIMARY KEY (`term_id`);
2941
2942--
2943-- Indexes for table `crm_users`
2944--
2945ALTER TABLE `crm_users`
2946 ADD PRIMARY KEY (`user_id`),
2947 ADD UNIQUE KEY `crm_users_user_email_uindex` (`user_email`),
2948 ADD KEY `crm_users_crm_groups_group_id_fk` (`user_group_id`),
2949 ADD KEY `fk_crm_users_crm_users1_idx` (`user_manager_id`),
2950 ADD KEY `fk_crm_users_crm_roles1_idx` (`user_role_id`);
2951
2952--
2953-- Indexes for table `crm_users_companies`
2954--
2955ALTER TABLE `crm_users_companies`
2956 ADD PRIMARY KEY (`company_id`,`user_id`),
2957 ADD KEY `fk_crm_company_has_crm_users_crm_users1_idx` (`user_id`),
2958 ADD KEY `fk_crm_company_has_crm_users_crm_company1_idx` (`company_id`);
2959
2960--
2961-- Indexes for table `crm_users_contacts`
2962--
2963ALTER TABLE `crm_users_contacts`
2964 ADD PRIMARY KEY (`contact_id`,`user_id`),
2965 ADD KEY `fk_crm_users_has_crm_customer_crm_customer1_idx` (`contact_id`),
2966 ADD KEY `fk_crm_users_has_crm_customer_crm_users1_idx` (`user_id`);
2967
2968--
2969-- Indexes for table `crm_users_leads`
2970--
2971ALTER TABLE `crm_users_leads`
2972 ADD PRIMARY KEY (`lead_id`,`user_id`),
2973 ADD KEY `fk_crm_users_has_crm_leads_crm_leads1_idx` (`lead_id`),
2974 ADD KEY `fk_crm_users_has_crm_leads_crm_users1_idx` (`user_id`);
2975
2976--
2977-- Indexes for table `invoice_control`
2978--
2979ALTER TABLE `invoice_control`
2980 ADD PRIMARY KEY (`invoice_id`),
2981 ADD KEY `invoice_id` (`invoice_id`);
2982
2983--
2984-- Indexes for table `lead_calls`
2985--
2986ALTER TABLE `lead_calls`
2987 ADD PRIMARY KEY (`lead_call_id`),
2988 ADD KEY `fk_lead_calls_crm_leads1_idx` (`lead_id`);
2989
2990--
2991-- Indexes for table `lead_files`
2992--
2993ALTER TABLE `lead_files`
2994 ADD PRIMARY KEY (`lead_files_id`),
2995 ADD KEY `fk_lead_files_crm_leads1_idx` (`lead_id`);
2996
2997--
2998-- Indexes for table `lead_meeting`
2999--
3000ALTER TABLE `lead_meeting`
3001 ADD PRIMARY KEY (`lead_meeting_id`),
3002 ADD KEY `fk_lead_meeting_crm_leads1_idx` (`lead_id`);
3003
3004--
3005-- Indexes for table `lead_meeting_users`
3006--
3007ALTER TABLE `lead_meeting_users`
3008 ADD PRIMARY KEY (`lead_meeting_id`,`lead_user_id`),
3009 ADD KEY `fk_lead_meeting_has_crm_users_crm_users1_idx` (`lead_user_id`),
3010 ADD KEY `fk_lead_meeting_has_crm_users_lead_meeting1_idx` (`lead_meeting_id`);
3011
3012--
3013-- Indexes for table `lead_notes`
3014--
3015ALTER TABLE `lead_notes`
3016 ADD PRIMARY KEY (`lead_note_id`),
3017 ADD KEY `fk_lead_notes_crm_leads1_idx` (`lead_id`);
3018
3019--
3020-- Indexes for table `lead_tasks`
3021--
3022ALTER TABLE `lead_tasks`
3023 ADD PRIMARY KEY (`lead_task_id`),
3024 ADD KEY `fk_lead_task_crm_leads1_idx` (`lead_id`);
3025
3026--
3027-- Indexes for table `opportunity_calls`
3028--
3029ALTER TABLE `opportunity_calls`
3030 ADD PRIMARY KEY (`opportunity_call_id`),
3031 ADD KEY `fk_opportunity_calls_crm_opportunities1_idx` (`opportunity_id`);
3032
3033--
3034-- Indexes for table `opportunity_files`
3035--
3036ALTER TABLE `opportunity_files`
3037 ADD PRIMARY KEY (`opportunity_files_id`),
3038 ADD KEY `fk_opportunity_files_crm_opportunities1_idx` (`opportunity_id`);
3039
3040--
3041-- Indexes for table `opportunity_meeting`
3042--
3043ALTER TABLE `opportunity_meeting`
3044 ADD PRIMARY KEY (`opportunity_meeting_id`),
3045 ADD KEY `fk_opportunity_meeting_crm_opportunities1_idx` (`opportunity_id`);
3046
3047--
3048-- Indexes for table `opportunity_meeting_users`
3049--
3050ALTER TABLE `opportunity_meeting_users`
3051 ADD PRIMARY KEY (`opportunity_meeting_id`,`opportunity_user_id`),
3052 ADD KEY `fk_opportunity_meeting_has_crm_users_crm_users1_idx` (`opportunity_user_id`),
3053 ADD KEY `fk_opportunity_meeting_has_crm_users_opportunity_meeting1_idx` (`opportunity_meeting_id`);
3054
3055--
3056-- Indexes for table `opportunity_notes`
3057--
3058ALTER TABLE `opportunity_notes`
3059 ADD PRIMARY KEY (`opportunity_note_id`),
3060 ADD KEY `fk_opportunity_notes_crm_opportunities1_idx` (`opportunity_id`);
3061
3062--
3063-- Indexes for table `opportunity_tasks`
3064--
3065ALTER TABLE `opportunity_tasks`
3066 ADD PRIMARY KEY (`opportunity_task_id`),
3067 ADD KEY `fk_opportunity_tasks_crm_opportunities1_idx` (`opportunity_id`);
3068
3069--
3070-- AUTO_INCREMENT for dumped tables
3071--
3072
3073--
3074-- AUTO_INCREMENT for table `coba`
3075--
3076ALTER TABLE `coba`
3077 MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
3078--
3079-- AUTO_INCREMENT for table `company_calls`
3080--
3081ALTER TABLE `company_calls`
3082 MODIFY `company_call_id` int(11) NOT NULL AUTO_INCREMENT;
3083--
3084-- AUTO_INCREMENT for table `company_files`
3085--
3086ALTER TABLE `company_files`
3087 MODIFY `company_files_id` int(11) NOT NULL AUTO_INCREMENT;
3088--
3089-- AUTO_INCREMENT for table `company_meeting`
3090--
3091ALTER TABLE `company_meeting`
3092 MODIFY `company_meeting_id` int(11) NOT NULL AUTO_INCREMENT;
3093--
3094-- AUTO_INCREMENT for table `company_notes`
3095--
3096ALTER TABLE `company_notes`
3097 MODIFY `company_note_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
3098--
3099-- AUTO_INCREMENT for table `company_tasks`
3100--
3101ALTER TABLE `company_tasks`
3102 MODIFY `company_task_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
3103--
3104-- AUTO_INCREMENT for table `contact_calls`
3105--
3106ALTER TABLE `contact_calls`
3107 MODIFY `contact_call_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
3108--
3109-- AUTO_INCREMENT for table `contact_files`
3110--
3111ALTER TABLE `contact_files`
3112 MODIFY `contact_files_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
3113--
3114-- AUTO_INCREMENT for table `contact_meeting`
3115--
3116ALTER TABLE `contact_meeting`
3117 MODIFY `contact_meeting_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
3118--
3119-- AUTO_INCREMENT for table `contact_notes`
3120--
3121ALTER TABLE `contact_notes`
3122 MODIFY `contact_note_id` int(11) NOT NULL AUTO_INCREMENT;
3123--
3124-- AUTO_INCREMENT for table `contact_tasks`
3125--
3126ALTER TABLE `contact_tasks`
3127 MODIFY `contact_task_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
3128--
3129-- AUTO_INCREMENT for table `crm_campaigns`
3130--
3131ALTER TABLE `crm_campaigns`
3132 MODIFY `campaign_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
3133--
3134-- AUTO_INCREMENT for table `crm_companies`
3135--
3136ALTER TABLE `crm_companies`
3137 MODIFY `company_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
3138--
3139-- AUTO_INCREMENT for table `crm_contacts`
3140--
3141ALTER TABLE `crm_contacts`
3142 MODIFY `contact_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
3143--
3144-- AUTO_INCREMENT for table `crm_groups`
3145--
3146ALTER TABLE `crm_groups`
3147 MODIFY `group_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
3148--
3149-- AUTO_INCREMENT for table `crm_industry`
3150--
3151ALTER TABLE `crm_industry`
3152 MODIFY `industry_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
3153--
3154-- AUTO_INCREMENT for table `crm_invoices`
3155--
3156ALTER TABLE `crm_invoices`
3157 MODIFY `invoice_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
3158--
3159-- AUTO_INCREMENT for table `crm_invoice_details`
3160--
3161ALTER TABLE `crm_invoice_details`
3162 MODIFY `invoice_detail_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
3163--
3164-- AUTO_INCREMENT for table `crm_leads`
3165--
3166ALTER TABLE `crm_leads`
3167 MODIFY `lead_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
3168--
3169-- AUTO_INCREMENT for table `crm_lead_label`
3170--
3171ALTER TABLE `crm_lead_label`
3172 MODIFY `lead_label_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
3173--
3174-- AUTO_INCREMENT for table `crm_modules`
3175--
3176ALTER TABLE `crm_modules`
3177 MODIFY `module_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
3178--
3179-- AUTO_INCREMENT for table `crm_news`
3180--
3181ALTER TABLE `crm_news`
3182 MODIFY `news_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
3183--
3184-- AUTO_INCREMENT for table `crm_opportunities`
3185--
3186ALTER TABLE `crm_opportunities`
3187 MODIFY `opportunity_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
3188--
3189-- AUTO_INCREMENT for table `crm_opportunity_stage`
3190--
3191ALTER TABLE `crm_opportunity_stage`
3192 MODIFY `opportunity_stage_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
3193--
3194-- AUTO_INCREMENT for table `crm_payment`
3195--
3196ALTER TABLE `crm_payment`
3197 MODIFY `payment_id` int(11) NOT NULL AUTO_INCREMENT;
3198--
3199-- AUTO_INCREMENT for table `crm_payment_methods`
3200--
3201ALTER TABLE `crm_payment_methods`
3202 MODIFY `payment_method_id` int(11) NOT NULL AUTO_INCREMENT;
3203--
3204-- AUTO_INCREMENT for table `crm_peoples`
3205--
3206ALTER TABLE `crm_peoples`
3207 MODIFY `people_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
3208--
3209-- AUTO_INCREMENT for table `crm_products`
3210--
3211ALTER TABLE `crm_products`
3212 MODIFY `product_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
3213--
3214-- AUTO_INCREMENT for table `crm_product_categories`
3215--
3216ALTER TABLE `crm_product_categories`
3217 MODIFY `category_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
3218--
3219-- AUTO_INCREMENT for table `crm_roles`
3220--
3221ALTER TABLE `crm_roles`
3222 MODIFY `role_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'User Administrator Hard Code All access module', AUTO_INCREMENT=8;
3223--
3224-- AUTO_INCREMENT for table `crm_setup_company`
3225--
3226ALTER TABLE `crm_setup_company`
3227 MODIFY `company_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
3228--
3229-- AUTO_INCREMENT for table `crm_source`
3230--
3231ALTER TABLE `crm_source`
3232 MODIFY `source_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
3233--
3234-- AUTO_INCREMENT for table `crm_terms`
3235--
3236ALTER TABLE `crm_terms`
3237 MODIFY `term_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
3238--
3239-- AUTO_INCREMENT for table `crm_users`
3240--
3241ALTER TABLE `crm_users`
3242 MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
3243--
3244-- AUTO_INCREMENT for table `lead_calls`
3245--
3246ALTER TABLE `lead_calls`
3247 MODIFY `lead_call_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
3248--
3249-- AUTO_INCREMENT for table `lead_files`
3250--
3251ALTER TABLE `lead_files`
3252 MODIFY `lead_files_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
3253--
3254-- AUTO_INCREMENT for table `lead_meeting`
3255--
3256ALTER TABLE `lead_meeting`
3257 MODIFY `lead_meeting_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
3258--
3259-- AUTO_INCREMENT for table `lead_notes`
3260--
3261ALTER TABLE `lead_notes`
3262 MODIFY `lead_note_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
3263--
3264-- AUTO_INCREMENT for table `lead_tasks`
3265--
3266ALTER TABLE `lead_tasks`
3267 MODIFY `lead_task_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
3268--
3269-- AUTO_INCREMENT for table `opportunity_calls`
3270--
3271ALTER TABLE `opportunity_calls`
3272 MODIFY `opportunity_call_id` int(11) NOT NULL AUTO_INCREMENT;
3273--
3274-- AUTO_INCREMENT for table `opportunity_files`
3275--
3276ALTER TABLE `opportunity_files`
3277 MODIFY `opportunity_files_id` int(11) NOT NULL AUTO_INCREMENT;
3278--
3279-- AUTO_INCREMENT for table `opportunity_meeting`
3280--
3281ALTER TABLE `opportunity_meeting`
3282 MODIFY `opportunity_meeting_id` int(11) NOT NULL AUTO_INCREMENT;
3283--
3284-- AUTO_INCREMENT for table `opportunity_notes`
3285--
3286ALTER TABLE `opportunity_notes`
3287 MODIFY `opportunity_note_id` int(11) NOT NULL AUTO_INCREMENT;
3288--
3289-- AUTO_INCREMENT for table `opportunity_tasks`
3290--
3291ALTER TABLE `opportunity_tasks`
3292 MODIFY `opportunity_task_id` int(11) NOT NULL AUTO_INCREMENT;
3293--
3294-- Constraints for dumped tables
3295--
3296
3297--
3298-- Constraints for table `company_calls`
3299--
3300ALTER TABLE `company_calls`
3301 ADD CONSTRAINT `fk_company_calls_crm_company1` FOREIGN KEY (`company_id`) REFERENCES `crm_companies` (`company_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3302
3303--
3304-- Constraints for table `company_files`
3305--
3306ALTER TABLE `company_files`
3307 ADD CONSTRAINT `fk_company_files_crm_company1` FOREIGN KEY (`company_id`) REFERENCES `crm_companies` (`company_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3308
3309--
3310-- Constraints for table `company_meeting`
3311--
3312ALTER TABLE `company_meeting`
3313 ADD CONSTRAINT `fk_company_meeting_crm_company1` FOREIGN KEY (`company_id`) REFERENCES `crm_companies` (`company_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3314
3315--
3316-- Constraints for table `company_meeting_users`
3317--
3318ALTER TABLE `company_meeting_users`
3319 ADD CONSTRAINT `fk_company_meeting_has_crm_users_company_meeting1` FOREIGN KEY (`company_meeting_id`) REFERENCES `company_meeting` (`company_meeting_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3320 ADD CONSTRAINT `fk_company_meeting_has_crm_users_crm_users1` FOREIGN KEY (`company_user_id`) REFERENCES `crm_users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3321
3322--
3323-- Constraints for table `company_notes`
3324--
3325ALTER TABLE `company_notes`
3326 ADD CONSTRAINT `fk_company_notes_crm_company1` FOREIGN KEY (`company_id`) REFERENCES `crm_companies` (`company_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3327
3328--
3329-- Constraints for table `company_tasks`
3330--
3331ALTER TABLE `company_tasks`
3332 ADD CONSTRAINT `fk_company_tasks_crm_company1` FOREIGN KEY (`company_id`) REFERENCES `crm_companies` (`company_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3333
3334--
3335-- Constraints for table `contact_calls`
3336--
3337ALTER TABLE `contact_calls`
3338 ADD CONSTRAINT `fk_customer_calls_crm_customers1` FOREIGN KEY (`contact_id`) REFERENCES `crm_contacts` (`contact_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3339
3340--
3341-- Constraints for table `contact_files`
3342--
3343ALTER TABLE `contact_files`
3344 ADD CONSTRAINT `fk_customer_files_copy1_crm_customers1` FOREIGN KEY (`contact_id`) REFERENCES `crm_contacts` (`contact_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3345
3346--
3347-- Constraints for table `contact_meeting`
3348--
3349ALTER TABLE `contact_meeting`
3350 ADD CONSTRAINT `fk_customer_meeting_crm_customers1` FOREIGN KEY (`contact_id`) REFERENCES `crm_contacts` (`contact_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3351
3352--
3353-- Constraints for table `contact_meeting_users`
3354--
3355ALTER TABLE `contact_meeting_users`
3356 ADD CONSTRAINT `fk_contact_meeting_has_crm_users_contact_meeting1` FOREIGN KEY (`contact_meeting_id`) REFERENCES `contact_meeting` (`contact_meeting_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3357 ADD CONSTRAINT `fk_contact_meeting_has_crm_users_crm_users1` FOREIGN KEY (`contact_user_id`) REFERENCES `crm_users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3358
3359--
3360-- Constraints for table `contact_notes`
3361--
3362ALTER TABLE `contact_notes`
3363 ADD CONSTRAINT `fk_customer_notes_crm_customers1` FOREIGN KEY (`contact_id`) REFERENCES `crm_contacts` (`contact_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3364
3365--
3366-- Constraints for table `contact_tasks`
3367--
3368ALTER TABLE `contact_tasks`
3369 ADD CONSTRAINT `fk_customer_tasks_crm_customers1` FOREIGN KEY (`contact_id`) REFERENCES `crm_contacts` (`contact_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3370
3371--
3372-- Constraints for table `crm_companies`
3373--
3374ALTER TABLE `crm_companies`
3375 ADD CONSTRAINT `fk_crm_companies_crm_companies1` FOREIGN KEY (`company_parent`) REFERENCES `crm_companies` (`company_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3376 ADD CONSTRAINT `fk_crm_company_crm_groups1` FOREIGN KEY (`company_groups`) REFERENCES `crm_groups` (`group_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3377 ADD CONSTRAINT `fk_crm_company_crm_industry1` FOREIGN KEY (`company_industry`) REFERENCES `crm_industry` (`industry_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3378
3379--
3380-- Constraints for table `crm_companies_products`
3381--
3382ALTER TABLE `crm_companies_products`
3383 ADD CONSTRAINT `crm_companies_products_ibfk_1` FOREIGN KEY (`company_id`) REFERENCES `crm_companies` (`company_id`),
3384 ADD CONSTRAINT `crm_companies_products_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `crm_products` (`product_id`);
3385
3386--
3387-- Constraints for table `crm_contacts`
3388--
3389ALTER TABLE `crm_contacts`
3390 ADD CONSTRAINT `fk_crm_contacts_crm_peoples1` FOREIGN KEY (`people_id`) REFERENCES `crm_peoples` (`people_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3391 ADD CONSTRAINT `fk_crm_customer_crm_company1` FOREIGN KEY (`company_id`) REFERENCES `crm_companies` (`company_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3392 ADD CONSTRAINT `fk_crm_customer_crm_groups1` FOREIGN KEY (`contact_groups`) REFERENCES `crm_groups` (`group_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3393
3394--
3395-- Constraints for table `crm_invoices`
3396--
3397ALTER TABLE `crm_invoices`
3398 ADD CONSTRAINT `fk_crm_invoices_crm_companies1` FOREIGN KEY (`company_id`) REFERENCES `crm_companies` (`company_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3399 ADD CONSTRAINT `fk_crm_invoices_crm_terms1` FOREIGN KEY (`term_id`) REFERENCES `crm_terms` (`term_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3400
3401--
3402-- Constraints for table `crm_invoices_products`
3403--
3404ALTER TABLE `crm_invoices_products`
3405 ADD CONSTRAINT `fk_crm_invoice_details_has_crm_products_crm_invoice_detail` FOREIGN KEY (`invoice_detail_id`) REFERENCES `crm_invoice_details` (`invoice_detail_id`),
3406 ADD CONSTRAINT `fk_crm_invoice_details_has_crm_products_crm_products1` FOREIGN KEY (`product_id`) REFERENCES `crm_products` (`product_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3407
3408--
3409-- Constraints for table `crm_invoice_details`
3410--
3411ALTER TABLE `crm_invoice_details`
3412 ADD CONSTRAINT `fk_crm_invoice_details_crm_invoices1` FOREIGN KEY (`invoice_id`) REFERENCES `crm_invoices` (`invoice_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3413
3414--
3415-- Constraints for table `crm_leads`
3416--
3417ALTER TABLE `crm_leads`
3418 ADD CONSTRAINT `fk_crm_leads_crm_groups1` FOREIGN KEY (`lead_groups`) REFERENCES `crm_groups` (`group_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3419 ADD CONSTRAINT `fk_crm_leads_crm_lead_status1` FOREIGN KEY (`lead_label`) REFERENCES `crm_lead_label` (`lead_label_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3420 ADD CONSTRAINT `fk_crm_leads_crm_peoples1` FOREIGN KEY (`people_id`) REFERENCES `crm_peoples` (`people_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3421
3422--
3423-- Constraints for table `crm_opportunities`
3424--
3425ALTER TABLE `crm_opportunities`
3426 ADD CONSTRAINT `fk_crm_opportunities_crm_campaigns1` FOREIGN KEY (`opportunity_campaign_id`) REFERENCES `crm_campaigns` (`campaign_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3427 ADD CONSTRAINT `fk_crm_opportunities_crm_companies1` FOREIGN KEY (`company_id`) REFERENCES `crm_companies` (`company_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3428 ADD CONSTRAINT `fk_crm_opportunities_crm_opportunity_stage1` FOREIGN KEY (`opportunity_stage_id`) REFERENCES `crm_opportunity_stage` (`opportunity_stage_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3429
3430--
3431-- Constraints for table `crm_opportunities_contacts`
3432--
3433ALTER TABLE `crm_opportunities_contacts`
3434 ADD CONSTRAINT `fk_crm_opportunities_has_crm_contacts_crm_contacts1` FOREIGN KEY (`contact_id`) REFERENCES `crm_contacts` (`contact_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3435 ADD CONSTRAINT `fk_crm_opportunities_has_crm_contacts_crm_opportunities1` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`opportunity_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3436
3437--
3438-- Constraints for table `crm_opportunities_products`
3439--
3440ALTER TABLE `crm_opportunities_products`
3441 ADD CONSTRAINT `fk_crm_opportunities_has_crm_products_crm_opportunities1` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`opportunity_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3442 ADD CONSTRAINT `fk_crm_opportunities_has_crm_products_crm_products1` FOREIGN KEY (`product_id`) REFERENCES `crm_products` (`product_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3443
3444--
3445-- Constraints for table `crm_payment`
3446--
3447ALTER TABLE `crm_payment`
3448 ADD CONSTRAINT `crm_payment_ibfk_1` FOREIGN KEY (`invoice_detail_id`) REFERENCES `crm_invoice_details` (`invoice_detail_id`),
3449 ADD CONSTRAINT `crm_payment_ibfk_2` FOREIGN KEY (`payment_method_id`) REFERENCES `crm_payment_methods` (`payment_method_id`);
3450
3451--
3452-- Constraints for table `crm_peoples`
3453--
3454ALTER TABLE `crm_peoples`
3455 ADD CONSTRAINT `fk_peoples_crm_industry1` FOREIGN KEY (`people_industry`) REFERENCES `crm_industry` (`industry_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3456 ADD CONSTRAINT `fk_peoples_crm_source1` FOREIGN KEY (`people_source`) REFERENCES `crm_source` (`source_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3457
3458--
3459-- Constraints for table `crm_products`
3460--
3461ALTER TABLE `crm_products`
3462 ADD CONSTRAINT `crm_products_crm_product_categories_category_id_fk` FOREIGN KEY (`product_category_id`) REFERENCES `crm_product_categories` (`category_id`);
3463
3464--
3465-- Constraints for table `crm_products_campaigns`
3466--
3467ALTER TABLE `crm_products_campaigns`
3468 ADD CONSTRAINT `fk_crm_products_has_crm_campaigns_crm_campaigns1` FOREIGN KEY (`campaign_id`) REFERENCES `crm_campaigns` (`campaign_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3469 ADD CONSTRAINT `fk_crm_products_has_crm_campaigns_crm_products1` FOREIGN KEY (`product_id`) REFERENCES `crm_products` (`product_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3470
3471--
3472-- Constraints for table `crm_roles_modules`
3473--
3474ALTER TABLE `crm_roles_modules`
3475 ADD CONSTRAINT `fk_crm_roles_has_crm_modules_crm_modules1` FOREIGN KEY (`crm_modules_module_id`) REFERENCES `crm_modules` (`module_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3476 ADD CONSTRAINT `fk_crm_roles_has_crm_modules_crm_roles1` FOREIGN KEY (`crm_roles_role_id`) REFERENCES `crm_roles` (`role_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3477
3478--
3479-- Constraints for table `crm_users`
3480--
3481ALTER TABLE `crm_users`
3482 ADD CONSTRAINT `crm_users_crm_groups_group_id_fk` FOREIGN KEY (`user_group_id`) REFERENCES `crm_groups` (`group_id`),
3483 ADD CONSTRAINT `fk_crm_users_crm_roles1` FOREIGN KEY (`user_role_id`) REFERENCES `crm_roles` (`role_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3484 ADD CONSTRAINT `fk_crm_users_crm_users1` FOREIGN KEY (`user_manager_id`) REFERENCES `crm_users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3485
3486--
3487-- Constraints for table `crm_users_companies`
3488--
3489ALTER TABLE `crm_users_companies`
3490 ADD CONSTRAINT `fk_crm_company_has_crm_users_crm_company1` FOREIGN KEY (`company_id`) REFERENCES `crm_companies` (`company_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3491 ADD CONSTRAINT `fk_crm_company_has_crm_users_crm_users1` FOREIGN KEY (`user_id`) REFERENCES `crm_users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3492
3493--
3494-- Constraints for table `crm_users_contacts`
3495--
3496ALTER TABLE `crm_users_contacts`
3497 ADD CONSTRAINT `fk_crm_users_has_crm_customer_crm_customer1` FOREIGN KEY (`contact_id`) REFERENCES `crm_contacts` (`contact_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3498 ADD CONSTRAINT `fk_crm_users_has_crm_customer_crm_users1` FOREIGN KEY (`user_id`) REFERENCES `crm_users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3499
3500--
3501-- Constraints for table `crm_users_leads`
3502--
3503ALTER TABLE `crm_users_leads`
3504 ADD CONSTRAINT `fk_crm_users_has_crm_leads_crm_leads1` FOREIGN KEY (`lead_id`) REFERENCES `crm_leads` (`lead_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3505 ADD CONSTRAINT `fk_crm_users_has_crm_leads_crm_users1` FOREIGN KEY (`user_id`) REFERENCES `crm_users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3506
3507--
3508-- Constraints for table `invoice_control`
3509--
3510ALTER TABLE `invoice_control`
3511 ADD CONSTRAINT `invoice_control_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `crm_invoices` (`invoice_id`);
3512
3513--
3514-- Constraints for table `lead_calls`
3515--
3516ALTER TABLE `lead_calls`
3517 ADD CONSTRAINT `fk_lead_calls_crm_leads1` FOREIGN KEY (`lead_id`) REFERENCES `crm_leads` (`lead_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3518
3519--
3520-- Constraints for table `lead_files`
3521--
3522ALTER TABLE `lead_files`
3523 ADD CONSTRAINT `fk_lead_files_crm_leads1` FOREIGN KEY (`lead_id`) REFERENCES `crm_leads` (`lead_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3524
3525--
3526-- Constraints for table `lead_meeting`
3527--
3528ALTER TABLE `lead_meeting`
3529 ADD CONSTRAINT `fk_lead_meeting_crm_leads1` FOREIGN KEY (`lead_id`) REFERENCES `crm_leads` (`lead_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3530
3531--
3532-- Constraints for table `lead_meeting_users`
3533--
3534ALTER TABLE `lead_meeting_users`
3535 ADD CONSTRAINT `fk_lead_meeting_has_crm_users_crm_users1` FOREIGN KEY (`lead_user_id`) REFERENCES `crm_users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3536 ADD CONSTRAINT `fk_lead_meeting_has_crm_users_lead_meeting1` FOREIGN KEY (`lead_meeting_id`) REFERENCES `lead_meeting` (`lead_meeting_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3537
3538--
3539-- Constraints for table `lead_notes`
3540--
3541ALTER TABLE `lead_notes`
3542 ADD CONSTRAINT `fk_lead_notes_crm_leads1` FOREIGN KEY (`lead_id`) REFERENCES `crm_leads` (`lead_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3543
3544--
3545-- Constraints for table `lead_tasks`
3546--
3547ALTER TABLE `lead_tasks`
3548 ADD CONSTRAINT `fk_lead_task_crm_leads1` FOREIGN KEY (`lead_id`) REFERENCES `crm_leads` (`lead_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3549
3550--
3551-- Constraints for table `opportunity_calls`
3552--
3553ALTER TABLE `opportunity_calls`
3554 ADD CONSTRAINT `fk_opportunity_calls_crm_opportunities1` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`opportunity_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3555
3556--
3557-- Constraints for table `opportunity_files`
3558--
3559ALTER TABLE `opportunity_files`
3560 ADD CONSTRAINT `fk_opportunity_files_crm_opportunities1` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`opportunity_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3561
3562--
3563-- Constraints for table `opportunity_meeting`
3564--
3565ALTER TABLE `opportunity_meeting`
3566 ADD CONSTRAINT `fk_opportunity_meeting_crm_opportunities1` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`opportunity_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3567
3568--
3569-- Constraints for table `opportunity_meeting_users`
3570--
3571ALTER TABLE `opportunity_meeting_users`
3572 ADD CONSTRAINT `fk_opportunity_meeting_has_crm_users_crm_users1` FOREIGN KEY (`opportunity_user_id`) REFERENCES `crm_users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
3573 ADD CONSTRAINT `fk_opportunity_meeting_has_crm_users_opportunity_meeting1` FOREIGN KEY (`opportunity_meeting_id`) REFERENCES `opportunity_meeting` (`opportunity_meeting_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3574
3575--
3576-- Constraints for table `opportunity_notes`
3577--
3578ALTER TABLE `opportunity_notes`
3579 ADD CONSTRAINT `fk_opportunity_notes_crm_opportunities1` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`opportunity_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3580
3581--
3582-- Constraints for table `opportunity_tasks`
3583--
3584ALTER TABLE `opportunity_tasks`
3585 ADD CONSTRAINT `fk_opportunity_tasks_crm_opportunities1` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`opportunity_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
3586
3587DELIMITER $$
3588--
3589-- Events
3590--
3591CREATE DEFINER=`root`@`localhost` EVENT `test_event_03` ON SCHEDULE EVERY 1 DAY STARTS '2017-09-07 02:53:40' ON COMPLETION NOT PRESERVE ENABLE DO CALL sp_recuring_invoice$$
3592
3593DELIMITER ;
3594
3595/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
3596/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
3597/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;