maquinista view-basic

This commit is contained in:
amazuecos
2025-04-25 07:40:20 +02:00
parent 288a3f02eb
commit 52b3b1ae4d
28 changed files with 911 additions and 132 deletions

View File

@ -1,30 +0,0 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class AddMaquinistaFieldsOrdenTrabajoTareas extends Migration
{
protected array $COLUMNS = [
"estado" => [
"type" => "ENUM",
"constraint" => ["P","I","D","F","E"],
"default" => "P",
"comment" => "(P)ENDING,(I)NIT,(D)ELAY,(F)INISHED,(E)RROR"
]
];
public function up()
{
$this->forge->addColumn("orden_trabajo_tareas", $this->COLUMNS);
}
public function down()
{
$this->forge->dropColumn("orden_trabajo_tareas",array_keys($this->COLUMNS));
}
}

View File

@ -2,7 +2,10 @@
namespace App\Database\Migrations;
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
use CodeIgniter\I18n\Time;
class AddTableOrdenTrabajoTareaProgressDates extends Migration
{
@ -13,36 +16,67 @@ class AddTableOrdenTrabajoTareaProgressDates extends Migration
"unsigned" => true,
"auto_increment" => true,
],
"init_at" => [
"type" => "INT",
"unsigned" => "INT",
"comment" => "Timestamp task init"
],
"end_at" => [
"type" => "INT",
"unsigned" => "INT",
"comment" => "Timestamp task finish"
],
"init_user_id" => [
"ot_tarea_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 11
],
"end_user_id" => [
"action_at" => [
"type" => "DATETIME",
"comment" => "Datetime task init"
],
"action_user_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 11
"constraint" => 11,
"null" => true,
],
"estado" => [
"type" => "ENUM",
"constraint" => ["P", "I", "S", "D", "F", "E"],
"default" => "P",
"comment" => "(P)ENDING,(I)NIT,(S)TOPPED,(D)ELAY,(F)INISHED,(E)RROR"
]
];
public function up()
{
$this->forge->addField($this->COLUMNS);
$currenttime = new RawSql('CURRENT_TIMESTAMP');
$this->forge->addField([
'created_at' => [
'type' => 'TIMESTAMP',
'default' => $currenttime,
],
'updated_at' => [
'type' => 'TIMESTAMP',
'null' => true,
],
'deleted_at' => [
'type' => 'TIMESTAMP',
'null' => true,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addForeignKey('ot_tarea_id', 'orden_trabajo_tareas', 'id');
$this->forge->createTable("orden_trabajo_tarea_progress_dates");
$m = model(OrdenTrabajoTarea::class);
$tareas = $m->findAll();
try {
foreach ($tareas as $key => $tarea) {
$this->db->table('orden_trabajo_tarea_progress_dates')->insert([
"ot_tarea_id" => $tarea->id,
"action_at" => $tarea->created_at->format('Y-m-d H:i:s'),
"action_user_id" => $tarea?->orden_trabajo()?->user_created_id ?? null,
]);
}
} catch (\Throwable $th) {
echo $th->getMessage();
}
}
public function down()
{
$this->forge->dropColumn("orden_trabajo_tareas",array_keys($this->COLUMNS));
$this->forge->dropTable("orden_trabajo_tarea_progress_dates");
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace App\Database\Migrations;
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
use CodeIgniter\I18n\Time;
class AddClickColumnOrdenTrabajoTarea extends Migration
{
protected array $COLUMNS = [
"click_init" => [
"type" => "INT",
"unsigned" => true,
"default" => 0,
"comment" => "Click iniciales de una tarea de impresion"
],
"click_end" => [
"type" => "INT",
"unsigned" => true,
"default" => 0,
"comment" => "Click finales de una tarea de impresion"
],
];
public function up()
{
$this->forge->addColumn('orden_trabajo_tareas', $this->COLUMNS);
}
public function down()
{
$this->forge->dropColumn('orden_trabajo_tareas', array_keys($this->COLUMNS));
}
}