imprimir_tarefa.php
23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<?php
/*
Copyright [2008] - Sérgio Fernandes Reinert de Lima
Este arquivo é parte do programa gpweb
O gpweb é um software livre; você pode redistribuí-lo e/ou modificá-lo dentro dos termos da Licença Pública Geral GNU como publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/GPL em português para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "licença GPL 2.odt", junto com este programa, se não, acesse o Portal do Software Público Brasileiro no endereço www.softwarepublico.gov.br ou escreva para a Fundação do Software Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
if (!defined('BASE_DIR')) die('Você não deveria acessar este arquivo diretamente.');
global $Aplic, $config;
echo '<html><head><LINK REL="SHORTCUT ICON" href="estilo/rondon/imagens/organizacao/10/favicon.ico"><link rel="stylesheet" type="text/css" href="estilo/rondon/estilo_'.$config['estilo_css'].'.css"></head><body>';
$tipo = getParam($_REQUEST, 'tipo', 0);
$tarefa_id = getParam($_REQUEST, 'tarefa_id', 0);
$baseline_id = getParam($_REQUEST, 'baseline_id', 0);
if ($Aplic->profissional) {
$barra=codigo_barra('tarefa', $tarefa_id);
if ($barra['cabecalho']) echo $barra['imagem'];
}
$obj = new CTarefa(($baseline_id ? true : false), true);
$obj->load($tarefa_id);
$listas_tarefas=($obj->tarefas_subordinadas ? $obj->tarefas_subordinadas : $tarefa_id);
if (!$podeAcessar || !$obj->podeAcessar()) $Aplic->redirecionar('m=publico&a=acesso_negado');
$q = new BDConsulta;
$prioridades = getSisValor('PrioridadeTarefa');
$tipos = getSisValor('TipoTarefa');
include_once ($Aplic->getClasseModulo('tarefas'));
global $tarefa_acesso;
$extra = array(0 => '(nenhum)', 1 => 'Marco', 2 => ucfirst($config['tarefa']).' Dinâmic'.$config['genero_tarefa'], 3 => ucfirst($config['tarefa']).' Inativ'.$config['genero_tarefa']);
$numero=0;
$tarefas[][]=array();
$usuarios=array();
$nomend=array(0 => '');
$nomend+= getSisValorND();
$lista_tarefas=array();
$unidade= getSisValor('TipoUnidade');
$departamentos=array();
$tarefas_dep[][]=array();
$df = '%d/%m/%Y';
$data_inicio = intval($obj->tarefa_inicio) ? new CData($obj->tarefa_inicio) : null;
$data_fim = intval($obj->tarefa_fim) ? new CData($obj->tarefa_fim) : null;
$hoje = new CData();
$estilo = (($obj->tarefa_percentagem < 99.99 && $hoje > $data_fim) && !empty($data_fim)) ? 'style="color:red; font-weight:bold"' : '';
$q->adTabela('tarefa_designados', 't');
$q->esqUnir('usuarios', 'u','t.usuario_id = u.usuario_id');
$q->esqUnir('contatos', 'c', 'usuario_contato = contato_id');
$q->adCampo('u.usuario_id, u.usuario_login, contato_email, perc_designado');
$q->adOnde('t.tarefa_id = '.(int)$tarefa_id);
$q->adOrdem('u.usuario_login');
$usuarios = $q->Lista();
$q->limpar();
$tipoDuracao = getSisValor('TipoDuracaoTarefa');
$projeto = null;
$horas_trabalhadas = (config('horas_trab_diario') ? config('horas_trab_diario') : 8);
$q->adTabela('projetos');
$q->esqUnir('tarefas', 't1', 'projetos.projeto_id = t1.tarefa_projeto');
$q->esqUnir('cias', 'com', 'cia_id = projeto_cia');
$q->esqUnir('usuarios', 'u', 'usuario_id = projeto_responsavel');
$q->esqUnir('contatos', 'con', 'contato_id = usuario_contato');
$q->adCampo('cia_nome, '.($config['militar'] < 10 ? 'concatenar_tres(contato_posto, \' \', contato_nomeguerra)' : 'contato_nomeguerra').' usuario_nome,projeto_data_fim, projeto_data_inicio, projeto_nome, projeto_cor, projeto_descricao');
$q->adCampo('projeto_percentagem');
$q->adOnde('projeto_id = '.$obj->tarefa_projeto. ' AND t1.tarefa_id = t1.tarefa_superior');
$q->adOnde('projeto_id = '.(int)$obj->tarefa_projeto);
$q->carregarObjeto($projeto);
$q->limpar();
echo '<table border="0" cellpadding="0" cellspacing="0" style="max-width: 21.001cm;overflow:hidden;">';
$sql = new BDConsulta;
$sql->adTabela('projetos');
$sql->esqUnir('cias','cias','cias.cia_id=projeto_cia');
$sql->esqUnir('municipios','municipios','municipio_id=cia_cidade');
$sql->adCampo('cia_cabacalho, projeto_responsavel, projeto_supervisor, projeto_nome, municipio_nome AS cia_cidade');
$sql->adOnde('projeto_id='.$obj->tarefa_projeto);
$dados_projeto=$sql->Linha();
$sql->limpar();
echo '<tr><td align="center"><img src="'.$Aplic->gpweb_brasao.'"/></td></tr>';
echo '<tr><td align="center"><font size=2>'.$dados_projeto['cia_cabacalho'].'</font></td></tr>';
echo '<tr><td style="height:10px;"> </td><tr>';
echo '<tr><td align="center"><h1>PROJETO '.$projeto->projeto_nome.'<br>TAREFA '.$obj->tarefa_nome.'</h1></td></tr>';
echo '<tr><td colspan=20 style="height:30px;"> </td></tr>';
if ($obj->tarefa_dono) {
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. RESPONSÁVEL PELA TAREFA</b></font><br> <font size=2>'.nome_funcao('','','','',$obj->tarefa_dono).'</font></td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
}
if ($obj->tarefa_descricao){
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. DESCRIÇÃO</b></font><br> <font size=2>'.$obj->tarefa_descricao.'</font></td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
}
if ($obj->tarefa_inicio){
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. DATA DE INÍCIO</b></font><br> <font size=2>'.$data_inicio->format($df).'</font></td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
}
if ($obj->tarefa_fim){
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. DATA DE TÉRMINO</b></font><br> <font size=2>'.$data_fim->format($df).'</font></td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
}
if ($obj->tarefa_duracao){
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. Duração</b></font><br> <font size=2>'.$obj->tarefa_duracao.' '.$tipoDuracao[$obj->tarefa_duracao_tipo].'</font></td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
}
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. PROGRESSO</b></font><br> <font size=2>';printf("%.1f%%", $obj->tarefa_percentagem); echo '</font></td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
if ($obj->tarefa_url_relacionada) {
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. ENDEREÇO URL</b></font><br> <font size=2>'.$obj->tarefa_url_relacionada.'</font></td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
}
$custo_estimado=$obj->custo_estimado();
$gasto_efetuado=$obj->gasto_efetuado();
$gasto_registro=$obj->gasto_registro();
if ($custo_estimado !='0.00') {
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. CUSTO ESTIMADO</b></font><br> <font size=2>'.$config['simbolo_moeda'].' '.$custo_estimado.'</font></td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
}
if ($gasto_efetuado !='0.00') {
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. CUSTO EFETIVO</b></font><br> <font size=2>'.$config['simbolo_moeda'].' '.$gasto_efetuado.'</font></td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
}
if ($gasto_registro !='0.00') {
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. GASTOS EXTRAS</b></font><br> <font size=2>'.$config['simbolo_moeda'].' '.$gasto_registro.'</font></td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
}
if (count($usuarios)>1) echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. DESIGNADOS</b></font>';
else echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. DESIGNADO</b></font>';
if (count($usuarios)) foreach ($usuarios as $linha) echo '<br> <font size=2>'.nome_funcao('','','','',$linha['usuario_id']).' '.$linha['perc_designado'].'%</font>';
else echo '<br> <font size=2>Ninguem foi designado para est'.($config['genero_tarefa']=='a' ? 'a' : 'e').' '.$config['tarefa'].'</font>';
echo '</td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
$q->adCampo('td.dependencias_req_tarefa_id, t.tarefa_nome');
$q->adTabela('tarefas', 't');
$q->adTabela('tarefa_dependencias', 'td');
$q->adOnde('td.dependencias_req_tarefa_id = t.tarefa_id');
$q->adOnde('td.dependencias_tarefa_id = '.(int)$tarefa_id);
$tarefaDep = $q->Lista();
$q->limpar();
if (count($tarefaDep)>1) echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. DEPENDÊNCIAS</b></font>';
else echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. DEPENDÊNCIA</b></font><br>';
if (count($tarefaDep)) foreach ($tarefaDep as $linha) echo '<br> <font size=2>'.$linha['tarefa_nome'].'</font>';
else echo ' <font size=2>Nenhuma predecessora para est'.($config['genero_tarefa']=='a' ? 'a' : 'e').' '.$config['tarefa'].'</font>';
echo '</td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
$q->adCampo('td.dependencias_tarefa_id, t.tarefa_nome');
$q->adTabela('tarefas', 't');
$q->adTabela('tarefa_dependencias', 'td');
$q->adOnde('td.dependencias_tarefa_id = t.tarefa_id');
$q->adOnde('td.dependencias_req_tarefa_id = '.(int)$tarefa_id);
$dependingTarefas = $q->Lista();
$q->limpar();
if (count($dependingTarefas)>1) echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. DEPENDÊNTES</b></font>';
else echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. DEPENDÊNTE</b></font>';
if (count($dependingTarefas)) foreach ($dependingTarefas as $linha) echo '<br> <font size=2>'.$linha['tarefa_nome'].'</font>';
else echo '<br> <font size=2>Nenhum'.($config['genero_tarefa']=='a' ? 'a' : '').' '.$config['tarefa'].' depende dest'.($config['genero_tarefa']=='a' ? 'a' : 'e').'</font>';
echo '</td></tr>';
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
$nd=array();
$RefRegistroTarefa = getSisValor('RefRegistroTarefa');
$RefRegistroTarefaImagem = getSisValor('RefRegistroTarefaImagem');
$projeto = new CProjeto;
$q = new BDConsulta;
$q->adTabela('tarefa_log');
$q->adCampo('tarefa_log.*, tarefa_nome, usuario_login, tarefa_id');
//$q->adCampo('contato_id');
$q->adUnir('usuarios', 'u', 'usuario_id = tarefa_log_criador');
$q->adUnir('tarefas', 't', 'tarefa_log_tarefa = t.tarefa_id');
$q->adUnir('contatos', 'ct', 'contato_id = usuario_contato');
$q->adOnde('tarefa_log_tarefa IN ('.$listas_tarefas.')');
$q->adOrdem('tarefa_log_data');
$logs = $q->Lista();
$hrs = 0;
$qnt=0;
$custo=array();
if (count($logs)){
echo '<tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. REGISTROS DAS TAREFAS</b></font></td></tr>';
echo '<tr><td align="left" nowrap="nowrap"><table border=0 cellpadding="2" cellspacing=0 class="tbl1">';
echo '<tr><th>Data</th><th>Tarefa</th><th>Ref.</th><th>Título</a></th><th>Responsável</th><th>Horas</th><th>Comentários</th><th>ND</th><th>Custos</th></tr>';
foreach ($logs as $linha) {
$qnt++;
$tarefa_log_data = intval($linha['tarefa_log_data']) ? new CData($linha['tarefa_log_data']) : null;
$estilo = $linha['tarefa_log_problema'] ? 'background-color:#cc6666;color:#ffffff' : '';
echo '<tr bgcolor="white" valign="top">';
echo '<td nowrap="nowrap">'.($tarefa_log_data ? $tarefa_log_data->format($df) : ' ').'</td>';
echo '<td style="white-space: pre-wrap; word-break: all; -ms-word-break: break-all;-ms-word-break: break-all;">'.nome_tarefa($linha['tarefa_id']).'</td>';
$imagem_referencia = '-';
if ($linha['tarefa_log_referencia'] > 0) {
if (isset($RefRegistroTarefaImagem[$linha['tarefa_log_referencia']])) $imagem_referencia = imagem('icones/'.$RefRegistroTarefaImagem[$linha['tarefa_log_referencia']], imagem('icones/'.$RefRegistroTarefaImagem[$linha['tarefa_log_referencia']]).' '.$RefRegistroTarefa[$linha['tarefa_log_referencia']], 'Forma pela qual foram obtidos os dados para efetuar este registro de trabalho.');
elseif (isset($RefRegistroTarefa[$linha['tarefa_log_referencia']])) $imagem_referencia = $RefRegistroTarefa[$linha['tarefa_log_referencia']];
}
echo '<td align="center" valign="middle">'.$imagem_referencia.'</td>';
echo '<td style="white-space: pre-wrap; word-break: all; -ms-word-break: break-all;-ms-word-break: break-all;'.$estilo.'">'.$linha['tarefa_log_nome'].'</td>';
echo '<td nowrap="nowrap">'.nome_funcao('','','','',$linha['tarefa_log_criador']).'</td>';
echo '<td align="right">'.sprintf('%.2f', $linha['tarefa_log_horas']).'</td>';
echo '<td style="white-space: pre-wrap; word-break: all; -ms-word-break: break-all;-ms-word-break: break-all;">'.str_replace("\n", '<br />', $linha['tarefa_log_descricao']).'</td>';
$nd=($linha['tarefa_log_categoria_economica'] && $linha['tarefa_log_grupo_despesa'] && $linha['tarefa_log_modalidade_aplicacao'] ? $linha['tarefa_log_categoria_economica'].'.'.$linha['tarefa_log_grupo_despesa'].'.'.$linha['tarefa_log_modalidade_aplicacao'].'.' : '').$linha['tarefa_log_nd'];
echo '<td align="center" valign="middle">'.($linha['tarefa_log_custo']!=0 ? dica('Natureza da Despesa', (isset($nomend[$linha['tarefa_log_nd']]) ? $nomend[$linha['tarefa_log_nd']] : '')).$linha['tarefa_log_nd'].dicaF(): ' ').'</td>';
echo '<td align="right">'.number_format($linha['tarefa_log_custo'], 2, ',', '.').'</td>';
echo '</tr>';
$hrs += (float)$linha['tarefa_log_horas'];
if (isset($custo[$linha['tarefa_log_nd']])) $custo[$linha['tarefa_log_nd']] += (float)$linha['tarefa_log_custo'];
else $custo[$linha['tarefa_log_nd']] = (float)$linha['tarefa_log_custo'];
}
if (!$qnt) $s = '<tr><td bgcolor="white">Nenhum registro de '.$config['genero_tarefa'].' encontrado.</td></tr></table></td></tr>';
else {
echo '<tr bgcolor="white" valign="top">';
echo '<td colspan="5" align="right" valign="middle"><b>Total de Horas:</b></td>';
$minutos = (int)(($hrs - ((int)$hrs)) * 60);
$minutos = ((strlen($minutos) == 1) ? ('0'.$minutos) : $minutos);
echo '<td align="right" valign="middle"><b>'.(int)$hrs.':'.$minutos.'</b></td>';
echo '<td align="right" colspan="2"><b>Custos</b>';
foreach ($custo as $nd => $somatorio) {
if ($somatorio > 0) echo '<br>'.$nd;
}
echo '<br><b>Total Geral</b>';
echo'</td>';
echo '<td align="right">';
$somatorio_total=0;
foreach ($custo as $nd => $somatorio) {
if ($somatorio > 0) echo '<br>'.number_format($somatorio, 2, ',', '.');
$somatorio_total+=$somatorio;
}
echo '<br><b>'.number_format($somatorio_total, 2, ',', '.').'</b></td>';
echo '</tr>';
echo '</table></td></tr><tr><td><table><tr><td> Legenda</td><td> </td><td bgcolor="#ffffff" style="border-style:solid; border-width:1px 1px 1px 1px;"> </td><td>Registro Normal </td><td bgcolor="#cc6666" style="border-style:solid; border-width:1px 1px 1px 1px;"> </td><td>Registro de Problema</td></tr></table></td></tr>';
}
}
echo '<tr><td colspan=20 style="height:20px;"> </td></tr>';
$objProjeto = new CProjeto();
$objProjeto->load($obj->tarefa_projeto);
$nd=array();
if ($custo_estimado !='0.00'){
echo '<tr><td><table><tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. CUSTOS PLANEJADOS</b></font></td></tr>';
echo '<tr><td> </td></tr>';
echo '<tr><td align="left" nowrap="nowrap">';
$q->adTabela('tarefa_custos', 't');
$q->adCampo('t.*, ((tarefa_custos_quantidade*tarefa_custos_custo)*((100+tarefa_custos_bdi)/100)) AS valor ');
$q->adOnde('t.tarefa_custos_tarefa IN ('.$listas_tarefas.')');
if ($Aplic->profissional && $config['aprova_custo']) $q->adOnde('tarefa_custos_aprovado = 1');
$q->adOrdem('tarefa_custos_tarefa, tarefa_custos_ordem');
$linhas= $q->Lista();
$qnt=0;
echo '<table align="center" border=0 cellpadding="2" cellspacing=0 class="tbl1">';
echo '<tr><th>Nome</th><th>Descrição</th><th>Unidade</th><th width="40">Qnt.</th><th>Valor ('.$config['simbolo_moeda'].')</th><th>ND</th><th width="100">Total ('.$config['simbolo_moeda'].')</th><th>Responsável</th></tr>';
$total=0;
$custo=array();
$tarefa=0;
foreach ($linhas as $dado) {
echo '<tr align="center"><td align="left">'.(++$qnt).' - '.$dado['tarefa_custos_nome'].'</td><td align="left">'.$dado['tarefa_custos_descricao'].'</td><td>'.(isset($unidade[$dado['tarefa_custos_tipo']]) ? $unidade[$dado['tarefa_custos_tipo']] : ' ').'</td><td>'.$dado['tarefa_custos_quantidade'].'</td><td align="right">'.number_format($dado['tarefa_custos_custo'], 2, ',', '.').'</td><td>'.dica('Natureza da Despesa', (isset($nomend[$dado['tarefa_custos_nd']]) ? $nomend[$dado['tarefa_custos_nd']] : '')).$dado['tarefa_custos_nd'].'</td><td align="right">'.number_format($dado['valor'], 2, ',', '.').'</td><td align="left">'.nome_funcao('','','','',$dado['tarefa_custos_usuario']).'</td><tr>';
if (isset($custo[$dado['tarefa_custos_nd']])) $custo[$dado['tarefa_custos_nd']] += (float)$dado['valor'];
else $custo[$dado['tarefa_custos_nd']] = (float)$dado['valor'];
$total+=$dado['valor'];
}
if ($qnt) {
if ($total) {
echo '<tr><td colspan="6" class="std" align="right">';
foreach ($custo as $indice_nd => $somatorio) if ($somatorio > 0) {
echo '<br>'.(isset($nomend[$indice_nd]) ? $nomend[$indice_nd] : 'Sem ND');
}
echo '<br><b>Total</td><td align="right">';
foreach ($custo as $indice_nd => $somatorio) if ($somatorio > 0) echo '<br>'.number_format($somatorio, 2, ',', '.');
echo '<br><b>'.number_format($total, 2, ',', '.').'</b></td><td colspan="2"> </td></tr>';
}
}
else echo '<tr><td colspan="8" class="std" align="left"><b>Nenhum item encontrado.</b></td></tr>';
echo '</table></td></tr></table></td></tr>';
}
$nd=array();
if ($gasto_efetuado !='0.00'){
echo '<tr><td><table><tr><td align="left" nowrap="nowrap"><font size=3><b>'.++$numero.'. CUSTOS EFETIVADOS</b></font></td></tr>';
echo '<tr><td> </td></tr>';
echo '<tr><td align="left" nowrap="nowrap">';
$q->adTabela('tarefa_gastos', 't');
$q->adCampo('t.*, ((tarefa_gastos_quantidade*tarefa_gastos_custo)*((100+tarefa_gastos_bdi)/100)) AS valor ');
$q->adOnde('t.tarefa_gastos_tarefa IN ('.$listas_tarefas.')');
$q->adOrdem('tarefa_gastos_tarefa, tarefa_gastos_ordem');
if ($Aplic->profissional && $config['aprova_gasto']) $q->adOnde('tarefa_gastos_aprovado = 1');
$linhas= $q->Lista();
$qnt=0;
echo '<table align="center" border=0 cellpadding="2" cellspacing=0 class="tbl1">';
echo '<tr><th>Nome</th><th>Descrição</th><th>Unidade</th><th width="40">Qnt.</th><th>Valor ('.$config['simbolo_moeda'].')</th><th>ND</th><th width="100">Total ('.$config['simbolo_moeda'].')</th><th>Responsável</th></tr>';
$total=0;
$custo=array();
$tarefa=0;
foreach ($linhas as $dado) {
echo '<tr align="center"><td align="left">'.++$qnt.' - '.$dado['tarefa_gastos_nome'].'</td><td align="left">'.$dado['tarefa_gastos_descricao'].'</td><td>'.$unidade[$dado['tarefa_gastos_tipo']].'</td><td>'.$dado['tarefa_gastos_quantidade'].'</td><td align="right">'.number_format($dado['tarefa_gastos_custo'], 2, ',', '.').'</td><td>'.dica('Natureza da Despesa', (isset($nomend[$dado['tarefa_gastos_nd']]) ? $nomend[$dado['tarefa_gastos_nd']] : ' ')).$dado['tarefa_gastos_nd'].'</td><td align="right">'.number_format($dado['valor'], 2, ',', '.').'</td><td align="left">'.nome_funcao('','','','',$dado['tarefa_gastos_usuario']).'</td><tr>';
if (isset($custo[$dado['tarefa_gastos_nd']])) $custo[$dado['tarefa_gastos_nd']] += (float)$dado['valor'];
else $custo[$dado['tarefa_gastos_nd']] = (float)$dado['valor'];
$total+=$dado['valor'];
}
if ($qnt) {
if ($total) {
echo '<tr><td colspan="6" class="std" align="right">';
foreach ($custo as $indice_nd => $somatorio) if ($somatorio > 0) echo '<br>'.(isset($nomend[$indice_nd]) && $nomend[$indice_nd] ? $nomend[$indice_nd] : 'Sem ND');
echo '<br><b>Total</td><td align="right">';
foreach ($custo as $indice_nd => $somatorio) if ($somatorio > 0) echo '<br>'.number_format($somatorio, 2, ',', '.');
echo '<br><b>'.number_format($total, 2, ',', '.').'</b></td><td colspan="2"> </td></tr>';
}
}
else echo '<tr><td colspan="8" class="std" align="left"> <b>Nenhum item encontrado.</b></td></tr>';
echo '</table></td></tr></table></td></tr>';
}
echo '<tr><td align="left"><font size=3><b>'.++$numero.'. GRÁFICO GANTT DO PROJETO</b></font></td></tr>';
$src = "?m=tarefas&a=gantt&sem_cabecalho=1&mostrarLegendas=1&proFiltro=&mostrarInativo=1mostrarTodoGantt=1&projeto_id=".$obj->tarefa_projeto."&tarefa_id=".$tarefa_id."&width=1060";
echo '<tr><td align="left"><img src="'.$src.'" alt=""></td></tr>';
//assinatura
$sql->adTabela('projetos');
$sql->esqUnir('usuarios','u2','u2.usuario_id=projetos.projeto_responsavel');
$sql->esqUnir('contatos','c2','c2.contato_id=u2.usuario_contato');
$sql->adCampo('concatenar_tres(c2.contato_posto, \' \', c2.contato_nomeguerra) AS nome_gerente, contato_nomecompleto, contato_posto');
$sql->adOnde('projeto_id='.$obj->tarefa_projeto);
$linha=$sql->Linha();
$sql->limpar();
echo '<tr><td style="height:30px;"> </td><tr>';
$data = new CData();
echo '<tr><td colspan=2 align="center"><font size=2>'.($dados_projeto['cia_cidade'] ? $dados_projeto['cia_cidade'].', ' : '').retorna_data_extenso($data->format(FMT_DATA_MYSQL)).'</font></td></tr>';
if ($linha['nome_gerente']){
echo '<tr><td colspan=2 style="height:50px;"> </td></tr>';
echo '<tr><td colspan=2 align="center">__________________________________________</td></tr>';
echo '<tr><td colspan=2 align="center"><font size=2>'.($linha['contato_posto'] ? $linha['contato_posto'].' ' :'').($linha['contato_nomecompleto'] ? $linha['contato_nomecompleto'] : $linha['nome_gerente']).'</font></td></tr>';
echo '<tr><td colspan=2 align="center"><font size=2>'.ucfirst($config['gerente']).' d'.$config['genero_projeto'].' '.ucfirst($config['projeto']).'</font></td></tr>';
}
if (!$Aplic->profissional && $config['barra_projeto']){
echo '<tr><td colspan=20><table><tr><td width=12></td><td><script>document.write(\'<img src="'.BASE_URL.'/lib/barras/barcode.php?quality=75&barcode=T'.$tarefa_id.'\">\')</script></td></tr></table></td></tr>';
}
if ($Aplic->profissional && $barra['rodape']) echo $barra['imagem'];
echo '</table>';
?>
<script language="javascript">
//self.print();
</script>