Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

marlone

Notice: Undefined variable:

Recommended Posts

<?php
session_start();
set_time_limit(0);

include 'config.php';
include 'functions.php';

function mes_extenso($referencia = NULL){
	switch ($referencia){
		case 1: $mes = " de Janeiro de "; break;
		case 2: $mes = " de Fevereiro de "; break;
		case 3: $mes = " de Março de "; break;
		case 4: $mes = " de Abril de "; break;
		case 5: $mes = " de Maio de "; break;
		case 6: $mes = " de Junho de "; break;
		case 7: $mes = " de Julho de "; break;
		case 8: $mes = " de Agosto de "; break;
		case 9: $mes = " de Setembro de "; break;
		case 10: $mes = " de Outubro de "; break;
		case 11: $mes = " de Novembro de "; break;
		case 12: $mes = " de Dezembro de "; break;
		default: $mes = " de _______________ de ";
	}
	return $mes;
}

if (isset($_GET['acao']) && $_GET['acao'] == 'apagar') {
    $id = $_GET['id'];
	
	$qr_lc=mysql_query("SELECT * FROM lc_movimento WHERE id='$id'");
    $row_lc=mysql_fetch_array($qr_lc);
	
	$id_orc = $row_lc['id_orcamento'];
	
	$qr_ticket=mysql_query("SELECT * FROM ticket_ticket WHERE ticketID='$id_orc'");
    $row_ticket=mysql_fetch_array($qr_ticket);
	
	if($row_ticket['ticket_id']){
		$sql = 'UPDATE ticket_ticket SET ';
		if(($row_ticket['sinal']-$row_lc['valor']) == 0){
			$sql .= 'sinal_pg = 0, ';
			$sql .= 'data_sinal = \'\', ';
		}
		$sql .= 'sinal = '.($row_ticket['sinal']-$row_lc['valor']).' ';			
		$sql .= 'WHERE ticketID = \''.$id_orc.'\' ';
		$sql_select =mysql_query($sql) or die(mysql_error());
	}

    mysql_query("DELETE FROM lc_movimento WHERE id='$id'");
    echo mysql_error();

    header("Location: ?mes=" . $_GET['mes'] . "&ano=" . $_GET['ano'] . "&ok=2");
    exit();
}

if (isset($_POST['acao']) && $_POST['acao'] == 'editar_cat') {
    $id = $_POST['id'];
    $nome = $_POST['nome'];

    mysql_query("UPDATE lc_cat SET nome='$nome' WHERE id='$id'");
    echo mysql_error();

    header("Location: ?mes=" . $_GET['mes'] . "&ano=" . $_GET['ano'] . "&cat_ok=3");
    exit();
}

if (isset($_GET['action']) && $_GET['action'] == 'pago') {
    $id = $_GET['id'];
    $data = date('d/m/Y');
	$arrayData = explode("/",$data);

	$dia = $arrayData[0];
	$mes = $arrayData[1];
	$ano = $arrayData[2];

    mysql_query("UPDATE lc_movimento SET tipo=0, dia = '$dia', mes = '$mes', ano = '$ano' WHERE id='$id'");
    echo mysql_error();

    header("Location: ?mes=" . $_GET['mes'] . "&ano=" . $_GET['ano'] . "&pago_ok=1");
    exit();
}

if (isset($_GET['action']) && $_GET['action'] == 'recebido') {
    $id = $_GET['id'];
    $data = date('d/m/Y');
	$arrayData = explode("/",$data);

	$dia = $arrayData[0];
	$mes = $arrayData[1];
	$ano = $arrayData[2];
	
	$qr_mv=mysql_query("SELECT * FROM lc_movimento WHERE id='$id'");
    $row_mv=mysql_fetch_array($qr_mv);
	
	$id_orc = $row_mv['id_orcamento'];
	
	$valor_pagamento = $row_mv['valor'];
	
	$qr_ticket=mysql_query("SELECT * FROM ticket_ticket WHERE ticketID='$id_orc'");
    $row_ticket=mysql_fetch_array($qr_ticket);
	
	if($row_mv['id_orcamento']!='' && (eregi('cheque',$row_mv['descricao']) || eregi('boleto',$row_mv['descricao']) )){//cheque ou boleto
		$sql = 'UPDATE ticket_ticket SET ';
			if(($row_ticket['sinal']+$valor_pagamento)>=$row_ticket['valor']){
				$sql .= 'data_resta = now(), ';
				$sql .= 'resta_pg = 1, ';
			}
		$sql .= 'sinal = '.($row_ticket['sinal']+$valor_pagamento).' ';			
		$sql .= 'WHERE ticketID = \''.$id_orc.'\' ';
		$sql_select =mysql_query($sql) or die(mysql_error());
	}

    mysql_query("UPDATE lc_movimento SET tipo=1, dia = '$dia', mes = '$mes', ano = '$ano' WHERE id='$id'");
    echo mysql_error();

    header("Location: ?mes=" . $_GET['mes'] . "&ano=" . $_GET['ano'] . "&recebido_ok=1");
    exit();
}

if (isset($_GET['acao']) && $_GET['acao'] == 'apagar_cat') {
    $id = $_GET['id'];

    $qr=mysql_query("SELECT c.id FROM lc_movimento m, lc_cat c WHERE c.id=m.cat && c.id=$id");
    if (mysql_num_rows($qr)>0){
        header("Location: ?mes=" . $_GET['mes'] . "&ano=" . $_GET['ano'] . "&cat_err=1");
        exit();
    }
    
    mysql_query("DELETE FROM lc_cat WHERE id='$id'");
    echo mysql_error();

    header("Location: ?mes=" . $_GET['mes'] . "&ano=" . $_GET['ano'] . "&cat_ok=2");
    exit();
}

if (isset($_POST['acao']) && $_POST['acao'] == 'editar_mov') {
    $id = $_POST['id'];
    $dia = $_POST['dia'];
	$mes = $_POST['mes'];
	$ano = $_POST['ano'];
    $tipo = $_POST['tipo'];
    $cat = $_POST['cat'];
    $descricao = $_POST['descricao'];
    $valor = str_replace(",", ".", str_replace('.','',$_POST['valor']));

    mysql_query("UPDATE lc_movimento SET dia='$dia', mes='$mes', ano='$ano', tipo='$tipo', cat='$cat', descricao='$descricao', valor='$valor' WHERE id='$id'");
    echo mysql_error();

    header("Location: ?mes=" . $_GET['mes'] . "&ano=" . $_GET['ano'] . "&ok=3");
    exit();
}

if (isset($_POST['acao']) && $_POST['acao'] == 2) {

    $nome = $_POST['nome'];

    mysql_query("INSERT INTO lc_cat (nome) values ('$nome')");

    echo mysql_error();

    header("Location: ?mes=" . $_GET['mes'] . "&ano=" . $_GET['ano'] . "&cat_ok=1");
    exit();
}

if (isset($_POST['acao']) && $_POST['acao'] == 1) {

    $data = $_POST['data'];
    $tipo = $_POST['tipo'];
    $cat = $_POST['cat'];
    $descricao = $_POST['descricao'];
    $valor = str_replace(",", ".", str_replace('.','',$_POST['valor']));

    $t = explode("/", $data);
    $dia = $t[0];
    $mes = $t[1];
    $ano = $t[2];

    mysql_query("INSERT INTO lc_movimento (dia,mes,ano,tipo,descricao,valor,cat) values ('$dia','$mes','$ano','$tipo','$descricao','$valor','$cat')");

    echo mysql_error();

    header("Location: ?mes=" . $_GET['mes'] . "&ano=" . $_GET['ano'] . "&ok=1");
    exit();
}

if (isset($_GET['mes']))
    $mes_hoje = $_GET['mes'];
else
    $mes_hoje = date('m');

if (isset($_GET['ano']))
    $ano_hoje = $_GET['ano'];
else
    $ano_hoje = date('Y');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title id='titulo'>Livro caixa <?php echo $lc_titulo?></title>
<meta name="LANGUAGE" content="Portuguese" />
<meta name="AUDIENCE" content="all" />
<meta name="RATING" content="GENERAL" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="scripts.js"></script>
<style type="text/css">
	ul{
		width:900px;
		align:center;
	}
	ul a{
		text-decoration:none;
	}
	ul a li{
		width:130px;
		padding:10px;
		list-style:none;
		color:#ffffff;
		background-color:#333;
		float:left;
		margin-left:5px;
	}
	ul a li:hover{
		color:#333;
		background-color:#e4e4e4;
	}
</style>
</head>
<body style="padding:10px" onload="loadingAjax('myDiv');">

<center>
<ul>
	<a href='<?=$site.'/';?>ticket/scp/vendas_adm.php'><li>Lista de atendimentos</li></a>
	<a href='<?=$site.'/';?>ticket/scp/livro_caixa'><li>Livro caixa</li></a>
	<a href='<?=$site.'/';?>ticket/scp/relatorio'><li>Relatorio</li></a>
	
</ul>
</center>
<div style="clear:both;"><br><br></div>
<table cellpadding="1" cellspacing="10"  width="900" align="center" style="background-color:#033">

<tr>
<td colspan="11" style="background-color:#005B5B;">
<h2 style="color:#FFF; margin:5px">Livro Caixa - <?php echo $lc_titulo?></h2>
</td>
<td colspan="2" align="right" style="background-color:#005B5B;">
<a style="color:#FFF" href="?mes=<?php echo date('m')?>&ano=<?php echo date('Y')?>">Hoje:<strong> <?php echo date('d')?> de <?php echo mostraMes(date('m'))?> de <?php echo date('Y')?></strong></a>&nbsp; 
</td>
</tr>
<tr>

<td width="70">
<select onchange="location.replace('?mes=<?php echo $mes_hoje?>&ano='+this.value)">
<?php
for ($i=2008;$i<=2020;$i++){
?>
<option value="<?php echo $i?>" <?php if ($i==$ano_hoje) echo "selected=selected"?> ><?php echo $i?></option>
<?php }?>
</select>
</td>


