mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Cambio de isk a iskn, añadido comando generador de iskn en libros del catalogo que no lo tengan
This commit is contained in:
@ -14,6 +14,7 @@ class CatalogoLibroImportar extends BaseCommand
|
||||
public function run(array $params)
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
$totalImportados = 0;
|
||||
|
||||
// Al inicio del método run()
|
||||
$papeles = $db->table('lg_papel_generico')
|
||||
@ -55,8 +56,9 @@ class CatalogoLibroImportar extends BaseCommand
|
||||
$customerId = (int) $params[0];
|
||||
CLI::write("Iniciando importación para customer_id = $customerId ...", 'yellow');
|
||||
|
||||
$libros = $db->table('catalogo_libro')
|
||||
$libros = $db->table('catalogo_libro_antiguo_erp')
|
||||
->where('customer_id', $customerId)
|
||||
->where('deleted_at', null)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
@ -135,19 +137,22 @@ class CatalogoLibroImportar extends BaseCommand
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'deleted_at' => $libro['deleted_at'],
|
||||
'isk' => null,
|
||||
'iskn' => null,
|
||||
];
|
||||
|
||||
$exists = $db->table('catalogo_libros_test')
|
||||
$exists = $db->table('catalogo_libros')
|
||||
->where('id', $libro['id'])
|
||||
->countAllResults();
|
||||
|
||||
if ($exists == 0) {
|
||||
$db->table('catalogo_libros_test')->insert($nuevoLibro);
|
||||
$db->table('catalogo_libros')->insert($nuevoLibro);
|
||||
$totalImportados++;
|
||||
}else{
|
||||
CLI::write("El libro con ISBN " . $libro['isbn'] . " ya existe para el cliente con id " . $customerId . ".", 'yellow');
|
||||
}
|
||||
}
|
||||
|
||||
CLI::write("Importación finalizada. Se insertaron " . count($libros) . " registros.", 'green');
|
||||
CLI::write("Importación finalizada. Se insertaron " . $totalImportados . " registros.", 'green');
|
||||
}
|
||||
|
||||
private function mapTipoImpresion($tipo)
|
||||
@ -160,7 +165,7 @@ class CatalogoLibroImportar extends BaseCommand
|
||||
case 'colorfoto':
|
||||
return 'colorhq';
|
||||
case 'bicolor':
|
||||
return 'negrohq';
|
||||
return 'color';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user