Skip to content

Commit

Permalink
Adicionando anotações em OS
Browse files Browse the repository at this point in the history
  • Loading branch information
RamonSilva20 committed Oct 9, 2019
1 parent b25e437 commit f213227
Show file tree
Hide file tree
Showing 9 changed files with 530 additions and 324 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Todas as alterações serão documentadas neste arquivo
Formato baseado em [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
e [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.10.0] - 2019-10-08

### Added
- Adicionando anotações na OS. [@RamonSilva20](https://github.com/RamonSilva20)

## [3.9.0] - 2019-10-05

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

![MapOS](https://raw.githubusercontent.com/RamonSilva20/mapos/master/assets/img/logo.png)

![version](https://img.shields.io/badge/version-3.9.0-blue.svg?longCache=true&style=flat-square)
![version](https://img.shields.io/badge/version-3.10.0-blue.svg?longCache=true&style=flat-square)
![license](https://img.shields.io/badge/license-MIT-green.svg?longCache=true&style=flat-square)
![theme](https://img.shields.io/badge/theme-Matrix--Admin-lightgrey.svg?longCache=true&style=flat-square)
![issues](https://img.shields.io/github/issues/RamonSilva20/mapos.svg?longCache=true&style=flat-square)
Expand Down
2 changes: 1 addition & 1 deletion application/config/config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');


$config['app_version'] = '3.9.0';
$config['app_version'] = '3.10.0';

/*
|--------------------------------------------------------------------------
Expand Down
648 changes: 331 additions & 317 deletions application/config/form_validation.php

Large diffs are not rendered by default.

37 changes: 36 additions & 1 deletion application/controllers/Os.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public function editar()
$this->data['produtos'] = $this->os_model->getProdutos($this->uri->segment(3));
$this->data['servicos'] = $this->os_model->getServicos($this->uri->segment(3));
$this->data['anexos'] = $this->os_model->getAnexos($this->uri->segment(3));
$this->data['anotacoes'] = $this->os_model->getAnotacoes($this->uri->segment(3));
$this->data['view'] = 'os/editarOs';
$this->load->view('tema/topo', $this->data);
}
Expand Down Expand Up @@ -365,7 +366,7 @@ public function enviar_email()

if ($enviouEmail) {
$this->session->set_flashdata('success', 'O email está sendo processado e será enviado em breve para o cliente.');
log_info('Enviou e-mail para o cliente: '.$this->data['result']->nomeCliente. '. E-mail: '. $this->data['result']->email);
log_info('Enviou e-mail para o cliente: ' . $this->data['result']->nomeCliente . '. E-mail: ' . $this->data['result']->email);
redirect(site_url('os'));
} else {
$this->session->set_flashdata('error', 'Ocorreu um erro ao enviar e-mail para o cliente.');
Expand Down Expand Up @@ -750,4 +751,38 @@ private function enviarOsPorEmail($idOs, $remetentes, $assunto)

return true;
}

public function adicionarAnotacao()
{
$this->load->library('form_validation');
if ($this->form_validation->run('anotacoes_os') == false) {
echo json_encode(validation_errors());
} else {
$data = array(
'anotacao' => $this->input->post('anotacao'),
'data_hora' => date('Y-m-d H:i:s'),
'os_id' => $this->input->post('os_id'),
);

if ($this->os_model->add('anotacoes_os', $data) == true) {

log_info('Adicionou anotação a uma OS.');
echo json_encode(array('result' => true));
} else {
echo json_encode(array('result' => false));
}
}
}

public function excluirAnotacao()
{
$id = $this->input->post('idAnotacao');
if ($this->os_model->delete('anotacoes_os', 'idAnotacoes', $id) == true) {

log_info('Removeu anotação de uma OS.');
echo json_encode(array('result' => true));
} else {
echo json_encode(array('result' => false));
}
}
}
7 changes: 7 additions & 0 deletions application/models/Os_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,11 @@ public function getAnexos($os)
$this->db->where('os_id', $os);
return $this->db->get('anexos')->result();
}

public function getAnotacoes($os)
{
$this->db->where('os_id', $os);
$this->db->order_by('idAnotacoes', 'desc');
return $this->db->get('anotacoes_os')->result();
}
}
131 changes: 128 additions & 3 deletions application/views/os/editarOs.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<li id="tabProdutos"><a href="#tab2" data-toggle="tab">Produtos</a></li>
<li id="tabServicos"><a href="#tab3" data-toggle="tab">Serviços</a></li>
<li id="tabAnexos"><a href="#tab4" data-toggle="tab">Anexos</a></li>
<li id="tabAnotacoes"><a href="#tab5" data-toggle="tab">Anotações</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
Expand Down Expand Up @@ -235,7 +236,7 @@
echo '<td>' . $s->nome . '</td>';
echo '<td>' . ($s->quantidade ?: 1) . '</td>';
echo '<td>' . $preco . '</td>';
echo '<td><span idAcao="' . $s->idServicos_os . '" title="Excluir Serviço" class="btn btn-danger"><i class="icon-remove icon-white"></i></span></td>';
echo '<td><span idAcao="' . $s->idServicos_os . '" title="Excluir Serviço" class="btn btn-danger servico"><i class="icon-remove icon-white"></i></span></td>';
echo '<td>R$ ' . number_format($subtotal, 2, ',', '.') . '</td>';
echo '</tr>';
} ?>
Expand Down Expand Up @@ -288,6 +289,44 @@
</div>
</div>
</div>

<!--Anotações-->
<div class="tab-pane" id="tab5">
<div class="span12" style="padding: 1%; margin-left: 0">

<div class="span12" id="divAnotacoes" style="margin-left: 0">

<a href="#modal-anotacao" id="btn-anotacao" role="button" data-toggle="modal" class="btn btn-success"><i class="icon-file"></i> Adicionar anotação</a>
<hr>
<table class="table table-bordered">
<thead>
<tr>
<th>Anotação</th>
<th>Data/Hora</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
<?php
foreach ($anotacoes as $a) {
echo '<tr>';
echo '<td>' . $a->anotacao . '</td>';
echo '<td>' . date('d/m/Y H:i:s', strtotime($a->data_hora)) . '</td>';
echo '<td><span idAcao="' . $a->idAnotacoes . '" title="Excluir Anotação" class="btn btn-danger anotacao"><i class="icon-remove icon-white"></i></span></td>';
echo '</tr>';
}
if(!$anotacoes){
echo '<tr><td colspan="2">Nenhuma anotação cadastrada</td></tr>';
}

?>
</tbody>
</table>
</div>

</div>
</div>
<!-- Fim tab anotações -->
</div>
</div>
&nbsp
Expand Down Expand Up @@ -316,6 +355,28 @@
</div>
</div>

<!-- Modal cadastro anotações -->
<div id="modal-anotacao" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<form action="#" method="POST" id="formAnotacao">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Adicionar Anotação</h3>
</div>
<div class="modal-body">
<div class="span12" id="divFormAnotacoes" style="margin-left: 0"></div>
<div class="span12" style="margin-left: 0">
<label for="anotacao">Anotação</label>
<textarea class="span12" name="anotacao" id="anotacao" cols="30" rows="3"></textarea>
<input type="hidden" name="os_id" value="<?php echo $result->idOs; ?>">
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true" id="btn-close-anotacao">Fechar</button>
<button class="btn btn-primary">Adicionar</button>
</div>
</form>
</div>

<!-- Modal Faturar-->
<div id="modal-faturar" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<form id="formFaturar" action="<?php echo current_url() ?>" method="post">
Expand Down Expand Up @@ -379,7 +440,6 @@
</div>



<script type="text/javascript" src="<?php echo base_url() ?>assets/js/jquery.validate.js"></script>
<script src="<?php echo base_url(); ?>assets/js/maskmoney.js"></script>

Expand Down Expand Up @@ -651,6 +711,45 @@
}
});

$("#formAnotacao").validate({
rules: {
anotacao: {
required: true
}
},
messages: {
anotacao: {
required: 'Insira a anotação'
}
},
submitHandler: function(form) {
var dados = $(form).serialize();
$("#divFormAnotacoes").html("<div class='progress progress-info progress-striped active'><div class='bar' style='width: 100%'></div></div>");

$.ajax({
type: "POST",
url: "<?php echo base_url(); ?>index.php/os/adicionarAnotacao",
data: dados,
dataType: 'json',
success: function(data) {
if (data.result == true) {
$("#divAnotacoes").load("<?php echo current_url(); ?> #divAnotacoes");
$("#anotacao").val('');
$('#btn-close-anotacao').trigger('click');
$("#divFormAnotacoes").html('');
} else {
Swal.fire({
type: "error",
title: "Atenção",
text: "Ocorreu um erro ao tentar adicionar anotação."
});
}
}
});
return false;
}
});

$("#formAnexos").validate({
submitHandler: function(form) {
//var dados = $( form ).serialize();
Expand Down Expand Up @@ -713,7 +812,7 @@

});

$(document).on('click', 'span', function(event) {
$(document).on('click', '.servico', function(event) {
var idServico = $(this).attr('idAcao');
if ((idServico % 1) == 0) {
$("#divServicos").html("<div class='progress progress-info progress-striped active'><div class='bar' style='width: 100%'></div></div>");
Expand Down Expand Up @@ -775,6 +874,32 @@
}
});
});

$(document).on('click', '.anotacao', function(event) {
var idAnotacao = $(this).attr('idAcao');
if ((idAnotacao % 1) == 0) {
$("#divAnotacoes").html("<div class='progress progress-info progress-striped active'><div class='bar' style='width: 100%'></div></div>");
$.ajax({
type: "POST",
url: "<?php echo base_url(); ?>index.php/os/excluirAnotacao",
data: "idAnotacao=" + idAnotacao,
dataType: 'json',
success: function(data) {
if (data.result == true) {
$("#divAnotacoes").load("<?php echo current_url(); ?> #divAnotacoes");

} else {
Swal.fire({
type: "error",
title: "Atenção",
text: "Ocorreu um erro ao tentar excluir serviço."
});
}
}
});
return false;
}
});

$(".datepicker").datepicker({
dateFormat: 'dd/mm/yy'
Expand Down
15 changes: 14 additions & 1 deletion banco.sql
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ CREATE TABLE IF NOT EXISTS `emitente` (
PRIMARY KEY (`id`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `email_queue`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `email_queue` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`to` varchar(255) NOT NULL,
Expand All @@ -521,6 +523,17 @@ CREATE TABLE IF NOT EXISTS `email_queue` (
PRIMARY KEY (`id`)
);

-- -----------------------------------------------------
-- Table `anotacaoes_os`
-- -----------------------------------------------------
CREATE TABLE `anotacoes_os` (
`idAnotacoes` INT(11) NOT NULL AUTO_INCREMENT,
`anotacao` VARCHAR(255) NOT NULL ,
`data_hora` DATETIME NOT NULL ,
`os_id` INT(11) NOT NULL ,
PRIMARY KEY (`idAnotacoes`)
);

INSERT INTO `permissoes` (`idPermissao`, `nome`, `permissoes`, `situacao`, `data`) VALUES
(1, 'Administrador', 'a:43:{s:8:"aCliente";s:1:"1";s:8:"eCliente";s:1:"1";s:8:"dCliente";s:1:"1";s:8:"vCliente";s:1:"1";s:8:"aProduto";s:1:"1";s:8:"eProduto";s:1:"1";s:8:"dProduto";s:1:"1";s:8:"vProduto";s:1:"1";s:8:"aServico";s:1:"1";s:8:"eServico";s:1:"1";s:8:"dServico";s:1:"1";s:8:"vServico";s:1:"1";s:3:"aOs";s:1:"1";s:3:"eOs";s:1:"1";s:3:"dOs";s:1:"1";s:3:"vOs";s:1:"1";s:6:"aVenda";s:1:"1";s:6:"eVenda";s:1:"1";s:6:"dVenda";s:1:"1";s:6:"vVenda";s:1:"1";s:9:"aGarantia";s:1:"1";s:9:"eGarantia";s:1:"1";s:9:"dGarantia";s:1:"1";s:9:"vGarantia";s:1:"1";s:8:"aArquivo";s:1:"1";s:8:"eArquivo";s:1:"1";s:8:"dArquivo";s:1:"1";s:8:"vArquivo";s:1:"1";s:11:"aLancamento";s:1:"1";s:11:"eLancamento";s:1:"1";s:11:"dLancamento";s:1:"1";s:11:"vLancamento";s:1:"1";s:8:"cUsuario";s:1:"1";s:9:"cEmitente";s:1:"1";s:10:"cPermissao";s:1:"1";s:7:"cBackup";s:1:"1";s:10:"cAuditoria";s:1:"1";s:8:"rCliente";s:1:"1";s:8:"rProduto";s:1:"1";s:8:"rServico";s:1:"1";s:3:"rOs";s:1:"1";s:6:"rVenda";s:1:"1";s:11:"rFinanceiro";s:1:"1";}', 1, '2014-09-03');

Expand Down
7 changes: 7 additions & 0 deletions updates/updata_3.9_to_3.10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE `anotacoes_os` (
`idAnotacoes` INT(11) NOT NULL AUTO_INCREMENT,
`anotacao` VARCHAR(255) NOT NULL ,
`data_hora` DATETIME NOT NULL ,
`os_id` INT(11) NOT NULL ,
PRIMARY KEY (`idAnotacoes`)
);

0 comments on commit f213227

Please sign in to comment.