<?php
for ($i=1;$i<=12;$i++){
	?>
    <td align="center" style="<?php if ($i!=12) echo "border-right:1px solid #FFF;"?> padding-right:5px">
    <a href="?mes=<?php echo $i?>&ano=<?php echo $ano_hoje?>" style="
    <?php if($mes_hoje==$i){?>    
    color:#033; font-size:16px; font-weight:bold; background-color:#FFF; padding:5px
    <?php }else{?>
    color:#FFF; font-size:16px;
    <?php }?>
    ">
    <?php echo mostraMes($i);?>
    </a>
    </td>
<?php
}
?>
</tr>
</table>
<br />



<table cellpadding="10" cellspacing="0" width="900" align="center" >
<tr>
<td colspan="2">

<h2><?php echo mostraMes($mes_hoje)?>/<?php echo $ano_hoje?></h2>
</td>
<td align="right">
<a href="javascript:;" onclick="abreFecha('add_cat')" class="bnt">[+] Adicionar Categoria</a>
<a href="javascript:;" onclick="abreFecha('add_movimento')" class="bnt"><strong>[+] Adicionar Movimento</strong></a>
</td>
</tr>

<tr >
<td colspan="3" >

    <?php
if (isset($_GET['cat_err']) && $_GET['cat_err']==1){
?>

<div style="padding:5px; background-color:#FF6; text-align:center; color:#030">
<strong>Esta categoria não pode ser removida, pois há movimentos associados a esta</strong>
</div>

<?php }?>

    <?php
if (isset($_GET['cat_ok']) && $_GET['cat_ok']==2){
?>

<div style="padding:5px; background-color:#FF6; text-align:center; color:#030">
<strong>Categoria removida com sucesso!</strong>
</div>

<?php }?>
    
<?php
if (isset($_GET['cat_ok']) && $_GET['cat_ok']==1){
?>

<div style="padding:5px; background-color:#FF6; text-align:center; color:#030">
<strong>Categoria Cadastrada com sucesso!</strong>
</div>

<?php }?>

<?php
if (isset($_GET['pago_ok']) && $_GET['pago_ok']==1){
?>

<div style="padding:5px; background-color:#FF6; text-align:center; color:#030">
<strong>Conta marcada como paga</strong>
</div>

<?php }?>

<?php
if (isset($_GET['recebido_ok']) && $_GET['recebido_ok']==1){
?>

<div style="padding:5px; background-color:#FF6; text-align:center; color:#030">
<strong>Pagamento confirmado!</strong>
</div>

<?php }?>
    
    <?php
if (isset($_GET['cat_ok']) && $_GET['cat_ok']==3){
?>

<div style="padding:5px; background-color:#FF6; text-align:center; color:#030">
<strong>Categoria alterada com sucesso!</strong>
</div>

<?php }?>

<?php
if (isset($_GET['ok']) && $_GET['ok']==1){
?>

<div style="padding:5px; background-color:#FF6; text-align:center; color:#030">
<strong>Movimento Cadastrado com sucesso!</strong>
</div>

<?php }?>

<?php
if (isset($_GET['ok']) && $_GET['ok']==2){
?>

<div style="padding:5px; background-color:#900; text-align:center; color:#FFF">
<strong>Movimento removido com sucesso!</strong>
</div>

<?php }?>
    
<?php
if (isset($_GET['ok']) && $_GET['ok']==3){
?>

<div style="padding:5px; background-color:#FF6; text-align:center; color:#030">
<strong>Movimento alterado com sucesso!</strong>
</div>

<?php }?>

<div style=" background-color:#F1F1F1; padding:10px; border:1px solid #999; margin:5px; display:none" id="add_cat">
    <h3>Adicionar Categoria</h3>
    <table width="100%">
        <tr>
            <td valign="top">
    

<form method="post" action="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>">
<input type="hidden" name="acao" value="2" />

Nome: <input type="text" name="nome" size="20" maxlength="50" />

<br />
<br />

<input type="submit" class="input" value="Enviar" />
</form>

            </td>
            <td valign="top" align="right">
                <b>Editar/Remover Categorias:</b><br/><br/>
<?php
$qr=mysql_query("SELECT id, nome FROM lc_cat");
while ($row=mysql_fetch_array($qr)){
?>
                <div id="editar2_cat_<?php echo $row['id']?>">
<?php echo $row['nome']?> 
                     <a style="font-size:10px; color:#666" onclick="return confirm('Tem certeza que deseja remover esta categoria?\nAtenção: Apenas categorias sem movimentos associados poderão ser removidas.')" href="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>&acao=apagar_cat&id=<?php echo $row['id']?>" title="Remover">[remover]</a>
                     <a href="javascript:;" style="font-size:10px; color:#666" onclick="document.getElementById('editar_cat_<?php echo $row['id']?>').style.display=''; document.getElementById('editar2_cat_<?php echo $row['id']?>').style.display='none'" title="Editar">[editar]</a>
                    
                </div>
                <div style="display:none" id="editar_cat_<?php echo $row['id']?>">
                    
<form method="post" action="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>">
<input type="hidden" name="acao" value="editar_cat" />
<input type="hidden" name="id" value="<?php echo $row['id']?>" />
<input type="text" name="nome" value="<?php echo $row['nome']?>" size="20" maxlength="50" />
<input type="submit" class="input" value="Alterar" />
</form> 
                </div>

<?php }?>

            </td>
        </tr>
    </table>
</div>

<div style=" background-color:#F1F1F1; padding:10px; border:1px solid #999; margin:5px; display:none" id="add_movimento">
<h3>Adicionar Movimento</h3>
<?php
$qr=mysql_query("SELECT * FROM lc_cat");
if (mysql_num_rows($qr)==0)
	echo "Adicione ao menos uma categoria";

else{
?>
<form method="post" action="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>">
<input type="hidden" name="acao" value="1" />
<strong>Data:</strong><br />
<input type="text" name="data" size="11" maxlength="10" value="<?php echo date('d')?>/<?php echo $mes_hoje?>/<?php echo $ano_hoje?>" />

<br />
<br />

<strong>Tipo:<br /></strong>
<label for="tipo_receita" style="color:#030"><input type="radio" name="tipo" value="1" id="tipo_receita" /> Receita</label>&nbsp; 
<label for="tipo_despesa" style="color:#C00"><input type="radio" name="tipo" value="0" id="tipo_despesa" /> Despesa</label>
<label for="tipo_pagar" style="color:#FF8C00"><input type="radio" name="tipo" value="2" id="tipo_pagar" /> à pagar</label>
<label for="tipo_receber" style="color:#006400"><input type="radio" name="tipo" value="3" id="tipo_receber" /> à receber</label>

<br />
<br />

<strong>Categoria:</strong><br />
<select name="cat">
<?php
while ($row=mysql_fetch_array($qr)){
?>
<option value="<?php echo $row['id']?>"><?php echo $row['nome']?></option>
<?php }?>
</select>

<br />
<br />

<strong>Descrição:</strong><br />
<input type="text" name="descricao" size="100" maxlength="255" />

<br />
<br />

<strong>Valor:</strong><br />
R$<input type="text" name="valor" size="8" maxlength="10" />

<br />
<br />

<input type="submit" class="input" value="Enviar" />

</form>
<?php }?>
</div>
</td>
</tr>

<tr>
<td align="left" valign="top" width="450" style="background-color:#D3FFE2">

<?php
$qr=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=1 && mes='$mes_hoje' && ano='$ano_hoje'");
$row=mysql_fetch_array($qr);
$entradas=$row['total'];

$qr=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=0 && mes='$mes_hoje' && ano='$ano_hoje'");
$row=mysql_fetch_array($qr);
$saidas=$row['total'];

$resultado_mes=$entradas-$saidas;

$mes_hoje_ticket = $mes_hoje;

if($mes_hoje_ticket<10){
	$mes_hoje_ticket = '0'.str_replace('0','',$mes_hoje_ticket);
}

?>

    <fieldset>
        <legend><strong>Entradas e Saídas deste mês</strong></legend>
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td><span style="font-size:18px; color:#030">Entradas:</span></td>
                <td align="right"><span style="font-size:18px; color:#030"><?php echo formata_dinheiro($entradas); $tot_acum = $entradas; ?></span></td>
            </tr>
            <tr>
                <td><span style="font-size:18px; color:#C00">Saídas:</span></td>
                <td align="right"><span style="font-size:18px; color:#C00"><?php echo formata_dinheiro($saidas) ?></span></td>
            </tr>
			
			
            <tr>
                <td colspan="2">
                    <hr size="1" />
                </td>
            </tr>
            <tr>
                <td><strong style="font-size:22px; color:<?php if ($resultado_mes < 0) echo "#C00"; else echo "#030" ?>">Resultado:</strong></td>
                <td align="right"><strong style="font-size:22px; color:<?php if ($resultado_mes < 0) echo "#C00"; else echo "#030" ?>"><?php echo formata_dinheiro($resultado_mes) ?></strong></td>
            </tr>
			<tr>
                <td><span style="font-size:18px; color:#333" id="pg_sinal_count">Sinal <?=$sinal_num ?>:</span></td>
                <td align="right"><span style="font-size:18px; color:#333" id="pg_sinal"><?php echo formata_dinheiro($sinal) ?></span></td>
            </tr>
			<tr>
                <td><span style="font-size:18px; color:#333" id="pg_resta_count">Entregas <?=$entregas_num ?>:</span></td>
                <td align="right"><span style="font-size:18px; color:#333" id="pg_resta"><?php echo formata_dinheiro($entregas) ?></span></td>
            </tr>
			<tr>
                <td><span style="font-size:18px; color:#333" id="pg_faturado_count">Faturados pagos <?=($faturado_num_resta+$faturado_num_sinal); ?>:</span></td>
                <td align="right"><span style="font-size:18px; color:#333" id="pg_faturado"><?php echo formata_dinheiro(($faturado_resta+$faturado_sinal)) ?></span></td>
            </tr>
        </table>
    </fieldset>

</td>

<td width="15">
</td>

<td align="left" valign="top" width="450" style="background-color:#F1F1F1">
<fieldset>
<legend>Balanço Geral desde 04/2016</legend>

<?php

if($ano_hoje==2015){
	$qr=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=1 && mes>'03' &&  ano = '2015' && mes<='$mes_hoje' ");
}else{
	$qr=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=1 && ano ='$ano_hoje' && mes<='$mes_hoje' "); 
}

$row=mysql_fetch_array($qr);
$entradas=$row['total'];
if($ano_hoje==2015){
	$qr=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=0 &&  mes>'03' && ano = '2015' && mes<='$mes_hoje' ");
}else{
	$qr=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=0 && ano = '$ano_hoje' && mes<='$mes_hoje' "); 
}


$row=mysql_fetch_array($qr);
$saidas=$row['total'];

$resultado_geral=$entradas-$saidas;
?>


<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><span style="font-size:18px; color:#030">Entradas:</span></td>
<td align="right"><span style="font-size:18px; color:#030"><?php echo formata_dinheiro($entradas);?></span></td>
</tr>
<tr>
<td><span style="font-size:18px; color:#C00">Saídas:</span></td>
<td align="right"><span style="font-size:18px; color:#C00"><?php echo formata_dinheiro($saidas)?></span></td>
</tr>
<tr>
<td colspan="2">
<hr size="1" />
</td>
</tr>
<tr>
<td><strong style="font-size:22px; color:<?php if ($resultado_geral<0) echo "#C00"; else echo "#030"?>">Resultado:</strong></td>
<td align="right"><strong style="font-size:22px; color:<?php if ($resultado_geral<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($resultado_geral)?></strong></td>
</tr>
</table>

</fieldset>
</td>

</tr>
</table>
<br />


<table cellpadding="5" cellspacing="0" width="900" align="center">
<tr>
<td colspan="2">
    <div style="float:right; text-align:right">
<form name="form_filtro_cat" method="get" action=""  >
<input type="hidden" name="mes" value="<?php echo $mes_hoje?>" >
<input type="hidden" name="ano" value="<?php echo $ano_hoje?>" >
    Filtrar por categoria:  <select name="filtro_cat" onchange="form_filtro_cat.submit()">
<option value="">Tudo</option>
<?php
$qr=mysql_query("SELECT DISTINCT c.id, c.nome FROM lc_cat c, lc_movimento m WHERE m.cat=c.id && m.mes='$mes_hoje' && m.ano='$ano_hoje'");
while ($row=mysql_fetch_array($qr)){
?>
<option <?php if (isset($_GET['filtro_cat']) && $_GET['filtro_cat']==$row['id'])echo "selected=selected"?> value="<?php echo $row['id']?>"><?php echo $row['nome']?></option>
<?php }?>
</select>
  <input type="submit" value="Filtrar" class="botao" />
</form>
    </div>
	
<div id="myDiv">
        <img id="loading-image" src="http://ckan.okblogfarm.org/wp-content/plugins/embed-facebook/slidewindow/loading.gif" style="display:none;"/> Carregando conteúdo, isso pode levar alguns minutos.
</div>
<div>
</div>
<h2>Movimentos deste Mês</h2>

</td>
</tr>
<?php
$filtros="";
if (isset($_GET['filtro_cat'])){
	if ($_GET['filtro_cat']!=''){	
		$filtros="&& cat='".$_GET['filtro_cat']."'";
                
                $qr=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=1 && mes='$mes_hoje' && ano='$ano_hoje' $filtros");
                $row=mysql_fetch_array($qr);
                $entradas=$row['total'];

                $qr=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=0 && mes='$mes_hoje' && ano='$ano_hoje' $filtros");
                $row=mysql_fetch_array($qr);
                $saidas=$row['total'];

                $resultado_mes=$entradas-$saidas;
                
        }
}
$resultado_mes = 0;
$qr=mysql_query("SELECT * FROM lc_movimento WHERE (tipo=0 or tipo=1) && mes='$mes_hoje' && ano='$ano_hoje' $filtros ORDER By dia, id");
$cont=0;
$data_30dias = date('Y-m-d', strtotime("-1 month",strtotime($ano_hoje.'-'.$mes_hoje.'-01')));
	$ex_30dias = explode("-", $data_30dias);
	$ano_30dias = $ex_30dias[0];
	$mes_30dias = $ex_30dias[1];
$data_60dias = date('Y-m-d', strtotime("-2 month",strtotime($ano_hoje.'-'.$mes_hoje.'-01')));
	$ex_60dias = explode("-", $data_60dias);
	$ano_60dias = $ex_60dias[0];
	$mes_60dias = $ex_60dias[1];
$data_90dias = date('Y-m-d', strtotime("-3 month",strtotime($ano_hoje.'-'.$mes_hoje.'-01')));
	$ex_90dias = explode("-", $data_90dias);
	$ano_90dias = $ex_90dias[0];
	$mes_90dias = $ex_90dias[1];

while ($row=mysql_fetch_array($qr)){
$cont++;

$cat=$row['cat'];
$qr2=mysql_query("SELECT nome FROM lc_cat WHERE id='$cat'");
$row2=mysql_fetch_array($qr2);
$categoria=$row2['nome'];
?>
<tr style="background-color:<?php if ($cont%2==0) echo "#F1F1F1"; else echo "#E0E0E0"?>" >
<td align="center" width="15"><?php echo $row['dia']?></td>
<td><?php
$variavel = $row['descricao'];
if (eregi("#", $variavel)) {
$id_orcamento = substr($variavel, 1, 6);

if($row['id_orcamento']==0){
$update_mov = "UPDATE lc_movimento SET "; 
$update_mov .= "id_orcamento = ".$id_orcamento."   ";
$update_mov .= "WHERE id = ".$row['id']." ";								
$update_mov = mysql_query($update_mov);
}

$sql_detalhes = "SELECT subject, source  FROM ticket_ticket "; 
$sql_detalhes .= "WHERE ticketID = ".$id_orcamento." ";								
$sql_detalhes = mysql_query($sql_detalhes);
$row_detalhes = mysql_fetch_array($sql_detalhes);

/*if($categoria=='' && $row_detalhes['source']!=''){
	$sql = 'UPDATE lc_movimento SET ';
	if($row_detalhes['source'] == 'Loja'){
		$sql .= 'cat = 7 ';
	}elseif($row_detalhes['source'] == 'Web'){
		$sql .= 'cat = 8 ';
	}elseif($row_detalhes['source'] == 'Direta'){
		$sql .= 'cat = 9 ';
	}
	$sql .= 'WHERE id = \''.$row['id'].'\' ';
	$sql_select =mysql_query($sql) or die(mysql_error());
}*/



$qr_teste = 'SELECT data_faturado, data_resta, data_sinal FROM ticket_ticket ';
$qr_teste .= 'WHERE (data_resta LIKE \''.$ano_hoje.'-'.$mes_hoje_ticket.'%\' OR data_sinal LIKE \''.$ano_hoje.'-'.$mes_hoje_ticket.'%\') ';
$qr_teste .= 'AND ticketID = \''.$id_orcamento.'\' ';
$qr_teste .= 'ORDER BY created DESC';
$qr_query_teste = mysql_query($qr_teste);
$dia_hoje_ticket = $row['dia'];
if($dia_hoje_ticket<10){
	$dia_hoje_ticket = '0'.str_replace('0','',$dia_hoje_ticket);
}
$foi = 0;
while($row_teste=mysql_fetch_array($qr_query_teste)){
	if($row_teste['data_faturado']==''){
		if($row_teste['data_resta']!='' && eregi($ano_hoje.'-'.$mes_hoje_ticket.'-'.$dia_hoje_ticket, $row_teste['data_resta'])){
				
				$pg_resta += $row['valor'];
				$pg_resta_count += 1;
			
		}elseif($row_teste['data_sinal']!='' && eregi($ano_hoje.'-'.$mes_hoje_ticket.'-'.$dia_hoje_ticket, $row_teste['data_sinal'])){
			
				$pg_sinal += $row['valor'];
				$pg_sinal_count += 1;
		
		}else{
		$pg_faturado += $row['valor'];
		$pg_faturado_count += 1;
		
		}
	}else{
		$pg_faturado += $row['valor'];
		$pg_faturado_count += 1;
	}
	$foi = 1;
}

echo str_replace("#".$id_orcamento,'<a href="'.$site.'/ticket/scp/recibo.php?orcamento='.$id_orcamento.'" target="_blank">#'.$id_orcamento.'</a>',$row['descricao'])." ".$row_detalhes['subject'];
}else{
 echo $row['descricao'];
 if($row['tipo']==1){
		$pg_faturado += $row['valor'];
		$pg_faturado_count += 1;
 }
 
}
?> <em>(<a href="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>&filtro_cat=<?php echo $cat?>"><?php echo $categoria?></a>)</em> <a href="javascript:;" style="font-size:10px; color:#666" onclick="document.getElementById('editar_mov_<?php echo $row['id']?>').style.display='';  " title="Editar">[editar]</a></td>

<?php
if($row['tipo']==0){
	
	
	$qr_90dias=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=0 && descricao LIKE '$row[descricao]' && mes='$mes_90dias' && ano='$ano_90dias' $filtros");
    $row_90dias=mysql_fetch_array($qr_90dias);
    $entradas_90dias=$row_90dias['total'];
	echo '<td align="right"><small style="color:#999; white-space: nowrap;">-'.formata_dinheiro($entradas_90dias).'</small></td>';
	
	$qr_60dias=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=0 && descricao LIKE '$row[descricao]' && mes='$mes_60dias' && ano='$ano_60dias' $filtros");
    $row_60dias=mysql_fetch_array($qr_60dias);
    $entradas_60dias=$row_60dias['total'];
	echo '<td align="right"><small style="color:#999; white-space: nowrap;">-'.formata_dinheiro($entradas_60dias).'</small></td>';	
	
	
	$qr_30dias=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=0 && descricao LIKE '$row[descricao]' && mes='$mes_30dias' && ano='$ano_30dias' $filtros");
    $row_30dias=mysql_fetch_array($qr_30dias);
    $entradas_30dias=$row_30dias['total'];
	echo '<td align="right"><small style="color:#999; white-space: nowrap;">-'.formata_dinheiro($entradas_30dias).'</small></td>';
}				
?>
<td align="right" <?php if ($row['tipo']==1) echo 'colspan="4"'; ?>><strong style="color:<?php if ($row['tipo']==0) echo "#C00"; else echo "#030"?>; white-space: nowrap;">
<?php if ($row['tipo']==0) echo "-"; else echo "+"?><?php echo formata_dinheiro($row['valor'])?></strong></td>
</tr>
    <tr style="display:none;<?php if ($_GET['id']==$row['id']) echo "border:#ff0000 solid 1px;";?> background-color:<?php if ($cont%2==0) echo "#F1F1F1"; else echo "#E0E0E0"?>" id="editar_mov_<?php echo $row['id']?>">
        <td colspan="3">
            <hr/>
            <form method="post" action="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>">
            <input type="hidden" name="acao" value="editar_mov" />
            <input type="hidden" name="id" value="<?php echo $row['id']?>" />
            
            <b>Dia:</b> <input type="text" name="dia" size="3" maxlength="2" value="<?php echo $row['dia']?>" />/<input type="text" name="mes" size="3" maxlength="2" value="<?php echo $row['mes']?>" />/<input type="text" name="ano" size="3" maxlength="2" value="<?php echo $row['ano']?>" />&nbsp;|&nbsp;
            <b>Tipo:</b> 
			<label for="tipo_receita" style="color:#030"><input  <?php if($row['tipo']==1) echo "checked=checked"?> type="radio" name="tipo" value="1" id="tipo_receita" /> Receita</label>&nbsp; 
			<label for="tipo_despesa" style="color:#C00"><input  <?php if($row['tipo']==0) echo "checked=checked"?> type="radio" name="tipo" value="0" id="tipo_despesa" /> Despesa</label>&nbsp; 
			<label for="tipo_pagar" style="color:#FF8C00"><input  <?php if($row['tipo']==2) echo "checked=checked"?> type="radio" name="tipo" value="2" id="tipo_pagar" /> à pagar</label>&nbsp; 
			<label for="tipo_receber" style="color:#006400"><input  <?php if($row['tipo']==3) echo "checked=checked"?> type="radio" name="tipo" value="3" id="tipo_receber" /> à receber</label>
			&nbsp;|&nbsp;
            <b>Categoria:</b>
<select name="cat">
<?php
$qr2=mysql_query("SELECT * FROM lc_cat");

while ($row2=mysql_fetch_array($qr2)){
?>
    <option <?php if($row2['id']==$row['cat']) echo "selected"?> value="<?php echo $row2['id']?>"><?php echo $row2['nome']?></option>
<?php }?>
</select>&nbsp;|&nbsp;
            <b>Valor:</b> R$<input type="text" value="<?php echo number_format($row['valor'],2,',',''); ?>" name="valor" size="8" maxlength="10" />
            <br/>
            <b>Descricao:</b> <input type="text" name="descricao" value="<?php echo $row['descricao']?>" size="70" maxlength="255" />
            
            <input type="submit" class="input" value="Alterar" />
            </form> 
            <div style="text-align: right">
            <a style="color:#FF0000" onclick="return confirm('Tem certeza que deseja apagar?')" href="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>&acao=apagar&id=<?php echo $row['id']?>" title="Remover">[remover]</a>  
            </div>
            <hr/>
        </td>
    </tr>
      
<?php
if($row['tipo']==1){
$resultado_mes += $row['valor'];
}else{
	$resultado_mes -= $row['valor'];
}
}
?>
<tr>
<td colspan="3" align="right">
<strong style="font-size:22px; color:<?php if ($resultado_mes<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($resultado_mes); ?></strong>

