mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en selector de pedidos
This commit is contained in:
@ -68,4 +68,30 @@ class LogisticaController extends BaseController
|
||||
return view(static::$viewPath . 'viewLogisticaSelectEnvios', $viewData);
|
||||
}
|
||||
|
||||
public function searchPedidoOrISBN($search = ""){
|
||||
|
||||
$modelPedido = model('App\Models\Pedidos\PedidoModel');
|
||||
|
||||
$search = trim($search);
|
||||
$searchClean = str_replace('-', '', $search);
|
||||
$modelPedido = model('App\Models\Pedidos\PedidoModel');
|
||||
|
||||
// Builder con joins
|
||||
$builder = $modelPedido->builder();
|
||||
$builder->select('pedidos.*');
|
||||
$builder->join('pedidos_linea', 'pedidos_linea.pedido_id = pedidos.id', 'left');
|
||||
$builder->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left');
|
||||
|
||||
// Agrupar condiciones: por ID exacto o por ISBN sin guiones
|
||||
$builder->groupStart()
|
||||
->where('pedidos.id', $search)
|
||||
->orWhere("REPLACE(presupuestos.isbn, '-', '')", $searchClean)
|
||||
->groupEnd();
|
||||
|
||||
$result = $builder->get()->getResult();
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $result,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateEnviosTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField([
|
||||
'id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'auto_increment' => true,
|
||||
],
|
||||
'finalizado' => [
|
||||
'type' => 'TINYINT',
|
||||
'constraint' => 1,
|
||||
'default' => 0,
|
||||
],
|
||||
'codigo_seguimiento' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 100,
|
||||
'null' => true,
|
||||
],
|
||||
'proveedor_id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'null' => true,
|
||||
],
|
||||
'comentarios' => [
|
||||
'type' => 'TEXT',
|
||||
'null' => true,
|
||||
],
|
||||
'att' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 100,
|
||||
'null' => true,
|
||||
],
|
||||
'direccion' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 300,
|
||||
'null' => true,
|
||||
],
|
||||
'ciudad' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 100,
|
||||
'null' => true,
|
||||
],
|
||||
'cp' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 10,
|
||||
'null' => true,
|
||||
],
|
||||
'email' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 150,
|
||||
'null' => true,
|
||||
],
|
||||
'telefono' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 60,
|
||||
'null' => true,
|
||||
],
|
||||
'pais_id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'null' => true,
|
||||
],
|
||||
'mostrar_precios' => [
|
||||
'type' => 'TINYINT',
|
||||
'constraint' => 1,
|
||||
'default' => 0,
|
||||
],
|
||||
'mostrar_iva' => [
|
||||
'type' => 'TINYINT',
|
||||
'constraint' => 1,
|
||||
'default' => 0,
|
||||
],
|
||||
'created_at' => [
|
||||
'type' => 'TIMESTAMP',
|
||||
'null' => false,
|
||||
'default' => '0000-00-00 00:00:00',
|
||||
],
|
||||
'updated_at' => [
|
||||
'type' => 'TIMESTAMP',
|
||||
'null' => false,
|
||||
'default' => '0000-00-00 00:00:00',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->forge->addKey('id', true);
|
||||
$this->forge->addForeignKey('proveedor_id', 'lg_proveedores', 'id', 'SET NULL', 'SET NULL');
|
||||
$this->forge->addForeignKey('pais_id', 'lg_paises', 'id', 'SET NULL', 'SET NULL');
|
||||
|
||||
$this->forge->createTable('envios');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable('envios');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user