Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once "../../manager.php";
- verifySession();
- if(array_intersect(array('6'), $_SESSION['codRole'])) {
- $postCodFornecedor = isset($_POST['codFornecedor']) ? (int) $_POST['codFornecedor'] : false;
- $postCodOs = isset($_POST['codOs']) ? (int) $_POST['codOs'] : false;
- $postCodOp = isset($_POST['codOp']) ? (int) $_POST['codOp'] : false;
- $acao = isset($_POST['acao']) ? $_POST['acao'] : false;
- echo $postCodOp;
- function detalhesOp($postCodOp)
- {
- $sql = new SqlManager();
- $selectDetalhesOs = $sql->getFields("SELECT
- códOP as codOp,
- FORNECEDOR as codFornecedor,
- OP as op,
- CONDIÇÕES as condicoes,
- FORMAPG as formaPagamento,
- convert(char(10),[DT FECHAMENTO],103) as dataFechamento,
- ATIVO as ativo
- FROM [ORDENS DE PAGAMENTO]
- Where [códOP] = " . $postCodOp);
- $sql->closeConnection();
- return $selectDetalhesOs;
- }
- if(isset($postCodOp)) {
- $infoOp = detalhesOp($postCodOp);
- $infoOp = isset($infoOp[0]) ? $infoOp[0] : null;
- } if ($postCodOp == null) {
- $mes=array('', 'JANEIRO', 'FEVEREIRO', 'MARÇO', 'ABRIL', 'MAIO', 'JUNHO', 'JULHO', 'AGOSTO', 'SETEMBRO', 'OUTUBRO', 'NOVEMBRO', 'DEZEMBRO');
- $ano =date('Y');
- $infoOp['codOp'] =null;
- $infoOp['codFornecedor'] = null;
- $infoOp['op'] = null;
- $infoOp['condicoes'] = "À Vista";
- $infoOp['formaPagamento'] = "Depósito em Conta";
- $infoOp['dataFechamento'] = null;
- $postCodOp = 'null';
- $infoOp['ativo'] = 1;
- } elseif ($postCodOp) {
- $infoOp = detalhesOp( $postCodOp );
- $infoOp = isset( $infoOp[ 0 ] ) ? $infoOp[ 0 ] : null;
- }
- $fornecedorSql = "SELECT CógidoDoNome as codFornecedor, Nome as nome FROM FORNECEDORES ORDER BY nome";
- $sql = new SqlManager();
- $listas = array(
- "listaFornecedor" => $sql->getFields($fornecedorSql)
- );
- $sql->closeConnection();
- } ?>
- <? if(array_intersect(array('6'), $_SESSION['codRole'])) { ?>
- <div id="modalPagamentosContent">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" id="fechaModal" onclick="carregatabelaOpGeral()">×</button>
- <h4 class="modal-title">Ordem de Pagamento </h4>
- </div>
- <div class="modal-body">
- <div class="row">
- <div class="col-sm-7">
- <label for="nome" class="control-label">Nome:</label>
- <select class="nomeSelect" id="nome" style="width:100%" value="<?= $postCodFornecedor ?>">
- <option value=""></option>
- <?php
- foreach ($listas["listaFornecedor"] as $lista) {
- ?>
- <option value="<?=$lista['codFornecedor']?>"<?php
- if ($lista['codFornecedor'] == $postCodFornecedor) {
- echo "selected";
- }
- ?>>
- <?= $lista["nome"] ?>
- </option>
- <?php
- }
- ?>
- </select>
- </div>
- <div class="col-sm-3">
- <label> Forma de Pagamento: </label>
- <input type="text" class="form-control" id="formaPagamento" value="<?= $infoOp["formaPagamento"]?>">
- </div><br>
- <div class="col-sm-2">
- <label>Ativo: </label>
- <input type="checkbox" class="form-control" data-toggle="toggle" data-width="50%" id="ativo" data-size="mini" data-onstyle="success" data-on="Ativo" data-offstyle="danger" data-off="Inativo" <?= $infoOp['ativo'] != 0 ? "checked" : "" ?>
- <?= $infoOp['ativo'] == 1 ? "checked" : "" ?>>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <label> Identificação: </label>
- <input type="text" class="form-control op" id="op" value="<?=$infoOp["op"]?>">
- </div>
- <div class="col-sm-3">
- <label> Condições: </label>
- <input type="text" class="form-control condicoes" id="condicoes" value="<?=$infoOp["condicoes"]?>">
- </div>
- <div class="col-sm-3">
- <label>Data de Fechamento: </label>
- <input type="text" class="form-control dataFechamento" id="dataFechamento" value=<?= $infoOp["dataFechamento"]?>>
- </div>
- </div> <br>
- <?php
- if ($infoOp["codOp"] == NULL) {
- ?>
- <div class="box-body form-group" align="center">
- <button type="button" class="btn btn-success" id="salvarOp">Salvar Op</button>
- </div>
- <?php
- }
- ?>
- <?php
- if (($postCodFornecedor != null) || ($infoOp["codOp"] =! null)) {
- ?>
- <div class="box box-body" id="pagamentos">
- <div class="col-sm-12">
- <table id="tabelaPagamentos" class="table table-bordered table-striped table-hover" data-order='[[0, "asc"]]' data-page-length="15">
- <style>
- .red {
- background-color: red !important;
- }
- </style>
- <thead>
- <tr>
- <th>Pedido</th>
- <th>Tarefa</th>
- <th>Início</th>
- <th>Conclusão</th>
- <th>Fechar</th>
- </tr>
- </thead>
- </table>
- </div>
- </div>
- <div class="modal fade" id="modalVoucher" role="dialog">
- <div class="modal-dialog" style="width:70%;height:auto">
- <div class="modal-content">
- <div id="voucherContent"></div>
- </div>
- </div>
- </div>
- <div class="modal fade" id="modalNovaOs" role="dialog">
- <div class="modal-dialog" style="width:70%;height:auto">
- <div class="modal-content">
- <div id="modalNovaOsContent"></div>
- </div>
- </div>
- </div>
- </div>
- <?php
- }
- ?>
- <?} else { ?>
- <div class="box col-sm-12">
- <label> Você não tem permissão para ver essa página </label>
- </div>
- <? } ?>
- <script>
- function insertOp(data) {
- var nome = $('#nome').val();
- var op = $('#op').val();
- var dataFechamento = $('#dataFechamento').val();
- var formaPagamento = $('#formaPagamento').val();
- var condicoes = $('#condicoes').val();
- var ativo = $('#ativo').is(":checked") ? 1 : 0;
- $.post("op_insert.php", {
- nome: nome,
- op: op,
- dataFechamento: dataFechamento,
- formaPagamento: formaPagamento,
- condicoes: condicoes,
- ativo: ativo
- }, function(data, status) {
- try {
- if (status == "success") {
- showNotification('OP ', 'Op inserida com sucesso', "success");
- }
- } catch (e) {}
- //console.log(data);
- var response = JSON.parse(data);
- $("#voucherContent").load("detalhesOp.php", {
- codOp: response.codOp,
- codFornecedor: response.codFornecedor
- });
- return;
- });
- }
- function concatenaNomeOp() {
- var data = new Date();
- var meses = new Array("JANEIRO", "FEVEREIRO", "MARÇO", "ABRIL", "MAIO", "JUNHO", "JULHO", "AGOSTO", "SETEMBRO", "OUTUBRO", "NOVEMBRO", "DEZEMBRO");
- var ano = data.getFullYear();
- var resultadoMes = meses[data.getMonth()];
- document.getElementById("op").value = resultadoMes + ' ' + ano + ' -' + $("#nome option:selected").text().toUpperCase().trim(); //coloca em Maiúsculo e remove os espaços desnecessários
- }
- function updateOp() {
- var nome = $('#nome').val();
- var op = $('#op').val();
- var dataFechamento = $('#dataFechamento').val();
- var formaPagamento = $('#formaPagamento').val();
- var condicoes = $('#condicoes').val();
- var ativo = $('#ativo').is(":checked") ? 1 : 0;
- $.post("op_update.php", {
- codOp: '<?= $postCodOp ?>',
- nome: nome,
- op: op,
- dataFechamento: dataFechamento,
- formaPagamento: formaPagamento,
- condicoes: condicoes,
- ativo: ativo
- }, function(data, source) {
- console.log(data);
- try {} catch (e) {}
- });
- carregaTabelaPagamentos();
- }
- <?php
- if (isset($_POST['codOp'])) {
- ?>
- $("input").change(function() {
- updateOp();
- });
- $("select").change(function() {
- updateOp();
- });
- <? } else { ?>
- concatenaNomeOp();
- <? } ?>
- $('#salvarOp').click(function() {
- if ($("#nome").val() == null || $("#nome").val() == "") {
- $("#nome").focus();
- showNotification('NOME', 'Campo vazio!', "danger");
- return false;
- }
- insertOp();
- carregaTabelaPagamentos();
- });
- <?php
- if ($postCodFornecedor != null ) {
- ?>
- var dataObject = {
- aoColumns: [{
- "mDataProp": "fechar"
- }],
- stateSave: true,
- paging: true,
- lengthChange: true,
- searching: true,
- ordering: true,
- info: true,
- autoWidth: true,
- bRetrieve: true,
- language: {
- url: "/dist/plugins/datatables/i18n/Portuguese-Brasil.json"
- }
- }
- function carregaTabelaPagamentos() {
- $.post("detalhesOp_select.php", {
- codFornecedor: <?= $postCodFornecedor ?>,
- codOp: <?= $postCodOp ?>
- }, function(data, status) {
- console.log(data);
- var response = JSON.parse(data);
- var aoColumnsDataTable = [];
- var arrayToTable = [];
- response.listaPagamentos.forEach(function(element, index, array) {
- objTable = {};
- element.tarefa = '<a href="" onclick="fItensOs(' + element.codOs + ')">' + element.tarefa + '</a>';
- if(element.op != null){
- element.fechar = 1;
- element.fechar = '<input type="checkbox" name="fechar" <? if ($infoOp["codOp"] == null){ echo "disabled";}?> onchange="associaOp(' + element.codOs + ',' + element.op + ',' + element.fechar + ');" checked>' <? if ($postCodOp == null){ echo "disabled";}?>;
- } else {
- element.fechar = 0;
- element.fechar = '<input type="checkbox" name="fechar" <? if ($infoOp["codOp"] == null){ echo "disabled";}?> onchange="associaOp(' + element.codOs + ',' + element.op + ',' + element.fechar + ');" >';
- }
- delete element.codOs;
- delete element.op;
- arrayToTable.push(element);
- });
- Object.keys(response.listaPagamentos[0]).forEach(function(element, index, array) {
- aoColumnsDataTable.push({
- "mDataProp": element
- });
- });
- dataObject.aoColumns = aoColumnsDataTable;
- refreshTabela(arrayToTable, aoColumnsDataTable);
- });
- }
- function fItensOs(codOs) {
- if (!(codOs > 0) || typeof codOs == "undefined" || codOs == null) {
- warningNotification("Nenhum dublador foi escalado para esta gravação");
- return;
- }
- $('#voucherContent').load("detalhesOs.php", {
- codOs: codOs
- }, function() { //fazer o debug quando o lote estiver zerado, não tiver OSs
- //console.log();
- });
- $('#modalVoucher2').modal("show");
- }
- function associaOp(codOs, op, fechar) {
- if(fechar == 1){
- op = null;
- } else if (fechar ==0){
- op = <?= $postCodOp ?>;
- }
- alert(fechar);
- alert(op);
- $.post("associaUpdate.php", {
- codOs : codOs,
- op : op,
- }, function(data, source) {
- try {
- carregaTabelaPagamentos();
- } catch (e) {}
- //console.log(data);
- });
- }
- <?php
- }
- ?>
- $(document).ready(function() {
- carregaTabelaPagamentos();
- $('.nomeSelect').select2();
- $('.dataFechamento').datepicker({
- language: "pt-BR",
- format: 'dd/mm/yyyy',
- todayBtn: "linked",
- todayHighlight: true,
- autoclose: true,
- });
- $('#tabelaPagamentos').DataTable( {
- dom: 'Bfrtip',
- buttons: [
- 'copy', 'csv', 'excel', 'pdf', 'print'
- ]
- } );
- $('#tabelaPagamentos').DataTable(dataObject);
- $('#tabelaPagamentos').DataTable( {
- dom: 'Bfrtip',
- buttons: [
- 'copy', 'csv', 'excel', 'pdf', 'print'
- ]
- } );
- $('#tabelaPagamentos').dataTable().fnClearTable();
- $('#tabelaPagamentos').dataTable().fnAddData(dataObject);
- $('#tabelaPagamentos').on('mouseover', function() {
- $('table a').on('click', function(e) {
- e.preventDefault();
- });
- });
- });
- $('#modalVoucher').on('hidden.bs.modal', function() {});
- $('#modalNovaOs').on('hidden.bs.modal', function() {});
- $(document).ajaxStart(function() {
- Pace.restart();
- });
- $("[data-toggle='toggle']").bootstrapToggle('destroy');
- $("[data-toggle='toggle']").bootstrapToggle();
- </script>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement