function TreeGrid_() { $pesquisa = new pesquisa(); $this->json = $pesquisa->json($this->select); $igniteui = new igniteui(); $igniteui->TreeGrid_($this->json, $this->column, $this->tabela, '', ''); }
function depreciacao() { echo "<div id='grid_relatorio' class='uk-width-1-1'></div>"; if (isset($_POST) and $_POST != null and $_POST['data_inicio'] != "00/00/0000" and $_POST['data_fim'] != "00/00/0000") { $data_inicio = DateTime::createFromFormat('d/m/Y', $_POST['data_inicio'])->format('Y-m-d'); $data_fim = DateTime::createFromFormat('d/m/Y', $_POST['data_fim'])->format('Y-m-d'); $filtro = ""; if ($_POST['cod_grupo_patrimonio'] != "") { $filtro .= " and cad_itens.cod_grupo_patrimonio='" . $_POST['cod_grupo_patrimonio'] . "' "; } if ($_POST['cod_filial'] != "") { $filtro .= " and cad_itens.cod_filial='" . $_POST['cod_filial'] . "' "; } $select = "\n\t\t\t\tSELECT \n\t\t\t\t\tcad_itens.cod_item,\n\t\t\t\t\tcad_grupo_patrimonio.descricao as nome_grupo,\n\t\t\t\t\tcad_itens.descricao,\n\t\t\t\t\tcad_itens.data_aquisicao,\n\t\t\t\t\tROUND(cad_itens.valor_aquisicao,2) as valor_aquisicao,\n\t\t\t\t\tcad_itens.vida_util as vida_util_item,\n\t\t\t\t\tcad_itens.taxa_depreciacao_anual as taxa_depreciacao_anual_item,\n\n\t\t\t\t\tcad_grupo_patrimonio.vida_util as vida_util_grupo,\n\t\t\t\t\tcad_grupo_patrimonio.taxa_depreciacao_anual as taxa_depreciacao_anual_grupo,\n\n\t\t\t\t\tROUND(ifnull(tb_saldo_inicial.valor, cad_itens.valor_aquisicao),2) as saldo_inicial,\n\t\t\t\t\tROUND(tb_depreciacao.valor,2) as depreciacao,\n\t\t\t\t\tROUND(ifnull(tb_saldo_inicial.valor, cad_itens.valor_aquisicao)+ tb_depreciacao.valor,2) as saldo_final\n\t\t\t\t\t\n\t\t\t\tFROM \n\t\t\t\t\timobilizado.cad_itens\n\n\t\t\t\tleft join imobilizado.cad_grupo_patrimonio on cad_itens.cod_grupo_patrimonio=cad_grupo_patrimonio.cod_grupo_patrimonio\n\t\t\t\tleft join ( select cod_item,data,sum(valor) as valor from imobilizado.cad_movimento where (data between '" . $data_inicio . "' and '" . $data_fim . "') and cod_tipo_movimento=6 group by cod_item) as tb_depreciacao on cad_itens.cod_item=tb_depreciacao.cod_item\n\t\t\t\tleft join ( select cod_item,sum(valor) as valor from imobilizado.cad_movimento where (data < '" . $data_inicio . "' ) group by cod_item) as tb_saldo_inicial on cad_itens.cod_item=tb_saldo_inicial.cod_item\n\t\t\t\t\n\t\t\t\twhere \n\t\t\t\t\tcad_itens.data_aquisicao<'" . $data_fim . "'\n\t\t\t\t\t" . $filtro . "\n\n\t\t\t\tgroup by\n\t\t\t\t\tcad_itens.cod_item\n\t\t\t\t\t\n\n\t\t"; //echo $select; $pesquisa = new pesquisa(); $base = $pesquisa->json($select); //echo $base; $column = "{headerText: 'ID', key: 'cod_item', width: '50px', dataType: 'string'},"; $column .= "{headerText: 'Grupo', key: 'nome_grupo', dataType: 'string'},"; $column .= "{headerText: 'Descrição do Item', key: 'descricao', dataType: 'string'},"; $column .= "{\n headerText: 'Aquisição',\n group: [\n\t\t\t\t\t\t\t\t{headerText: 'Data', key: 'data_aquisicao', width:'80px', dataType: 'date', format:'d/MM/yyyy'},\n\t\t\t\t\t\t\t\t{headerText: 'Valor', key: 'valor_aquisicao', width:'80px', dataType: 'number', format:'0.00'},\n\t\t\t\t\t\t]\n\t\t\t\t\t\t},"; $column .= "{\n headerText: 'Vida útil',\n group: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\theaderText: 'Item',\n\t\t\t\t\t\t\t\tgroup: [\n\t\t\t\t\t\t\t\t\t\t{headerText: 'V.U.', key: 'vida_util_item', width:'50px', dataType: 'number', format:'int'},\n\t\t\t\t\t\t\t\t\t\t{headerText: 'Taxa Anual', key: 'taxa_depreciacao_anual_item', width:'50px', dataType: 'number', format:'0.00'},\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\theaderText: 'Grupo',\n\t\t\t\t\t\t\t\tgroup: [\n\t\t\t\t\t\t\t\t\t\t{headerText: 'V.U.', key: 'vida_util_grupo', width:'50px', dataType: 'number', format:'int'},\n\t\t\t\t\t\t\t\t\t\t{headerText: 'Taxa Anual', key: 'taxa_depreciacao_anual_grupo', width:'50px', dataType: 'number', format:'0.00'},\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\n\t\t\t\t\t\t]\n\t\t\t\t\t\t},"; $column .= "{\n headerText: 'Saldos',\n group: [\n\t\t\t\t\t\t\t\t{headerText: 'Inicial', key: 'saldo_inicial', width:'80px', dataType: 'number', format:'0.00'},\n\t\t\t\t\t\t\t\t{headerText: 'Depreciação', key: 'depreciacao', width:'80px', dataType: 'number', format:'0.00'},\n\t\t\t\t\t\t\t\t{headerText: 'Final', key: 'saldo_final', width:'80px', dataType: 'number', format:'0.00'}\n\t\t\t\t\t\t]\n\t\t\t\t\t\t},"; $groupby = ""; $igniteui = new igniteui(); $igniteui->igrid_relatorios($base, $column, $groupby); } }
<?php session_start(); include "php.php"; if (isset($_SESSION['loged']) and $_SESSION['loged'] == true) { //var_dump($_POST); if (isset($_POST['cod_orcamento']) and isset($_POST['cod_centro_custo']) and isset($_POST['act']) and $_POST['act'] == "pesquisar") { ///pesquisar orcamento $select = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\t`cad_lancamento`.`cad_lancamento`,\n\t\t\t\t\t\t`cad_lancamento`.`cod_orcamento`,\n\t\t\t\t\t\t`cad_lancamento`.`cod_centro_custo`,\n\t\t\t\t\t\t`cad_lancamento`.`cod_conta`,\n\t\t\t\t\t\tDATE_FORMAT(`cad_lancamento`.`data`,'%m-%Y') as data,\n\t\t\t\t\t\t`cad_lancamento`.`valor`,\n\t\t\t\t\t\t`cad_lancamento`.`historico`,\n\t\t\t\t\t\t`cad_lancamento`.`cod_empresa`\n\t\t\t\t\tFROM \n\t\t\t\t\t\t`orcamento`.`cad_lancamento`\n\n\t\t\t\t\twhere\n\t\t\t\t\t\tcod_orcamento='" . $_POST['cod_orcamento'] . "' and\n\t\t\t\t\t\tcod_centro_custo='" . $_POST['cod_centro_custo'] . "' and\n\t\t\t\t\t\tcod_empresa='" . $_SESSION['cod_empresa'] . "' "; $pesquisa = new pesquisa(); $json = $pesquisa->json($select); echo $json; $sql = new sql(); } if (isset($_POST['cod_orcamento']) and isset($_POST['cod_centro_custo']) and isset($_POST['act']) and $_POST['act'] == "salvar") { //var_dump($_POST); $sql = new sql(); //excluir $table = 'cad_lancamento'; $where = "cod_orcamento='" . $_POST['cod_orcamento'] . "' and cod_centro_custo='" . $_POST['cod_centro_custo'] . "' "; $sql->delete($table, $where, 'N'); //incluir $table = 'cad_lancamento'; $campos = $_POST['campos']; $bs = $_POST['bs']; $bs = str_replace("[[", "(", $bs); $bs = str_replace("]]", ")", $bs); $bs = str_replace("[", "(", $bs); $bs = str_replace("]", ")", $bs); $bs = str_replace(")", ",'" . $_SESSION['cod_empresa'] . "','" . $_SESSION['cod_usuario'] . "')", $bs); $sql->insert_($table, $campos, $bs, 'S'); }