Montar relatório mensal de horas trabalhadas
Tenho a seguinte tabela:
-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tempo de Geração: Jul 09, 2013 as 12:48 AM
-- Versão do Servidor: 5.5.8
-- Versão do PHP: 5.3.5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Banco de Dados: base
--
-- --------------------------------------------------------
--
-- Estrutura da tabela horas
--
DROP TABLE IF EXISTS `horas`;
CREATE TABLE IF NOT EXISTS `horas` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nrfunc` int(7) NOT NULL,
`data` date NOT NULL,
`diames` int(2) NOT NULL,
`semana` int(2) NOT NULL,
`hi` datetime NOT NULL,
`ht` datetime NOT NULL,
`total` varchar(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=35 ;
--
-- Extraindo dados da tabela horas
--
INSERT INTO horas (id, nrfunc, data, diames, semana, hi, ht, total) VALUES
(1, 9288, '2013-06-01', 1, 22, '2013-06-01 08:30:00', '2013-06-01 13:00:00', '4.5'),
(2, 9288, '2013-06-02', 2, 23, '2013-06-02 08:30:00', '2013-06-02 18:00:00', '9.5'),
(3, 9288, '2013-06-19', 19, 25, '2013-06-19 08:30:00', '2013-06-19 18:00:00', '9.5'),
(4, 9288, '2013-06-04', 4, 23, '2013-06-04 08:30:00', '2013-06-04 18:00:00', '9.5'),
(5, 9288, '2013-06-05', 5, 23, '2013-06-05 08:30:00', '2013-06-05 18:00:00', '9.5'),
(6, 9288, '2013-06-06', 6, 23, '2013-06-06 08:30:00', '2013-06-06 18:00:00', '9.5'),
(7, 9288, '2013-06-07', 7, 23, '2013-06-07 08:30:00', '2013-06-07 18:00:00', '9.5'),
(8, 9288, '2013-06-08', 8, 23, '2013-06-08 08:30:00', '2013-06-08 18:00:00', '9.5'),
(9, 9288, '2013-06-09', 9, 24, '2013-06-09 08:30:00', '2013-06-09 18:00:00', '9.5'),
(10, 9288, '2013-06-10', 10, 24, '2013-06-10 08:30:00', '2013-06-10 18:00:00', '9.5'),
(11, 9288, '2013-06-11', 11, 24, '2013-06-11 08:30:00', '2013-06-11 18:00:00', '9.5'),
(12, 9288, '2013-06-15', 15, 24, '2013-06-15 08:30:00', '2013-06-15 18:00:00', '9.5'),
(13, 9288, '2013-06-16', 16, 25, '2013-06-16 14:00:00', '2013-06-16 20:00:00', '6'),
(14, 9288, '2013-06-16', 16, 25, '2013-06-16 14:00:00', '2013-06-16 20:00:00', '6'),
(15, 9288, '2013-06-18', 18, 25, '2013-06-18 14:00:00', '2013-06-18 20:00:00', '6'),
(16, 9288, '2013-06-19', 19, 25, '2013-06-19 14:00:00', '2013-06-19 20:00:00', '6'),
(17, 9288, '2013-06-20', 20, 25, '2013-06-20 14:00:00', '2013-06-20 20:00:00', '6'),
(18, 9288, '2013-06-22', 22, 25, '2013-06-22 14:00:00', '2013-06-22 20:00:00', '6'),
(19, 9288, '2013-06-23', 23, 25, '2013-06-23 14:00:00', '2013-06-23 20:00:00', '6'),
(20, 9288, '2013-06-24', 24, 25, '2013-06-24 14:00:00', '2013-06-24 20:00:00', '6'),
(21, 1955, '2013-06-02', 2, 23, '2013-06-02 07:00:00', '2013-06-02 19:00:00', '12'),
(22, 1955, '2013-06-03', 3, 23, '2013-06-03 19:00:00', '2013-06-04 07:00:00', '12'),
(23, 1955, '2013-06-06', 6, 23, '2013-06-06 07:00:00', '2013-06-06 19:00:00', '12'),
(24, 1955, '2013-06-07', 7, 23, '2013-06-07 19:00:00', '2013-06-08 07:00:00', '12'),
(25, 1955, '2013-06-10', 10, 24, '2013-06-10 07:00:00', '2013-06-10 19:00:00', '12'),
(26, 1955, '2013-06-11', 11, 24, '2013-06-11 19:00:00', '2013-06-12 07:00:00', '12'),
(27, 1955, '2013-06-14', 14, 24, '2013-06-14 07:00:00', '2013-06-14 19:00:00', '12'),
(28, 1955, '2013-06-15', 15, 24, '2013-06-15 19:00:00', '2013-06-16 07:00:00', '12'),
(29, 1955, '2013-06-18', 18, 25, '2013-06-18 07:00:00', '2013-06-18 19:00:00', '12'),
(30, 1955, '2013-06-19', 19, 25, '2013-06-19 19:00:00', '2013-06-20 07:00:00', '12'),
(33, 5181, '2013-06-07', 7, 23, '2013-06-07 08:30:00', '2013-06-07 18:00:00', '9.5'),
(34, 9288, '2013-06-25', 25, 25, '2013-06-25 14:00:00', '2013-06-25 20:00:00', '6');
É possível com base na tabela acima montar um relatório igual ao da imagem abaixo:
/applications/core/interface/imageproxy/imageproxy.php?img=http://imageshack.us/a/img15/9045/n0gc.png&key=a648e8652aced0d132619fda3715f557389032b91bf6c87150b30b2d6551bd67" alt="n0gc.png" />
A idéia é mostrar as horas trabalhadas por dia durante o mes com subtotal por semana de todos os funcionários.
Discussão (1)
Carregando comentários...