</td>
</tr>
<tr>
<td colspan="3">

<br>
<br>

<h2>Contas à pagar (Cumulativo)</h2>

</td>
</tr>
<?php
$filtros="";
if (isset($_GET['filtro_cat'])){
	if ($_GET['filtro_cat']!=''){	
		$filtros="&& cat='".$_GET['filtro_cat']."'";
	}
}
                
                $qr=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=2 $filtros");
                $row=mysql_fetch_array($qr);
                $a_pagar=$row['total'];
                
$qr=mysql_query("SELECT * FROM lc_movimento WHERE tipo=2 $filtros ORDER By  ano, mes, dia");
$cont=0;
while ($row=mysql_fetch_array($qr)){
$cont++;

$cat=$row['cat'];
$qr2=mysql_query("SELECT nome FROM lc_cat WHERE id='$cat'");
$row2=mysql_fetch_array($qr2);
$categoria=$row2['nome'];

?>
<tr style="background-color:<?php if ($cont%2==0) echo "#F1F1F1"; else echo "#E0E0E0"?>" >
<td align="center" width="15"><?php echo $row['dia']?>/<?php echo $row['mes']?></td>
<td><?php
$variavel = $row['descricao'];
if (eregi("#", $variavel)) {
$id_orcamento = substr($variavel, 1, 6);
echo str_replace("#".$id_orcamento,'<a href="'.$site.'/ticket/scp/recibo.php?orcamento='.$id_orcamento.'" target="_blank">#'.$id_orcamento.'</a>',$row['descricao']);
}else{
 echo $row['descricao'];
}
?> <em>(<a href="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>&filtro_cat=<?php echo $cat?>"><?php echo $categoria?></a>)</em> <a href="?id=<?php echo $row['id']?>&action=pago&mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>" style="font-size:10px; color:#666" " title="Editar">[<strong>Cadastrar como Pago na data de Hoje</strong>]</a><a href="javascript:;" style="font-size:10px; color:#666" onclick="document.getElementById('editar_mov_<?php echo $row['id']?>').style.display='';  " title="Editar">[editar]</a></td>
<td align="right"><strong style="color:<?php if ($row['tipo']==2) echo "#FF8C00"; else echo "#030"?>"><?php if ($row['tipo']==2) echo "-"; else echo "+"?><?php echo formata_dinheiro($row['valor'])?></strong></td>
</tr>
 </tr>
    <tr style="display:none; background-color:<?php if ($cont%2==0) echo "#F1F1F1"; else echo "#E0E0E0"?>" id="editar_mov_<?php echo $row['id']?>">
        <td colspan="3">
            <hr/>
            <form method="post" action="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>">
            <input type="hidden" name="acao" value="editar_mov" />
            <input type="hidden" name="id" value="<?php echo $row['id']?>" />
            
            <b>Dia:</b> <input type="text" name="dia" size="3" maxlength="2" value="<?php echo $row['dia']?>" />/<input type="text" name="mes" size="3" maxlength="2" value="<?php echo $row['mes']?>" />/<input type="text" name="ano" size="3" maxlength="2" value="<?php echo $row['ano']?>" />&nbsp;|&nbsp;
            <b>Tipo:</b> 
			<label for="tipo_receita" style="color:#030"><input  <?php if($row['tipo']==1) echo "checked=checked"?> type="radio" name="tipo" value="1" id="tipo_receita" /> Receita</label>&nbsp; 
			<label for="tipo_despesa" style="color:#C00"><input  <?php if($row['tipo']==0) echo "checked=checked"?> type="radio" name="tipo" value="0" id="tipo_despesa" /> Despesa</label>&nbsp; 
			<label for="tipo_pagar" style="color:#FF8C00"><input  <?php if($row['tipo']==2) echo "checked=checked"?> type="radio" name="tipo" value="2" id="tipo_pagar" /> à pagar</label>&nbsp; 
			<label for="tipo_receber" style="color:#006400"><input  <?php if($row['tipo']==3) echo "checked=checked"?> type="radio" name="tipo" value="3" id="tipo_receber" /> à receber</label>
			&nbsp;|&nbsp;
            <b>Categoria:</b>
<select name="cat">
<?php
$qr2=mysql_query("SELECT * FROM lc_cat");
while ($row2=mysql_fetch_array($qr2)){
?>
    <option <?php if($row2['id']==$row['cat']) echo "selected"?> value="<?php echo $row2['id']?>"><?php echo $row2['nome']?></option>
<?php }?>
</select>&nbsp;|&nbsp;
            <b>Valor:</b> R$<input type="text" value="<?php echo number_format($row['valor'],2,',',''); ?>" name="valor" size="8" maxlength="10" />
            <br/>
            <b>Descricao:</b> <input type="text" name="descricao" value="<?php echo $row['descricao']?>" size="70" maxlength="255" />
            
            <input type="submit" class="input" value="Alterar" />
            </form> 
            <div style="text-align: right">
            <a style="color:#FF0000" onclick="return confirm('Tem certeza que deseja apagar?')" href="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>&acao=apagar&id=<?php echo $row['id']?>" title="Remover">[remover]</a> 
            </div>
            <hr/>
        </td>
    </tr>
      
<?php
}
?>
<tr>
<td colspan="3" align="right">
<strong style="font-size:22px; color:<?php if ($a_pagar<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($a_pagar)?></strong>
</td>
</tr>
<tr>
<td colspan="3">

<br>
<br>

<h2>Contas à receber (Cumulativo)</h2>

</td>
</tr>
<?php
if (isset($_GET['filtro_cat'])){
	if ($_GET['filtro_cat']!=''){	
		$filtros="&& cat='".$_GET['filtro_cat']."'";
	}
}
                
                $qr=mysql_query("SELECT SUM(valor) as total FROM lc_movimento WHERE tipo=3 $filtros");
                $row=mysql_fetch_array($qr);
                $a_pagar=$row['total'];
                
$qr=mysql_query("SELECT * FROM lc_movimento WHERE tipo=3 $filtros ORDER By ano, mes, dia");

