diff --git a/app/Relatorio.php b/app/Relatorio.php index b27fb0a..9ee2f5b 100644 --- a/app/Relatorio.php +++ b/app/Relatorio.php @@ -38,6 +38,10 @@ public function getRelatorio() $dt = Util::dataToMysql(request('periodo_final')); $this->query->where('data', '<=', $dt); endif; + if (request('forma_pagamento')): + $this->query->where('forma_pagamento', request('forma_pagamento')); + endif; + $this->items = $this->query->orderBy('data', 'desc')->get(); $this->calcTotalGeral(); return $this; diff --git a/app/Venda.php b/app/Venda.php index c1acdc2..f6bdea6 100755 --- a/app/Venda.php +++ b/app/Venda.php @@ -7,7 +7,7 @@ class Venda extends Model { - protected $fillable=['produto_id',"cliente_id",'valor_compra','valor_venda','qtd','observacao','data']; + protected $fillable=['produto_id',"cliente_id",'valor_compra','valor_venda','qtd','observacao','data','forma_pagamento']; protected $dates = array('data'); public function produto() @@ -102,6 +102,12 @@ public function setDataAttribute($value) $this->attributes['data'] = Carbon::createFromFormat('d/m/Y', $value); } + public function getNomeFormaPagamentoAttribute() + { + $nomes=[1=>'Dinheiro',2=>'Cartão']; + return isset($nomes[$this->forma_pagamento])?$nomes[$this->forma_pagamento]:null; + } + public function moneytoBr($attr) { return number_format($this->$attr, 2, ',', '.'); diff --git a/database/migrations/2017_08_08_014107_create_vendas_table.php b/database/migrations/2017_08_08_014107_create_vendas_table.php index 47c0a60..829fcab 100755 --- a/database/migrations/2017_08_08_014107_create_vendas_table.php +++ b/database/migrations/2017_08_08_014107_create_vendas_table.php @@ -21,6 +21,7 @@ public function up() $table->decimal('valor_compra', 10, 2); $table->decimal('valor_venda', 10, 2); $table->integer('qtd'); + $table->integer('forma_pagamento'); $table->string('observacao')->nullable(); $table->timestamps(); $table->foreign('cliente_id')->references('id')->on('clientes'); diff --git a/public/js/vendas.js b/public/js/vendas.js index a410604..d21be24 100644 --- a/public/js/vendas.js +++ b/public/js/vendas.js @@ -78,6 +78,7 @@ $("#form-venda").validate({ valor_venda: {required: true}, produto_id: {required: true}, cliente_id: {required: true}, + forma_pagamento: {required: true}, qtd: {required: true} }, @@ -87,6 +88,7 @@ $("#form-venda").validate({ valor_venda: {required: 'Digite o valor da Venda'}, produto_id: {required: "Selecione o Produto"}, cliente_id: {required: "Selecione o Cliente"}, + forma_pagamento: {required: "Selecione forma de Pagamento"}, qtd: {required: "Digite a Qtd."} } diff --git a/resources/macros/componentes.php b/resources/macros/componentes.php index 7a3418f..a0a55cc 100644 --- a/resources/macros/componentes.php +++ b/resources/macros/componentes.php @@ -2,3 +2,4 @@ Form::component('bsText', 'components.form.text', ['name', 'value' => null, 'attributes' => []]); Form::component('listMultiple', 'components.form.listMultiple', ['name', 'elements','value' => [], 'attributes' => []]); +Form::component('list', 'components.form.list', ['name', 'elements','value' => null, 'attributes' => []]); diff --git a/resources/views/components/form/list.blade.php b/resources/views/components/form/list.blade.php new file mode 100644 index 0000000..9f845b4 --- /dev/null +++ b/resources/views/components/form/list.blade.php @@ -0,0 +1,38 @@ +$attribute): + $atributos.="$key=$attribute "; +endforeach; +//echo $atributos; exit(); +?> + +