/* TAGS */
truncate table ccmanager_tags;

SET NAMES utf8;

insert into ccmanager_tags (cid,tag)
select cid,concat('Year-',date_format(rab_date,'%Y'))
from ccmanager
where pid in (1,103,104);


insert into ccmanager_tags (cid,tag)
select a.cid,date_format(b.rab_date,'%b-%Y')
from ccmanager b, ccmanager_tags a
where b.cid = a.cid; 


insert into ccmanager_tags (cid,tag)
select cid,'John Doe Diesel Supplier'
from ccmanager
where pid in (103)
and mid = 2
and code_categ like '012%';

insert into ccmanager_tags (cid,tag)
select cid,'Nick Jones Petrol Station'
from ccmanager
where pid in (103)
and mid = 2
and code_categ like '011%';

insert into ccmanager_tags (cid,tag)
select cid,'Lubricants Shop'
from ccmanager
where pid in (103)
and mid = 2
and code_categ='0401';

insert into ccmanager_tags (cid,tag)
select cid,'Προμηθευτής Πετρελαίου'
from ccmanager
where pid in (104)
and mid = 2
and code_categ like '012%';

insert into ccmanager_tags (cid,tag)
select cid,'Προμηθευτής Βενζίνης'
from ccmanager
where pid in (104)
and mid = 2
and code_categ like '011%';

insert into ccmanager_tags (cid,tag)
select cid,'Κατάστημα Λιπαντικών'
from ccmanager
where pid in (104)
and mid = 2
and code_categ='0401';

/* PID 301 TAGS */

insert into ccmanager_tags (cid,tag)
select cid,'North Oil Fuels'
from ccmanager
where pid in (301)
and mid = 2
and code_categ in ('0101','0102')
and code_center in (select code_center from centers where code_center_group = '1000');

insert into ccmanager_tags (cid,tag)
select cid,'Southern Fuel Company'
from ccmanager
where pid in (301)
and mid = 2
and code_categ in ('0101','0102')
and code_center in (select code_center from centers where code_center_group = '2000');

insert into ccmanager_tags (cid,tag)
select cid,'Down Town Fuels'
from ccmanager
where pid in (301)
and mid = 2
and code_categ in ('0101','0102')
and code_center in (select code_center from centers where code_center_group = '3000');

insert into ccmanager_tags (cid,tag)
select cid,'CNG Central'
from ccmanager
where pid in (301)
and mid = 2
and code_categ in ('0131');


insert into ccmanager_tags (cid,tag)
select cid,'Salaries'
from ccmanager
where pid in (301)
and mid = 2
and code_center in ('5001');

/* VARIOUS UPDATES ON SYSTEM */
update ccmanager set rab_qty = 1 where rab_uc is null;