$cont=0;
while ($row=mysql_fetch_array($qr)){
$cont++;

$cat=$row['cat'];
$qr2=mysql_query("SELECT nome FROM lc_cat WHERE id='$cat'");
$row2=mysql_fetch_array($qr2);
$categoria=$row2['nome'];

?>
<tr style="background-color:<?php if ($cont%2==0) echo "#F1F1F1"; else echo "#E0E0E0"?>" >
<td align="center" width="15"><?php echo $row['dia']?>/<?php echo $row['mes']?></td>
<td><?php
$variavel = $row['descricao'];
if (eregi("#", $variavel)) {
$id_orcamento = substr($variavel, 1, 6);

$sql_detalhes = "SELECT subject, source  FROM ticket_ticket "; 
$sql_detalhes .= "WHERE ticketID = ".$id_orcamento." ";								
$sql_detalhes = mysql_query($sql_detalhes);
$row_detalhes = mysql_fetch_array($sql_detalhes);

echo str_replace("#".$id_orcamento,'<a href="'.$site.'/ticket/scp/recibo.php?orcamento='.$id_orcamento.'" target="_blank">#'.$id_orcamento.'</a>',$row['descricao'])." ".$row_detalhes['subject'];
}else{
 echo $row['descricao'];
 
}
?> <em>(<a href="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>&filtro_cat=<?php echo $cat?>"><?php echo $categoria?></a>)</em> <a href="?id=<?php echo $row['id']?>&action=recebido&mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>" style="font-size:10px; color:#666" " title="Editar">[Lançar como Recebido na data de Hoje]</a><a href="javascript:;" style="font-size:10px; color:#666" onclick="document.getElementById('editar_mov_<?php echo $row['id']?>').style.display='';  " title="Editar">[editar]</a></td>
<td align="right"><strong style="color:<?php if ($row['tipo']==3) echo "#006400"; else echo "#030"?>"><?php echo "+" ?><?php echo formata_dinheiro($row['valor'])?></strong></td>
</tr>
 </tr>
    <tr style="display:none; background-color:<?php if ($cont%2==0) echo "#F1F1F1"; else echo "#E0E0E0"?>" id="editar_mov_<?php echo $row['id']?>">
        <td colspan="3">
            <hr/>
            <form method="post" action="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>">
            <input type="hidden" name="acao" value="editar_mov" />
            <input type="hidden" name="id" value="<?php echo $row['id']?>" />
            
            <b>Dia:</b> <input type="text" name="dia" size="3" maxlength="2" value="<?php echo $row['dia']?>" />/<input type="text" name="mes" size="3" maxlength="2" value="<?php echo $row['mes']?>" />/<input type="text" name="ano" size="3" maxlength="2" value="<?php echo $row['ano']?>" />&nbsp;|&nbsp;
            <b>Tipo:</b> 
			<label for="tipo_receita" style="color:#030"><input  <?php if($row['tipo']==1) echo "checked=checked"?> type="radio" name="tipo" value="1" id="tipo_receita" /> Receita</label>&nbsp; 
			<label for="tipo_despesa" style="color:#C00"><input  <?php if($row['tipo']==0) echo "checked=checked"?> type="radio" name="tipo" value="0" id="tipo_despesa" /> Despesa</label>&nbsp; 
			<label for="tipo_pagar" style="color:#FF8C00"><input  <?php if($row['tipo']==2) echo "checked=checked"?> type="radio" name="tipo" value="2" id="tipo_pagar" /> à pagar</label>&nbsp; 
			<label for="tipo_receber" style="color:#006400"><input  <?php if($row['tipo']==3) echo "checked=checked"?> type="radio" name="tipo" value="3" id="tipo_receber" /> à receber</label>
			&nbsp;|&nbsp;
            <b>Categoria:</b>
<select name="cat">
<?php
$qr2=mysql_query("SELECT * FROM lc_cat");
while ($row2=mysql_fetch_array($qr2)){
?>
    <option <?php if($row2['id']==$row['cat']) echo "selected"?> value="<?php echo $row2['id']?>"><?php echo $row2['nome']?></option>
<?php }?>
</select>&nbsp;|&nbsp;
            <b>Valor:</b> R$<input type="text" value="<?php echo number_format($row['valor'],2,',',''); ?>" name="valor" size="8" maxlength="10" />
            <br/>
            <b>Descricao:</b> <input type="text" name="descricao" value="<?php echo $row['descricao']?>" size="70" maxlength="255" />
            
            <input type="submit" class="input" value="Alterar" />
            </form> 
            <div style="text-align: right">
            <a style="color:#FF0000" onclick="return confirm('Tem certeza que deseja apagar?')" href="?mes=<?php echo $mes_hoje?>&ano=<?php echo $ano_hoje?>&acao=apagar&id=<?php echo $row['id']?>" title="Remover">[remover]</a> 
            </div>
            <hr/>
        </td>
    </tr>
      
<?php
}
?>
<tr>
<td colspan="3" align="right">
<strong style="font-size:22px; color:<?php if ($a_pagar<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($a_pagar)?></strong>
</td>
</tr>
<tr>
<td colspan="3">

