mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'dev/tarifas' into 'main'
Dev/tarifas See merge request jjimenez/safekat!15
This commit is contained in:
@ -103,6 +103,24 @@ abstract class GoBaseController extends Controller {
|
||||
*/
|
||||
public $viewData;
|
||||
|
||||
|
||||
/**
|
||||
* JJO: Variable para indicar si el controlador hace soft_delete o no
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $soft_delete = false;
|
||||
/**
|
||||
* JJO: Variable quién puede ver los registros borrados
|
||||
*
|
||||
* 0 -> Not Deleted
|
||||
* 1 -> Soft Deleted, shows up in lists of deleted items for management users
|
||||
* 2 -> Soft Deleted, does not show up for any user except admin users
|
||||
* 3 -> Only shows up for developers.
|
||||
* @var int
|
||||
*/
|
||||
public $delete_flag = 0;
|
||||
|
||||
public $currentAction;
|
||||
|
||||
/**
|
||||
@ -208,7 +226,12 @@ abstract class GoBaseController extends Controller {
|
||||
}
|
||||
|
||||
if (isset($this->primaryModel) && isset(static::$singularObjectNameCc) && !empty(static::$singularObjectNameCc) && !isset($this->viewData[(static::$singularObjectNameCc) . 'List'])) {
|
||||
$this->viewData[(static::$singularObjectNameCc) . 'List'] = $this->primaryModel->asObject()->findAll();
|
||||
//JJO
|
||||
if ($this->soft_delete):
|
||||
$this->viewData[(static::$singularObjectNameCc) . 'List'] = $this->primaryModel->asObject()->where('is_deleted', 0)->findAll();
|
||||
else:
|
||||
$this->viewData[(static::$singularObjectNameCc) . 'List'] = $this->primaryModel->asObject()->findAll();
|
||||
endif;
|
||||
}
|
||||
|
||||
// if $this->currentView is assigned a view name, use it, otherwise assume the view something like 'viewSingleObjectList'
|
||||
@ -323,12 +346,19 @@ abstract class GoBaseController extends Controller {
|
||||
|
||||
if (!isset($error)) :
|
||||
try {
|
||||
if ($deletePermanently) :
|
||||
if (is_numeric($id)) :
|
||||
if ($deletePermanently && !$this->soft_delete) :
|
||||
if (is_numeric($id)) :
|
||||
$rawResult = $this->primaryModel->delete($id);
|
||||
else:
|
||||
$rawResult = $this->primaryModel->where($this->primaryModel->getPrimaryKeyName(), $id)->delete();
|
||||
endif;
|
||||
elseif ($this->soft_delete):
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$rawResult = $this->primaryModel->where('id',$id)
|
||||
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
|
||||
'is_deleted' => $this->delete_flag])
|
||||
->update();
|
||||
|
||||
else:
|
||||
$rawResult = $this->primaryModel->update($id, ['deleted' => true]);
|
||||
endif;
|
||||
|
||||
@ -21,6 +21,10 @@ class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('Tarifaacabado.moduleTitle');
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
@ -101,6 +105,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
if ($requestedId == null) :
|
||||
@ -123,7 +128,11 @@ class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
@ -224,81 +233,5 @@ class Tarifaacabado extends \App\Controllers\GoBaseController {
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($requestedId, bool $deletePermanently = false) {
|
||||
|
||||
if (is_string($requestedId)) :
|
||||
if (is_numeric($requestedId)) :
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_NUMBER_INT);
|
||||
else:
|
||||
$onlyAlphaNumeric = true;
|
||||
$fromGetRequest = true;
|
||||
$idSanitization = goSanitize($requestedId, $onlyAlphaNumeric, $fromGetRequest); // filter_var(trim($requestedId), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$id = $idSanitization[0];
|
||||
endif;
|
||||
else:
|
||||
$id = intval($requestedId);
|
||||
endif;
|
||||
|
||||
if (empty($id) || $id === 0) :
|
||||
$error = 'Invalid identifier provided to delete the object.';
|
||||
endif;
|
||||
|
||||
$rawResult = null;
|
||||
|
||||
if (!isset($error)) :
|
||||
try {
|
||||
if ($deletePermanently) :
|
||||
if (is_numeric($id)) :
|
||||
$rawResult = $this->primaryModel->delete($id);
|
||||
else:
|
||||
$rawResult = $this->primaryModel->where($this->primaryModel->getPrimaryKeyName(), $id)->delete();
|
||||
endif;
|
||||
else:
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$rawResult = $this->primaryModel->where('id',$id)
|
||||
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s')])
|
||||
->update();
|
||||
endif;
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', "Exception: Error deleting object named '".(static::$singularObjectName ?? 'unknown')."' with $id :\r\n".$e->getMessage());
|
||||
}
|
||||
endif;
|
||||
|
||||
$ar = $this->primaryModel->db->affectedRows();
|
||||
|
||||
try {
|
||||
$dbError = $this->primaryModel->db->error();
|
||||
} catch (\Exception $e2) {
|
||||
if ($e2->getMessage() != "Trying to get property 'errno' of non-object") {
|
||||
log_message('error', $e2->getCode() . ' : ' . $e2->getMessage()) ;
|
||||
}
|
||||
}
|
||||
if (isset($dbError['code']) && isset($dbError['message'])) {
|
||||
log_message('error', $dbError['code'].' '.$dbError['message']);
|
||||
} else {
|
||||
$dbError = ['code' => '', 'message'=>''];
|
||||
}
|
||||
|
||||
$result = ['persisted'=>$ar>0, 'ar'=>$ar, 'persistedId'=>null, 'affectedRows'=>$ar, 'errorCode'=>$dbError['code'], 'error'=>$dbError['message']];
|
||||
|
||||
$nameOfDeletedObject = static::$singularObjectNameCc;
|
||||
|
||||
if ($ar < 1) :
|
||||
$errorMessage = lang('Basic.global.deleteError', [$nameOfDeletedObject]); // 'No ' . static::$singularObjectName . ' was deleted now, because it probably had already been deleted.';
|
||||
$fdKey = isset($this->viewData['usingSweetAlert'] ) && $this->viewData['usingSweetAlert'] ? 'sweet-error' : 'errorMessage';
|
||||
$errorMessage = str_replace("'", "\'", $errorMessage);
|
||||
return $this->redirect2listView($fdKey, str_replace("'", '', $errorMessage));
|
||||
else:
|
||||
$message = lang('Basic.global.deleteSuccess', [$nameOfDeletedObject]); // 'The ' . static::$singularObjectName . ' was successfully deleted.';
|
||||
$fdKey = isset($this->viewData['usingSweetAlert'] ) && $this->viewData['usingSweetAlert'] ? 'sweet-success' : 'successMessage';
|
||||
if ($result['affectedRows']>1) :
|
||||
log_message('warning', "More than one row has been deleted in attempt to delete row for object named '".(static::$singularObjectName ?? 'unknown')."' with id: $id");
|
||||
endif;
|
||||
$message = str_replace("'", "\'", $message);
|
||||
return $this->redirect2listView($fdKey, $message);
|
||||
endif;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,10 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('Tarifamanipulado.moduleTitle');
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
@ -101,6 +105,9 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
@ -119,9 +126,12 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
@ -22,6 +22,10 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('Preimpresions.moduleTitle');
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
@ -100,7 +104,10 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
@ -119,9 +126,12 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController {
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
@ -17,6 +17,7 @@ class TarifaacabadoEntity extends Entity
|
||||
"user_created_id" => 1,
|
||||
"user_update_id" => 1,
|
||||
"deleted_at" => null,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
|
||||
@ -17,6 +17,8 @@ class TarifamanipuladoEntity extends \CodeIgniter\Entity\Entity
|
||||
"formula_price" => null,
|
||||
"user_created_id" => 1,
|
||||
"user_update_id" => 1,
|
||||
"deleted_at" => null,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
|
||||
@ -11,6 +11,8 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity
|
||||
"precio" => null,
|
||||
"user_created_id" => 1,
|
||||
"user_update_id" => 1,
|
||||
"deleted_at" => null,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
|
||||
@ -26,12 +26,13 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
"ajuste",
|
||||
"formula_price",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
"user_update_id",
|
||||
];
|
||||
protected $returnType = "App\Entities\Tarifas\TarifaacabadoEntity";
|
||||
|
||||
public static $labelField = "Select a field...";
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"ajuste" => [
|
||||
|
||||
@ -21,6 +21,8 @@ class TarifamanipuladoModel extends \App\Models\GoBaseModel
|
||||
"ajuste",
|
||||
"ajuste_total_pedido",
|
||||
"formula_price",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
"user_update_id",
|
||||
];
|
||||
@ -28,10 +30,9 @@ class TarifamanipuladoModel extends \App\Models\GoBaseModel
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
@ -68,14 +69,6 @@ class TarifamanipuladoModel extends \App\Models\GoBaseModel
|
||||
"label" => "Manipuladoes.tiradaMin",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"user_created_id" => [
|
||||
"label" => "Manipuladoes.userCreatedId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"user_update_id" => [
|
||||
"label" => "Manipuladoes.userUpdateId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
@ -110,14 +103,6 @@ class TarifamanipuladoModel extends \App\Models\GoBaseModel
|
||||
"tirada_min" => [
|
||||
"integer" => "Manipuladoes.validation.tirada_min.integer",
|
||||
"required" => "Manipuladoes.validation.tirada_min.required",
|
||||
],
|
||||
"user_created_id" => [
|
||||
"integer" => "Manipuladoes.validation.user_created_id.integer",
|
||||
"required" => "Manipuladoes.validation.user_created_id.required",
|
||||
],
|
||||
"user_update_id" => [
|
||||
"integer" => "Manipuladoes.validation.user_update_id.integer",
|
||||
"required" => "Manipuladoes.validation.user_update_id.required",
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -12,15 +12,21 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $allowedFields = ["nombre", "precio", "user_created_id", "user_update_id"];
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"precio",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
"user_update_id"];
|
||||
protected $returnType = "App\Entities\Tarifas\TarifapreimpresionEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
@ -32,15 +38,7 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel
|
||||
"precio" => [
|
||||
"label" => "Tarifapreimpresion.precio",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"user_created_id" => [
|
||||
"label" => "Tarifapreimpresion.userCreatedId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"user_update_id" => [
|
||||
"label" => "Tarifapreimpresion.userUpdateId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
@ -52,13 +50,5 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel
|
||||
"decimal" => "Tarifapreimpresion.validation.precio.decimal",
|
||||
"required" => "Tarifapreimpresion.validation.precio.required",
|
||||
],
|
||||
"user_created_id" => [
|
||||
"integer" => "Tarifapreimpresion.validation.user_created_id.integer",
|
||||
"required" => "Tarifapreimpresion.validation.user_created_id.required",
|
||||
],
|
||||
"user_update_id" => [
|
||||
"integer" => "Tarifapreimpresion.validation.user_update_id.integer",
|
||||
"required" => "Tarifapreimpresion.validation.user_update_id.required",
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -14,13 +14,6 @@
|
||||
<input type="number" id="tiradaMin" name="tirada_min" required placeholder="0" maxLength="11" class="form-control" value="<?=old('tirada_min', $tarifaacabado_->tirada_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioMin" class="form-label">
|
||||
<?=lang('Tarifaacabado.precioMin') ?>*
|
||||
</label>
|
||||
<input type="number" id="precioMin" name="precio_min" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?=old('precio_min', $tarifaacabado_->precio_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="tiradaMax" class="form-label">
|
||||
<?=lang('Tarifaacabado.tiradaMax') ?>*
|
||||
@ -28,6 +21,13 @@
|
||||
<input type="number" id="tiradaMax" name="tirada_max" required placeholder="0" maxLength="11" class="form-control" value="<?=old('tirada_max', $tarifaacabado_->tirada_max) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioMin" class="form-label">
|
||||
<?=lang('Tarifaacabado.precioMin') ?>*
|
||||
</label>
|
||||
<input type="number" id="precioMin" name="precio_min" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?=old('precio_min', $tarifaacabado_->precio_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioMax" class="form-label">
|
||||
<?=lang('Tarifaacabado.precioMax') ?>*
|
||||
|
||||
@ -16,71 +16,79 @@
|
||||
<table id="tableOfTarifasacabado" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php /*
|
||||
<th><?= lang('Tarifaacabado.id') ?></th>
|
||||
*/ ?>
|
||||
|
||||
<th><?= lang('Tarifaacabado.nombre') ?></th>
|
||||
<th><?= lang('Tarifaacabado.tiradaMin') ?></th>
|
||||
<th><?= lang('Tarifaacabado.precioMin') ?></th>
|
||||
<th><?= lang('Tarifaacabado.tiradaMax') ?></th>
|
||||
<th><?= lang('Tarifaacabado.precioMin') ?></th>
|
||||
<th><?= lang('Tarifaacabado.precioMax') ?></th>
|
||||
<th><?= lang('Tarifaacabado.ajuste') ?></th>
|
||||
<th><?= lang('Tarifaacabado.formulaPrice') ?></th>
|
||||
|
||||
<?php /*
|
||||
<th><?= lang('Tarifaacabado.userCreatedId') ?></th>
|
||||
<th><?= lang('Tarifaacabado.userUpdateId') ?></th>
|
||||
<th><?= lang('Tarifaacabado.deletedAt') ?></th>
|
||||
<th><?= lang('Tarifaacabado.createdAt') ?></th>
|
||||
<th><?= lang('Tarifaacabado.updatedAt') ?></th>
|
||||
*/ ?>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($tarifaacabadoList as $item ) : ?>
|
||||
<?php if(empty($item->deleted_at)): ?>
|
||||
<tr>
|
||||
<td class="align-middle text-center">
|
||||
<?=$item->id ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->tirada_min) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_min) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->tirada_max) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_max) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->ajuste) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->formula_price) || strlen($item->formula_price) < 51 ? esc($item->formula_price) : character_limiter(esc($item->formula_price), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_created_id) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_update_id) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->deleted_at) ? '' : date('d/m/Y H:m:s', strtotime($item->deleted_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-center text-nowrap">
|
||||
<?=anchor(route_to('editTarifaacabado', $item->id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?>
|
||||
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteTarifaacabado', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<?php /*
|
||||
<td class="align-middle text-center">
|
||||
<?=$item->id ?>
|
||||
</td>
|
||||
*/ ?>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->tirada_min) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->tirada_max) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_min) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_max) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->ajuste) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->formula_price) || strlen($item->formula_price) < 51 ? esc($item->formula_price) : character_limiter(esc($item->formula_price), 50) ?>
|
||||
</td>
|
||||
<?php /*
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_created_id) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_update_id) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->deleted_at) ? '' : date('d/m/Y H:m:s', strtotime($item->deleted_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at)) ?>
|
||||
</td>
|
||||
*/ ?>
|
||||
<td class="align-middle text-center text-nowrap">
|
||||
<?=anchor(route_to('editTarifaacabado', $item->id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?>
|
||||
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteTarifaacabado', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -136,7 +144,7 @@
|
||||
"scrollX": true,
|
||||
"stateSave": true,
|
||||
"language": {
|
||||
url: "/assets/dt/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
|
||||
@ -14,13 +14,6 @@
|
||||
<input type="number" id="tiradaMin" name="tirada_min" required placeholder="0" maxLength="11" class="form-control" value="<?=old('tirada_min', $tarifamanipuladoEntity->tirada_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioMin" class="form-label">
|
||||
<?=lang('Tarifamanipulado.precioMin') ?>*
|
||||
</label>
|
||||
<input type="number" id="precioMin" name="precio_min" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?=old('precio_min', $tarifamanipuladoEntity->precio_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="tiradaMax" class="form-label">
|
||||
<?=lang('Tarifamanipulado.tiradaMax') ?>*
|
||||
@ -28,6 +21,13 @@
|
||||
<input type="number" id="tiradaMax" name="tirada_max" required placeholder="0" maxLength="11" class="form-control" value="<?=old('tirada_max', $tarifamanipuladoEntity->tirada_max) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioMin" class="form-label">
|
||||
<?=lang('Tarifamanipulado.precioMin') ?>*
|
||||
</label>
|
||||
<input type="number" id="precioMin" name="precio_min" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?=old('precio_min', $tarifamanipuladoEntity->precio_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioMax" class="form-label">
|
||||
<?=lang('Tarifamanipulado.precioMax') ?>*
|
||||
@ -57,7 +57,7 @@
|
||||
</label>
|
||||
<textarea rows="3" id="formulaPrice" name="formula_price" required style="height: 10em;" class="form-control"><?=old('formula_price', $tarifamanipuladoEntity->formula_price) ?></textarea>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<?php /*
|
||||
<div class="mb-3">
|
||||
<label for="userCreatedId" class="form-label">
|
||||
<?=lang('Tarifamanipulado.userCreatedId') ?>*
|
||||
@ -71,7 +71,7 @@
|
||||
</label>
|
||||
<input type="number" id="userUpdateId" name="user_update_id" required placeholder="1" maxLength="10" class="form-control" value="<?=old('user_update_id', $tarifamanipuladoEntity->user_update_id) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
*/ ?>
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -15,28 +15,34 @@
|
||||
<table id="tableOfTarifasmanipulado" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php /*
|
||||
<th><?= lang('Tarifamanipulado.id') ?></th>
|
||||
*/ ?>
|
||||
<th><?= lang('Tarifamanipulado.nombre') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.tiradaMin') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.precioMin') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.tiradaMax') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.precioMin') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.precioMax') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.ajuste') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.ajusteTotalPedido') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.formulaPrice') ?></th>
|
||||
<?php /*
|
||||
<th><?= lang('Tarifamanipulado.userCreatedId') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.userUpdateId') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.createdAt') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.updatedAt') ?></th>
|
||||
*/ ?>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($tarifamanipuladoList as $item ) : ?>
|
||||
<tr>
|
||||
<?php /*
|
||||
<td class="align-middle text-center">
|
||||
<?=$item->id ?>
|
||||
</td>
|
||||
*/ ?>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?>
|
||||
</td>
|
||||
@ -44,10 +50,10 @@
|
||||
<?= esc($item->tirada_min) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_min) ?>
|
||||
<?= esc($item->tirada_max) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->tirada_max) ?>
|
||||
<?= esc($item->precio_min) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_max) ?>
|
||||
@ -61,6 +67,7 @@
|
||||
<td class="align-middle">
|
||||
<?= empty($item->formula_price) || strlen($item->formula_price) < 51 ? esc($item->formula_price) : character_limiter(esc($item->formula_price), 50) ?>
|
||||
</td>
|
||||
<?php /*
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_created_id) ?>
|
||||
</td>
|
||||
@ -73,6 +80,7 @@
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at)) ?>
|
||||
</td>
|
||||
*/ ?>
|
||||
<td class="align-middle text-center text-nowrap">
|
||||
<?=anchor(route_to('editTarifamanipulado', $item->id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?>
|
||||
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteTarifamanipulado', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
|
||||
@ -136,7 +144,7 @@
|
||||
"scrollX": true,
|
||||
"stateSave": true,
|
||||
"language": {
|
||||
url: "/assets/dt/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
</label>
|
||||
<input type="number" id="precio" name="precio" required maxLength="31" step="0.01" class="form-control" value="<?=old('precio', $tarifapreimpresionEntity->precio) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<?php /*
|
||||
<div class="mb-3">
|
||||
<label for="userCreatedId" class="form-label">
|
||||
<?=lang('Tarifapreimpresion.userCreatedId') ?>*
|
||||
@ -27,7 +27,7 @@
|
||||
</label>
|
||||
<input type="number" id="userUpdateId" name="user_update_id" required placeholder="1" maxLength="10" class="form-control" value="<?=old('user_update_id', $tarifapreimpresionEntity->user_update_id) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
*/ ?>
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -15,28 +15,35 @@
|
||||
<table id="tableOfTarifaspreimpresion" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php /*
|
||||
<th><?= lang('Tarifapreimpresion.id') ?></th>
|
||||
*/ ?>
|
||||
<th><?= lang('Tarifapreimpresion.nombre') ?></th>
|
||||
<th><?= lang('Tarifapreimpresion.precio') ?></th>
|
||||
<?php /*
|
||||
<th><?= lang('Tarifapreimpresion.userCreatedId') ?></th>
|
||||
<th><?= lang('Tarifapreimpresion.userUpdateId') ?></th>
|
||||
<th><?= lang('Tarifapreimpresion.createdAt') ?></th>
|
||||
<th><?= lang('Tarifapreimpresion.updatedAt') ?></th>
|
||||
*/ ?>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($tarifapreimpresionList as $item ) : ?>
|
||||
<tr>
|
||||
<?php /*
|
||||
<td class="align-middle text-center">
|
||||
<?=$item->id ?>
|
||||
</td>
|
||||
*/ ?>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio) ?>
|
||||
</td>
|
||||
<?php /*
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_created_id) ?>
|
||||
</td>
|
||||
@ -49,6 +56,7 @@
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at)) ?>
|
||||
</td>
|
||||
*/ ?>
|
||||
<td class="align-middle text-center text-nowrap">
|
||||
<?=anchor(route_to('editTarifapreimpresion', $item->id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?>
|
||||
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteTarifapreimpresion', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
|
||||
@ -111,7 +119,7 @@
|
||||
"scrollX": true,
|
||||
"stateSave": true,
|
||||
"language": {
|
||||
url: "/assets/dt/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
|
||||
53
from mac to app.txt
Normal file
53
from mac to app.txt
Normal file
@ -0,0 +1,53 @@
|
||||
Pasos para usar ficheros del mac
|
||||
1.- Copiar controlador, modelo, vistas y entidad
|
||||
2.- Copiar los ficheros de idioma. Le pone nombre raro (por ejemplo: Manipuladoes.php en lugar de Tarifamanipulado.php). Buscar y reemplazar en todos los ficheros. En este ejemplo: lang('Manipuladoes -> lang('Tarifamanipulado)
|
||||
3.- Editar los idiomas
|
||||
4.- En las vistas (formulario y lista) cambiar la segunda linea
|
||||
Esto: <?= $this->extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?>
|
||||
por esto: <?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
5.- En las vistas cambiar Themes por themes
|
||||
6.- Quitar de la tabla la primera columna para que no se repitan los botones. Es decir:
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
|
||||
<td class="align-middle text-center text-nowrap">
|
||||
<?=anchor(route_to('editTarifamanipulado', $item->id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?>
|
||||
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteTarifamanipulado', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
|
||||
</td>
|
||||
|
||||
7.- Modificar las fechas de esto: date('mm/dd/YYYY H:i' a esto date('d/m/Y H:m:s'
|
||||
8.- Cambiar los botones de exportar de sitio: "dom": 'lfrtipB' por "dom": 'lfBrtip'
|
||||
9.- Poner el botón de añadir debajo del h3 del card header en lugar del footer
|
||||
10.- Copiar las nuevas rutas
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Pasos para añadir el soft delete a una tabla
|
||||
1.- En la bbdd añadir la columna is_deleted (TINYINT, 4 bits, sin signo, valor predeterminado '0')
|
||||
2.- En la bbdd añadir la columna deleted_at (TIMESTAMP, permitir NULL, valor predeterminado NULL)
|
||||
3.- En la entidad añadir a los atributos:
|
||||
"deleted_at" => null,
|
||||
"is_deleted" => 0,
|
||||
4.- En el modelo. Añadir en allowedFields:
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
También añadir la variable protected $deletedField = 'deleted_at';
|
||||
5.- En el controlador:
|
||||
En el index añadir debajo de $this->view..
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
En el edit: justo al principio
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
debajo de $sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
}
|
||||
Reference in New Issue
Block a user