function FindCod($Cod) { $Read = new ImpPostos(); $Read->setPostos_numero($Cod); $Result = $Read->Execute()->Query("#postos_numero#"); if (!empty($Result)) { return $Result[0]->postos_id; } }
<?php if (file_exists('include/contadores-de-impressao/_models/AdminImpressoras.class.php')) { include 'include/contadores-de-impressao/_models/AdminImpressoras.class.php'; } $ImpPostos = new ImpPostos(); $ImpPostos->Execute()->find("postos_id={$Link->getLocal()[2]}"); ?> <a style="float: right;" class="btn btn-info" href="<?php echo IMP_INCLUDE; ?> ">Voltar</a> <h2><small><?php echo $ImpPostos->Execute()->getResult()->postos_nome; ?> </small></h2> <?php $AdImpress = new AdminImpressoras($Link->getLocal()[2]); $data = filter_input_array(INPUT_POST, FILTER_DEFAULT); if (!empty($data['sendContador'])) { unset($data['sendContador']); $data['user_id'] = !empty($_SESSION['userlogin']) ? $_SESSION['userlogin']['user_id'] : null; $minContador = $AdImpress->MinContador($data['contadores_contador'], $Link->getLocal()[3]); if (!$minContador) { $AdImpress->ExeRegister($data); header("Location: " . IMP_INCLUDE . $Link->getLocal()[2]); } else { WSErro("O contador deve ser maior que: <b>{$minContador[0]->contadores_contador}</b>", WS_INFOR); }
WSErro("Erro ao deletar", WS_ERROR); } break; default: WSErro("Opss! opção invalida.", WS_ERROR); break; } } else { WSErro("O modelo informado não pode ser encontrado!", WS_INFOR); } } $getPage = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT); $Pager = new Pager(IMP_INCLUDE . "admin/&exe=modelo/index&page="); $Pager->ExePager($getPage, 15); $Read = new ImpPostos(); $Read->Execute()->FullRead("SELECT * FROM imp_modelo ORDER BY modelo_status LIMIT :limit OFFSET :offset", "limit={$Pager->getLimit()}&offset={$Pager->getOffset()}", true); ?> <article> <?php if (!$Read->Execute()->getResult()) { $Pager->ReturnPage(); WSErro("Desculpa, ainda não temos modelo cadastrados", WS_INFOR); } else { ?> <table class="table table-striped text-center"> <thead> <tr> <th class="text-center">#</th> <th class="text-center">Nome</th> <th class="text-center">Status</th> <th>Actions</th>
/** * Encontra descricao do posto com base na chave estrangeira * * @param int $postos_id * @return String */ public function Posto($postos_id) { $ImpPostos = new ImpPostos(); $ImpPostos->Execute()->find("postos_id={$postos_id}"); return $ImpPostos->Execute()->getResult()->postos_nome; }
unset($Dados["SendPostForm"]); $AdminPostos = new AdminPostos(); if (in_array("", $Dados)) { WSErro("Preencha todos os campos!", WS_ALERT); } elseif (!is_numeric($Dados['postos_numero'])) { WSErro("O Campo <b>Numero</b>, deve ser um valor numerico.", WS_ERROR); } else { if ($AdminPostos->ExeUpdate($Dados)) { WSErro("Atualizado com sucesso!", WS_ACCEPT); } else { WSErro("Erro ao atualizar!", WS_ERROR); } } } else { $ImpPostos = new ImpPostos(); $ImpPostos->Execute()->find("postos_id={$postoId}"); $Dados = (array) $ImpPostos->Execute()->getResult(); } $checkCreate = filter_input(INPUT_GET, 'create', FILTER_VALIDATE_BOOLEAN); if ($checkCreate && empty($AdminPostos)) { WSErro("O posto <b>{$Dados['postos_nome']}</b> foi cadastrado com sucesso no sistema!", WS_ACCEPT); } ?> <article> <h1>Atualizar Postos:</h1> <div class="row"> <form class="form col-md-offset-2 col-md-4" name="postos" method="post"> <div class="form-group">
"> </div> <div class="form-group"> <label>Descrição:</label> <input name="impressora_descricao" type="text" placeholder="Descrição" class="form-control" value="<?php echo $Dados['impressora_descricao']; ?> "> </div> <div class="row"> <?php $ImpPostos = new ImpPostos(); $ImpPostos->Execute()->findAll(); ?> <div class="form-group col-md-4"> <label>Posto:</label> <select class="form-control" name="fk_postos"> <option value=""> Selecione um posto: </option> <?php foreach ($ImpPostos->Execute()->getResult() as $posto) { extract((array) $posto); echo "<option value=\"{$postos_id}\" " . ($Dados['fk_postos'] == $postos_id ? "selected=true" : "") . ">" . ucfirst(strtolower($postos_nome)) . "</option>"; } ?> </select> </div> <?php
WSErro("Erro ao deletar", WS_ERROR); } break; default: WSErro("Opss! opção invalida.", WS_ERROR); break; } } else { WSErro("O posto informado não pode ser encontrado!", WS_INFOR); } } $getPage = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT); $Pager = new Pager(IMP_INCLUDE . "admin/&exe=postos/index&page="); $Pager->ExePager($getPage, 15); $Read = new ImpPostos(); $Read->Execute()->FullRead("SELECT * FROM imp_postos ORDER BY postos_ativo LIMIT :limit OFFSET :offset", "limit={$Pager->getLimit()}&offset={$Pager->getOffset()}", true); ?> <article> <?php if (!$Read->Execute()->getResult()) { $Pager->ReturnPage(); WSErro("Desculpa, ainda não temos postos cadastrados", WS_INFOR); } else { ?> <table class="table table-striped text-center"> <thead> <tr> <th class="text-center">#</th> <th class="text-center">Nome</th> <th class="text-center">Numero</th> <th class="text-center">Impressoras</th>
<?php $Read = new ImpPostos(); switch ($method) { case "GET": //retorna todos os itens if (isset($id)) { $Read->setPostos_id($id); $Read->Execute()->find(); if ($Read->Execute()->getResult()) { echo json_encode($Read->Execute()->getResult()); } else { http_response_code(404); } } elseif (!empty($query) && $query == 'ativos') { $Read->Execute()->Query("postos_ativo=1"); Check::JsonReturn($Read->Execute()->getResult(), 'Nenhuma unidade cadastrada!', '204'); } else { $Read->Execute()->findAll(); Check::JsonReturn($Read->Execute()->getResult(), 'Nenhuma unidade cadastrada!', '204'); } break; case "POST": if (!empty($request->postos_id)) { //update $Read->setThis($request); $Read->Execute()->update(NULL, 'postos_id'); echo json_encode($request); } else { //salvar $Read->setThis($request);