delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;
delete from ccmanager where pid=501 limit 10000;

/* ORIGINAL IMPORT FROM CTOS
insert into categs (pid,code_categ,desc_categ,um,comm_categ,code_categ_group)
select 501,a.empcode,concat(a.fname,' ',a.lname),'HRS',b.desc_des,4000
from aac_time_emp a, aac_time_des b
where a.des_id = b.des_id;

update categs g set a.code_categ_group = (select x.code_categ_group from categs_groups x where x.pid = a.pid and x.desc_categ_group = a.comm_categ) where a.pid=501;
*/

delete from categs where pid=501;

INSERT INTO `categs` (`pid`, `code_categ`, `desc_categ`, `um`, `comm_categ`, `code_categ_group`) VALUES
(501,	'L000001',	'Kinley Wyatt',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000002',	'Zayden Gregory',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000003',	'Isabell Bolton',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000004',	'Vance Daniels',	'HRS',	'DRIVER',	'3000'),
(501,	'L000005',	'Jaqueline Moran',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000006',	'Jamarcus Mayo',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000007',	'Finley Orr',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000008',	'Jerimiah Stark',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000009',	'Esther Harvey',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000010',	'Katelyn Schmidt',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000011',	'Saige Fields',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000012',	'Mikaela Gentry',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000013',	'Roger Moses',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000014',	'Victoria Cherry',	'HRS',	'DRIVER',	'3000'),
(501,	'L000015',	'Bryan Guerra',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000016',	'Jeremy Schmitt',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000017',	'Cooper Tucker',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000018',	'Amare Hoffman',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000019',	'Peter Turner',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000020',	'Camila Roberson',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000021',	'Jewel Oneal',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000022',	'Philip Robbins',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000023',	'Aliana Walton',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000024',	'Zion Davenport',	'HRS',	'DRIVER',	'3000'),
(501,	'L000025',	'Morgan Mcdowell',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000026',	'Maverick Blake',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000027',	'Reynaldo Morton',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000028',	'Izaiah Norman',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000029',	'Jairo Key',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000030',	'Naomi Schultz',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000031',	'Marlee Bates',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000032',	'Joanna Boyer',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000033',	'Johnathan English',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000034',	'Ezequiel Logan',	'HRS',	'DRIVER',	'3000'),
(501,	'L000035',	'Jaylee Estes',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000036',	'Beckham Mccarty',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000037',	'Laylah Barnes',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000038',	'Titus Jackson',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000039',	'Emmalee Hoover',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000040',	'Laney Solis',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000041',	'Denzel Armstrong',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000042',	'Jovany Ross',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000043',	'Jaelyn Nolan',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000044',	'Jaxson Mason',	'HRS',	'DRIVER',	'3000'),
(501,	'L000045',	'Ricky Knight',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000046',	'Lindsay Rivas',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000047',	'Ty Waller',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000048',	'Aydin Mcneil',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000049',	'Belen Shepherd',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000050',	'Phoenix Murphy',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000051',	'Aleah Beck',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000052',	'Markus Bridges',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000053',	'Skyler Dunlap',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000054',	'Gillian Beasley',	'HRS',	'DRIVER',	'3000'),
(501,	'L000055',	'Gianna Zavala',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000056',	'Neil York',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000057',	'Harry Mcintyre',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000058',	'Alivia Fernandez',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000059',	'Tia Mcclain',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000060',	'Santino Cordova',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000061',	'Mariana Irwin',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000062',	'Deven Avery',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000063',	'Elsa Calderon',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000064',	'Emerson Wilkins',	'HRS',	'DRIVER',	'3000'),
(501,	'L000065',	'Leo Cooper',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000066',	'Chelsea Black',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000067',	'Natalie Sawyer',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000068',	'Yamilet Williams',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000069',	'Luciana Schaefer',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000070',	'Kolten Calhoun',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000071',	'Jocelyn Costa',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000072',	'Haley Morris',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000073',	'Gabrielle Monroe',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000074',	'Meadow Davis',	'HRS',	'DRIVER',	'3000'),
(501,	'L000075',	'Caden Andrews',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000076',	'Hunter Moss',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000077',	'Alec Carter',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000078',	'Phoenix Valenzuela',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000079',	'Casey Kent',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000080',	'Danielle Mills',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000081',	'Willow Abbott',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000082',	'Reece Le',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000083',	'Kallie Lozano',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000084',	'Jaylen Bruce',	'HRS',	'DRIVER',	'3000'),
(501,	'L000085',	'Miriam Wilson',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000086',	'Silas Lyons',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000087',	'Nicholas Wong',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000088',	'Dillan Dickerson',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000089',	'Slade Patrick',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000090',	'Chanel Maxwell',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000091',	'Jorge Hodges',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000092',	'Darren Walter',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000093',	'Kareem Huang',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000094',	'Aditya Harding',	'HRS',	'DRIVER',	'3000'),
(501,	'L000095',	'Lilianna Fuentes',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000096',	'Kolby Swanson',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000097',	'Dario Cummings',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000098',	'Leonidas Mcgrath',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000099',	'Darien Braun',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000100',	'Jadyn Williamson',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000101',	'Tucker Dyer',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000102',	'Caiden Bright',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000103',	'Amber Blankenship',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000104',	'Hayden Little',	'HRS',	'DRIVER',	'3000'),
(501,	'L000105',	'Yael Boyd',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000106',	'Cayden Bradford',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000107',	'Jolie Gillespie',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000108',	'Manuel Gould',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000109',	'Keegan Morrow',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000110',	'Yareli Benson',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000111',	'Harmony Melton',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000112',	'Jonah Guzman',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000113',	'Billy Thompson',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000114',	'Jordyn Fletcher',	'HRS',	'DRIVER',	'3000'),
(501,	'L000115',	'Maren Kirby',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000116',	'Milo Huber',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000117',	'Piper Proctor',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000118',	'Gianni Sexton',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000119',	'Santos Phelps',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000120',	'Kennedy Singleton',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000121',	'Angel Huff',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000122',	'Zara Elliott',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000123',	'Catherine Lane',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000124',	'Dominik Weber',	'HRS',	'DRIVER',	'3000'),
(501,	'L000125',	'Azul Khan',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000126',	'Tiara Sutton',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000127',	'Dashawn Green',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000128',	'Lara Barker',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000129',	'Kaleb Bowen',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000130',	'Claire Clarke',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000131',	'Heidy Wagner',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000132',	'Kyler Shelton',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000133',	'Dayami Cameron',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000134',	'Makhi Bush',	'HRS',	'DRIVER',	'3000'),
(501,	'L000135',	'Barrett Richmond',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000136',	'Colten Maddox',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000137',	'Shayla Hill',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000138',	'Phillip Sherman',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000139',	'Tori Salinas',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000140',	'Lauren Torres',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000141',	'Marques Gilbert',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000142',	'Jeramiah Lucas',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000143',	'Harper Brewer',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000144',	'Jaden Mccoy',	'HRS',	'DRIVER',	'3000'),
(501,	'L000145',	'Yesenia Morse',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000146',	'Jaiden Christian',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000147',	'Taliyah Roth',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000148',	'Mckinley Manning',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000149',	'Patrick Krueger',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000150',	'Cedric Gross',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000151',	'Margaret Robinson',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000152',	'Stella Cruz',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000153',	'Kristin Hickman',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000154',	'Teagan Wade',	'HRS',	'DRIVER',	'3000'),
(501,	'L000155',	'Tiffany Holden',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000156',	'Orion Santana',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000157',	'Trystan Bass',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000158',	'Noemi Chaney',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000159',	'Angelo Ferrell',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000160',	'Eliana Tran',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000161',	'Holly Moon',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000162',	'Maya Mercado',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000163',	'Hugh Fuller',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000164',	'Everett Baldwin',	'HRS',	'DRIVER',	'3000'),
(501,	'L000165',	'Marc Berger',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000166',	'Valery Livingston',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000167',	'Izayah Rodriguez',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000168',	'Ishaan Robles',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000169',	'Gina Mosley',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000170',	'Alani Harmon',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000171',	'Jalen Evans',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000172',	'Uriah Blackwell',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000173',	'Peyton Lucero',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000174',	'Corinne Lindsey',	'HRS',	'DRIVER',	'3000'),
(501,	'L000175',	'Marcel Bryant',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000176',	'Justus Wiggins',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000177',	'Moshe Hart',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000178',	'Diamond Mcdaniel',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000179',	'Marisa Gray',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000180',	'Taniya Small',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000181',	'Grayson Ho',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000182',	'Carolina Booth',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000183',	'Colt Buchanan',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000184',	'Hailey Wolfe',	'HRS',	'DRIVER',	'3000'),
(501,	'L000185',	'Precious Donaldson',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000186',	'Lexie Bailey',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000187',	'Dulce Goodman',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000188',	'Jorden Garcia',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000189',	'Denisse Mueller',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000190',	'Adyson King',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000191',	'Zachary Ward',	'HRS',	'ENGINEER',	'2000'),
(501,	'L000192',	'Tomas Ayers',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000193',	'Rey Ellis',	'HRS',	'FOREMAN',	'1000'),
(501,	'L000194',	'Zachariah Galloway',	'HRS',	'DRIVER',	'3000'),
(501,	'L000195',	'London Gonzalez',	'HRS',	'WORKER SKILLED',	'4001'),
(501,	'L000196',	'Evangeline Parsons',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000197',	'Yurem Ashley',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000198',	'Yasmin Atkinson',	'HRS',	'WORKER SEMISKILLED',	'4002'),
(501,	'L000199',	'Braden Hayes',	'HRS',	'WORKER UNSKILLED',	'4003'),
(501,	'L000000',	'Cali Barrera',	'HRS',	'WORKER UNSKILLED',	'4003');





/* TIME KEEP CONTROL */
/* pid=501 */

/* CENTER 0100  */
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid)
select c.code_center,g.code_categ,x.calday,8,1,1,c.pid
from centers c, categs g, calendar x
where c.pid=501 and g.pid = 501
and c.code_center = '0100'
and g.code_categ like 'L0000%' 
and x.calday >= '2019-01-01' and x.calday <= now()
and date_format(x.calday,'%a') not in ('Sat','Sun');

insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid)
select c.code_center,g.code_categ,x.calday,8,1.2,1,c.pid
from centers c, categs g, calendar x
where c.pid=501 and g.pid = 501
and c.code_center = '0100'
and g.code_categ like 'L0000%'
and x.calday >= '2019-01-01' and x.calday <= now()
and date_format(x.calday,'%a') in ('Sat');


/* CENTER 0200  */
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid)
select c.code_center,g.code_categ,x.calday,8,1,1,c.pid
from centers c, categs g, calendar x
where c.pid=501 and g.pid = 501
and c.code_center = '0200'
and g.code_categ like 'L0001%'
and x.calday >= '2019-01-01' and x.calday <= now()
and date_format(x.calday,'%a') not in ('Sat','Sun');

insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid)
select c.code_center,g.code_categ,x.calday,8,1.2,1,c.pid
from centers c, categs g, calendar x
where c.pid=501 and g.pid = 501
and c.code_center = '0200'
and (g.code_categ like 'L00011%' 
		or g.code_categ like 'L00012%' 
		or g.code_categ like 'L00013%' 
		or g.code_categ like 'L00014%' 
		or g.code_categ like 'L00015%' 
		or g.code_categ like 'L00016%')
and x.calday >= '2019-01-01' and x.calday <= now()
and date_format(x.calday,'%a') in ('Sat');

/* CENTER 0300  */
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid)
select c.code_center,g.code_categ,x.calday,8,1,1,c.pid
from centers c, categs g, calendar x
where c.pid=501 and g.pid = 501
and c.code_center = '0300'
and (g.code_categ like 'L00017%' 
		or g.code_categ like 'L00018%' 
		or g.code_categ like 'L00019%')
and x.calday >= '2019-01-01' and x.calday <= now()
and date_format(x.calday,'%a') not in ('Sat','Sun');

insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid)
select c.code_center,g.code_categ,x.calday,8,1.2,1,c.pid
from centers c, categs g, calendar x
where c.pid=501 and g.pid = 501
and c.code_center = '0300'
and (g.code_categ like 'L00017%' 
		or g.code_categ like 'L00018%' 
		or g.code_categ like 'L00019%')
and x.calday >= '2019-01-01' and x.calday <= now()
and date_format(x.calday,'%a') in ('Sat');

/* CENTER 2100  */
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid)
select c.code_center,g.code_categ,x.calday,8,1,1,c.pid
from centers c, categs g, calendar x
where c.pid=501 and g.pid = 501
and c.code_center = '2100'
and g.code_categ in (select code_categ from categs where code_categ_group = '4003' and pid=501)
and x.calday >= '2019-01-01' and x.calday <= now()
and date_format(x.calday,'%a') not in ('Sat','Sun')
ORDER BY RAND()
limit 2000;


/* CENTER 2200  */
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid)
select c.code_center,g.code_categ,x.calday,8,1,1,c.pid
from centers c, categs g, calendar x
where c.pid=501 and g.pid = 501
and c.code_center = '2200'
and g.code_categ in (select code_categ from categs where code_categ_group = '2000' and pid=501)
and x.calday >= '2019-01-01' and x.calday <= now()
and date_format(x.calday,'%a') not in ('Sat','Sun')
ORDER BY RAND()
limit 1000;



update ccmanager set rab_number = rab_number * 144 where code_categ in (select code_categ from categs where code_categ_group = '1000' and pid=501) and pid=501; 
update ccmanager set rab_number = rab_number * 160 where code_categ in (select code_categ from categs where code_categ_group = '2000' and pid=501) and pid=501; 
update ccmanager set rab_number = rab_number * 96 where code_categ in (select code_categ from categs where code_categ_group = '3000' and pid=501) and pid=501; 
update ccmanager set rab_number = rab_number * 80 where code_categ in (select code_categ from categs where code_categ_group = '4001' and pid=501) and pid=501; 
update ccmanager set rab_number = rab_number * 68 where code_categ in (select code_categ from categs where code_categ_group = '4002' and pid=501) and pid=501; 
update ccmanager set rab_number = rab_number * 57.6 where code_categ in (select code_categ from categs where code_categ_group = '4003' and pid=501) and pid=501; 


/* PID 501 TAGS */

delete from ccmanager_tags where tag in (select desc_categ_group from categs_groups where pid = 501);

insert into ccmanager_tags (cid,tag)
select a.cid,b.comm_categ
from ccmanager a, categs b
where a.pid in (501)
and a.pid = b.pid
and a.code_categ = b.code_categ;