insert into system_user values (
    1,'admin','admin','d033e22ae348aeb5660fc2140aec35850c4da997','admin','2015-04-22 10:54:34.56','2015-04-23 14:43:44','0','0'
);

INSERT INTO signal            
    VALUES (0, '', '', '#FFFFFF', 0.0,date(now()),date(now()),'0','0');

INSERT INTO signal
    VALUES (1, 'Vermelho', 'red', '#FF0000', 0.2,date(now()),date(now()),'0','0');

INSERT INTO signal
    VALUES (2, 'Amarelo', 'yellow', '#FFFF00', 0.3,date(now()),date(now()),'0','0');

INSERT INTO signal            
    VALUES (3, 'Azul', 'blue', '#0000FF', 0.5,date(now()),date(now()),'0','0');

INSERT INTO signal            
    VALUES (4, 'Roxo', 'purple', '#800080', 0.7,date(now()),date(now()),'0','0');

INSERT INTO signal            
    VALUES (5, 'Preto', 'black', '#000000',null,date(now()),date(now()),'0','0');

INSERT INTO signal            
    VALUES (6, 'Cinza', 'gray', '#808080',null,date(now()),date(now()),'0','0');





CREATE OR REPLACE FUNCTION working_days(start_date date, end_date date) RETURNS integer AS
$BODY$
declare  
  days int := 0;
begin
  days = (select count(1)
	        from (select(start_date+s.a*'1 day'::interval) AS dia 
		           from generate_series(0, end_date - start_date, 1) AS s(a)) days 
           where extract(DOW from dia) between 1 and 5);
  return days;
end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION working_days(date, date) OWNER TO postgres;


INSERT INTO company
    VALUES (1, 'VHX', 4, '0', '0', '0', 'Porto Alegre', 'RS', '23423423', '23423423', 
            'asdfad@asdfadsf.com',date(now()),date(now()),'0','0');

INSERT INTO company
    VALUES (2, 'ATLANTA', 5, '0', '6767676', '6767676', 'Porto Alegre', 'RS', '67676767', '676767676', 
            '676767@676767.com',date(now()),date(now()),'0','0');
			
INSERT INTO company
    VALUES (3, 'CFV POA', 6, '0', '6767676', '6767676', 'Porto Alegre', 'RS', '67676767', '676767676', 
            '676767@676767.com',date(now()),date(now()),'0','0');
			
INSERT INTO company
    VALUES (4, 'CFC SL', 7, 'fffffff', '6767676', '6767676', 'Porto Alegre', 'RS', '67676767', '676767676', 
            '676767@676767.com',date(now()),date(now()),'0','0');
			
vhx - 4
Atlanta - 5
Cfv Poa - 6
Cfv SL -7