Xinon mobile/improve

This commit is contained in:
Luca Haid
2026-01-17 12:48:08 +00:00
parent 51c9c5ae7e
commit 1426d769d2
37 changed files with 7502 additions and 1042 deletions

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddShippingNoteNumber extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "thetool") {
$table = $this->table('WarehouseShippingNote');
$table
->addColumn('shippingNoteNumber', 'string', ['limit' => 20, 'null' => true, 'after' => 'id'])
->addIndex(['shippingNoteNumber'], ['unique' => true])
->update();
// Get all shipping notes ordered by create timestamp to assign numbers in chronological order
$rows = $this->fetchAll(
"SELECT id, YEAR(FROM_UNIXTIME(`create`)) as year
FROM WarehouseShippingNote
ORDER BY `create` ASC, id ASC"
);
// Group by year and assign sequential numbers
$yearCounters = [];
foreach ($rows as $row) {
$year = $row['year'];
if (!isset($yearCounters[$year])) {
$yearCounters[$year] = 0;
}
$yearCounters[$year]++;
$shippingNoteNumber = 'LS' . $year . '-X' . str_pad((string)$yearCounters[$year], 4, '0', STR_PAD_LEFT);
$this->execute(
"UPDATE WarehouseShippingNote SET shippingNoteNumber = '{$shippingNoteNumber}' WHERE id = {$row['id']}"
);
}
}
}
public function down(): void
{
if ($this->getEnvironment() == "thetool") {
$table = $this->table('WarehouseShippingNote');
$table->removeColumn('shippingNoteNumber')->update();
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddOrderMovementLinking extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "thetool") {
// Add columns to WarehouseOrder for linking to movements and delivery note files
$orderTable = $this->table('WarehouseOrder');
$orderTable
->addColumn('linkedMovementIds', 'text', ['null' => true, 'after' => 'note'])
->addColumn('deliveryNoteFileIds', 'text', ['null' => true, 'after' => 'linkedMovementIds'])
->update();
// Add column to WarehouseMovement for linking back to orders
$movementTable = $this->table('WarehouseMovement');
$movementTable
->addColumn('linkedOrderId', 'integer', ['null' => true, 'signed' => false, 'after' => 'note'])
->addIndex(['linkedOrderId'], ['name' => 'idx_linkedOrderId'])
->update();
}
}
public function down(): void
{
if ($this->getEnvironment() == "thetool") {
$orderTable = $this->table('WarehouseOrder');
$orderTable
->removeColumn('linkedMovementIds')
->removeColumn('deliveryNoteFileIds')
->update();
$movementTable = $this->table('WarehouseMovement');
$movementTable
->removeIndex(['linkedOrderId'])
->removeColumn('linkedOrderId')
->update();
}
}
}