feat:errores presupuesto

This commit is contained in:
amazuecos
2024-10-19 07:29:47 +00:00
parent f1df4559f7
commit f9b12cbcdd
4 changed files with 36 additions and 22 deletions

View File

@ -23,8 +23,6 @@ class ConfigErrores extends BaseResourceController
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{ {
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
$this->errorPresupuestoModel = model(ErrorPresupuestoModel::class); $this->errorPresupuestoModel = model(ErrorPresupuestoModel::class);
} }
@ -32,11 +30,13 @@ class ConfigErrores extends BaseResourceController
public function index() public function index()
{ {
return view(static::$viewPath . $this->indexRoute, $this->viewData); return view(static::$viewPath . $this->indexRoute, $this->viewData);
} }
public function viewForm(int $error_presupuesto_id) public function viewForm(int $error_presupuesto_id)
{ {
$this->errorPresupuestoModel->update($error_presupuesto_id, [
"last_user_id" => auth()->user()->id
]);
return view(static::$viewPath . 'viewErrorPresupuestoForm', ["error_presupuesto_id" => $error_presupuesto_id]); return view(static::$viewPath . 'viewErrorPresupuestoForm', ["error_presupuesto_id" => $error_presupuesto_id]);
} }
public function store() public function store()
@ -60,10 +60,9 @@ class ConfigErrores extends BaseResourceController
public function datatable() public function datatable()
{ {
$query = $this->errorPresupuestoModel->getQueryDatatable(); $query = $this->errorPresupuestoModel->getQueryDatatable();
return DataTable::of($query) return DataTable::of($query)
->add("action", fn($q) => $q->id) ->add("action", fn($q) => $q->id)
->toJson(true); ->toJson(true);
} }
} }

View File

@ -62,7 +62,7 @@ class ErrorPresupuesto extends Model
"presupuesto_id" => $presupuesto_id, "presupuesto_id" => $presupuesto_id,
"presupuesto_user_id" => $presupuesto_user_id, "presupuesto_user_id" => $presupuesto_user_id,
"error" => $error, "error" => $error,
"datos" => json_encode($datos) "datos_presupuesto" => json_encode($datos)
]); ]);
} }
public function updateComment(int $error_presupuesto_id, string $comment): bool public function updateComment(int $error_presupuesto_id, string $comment): bool
@ -81,7 +81,8 @@ class ErrorPresupuesto extends Model
"CONCAT(t1.first_name,' ',t1.last_name) as presupuestoUser", "CONCAT(t1.first_name,' ',t1.last_name) as presupuestoUser",
"CONCAT(t2.first_name,' ',t2.last_name) as lastUser", "CONCAT(t2.first_name,' ',t2.last_name) as lastUser",
"presupuesto_errores.created_at", "presupuesto_errores.created_at",
"presupuesto_errores.datos", "presupuesto_errores.datos_presupuesto",
"presupuesto_errores.error",
"presupuesto_errores.visto", "presupuesto_errores.visto",
"presupuesto_errores.comment", "presupuesto_errores.comment",

View File

