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


/* EXPECTED MONTHLY QTYS AND COSTS FOR ATL001 WHICH IS THE DRIVER LINES WILL BE DELETED */
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid) values ('GA.ATL001','1001','2010-01-01',10,10000,1,1001);
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid) values ('GA.ATL001','1002','2010-01-01',10,2000,1,1001);
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid) values ('GA.ATL001','2001','2010-01-01',3,6000,1,1001);
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid) values ('GA.ATL001','2002','2010-01-01',3,3000,1,1001);
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid) values ('GA.ATL001','3001','2010-01-01',2000,6000,1,1001);
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid) values ('GA.ATL001','3002','2010-01-01',2000,1000,1,1001);
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid) values ('GA.ATL001','3002','2010-01-01',4000,2000,1,1001);
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid) values ('GA.ATL001','4001','2010-01-01',1,5000,1,1001);
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid) values ('GA.ATL001','5001','2010-01-01',1,1000,1,1001);
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid) values ('GA.ATL001','5002','2010-01-01',1,500,1,1001);

/* INSERT BUDGET FOR YEAR 2019 FOR 12 MONTHS */
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid)
select f.code_center,r.code_categ,c.calday,r.rab_qty*12,r.rab_number*12,1,1001
from centers f, ccmanager r, calendar c
where f.pid = 1001 
and r.pid = 1001 and r.rab_date = '2010-01-01'
and c.calday = '2020-01-01';

/* INSERT COSTS UNTIL END OF OCT 2019 */
insert into ccmanager (code_center,code_categ,rab_date,rab_qty,rab_number,mid,pid)
select f.code_center,r.code_categ,c.calday,r.rab_qty,r.rab_number,2,1001
from centers f, ccmanager r, calendar c
where f.pid = 1001 
and r.pid = 1001 and r.rab_date = '2010-01-01'
and date_format(c.calday,'%d') = '28'
and c.calday >= '2020-01-01' and c.calday <= now();

update ccmanager set rab_qty=rab_qty*6,  rab_number=rab_number*6  where pid = 1001 and code_center = 'TX.AUS001';
update ccmanager set rab_qty=rab_qty*4,  rab_number=rab_number*4  where pid = 1001 and code_center = 'TX.DAL001';
update ccmanager set rab_qty=rab_qty*8,  rab_number=rab_number*8  where pid = 1001 and code_center = 'HI.HON001';
update ccmanager set rab_qty=rab_qty*18, rab_number=rab_number*18 where pid = 1001 and code_center = 'TX.HOS001';
update ccmanager set rab_qty=rab_qty*12, rab_number=rab_number*12 where pid = 1001 and code_center = 'CA.LAC001';
update ccmanager set rab_qty=rab_qty*14, rab_number=rab_number*14 where pid = 1001 and code_center = 'CA.LAC002';
update ccmanager set rab_qty=rab_qty*20, rab_number=rab_number*20 where pid = 1001 and code_center = 'NY.NYC001';
update ccmanager set rab_qty=rab_qty*6,  rab_number=rab_number*6  where pid = 1001 and code_center = 'CA.SAC001';
update ccmanager set rab_qty=rab_qty*16, rab_number=rab_number*16 where pid = 1001 and code_center = 'CA.SAN001';


delete from ccmanager where pid = 1001 and rab_date = '2010-01-01';