<br>
<br>
<?
if($_GET['atualizando']!=''){
	$atualizando = $_GET['atualizando'];
}else{
$atualizando = 0;
}
 if ($atualizando==0) { ?>

<h2>Caixas por Categoria(cumulativo) desde 05/2016</h2>

</td>
</tr>
<?php
$filtros="";

	if ($_GET['filtro_cat']!=''){	
		$filtros="&& cat='".$_GET['filtro_cat']."'";
		 }
                
				$qr=mysql_query("SELECT *  FROM lc_movimento WHERE ((mes>'04' && ano='2016') or ((mes<='$mes_hoje' or ano<'$ano_hoje') && ano<='$ano_hoje' && ano>='2017')) ");
				   
					
                while($row=mysql_fetch_array($qr)){					
					
					if($row['tipo']==1){
						if($row['ano']<=2017){//entradas
							
							$prolabore += $row['valor']*0.1;
							$guardado += $row['valor']*0.1;
							$custo_m_prima += $row['valor']*0.1665;
							$comissao += $row['valor']*0.05;
							$nota_fiscal += $row['valor']*0.045;
							$despesa_fixa += $row['valor']*0.1130;
							$funcionarios += $row['valor']*0.29;		
							$custo_variavel += $row['valor']*0.0355;					
							if(($row['ano']==2016 && $row['mes']>=11) or $row['ano']>=2017){
								$fundo_emergencia += $row['valor']*0.1;
							}					
						
						}else{
							
							$prolabore += $row['valor']*0.1;
							$guardado += $row['valor']*0.08;
							$custo_m_prima += $row['valor']*0.2243;
							$comissao += $row['valor']*0.03;
							$nota_fiscal += $row['valor']*0.045;
							$despesa_fixa += $row['valor']*0.0752;
							$funcionarios += $row['valor']*0.29;		
							$custo_variavel += $row['valor']*0.0555;
							if(($row['ano']==2016 && $row['mes']>=11) or $row['ano']>=2017){
								$fundo_emergencia += $row['valor']*0.1;
							}
							
						}
						
							if($row['ano']<=2017 && $ano_hoje==$row['ano'] && $row['mes']==$mes_hoje){
					
								$prolabore_mes += $row['valor']*0.1;
								$guardado_mes += $row['valor']*0.1;
								$custo_m_prima_mes += $row['valor']*0.1665;
								$comissao_mes += $row['valor']*0.05;
								$nota_fiscal_mes += $row['valor']*0.045;
								$despesa_fixa_mes += $row['valor']*0.1130;
								$funcionarios_mes += $row['valor']*0.29;				
								$custo_variavel_mes += $row['valor']*0.0355;
								$fundo_emergencia_mes += $row['valor']*0.1;
								
								$entradas_mes+=$row['valor'];
							
							}elseif($row['mes']==$mes_hoje && $row['ano']==$ano_hoje){
								
								$prolabore_mes += $row['valor']*0.1;
								$guardado_mes += $row['valor']*0.08;
								$custo_m_prima_mes += $row['valor']*0.2243;
								$comissao_mes += $row['valor']*0.03;
								$nota_fiscal_mes += $row['valor']*0.045;
								$despesa_fixa_mes += $row['valor']*0.0752;
								$funcionarios_mes += $row['valor']*0.29;				
								$custo_variavel_mes += $row['valor']*0.0555;
								$fundo_emergencia_mes += $row['valor']*0.1;
								
								$entradas_mes+=$row['valor'];
								
							}	
						
						$entradas+=$row['valor'];
						$acumulado_periodo += $row['valor'];
						
						}elseif($row['tipo']==0){//saidas
						
							if($row['cat']==14){
								$prolabore_saida += $row['valor'];
							}elseif($row['cat']==15){
								$guardado_saida += $row['valor'];
							}elseif($row['cat']==16){
								$custo_m_prima_saida += $row['valor'];
							}elseif($row['cat']==17){
								$comissao_saida += $row['valor'];
							}elseif($row['cat']==18){
								$nota_fiscal_saida += $row['valor'];
							}elseif($row['cat']==19){
								$despesa_fixa_saida += $row['valor'];
							}elseif($row['cat']==20){
								$funcionarios_saida += $row['valor'];
							}elseif($row['cat']==21){
								if($row['ano']==2016){
									if($row['mes']>11){
										$fundo_emergencia_saida += $row['valor'];
									}
								}else{
									$fundo_emergencia_saida += $row['valor'];
								}
							}elseif($row['cat']==23){
								$custo_variavel_saida += $row['valor'];
							}
							
							if($row['mes']==$mes_hoje && $row['ano']==$ano_hoje){
							
								if($row['cat']==14){
									$prolabore_saida_mes += $row['valor'];
								}elseif($row['cat']==15){
									$guardado_saida_mes += $row['valor'];
								}elseif($row['cat']==16){
									$custo_m_prima_saida_mes += $row['valor'];
								}elseif($row['cat']==17){
									$comissao_saida_mes += $row['valor'];
								}elseif($row['cat']==18){
									$nota_fiscal_saida_mes += $row['valor'];
								}elseif($row['cat']==19){
									$despesa_fixa_saida_mes += $row['valor'];
								}elseif($row['cat']==20){
									$funcionarios_saida_mes += $row['valor'];
								}elseif($row['cat']==21){
									if($row['ano']==2016){
										if($row['mes']>11){
											$fundo_emergencia_saida_mes += $row['valor'];
										}
									}else{
										$fundo_emergencia_saida_mes += $row['valor'];
									}
									
								}elseif($row['cat']==23){
									$custo_variavel_saida_mes += $row['valor'];
								}
							}
						
						}//fim das saidas

					
					
					
					
				}
				
               
				
				
   $prolabore_saldo_anterior = ($prolabore-$prolabore_mes)-($prolabore_saida-$prolabore_saida_mes);
   $guardado_saldo_anterior = ($guardado-$guardado_mes)-($guardado_saida-$guardado_saida_mes);
   $custo_m_prima_saldo_anterior = ($custo_m_prima-$custo_m_prima_mes)-($custo_m_prima_saida-$custo_m_prima_saida_mes);
   $comissao_saldo_anterior = ($comissao-$comissao_mes)-($comissao_saida-$comissao_saida_mes);
   $nota_fiscal_saldo_anterior = ($nota_fiscal-$nota_fiscal_mes)-($nota_fiscal_saida-$nota_fiscal_saida_mes);
   $despesa_fixa_saldo_anterior = ($despesa_fixa-$despesa_fixa_mes)-($despesa_fixa_saida-$despesa_fixa_saida_mes);
   $funcionarios_saldo_anterior = ($funcionarios-$funcionarios_mes)-($funcionarios_saida-$funcionarios_saida_mes);
   $fundo_emergencia_anterior = ($fundo_emergencia-$fundo_emergencia_mes)-($fundo_emergencia_saida-$fundo_emergencia_saida_mes);
   $custo_variavel_saida_mes = $custo_variavel_saida_mes;/*($custo_variavel-$custo_variavel_mes)-(custo_variavel_saida-$custo_variavel_saida_mes);*/
   $custo_variavel_saldo_anterior = (($custo_variavel-$custo_variavel_saida)-($custo_variavel_mes-$custo_variavel_saida_mes));/*($custo_variavel-$custo_variavel_mes)-(custo_variavel_saida-$custo_variavel_saida_mes);*/

?>

<tr style="background-color:<?php echo "#FFF5EE"?>">
	<td align="center" width="15">Fundo Investimento  </td>
	<td>Saldo Anterior</td>
	<td align="right"><strong style="color:<?php if ($guardado_saldo_anterior<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($guardado_saldo_anterior)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Fundo Investimento <? if($ano_hoje<=2017){ ?> 10% <? }else{ ?> 8% <? } ?> </td>
	<td>Entradas deste Mes</td>
	<td align="right"><strong style="color:<?php if ($guardado_mes<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($guardado_mes)?></strong></td>
	</tr>
	<tr style="background-color:<?php echo "#FFF5EE"?>">
	<td align="center" width="15">Fundo Investimento </td>
	<td>Saidas deste Mes(<?=number_format((($guardado_saida_mes/$tot_acum)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:#C00"><?php echo formata_dinheiro($guardado_saida_mes)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Fundo Investimento</td>
	<td>Saldo Atual</td>
	<td align="right"><strong style="color:<?php if (($guardado_mes-$guardado_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro(($guardado_mes-$guardado_saida_mes))?></strong></td>
	</tr>
	<tr>
	<tr style="background-color:<?php echo "#FFF5EE"?>">
	<td align="center" width="15">Fundo Investimento </td>
	<td>Saldo Geral (<?=number_format((($guardado_saida/$acumulado_periodo)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:<?php if ($guardado_saldo_anterior+($guardado_mes-$guardado_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($guardado_saldo_anterior+($guardado_mes-$guardado_saida_mes))?></strong></td>
	</tr>
	<tr>
	<td colspan="3">
	<br> </td>
</tr>

<tr style="background-color:<?php echo "#E0E0E0"?>">
	<td align="center" width="15">Soberano </td>
	<td>Saldo Anterior desde 11/16 </td>
	<td align="right"><strong style="color:<?php if ($fundo_emergencia_anterior<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($fundo_emergencia_anterior)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Soberano <? if($ano_hoje<=2017){ ?> 10% <? }else{ ?> 10% <? } ?></td>
	<td>Entradas deste Mes</td>
	<td align="right"><strong style="color:<?php if ($fundo_emergencia_mes<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($fundo_emergencia_mes)?></strong></td>
	</tr>
	<tr style="background-color:<?php echo "#E0E0E0"?>">
	<td align="center" width="15">Soberano</td>
	<td>Saidas deste Mes(<?=number_format((($fundo_emergencia_saida_mes/$tot_acum)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:#C00"><?php echo formata_dinheiro($fundo_emergencia_saida_mes)?></strong></td> 
	</tr>
	<tr>
	<td align="center" width="15">Soberano</td>
	<td>Saldo Atual</td>
	<td align="right"><strong style="color:<?php if (($fundo_emergencia_mes-$fundo_emergencia_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro(($fundo_emergencia_mes-$fundo_emergencia_saida_mes))?></strong></td>
	</tr>
	<tr style="background-color:<?php echo "#E0E0E0"?>">
	<td align="center" width="15">Soberano</td>
	<td>Saldo Geral (<?=number_format((($fundo_emergencia_saida/$acumulado_periodo)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:<?php if ($fundo_emergencia_anterior+($fundo_emergencia_mes-$fundo_emergencia_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($fundo_emergencia_anterior+($fundo_emergencia_mes-$fundo_emergencia_saida_mes))?></strong></td>
	</tr>
	<tr>
	<td colspan="3"><br></td>
</tr>

<tr style="background-color:<?php echo "#F0F8FF"?>">
	<td align="center" width="15">Prolabore </td>
	<td>Saldo Anterior</td>
	<td align="right"><strong style="color:<?php if ($prolabore_saldo_anterior<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($prolabore_saldo_anterior)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Prolabore <? if($ano_hoje<=2017){ ?> 10% <? }else{ ?> 10% <? } ?></td>
	<td>Entradas deste Mes</td>
	<td align="right"><strong style="color:<?php if ($prolabore_mes<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($prolabore_mes)?></strong></td>
	</tr>
	<tr style="background-color:<?php echo "#F0F8FF"?>">
	<td align="center" width="15">Prolabore</td>
	<td>Saidas deste Mes(<?=number_format((($prolabore_saida_mes/$tot_acum)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:#C00"><?php echo formata_dinheiro($prolabore_saida_mes)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Prolabore </td>
	<td>Saldo Atual</td>
	<td align="right"><strong style="color:<?php if (($prolabore_mes-$prolabore_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro(($prolabore_mes-$prolabore_saida_mes))?></strong></td>
	</tr>
	<tr>
	<tr style="background-color:<?php echo "#F0F8FF"?>">
	<td align="center" width="15">Prolabore </td>
	<td>Saldo Geral (<?=number_format((($prolabore_saida/$acumulado_periodo)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:<?php if ($prolabore_saldo_anterior+($prolabore_mes-$prolabore_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($prolabore_saldo_anterior+($prolabore_mes-$prolabore_saida_mes))?></strong></td>
	</tr>
	<tr>
	<td colspan="3"> <br></td>
</tr>

<tr style="background-color:<?php echo "#F5F5DC"?>">
	<td align="center" width="15">M Prima</td>
	<td>Saldo Anterior</td>
	<td align="right"><strong style="color:<?php if ($custo_m_prima_saldo_anterior<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($custo_m_prima_saldo_anterior)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">M Prima <? if($ano_hoje<=2017){ ?> 16,65% <? }else{ ?> 22,43% <? } ?></td>
	<td>Entradas deste Mes</td>
	<td align="right"><strong style="color:<?php if ($custo_m_prima_mes<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($custo_m_prima_mes)?></strong></td>
	</tr>
	<tr style="background-color:<?php echo "#F5F5DC"?>">
	<td align="center" width="15">M Prima</td>
	<td>Saidas deste Mes(<?=number_format((($custo_m_prima_saida_mes/$tot_acum)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:#C00"><?php echo formata_dinheiro($custo_m_prima_saida_mes)?></strong></td>
	</tr>
	<tr >
	<td align="center" width="15">M Prima</td>
	<td>Saldo Atual</td>
	<td align="right"><strong style="color:<?php if (($custo_m_prima_mes-$custo_m_prima_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro(($custo_m_prima_mes-$custo_m_prima_saida_mes))?></strong></td>
	</tr>
	<tr>
	<tr style="background-color:<?php echo "#F5F5DC"?>">
	<td align="center" width="15">M Prima</td>
	<td>Saldo Geral (<?=number_format((($custo_m_prima_saida/$acumulado_periodo)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:<?php if ($custo_m_prima_saldo_anterior+($custo_m_prima_mes-$custo_m_prima_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($custo_m_prima_saldo_anterior+($custo_m_prima_mes-$custo_m_prima_saida_mes))?></strong></td>
	</tr>
	<tr>
	<td colspan="3"><br></td>
</tr>

<tr style="background-color:<?php echo "#EEE8AA"?>">
	<td align="center" width="15">Comissão</td>
	<td>Saldo Anterior</td>
	<td align="right"><strong style="color:<?php if ($comissao_saldo_anterior<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($comissao_saldo_anterior)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Comissão <? if($ano_hoje<=2017){ ?> 5% <? }else{ ?> 3% <? } ?></td>
	<td>Entradas deste Mes</td>
	<td align="right"><strong style="color:<?php if ($comissao_mes<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($comissao_mes)?></strong></td>
	</tr>
	<tr style="background-color:<?php echo "#EEE8AA"?>">
	<td align="center" width="15">Comissão</td>
	<td>Saidas deste Mes(<?=number_format((($comissao_saida_mes/$tot_acum)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:#C00"><?php echo formata_dinheiro($comissao_saida_mes)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Comissão</td>
	<td>Saldo Atual</td>
	<td align="right"><strong style="color:<?php if (($comissao_mes-$comissao_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro(($comissao_mes-$comissao_saida_mes))?></strong></td>
	</tr>
	<tr>
	<tr style="background-color:<?php echo "#EEE8AA"?>">>
	<td align="center" width="15">Comissão</td>
	<td>Saldo Geral (<?=number_format((($comissao_saida/$acumulado_periodo)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:<?php if ($comissao_saldo_anterior+($comissao_mes-$comissao_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($comissao_saldo_anterior+($comissao_mes-$comissao_saida_mes))?></strong></td>
	</tr>
	<tr>
	<td colspan="3"><br></td>
</tr>

<tr style="background-color:<?php echo "#FFE4E1"?>">
	<td align="center" width="15">Fisco</td>
	<td>Saldo Anterior</td>
	<td align="right"><strong style="color:<?php if ($nota_fiscal_saldo_anterior<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($nota_fiscal_saldo_anterior)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Fisco <? if($ano_hoje<=2017){ ?> 4,5% <? }else{ ?> 4,5% <? } ?></td>
	<td>Entradas deste Mes</td>
	<td align="right"><strong style="color:<?php if ($nota_fiscal_mes<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($nota_fiscal_mes)?></strong></td>
	</tr>
	<tr style="background-color:<?php echo "#FFE4E1"?>">
	<td align="center" width="15">Fisco</td>
	<td>Saidas deste Mes(<?=number_format((($nota_fiscal_saida_mes/$tot_acum)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:#C00"><?php echo formata_dinheiro($nota_fiscal_saida_mes)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Fisco</td>
	<td>Saldo Atual</td>
	<td align="right"><strong style="color:<?php if (($nota_fiscal_mes-$nota_fiscal_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro(($nota_fiscal_mes-$nota_fiscal_saida_mes))?></strong></td>
	</tr>
	<tr>
	<tr style="background-color:<?php echo "#FFE4E1"?>">
	<td align="center" width="15">Fisco</td>
	<td>Saldo Geral (<?=number_format((($nota_fiscal_saida/$acumulado_periodo)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:<?php if ($nota_fiscal_saldo_anterior+($nota_fiscal_mes-$nota_fiscal_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($nota_fiscal_saldo_anterior+($nota_fiscal_mes-$nota_fiscal_saida_mes))?></strong></td>
	</tr>
	<tr>
	<td colspan="3"><br></td>
</tr>

<tr style="background-color:<?php echo "#D8BFD8"?>">
	<td align="center" width="15">Desp. Fixa</td>
	<td>Saldo Anterior</td>
	<td align="right"><strong style="color:<?php if ($despesa_fixa_saldo_anterior<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($despesa_fixa_saldo_anterior)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Desp. Fixa <? if($ano_hoje<=2017){ ?> 11,30% <? }else{ ?> 7,52% <? } ?></td>
	<td>Entradas deste Mes</td>
	<td align="right"><strong style="color:<?php if ($despesa_fixa_mes<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($despesa_fixa_mes)?></strong></td>
	</tr>
	<tr style="background-color:<?php  echo "#D8BFD8"?>">
	<td align="center" width="15">Desp. Fixa</td>
	<td>Saidas deste Mes(<?=number_format((($despesa_fixa_saida_mes/$tot_acum)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:#C00"><?php echo formata_dinheiro($despesa_fixa_saida_mes)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Desp. Fixa</td>
	<td>Saldo Atual</td>
	<td align="right"><strong style="color:<?php if (($despesa_fixa_mes-$despesa_fixa_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro(($despesa_fixa_mes-$despesa_fixa_saida_mes))?></strong></td>
	</tr>
	<tr style="background-color:<?php  echo "#D8BFD8"?>">
	<td align="center" width="15" >Desp. Fixa</td>
	<td>Saldo Geral (<?=number_format((($despesa_fixa_saida/$acumulado_periodo)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:<?php if ($despesa_fixa_saldo_anterior+($despesa_fixa_mes-$despesa_fixa_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($despesa_fixa_saldo_anterior+($despesa_fixa_mes-$despesa_fixa_saida_mes))?></strong></td>
	</tr>
	<tr>
	<td colspan="3"><br></td>
</tr>

<tr style="background-color:<?php echo "#E0E0E0"?>">
	<td align="center" width="15">Funcionarios</td>
	<td>Saldo Anterior</td>
	<td align="right"><strong style="color:<?php if ($funcionarios_saldo_anterior<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($funcionarios_saldo_anterior)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Funcionarios <? if($ano_hoje<=2017){ ?> 29% <? }else{ ?> 29% <? } ?></td>
	<td>Entradas deste Mes</td>
	<td align="right"><strong style="color:<?php if ($funcionarios_mes<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($funcionarios_mes)?></strong></td>
	</tr>
	<tr style="background-color:<?php echo "#E0E0E0"?>">
	<td align="center" width="15">Funcionarios</td>
	<td>Saidas deste Mes(<?=number_format((($funcionarios_saida_mes/$tot_acum)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:#C00"><?php echo formata_dinheiro($funcionarios_saida_mes)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Funcionarios</td>
	<td>Saldo Atual</td>
	<td align="right"><strong style="color:<?php if (($funcionarios_mes-$funcionarios_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro(($funcionarios_mes-$funcionarios_saida_mes))?></strong></td>
	</tr>
	<tr style="background-color:<?php echo "#E0E0E0"?>">
	<td align="center" width="15">Funcionarios</td>
	<td>Saldo Geral (<?=number_format((($funcionarios_saida/$acumulado_periodo)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:<?php if ($funcionarios_saldo_anterior+($funcionarios_mes-$funcionarios_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($funcionarios_saldo_anterior+($funcionarios_mes-$funcionarios_saida_mes))?></strong></td>
	</tr>
	<tr>
	<td colspan="3"><br></td>
</tr>


<tr style="background-color:<?php  echo "#D8BFD8"?>">
	<td align="center" width="15">Custo Variável</td>
	<td>Saldo anterior</td>
	<td align="right"><strong style="color:<?php if ($custo_variavel_saldo_anterior<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($custo_variavel_saldo_anterior)?></strong></td>
	</tr>
<tr>
	<td align="center" width="15">Custo Variável <? if($ano_hoje<=2017){ ?> 3,55% <? }else{ ?> 5,55% <? } ?></td>
	<td>Entradas deste Mes</td>
	<td align="right"><strong style="color:<?php if ($custo_variavel_mes<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($custo_variavel_mes)?></strong></td>
	</tr>
	<tr style="background-color:<?php  echo "#D8BFD8"?>">
	<td align="center" width="15">Custo Variavel</td>
	<td>Saidas deste Mes(<?=number_format((($custo_variavel_saida_mes/$tot_acum)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:#C00"><?php echo formata_dinheiro($custo_variavel_saida_mes)?></strong></td>
	</tr>
	<tr>
	<td align="center" width="15">Custo Variavel</td>
	<td>Saldo Atual</td>
	<td align="right"><strong style="color:<?php if (($custo_variavel_mes-$custo_variavel_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro(($custo_variavel_mes-$custo_variavel_saida_mes))?></strong></td>
	</tr>
	<tr style="background-color:<?php  echo "#D8BFD8"?>">
	<td align="center" width="15">Custo Variavel</td>
	<td>Saldo Geral (<?=number_format((($custo_variavel_saida/$acumulado_periodo)*100), 2, ',', ' '); ?>%)</td>
	<td align="right"><strong style="color:<?php if ($custo_variavel_saldo_anterior+($custo_variavel_mes-$custo_variavel_saida_mes)<0) echo "#C00"; else echo "#030"?>"><?php echo formata_dinheiro($custo_variavel_saldo_anterior+($custo_variavel_mes-$custo_variavel_saida_mes))?></strong></td>
	</tr>
	<tr>
	<td colspan="3"><br></td>
</tr>



</table>

<? echo '(('.$custo_variavel.'-'.custo_variavel_saida.')-('.$custo_variavel_mes.'-'.$custo_variavel_saida_mes.'))'; ?>
<br />
<br />
<? }else{
	
	echo '<h1>O livro caixa está sofrendo manutenção</h1>';
	
} ?>
<table cellpadding="5" cellspacing="0" width="900" align="center"> 
<tr>
<td align="right">
<hr size="1" />
<em>Livro Caixa - <strong><?php echo $lc_titulo?></strong> - HFX Digital <a href="login.php?sair">Fazer logout</a></em>
</td>
</tr>
</table>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
   <script>
		function loadingAjax(div_id) {
			  var divIdHtml = $("#"+div_id).html();
			  $.ajax({
				   type: "POST",
				   url: "todo_livro.php",
				   data: "name=John&id=28",
				   beforeSend: function() {
					  $("#loading-image").show();
				   },
				   success: function(msg) {
					  $("#"+div_id).html(divIdHtml + msg);
					  $("#loading-image").hide();
				   }
			  });
		}
</script> 

	<script>							

												  $(document).ready(function() {

															$("#pg_sinal").html('<?=formata_dinheiro($pg_sinal); ?>');
															$("#pg_sinal_count").html('Sinal <?=$pg_sinal_count; ?>');
															$("#pg_resta").html('<?=formata_dinheiro($pg_resta); ?>');
															$("#pg_resta_count").html('Entregas <?=$pg_resta_count; ?>');
															$("#pg_faturado").html('<?=formata_dinheiro($pg_faturado); ?>');
															$("#pg_faturado_count").html('Faturamento quitados <?=$pg_faturado_count; ?>');
															$("#myDiv").load('my_div.php');
															
													 });
													 
													

												</script>

</body>
</html>

Notice: Undefined variable: custo_m_prima_saida in C:\xampp\htdocs\index.php on line 1132

Notice: Undefined variable: custo_variavel_saida in C:\xampp\htdocs\index.php on line 1150

Notice: Undefined variable: despesa_fixa_saida in C:\xampp\htdocs\index.php on line 1138

Notice: Undefined variable: funcionarios_saida in C:\xampp\htdocs\index.php on line 1140

Notice: Undefined variable: nota_fiscal_saida in C:\xampp\htdocs\index.php on line 1136

Notice: Undefined variable: prolabore in C:\xampp\htdocs\index.php on line 1064

Notice: Undefined variable: guardado in C:\xampp\htdocs\index.php on line 1065

Notice: Undefined variable: custo_m_prima in C:\xampp\htdocs\index.php on line 1066

Notice: Undefined variable: comissao in C:\xampp\htdocs\index.php on line 1067

Notice: Undefined variable: nota_fiscal in C:\xampp\htdocs\index.php on line 1068

Notice: Undefined variable: despesa_fixa in C:\xampp\htdocs\index.php on line 1069

Notice: Undefined variable: funcionarios in C:\xampp\htdocs\index.php on line 1070

Notice: Undefined variable: custo_variavel in C:\xampp\htdocs\index.php on line 1071

Notice: Undefined variable: acumulado_periodo in C:\xampp\htdocs\index.php on line 1123

Notice: Undefined variable: prolabore_saida in C:\xampp\htdocs\index.php on line 1128

Notice: Undefined variable: guardado_saida in C:\xampp\htdocs\index.php on line 1130

Notice: Undefined variable: comissao_saida in C:\xampp\htdocs\index.php on line 1134

Notice: Undefined variable: fundo_emergencia in C:\xampp\htdocs\index.php on line 1073

Notice: Undefined variable: fundo_emergencia_saida in C:\xampp\htdocs\index.php on line 1144

Notice: Undefined variable: prolabore_mes in C:\xampp\htdocs\index.php on line 1108

Notice: Undefined variable: guardado_mes in C:\xampp\htdocs\index.php on line 1109

Notice: Undefined variable: custo_m_prima_mes in C:\xampp\htdocs\index.php on line 1110

Notice: Undefined variable: comissao_mes in C:\xampp\htdocs\index.php on line 1111

Notice: Undefined variable: nota_fiscal_mes in C:\xampp\htdocs\index.php on line 1112

Notice: Undefined variable: despesa_fixa_mes in C:\xampp\htdocs\index.php on line 1113

Notice: Undefined variable: funcionarios_mes in C:\xampp\htdocs\index.php on line 1114

Notice: Undefined variable: custo_variavel_mes in C:\xampp\htdocs\index.php on line 1115

Notice: Undefined variable: fundo_emergencia_mes in C:\xampp\htdocs\index.php on line 1116

Notice: Undefined variable: entradas_mes in C:\xampp\htdocs\index.php on line 1118

Notice: Undefined variable: custo_m_prima_saida_mes in C:\xampp\htdocs\index.php on line 1160

Notice: Undefined variable: custo_variavel_saida_mes in C:\xampp\htdocs\index.php on line 1179

Notice: Undefined variable: nota_fiscal_saida_mes in C:\xampp\htdocs\index.php on line 1164

Notice: Undefined variable: despesa_fixa_saida_mes in C:\xampp\htdocs\index.php on line 1166

Notice: Undefined variable: prolabore_saida_mes in C:\xampp\htdocs\index.php on line 1156

Notice: Undefined variable: funcionarios_saida_mes in C:\xampp\htdocs\index.php on line 1168

Notice: Undefined variable: guardado_saida_mes in C:\xampp\htdocs\index.php on line 1158

Notice: Undefined variable: comissao_saida_mes in C:\xampp\htdocs\index.php on line 1162

Notice: Undefined variable: fundo_emergencia_saida_mes in C:\xampp\htdocs\index.php on line 1175

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por landerbadi
      Boa tarde pessoal. Estou tentado fazer uma consulta no banco de dados porém estou tendo dificuldades. Tenho uma tabela chamada "itens" com os seguintes campos: id, item, ativo. Nela tem cadastrado vários itens. No campo ativo eu coloco a letra "S" para informar que este item está ativo no sistema. Por exemplo: 1, casa, S 2, mesa, S 3, cama, S 4, moto S 5, rádio O quinto registro "radio" não está ativo no sistema pois não tem um "S" no campo ativo. E outra tabela chamada "produtos" com os seguintes campos (id, item1, item2, item3) com os seguintes registros: 1, casa, mesa, moto 2, mesa, casa, cama 3, rádio, cama, mesa Eu preciso fazer uma busca na tabela produtos da seguinte maneira: Eu escolho um registro na tabela "itens", por exemplo "mesa". Preciso fazer com que o php me liste todos os registros da tabela "produtos" que contenham a palavra "mesa". Até aqui tudo bem eu consigo listar. Estou fazendo assim: <?php $item = "mesa" $sql = mysqli_query($conn, "SELECT * FROM produtos WHERE item1 LIKE '$item' OR item2 LIKE '$item' OR item3 LIKE '$item' LIMIT 10"); while($aux = mysqli_fetch_assoc($sql)) { $id = $aux["id"]; $item1 = $aux["item1"]; $item2 = $aux["item2"]; $item3 = $aux["item3"]; echo $id . " - " . $item1 . ", " . $item2 . ", " $item3 . "<br>"; } ?> O problema é que está listando todos os registros que contém o item mesa. Eu preciso que o php verifique os demais item e me liste somente os registro em que todos os registros estejam ativos no sistema. No exemplo acima ele não deveria listar o registro 3. pois nesse registro contém o item "radio" e este item não está ativo no sistema. Ou seja, o registro "radio" na tabela itens não possui um "S" na coluna "ativo". Alguém sabe como resolver isso?
    • Por ILR master
      Fala galera.
      Espero que todos estejam bem.
      Seguinte: Tenho um arquivo xml onde alguns campos estão com : (dois pontos), como o exemplo abaixo:
       
      <item>
      <title>
      d sa dsad sad sadasdas
      </title>
      <link>
      dsadas dsa sad asd as dsada
      </link>
      <pubDate>sadasdasdsa as</pubDate>
      <dc:creator>
      d sad sad sa ad as das
      </dc:creator>
      </item>
       
      Meu código:
       
      $link = "noticias.xml"; 
      $xml = simplexml_load_file($link); 
      foreach($xml -> channel as $ite) {     
           $titulo = $ite -> item->title;
           $urltitulo = $ite -> item->link;
           print $urltitulo = $ite -> item->dc:creator;
      } //fim do foreach
      ?>
       
      Esse campo dc:creator eu não consigo ler. Como faço?
       
      Agradeço quem puder me ajudar.
       
      Abs
       
       
    • Por First
      Olá a todos!
       
      Eu estou criando um sistema do zero mas estou encontnrando algumas dificuldades e não estou sabendo resolver, então vim recorrer ajuda de vocês.
      Aqui está todo o meu código: https://github.com/PauloJagata/aprendizado/
       
      Eu fiz um sistema de rotas mas só mostra o conteúdo da '/' não sei porque, quando eu tento acessar o register nada muda.
      E eu também quero que se não estiver liberado na rota mostra o erro de 404, mas quando eu tento acessar um link inválido, nada acontece.
      Alguém pode me ajudar com isso? E se tiver algumas sugestão para melhoria do código também estou aceitando.
       
       
      Desde já, obrigado.
    • Por landerbadi
      Olá pessoal, boa tarde
       
      Tenho uma tabela chamada "produtos" com os seguintes campos (id, produto) e outra tabela chamada "itens" com os seguintes campos (id, prod_01, prod_02, prod_03, prod_04).
       
      Na tabela produtos eu tenho cadastrado os seguintes produtos: laranja, maçã, uva, goiaba, arroz, feijão, macarrão, etc.
       
      Na tabela itens eu tenho cadastrado os itens da seguinte maneira:
       
      1, laranja, uva, arroz, feijão;
      2, maçã, macarrão, goiaba, uva;
      3, arroz, feijão, maçã, azeite
       
      Meu problema é o seguinte: 
      Eu escolho um produto da tabela "produtos", por exemplo "uva".  Preciso fazer uma consulta na tabela "itens" para ser listado todos os registros que contenham o produto "uva" e que todos os demais produtos estejam cadastrados na tabela "produtos".
       
      No exemplo acima seria listado apenas dois registros, pois o terceiro registro não contém o produto "uva". 
       
      Alguém pode me ajudar? Pois estou quebrando a cabeça a vários dias e não consigo achar uma solução.
    • Por landerbadi
      Boa tarde pessoal. Estou tentado fazer uma consulta no banco de dados porém estou tendo dificuldades. Tenho uma tabela chamada "itens" com os seguintes campos: id, item, plural, ativo. Nela tem cadastrado vários itens e seu respectivo plural. No campo ativo eu coloco a letra "S" para informar que esta palavra está ativa no sistema. Por exemplo: 1, casa, casas, S 2, mesa, mesas, S 3, cama, camas, S 4, moto, motos, S 5, rádio, rádios O quinto registro "radio" não está ativo no sistema pois não tem um "S" no campo ativo. E outra tabela chamada "variações" com os seguintes campos (id, item1, item2, item3) com os seguintes registros: 1, casa, camas, moto 2, mesas, casas, radio 3, rádio, cama, mesa Eu preciso fazer uma busca na tabela variações da seguinte maneira: Eu escolho um registro na tabela "itens", por exemplo "casa". Preciso fazer com que o php me liste todos os registros da tabela "variações" que contenham a palavra "casa". Porém se tiver algum registro com a palavra "casas" também tem que ser listado. Neste caso ele irá encontrar dois registros. Agora eu preciso que o php verifique os demais itens e faça a listagem apenas dos item que estão ativos (que contenham um "S" no campo ativo. Neste caso ele irá encontrar apenas um registro, pois o segundo registro contém a palavra "rádio". E "rádio" não está ativo na tabela itens. Como faço isso?
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.