94 lines
2.5 KiB
PHP
94 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Cadastro\Material;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\Cadastro\Material\MaterialService;
|
|
use Illuminate\Http\Response;
|
|
|
|
class MaterialController extends Controller
|
|
{
|
|
protected $modulo = 'cadastro';
|
|
protected $funcionalidade = 'material';
|
|
|
|
public function autocomplete()
|
|
{
|
|
return datatables()->of(MaterialService::autocomplete())->make(true);
|
|
}
|
|
|
|
public function datatable()
|
|
{
|
|
return datatables()
|
|
->of(MaterialService::datatable())
|
|
->filterColumn('apresentacao', function ($query, $keyword) {
|
|
|
|
$query->whereRaw("CONCAT(
|
|
UPPER(cadastro_apresentacao.nome),
|
|
' ',
|
|
CAST(cadastro_material.quantidade AS INTEGER),
|
|
' ',
|
|
UPPER(COALESCE(apresentacao_unidade_medida.nome, ''))
|
|
) like ?", ["%{$keyword}%"]);
|
|
})
|
|
->make(true);
|
|
}
|
|
|
|
public function getEstoque($materialId, $centroCustoId = null)
|
|
{
|
|
return response()->json(
|
|
MaterialService::getEstoque($materialId, $centroCustoId),
|
|
Response::HTTP_OK
|
|
);
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(MaterialService::create(), Response::HTTP_CREATED);
|
|
}
|
|
|
|
public function store()
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(MaterialService::store(), Response::HTTP_CREATED);
|
|
}
|
|
|
|
public function edit($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(MaterialService::edit($id), Response::HTTP_OK);
|
|
}
|
|
|
|
public function update($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(MaterialService::update($id), Response::HTTP_OK);
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(MaterialService::destroy($id), Response::HTTP_NO_CONTENT);
|
|
}
|
|
|
|
public function editMaterialBnafar($materialId)
|
|
{
|
|
return response()->json(MaterialService::editMaterialBnafar($materialId), Response::HTTP_OK);
|
|
}
|
|
|
|
public function updateMaterialBnafar($materialId)
|
|
{
|
|
return response()->json(MaterialService::updateMaterialBnafar($materialId), Response::HTTP_OK);
|
|
}
|
|
|
|
public function storeIntegracaoBnafarMedicamentos($materialId)
|
|
{
|
|
return response()->json(MaterialService::storeIntegracaoBnafarMedicamentos($materialId), Response::HTTP_CREATED);
|
|
}
|
|
}
|