mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado tarifas envio
This commit is contained in:
@ -10,6 +10,7 @@ use App\Entities\Tarifas\TarifaEnvioZonaEntity;
|
||||
use App\Models\Tarifas\TarifaEnvioModel;
|
||||
|
||||
use App\Models\Tarifas\TarifaEnvioZonaModel;
|
||||
use App\Models\Tarifas\TarifaEnvioPrecioModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
@ -208,6 +209,43 @@ class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function delete($id = null)
|
||||
{
|
||||
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) {
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc));
|
||||
} else {
|
||||
$objName = lang('Basic.global.record');
|
||||
}
|
||||
|
||||
if (!$this->soft_delete){
|
||||
|
||||
if (!$this->model->delete($id)) {
|
||||
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
|
||||
}
|
||||
}
|
||||
else{
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
|
||||
$precioModel = new TarifaEnvioPrecioModel();
|
||||
$precioResult = $precioModel->removeAllPrecioLineas($id, $datetime, $this->delete_flag);
|
||||
|
||||
$rawResult = $this->model->where('id',$id)
|
||||
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
|
||||
'is_deleted' => $this->delete_flag])
|
||||
->update();
|
||||
|
||||
if (!$rawResult && !$precioResult) {
|
||||
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented
|
||||
$message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]);
|
||||
$response = $this->respondDeleted(['id' => $id, 'msg' => $message]);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function datatable_editor()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
@ -308,12 +346,14 @@ class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
|
||||
$order = TarifaEnvioZonaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$tarifa_envio_id = $reqData['tarifa_envio_id'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getResource($search, $tarifa_envio_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
$this->model->getResource($search, $tarifa_envio_id)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
|
||||
Reference in New Issue
Block a user