@ -25,7 +25,7 @@
</div> </div>
<div class="col-md-2 overflow-hidden w-20"> <div class="col-md-2 overflow-hidden w-20">
<label class="switch switch-square switch-lg"> <label class="switch switch-square switch-lg">
<input type="checkbox" class="switch-input" disabled> <input type="checkbox" class="switch-input" id="error-presupuesto-visto" name="visto" disabled>
<span class="switch-toggle-slider"> <span class="switch-toggle-slider">
<span class="switch-on"> <span class="switch-on">
<i class="ti ti-eye"></i> <i class="ti ti-eye"></i>
@ -44,15 +44,22 @@
<textarea rows="10" class="form-control" id="datos-presupuesto" <textarea rows="10" class="form-control" id="datos-presupuesto"
placeholder="Datos presupuesto" disabled></textarea> placeholder="Datos presupuesto" disabled></textarea>
</div> </div>
<div class="col-md-6 mb-3 overflow-hidden"> <div class="col-md-6 mb-3 overflow-hidden">
<label for="error-presupuesto">Error</label>
<textarea rows="10" class="form-control" id="error-presupuesto"
placeholder="Error" disabled></textarea>
</div>
<div class="col-md-12 mb-3 overflow-hidden">
<label for="comments-presupuesto">Comentarios</label> <label for="comments-presupuesto">Comentarios</label>
<div class="input-group mb-3"> <textarea rows="10" class="form-control" id="comments-presupuesto"
<textarea rows="10" class="form-control" id="comments-presupuesto" placeholder="Comentarios"></textarea>
placeholder="Comentarios"></textarea>
<button class="btn btn-primary button-update-comment" type="button"><span </div>
class="ti ti-md ti-send" id="update-button-icon"></span></button> <div class="col-md-12">
</div> <button class="btn btn-primary button-update-comment w-100" type="button">
<span class="ti ti-sm ti-send me-1" id="update-button-icon"></span>
<span class="spinner-border me-1" role="status" aria-hidden="true" id="update-button-loader" hidden></span>
<?= lang("App.global_save") ?></button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -11,7 +11,11 @@ class ErrorPresupuestoForm {
this.inputDatos = this.item.find("#datos-presupuesto") this.inputDatos = this.item.find("#datos-presupuesto")
this.inputComments = this.item.find("#comments-presupuesto") this.inputComments = this.item.find("#comments-presupuesto")
this.errorPresupuestoId = this.item.find("#error-presupuesto-id").attr("value") this.errorPresupuestoId = this.item.find("#error-presupuesto-id").attr("value")
this.updateBtnIcon = this.item.find("#update-button-icon") this.updateBtnIcon = this.item.find(".button-update-comment")
this.checkVisto = this.item.find("#error-presupuesto-visto")
this.loader = this.item.find("#update-button-loader")
this.btnIcon = this.item.find("#update-button-icon")
} }
init() { init() {
this.item.on("click",".button-update-comment",this.handlePostErrorPresupuesto.bind(this)) this.item.on("click",".button-update-comment",this.handlePostErrorPresupuesto.bind(this))
@ -32,10 +36,15 @@ class ErrorPresupuestoForm {
this.inputPresupuestoUserId.val(data.data.presupuestoUser) this.inputPresupuestoUserId.val(data.data.presupuestoUser)
this.inputDatos.val(data.data.datos) this.inputDatos.val(data.data.datos)
this.inputComments.val(data.data.comment) this.inputComments.val(data.data.comment)
this.updateBtnIcon.removeClass() this.updateBtnIcon.prop("disabled",false)
this.updateBtnIcon.addClass("ti ti-md ti-send") this.checkVisto.prop("checked",parseInt(data.data.visto) == 1 ? true : false)
this.setLoader(false)
} }
setLoader(state = true){
this.loader.prop("hidden",!state)
this.btnIcon.prop("hidden",state)
}
handleGetErrorPresupuestoError(){} handleGetErrorPresupuestoError(){}
handlePostErrorPresupuesto() handlePostErrorPresupuesto()
{ {
@ -43,8 +52,8 @@ class ErrorPresupuestoForm {
{ {
"comments" : this.inputComments.val() "comments" : this.inputComments.val()
} }
this.updateBtnIcon.removeClass() this.updateBtnIcon.prop("disabled",true)
this.updateBtnIcon.addClass("spinner-border spinner-border-lg text-secondary") this.setLoader()
const ajax = new Ajax( const ajax = new Ajax(
`/configuracion/errores-presupuesto/edit/${this.errorPresupuestoId}`, `/configuracion/errores-presupuesto/edit/${this.errorPresupuestoId}`,
data, data,
@ -55,8 +64,6 @@ class ErrorPresupuestoForm {
ajax.post() ajax.post()
} }
handlePostErrorPresupuestoSuccess(){ handlePostErrorPresupuestoSuccess(){
this.updateBtnIcon.removeClass()
this.updateBtnIcon.addClass("ti ti-md ti-check")
this.handleGetErrorPresupuesto() this.handleGetErrorPresupuesto()
} }