Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
276 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace FacturaScripts\Core\Model; | ||
|
||
class SettingsModel extends Base\ModelClass | ||
{ | ||
use Base\ModelTrait; | ||
|
||
/** @var int */ | ||
public $id; | ||
|
||
/** @var string */ | ||
public $classnamemodel; | ||
|
||
/** @var string */ | ||
public $idmodel; | ||
|
||
/** @var string */ | ||
public $idempresa; | ||
|
||
/** @var array */ | ||
public $settings; | ||
|
||
public static function primaryColumn(): string | ||
{ | ||
return 'id'; | ||
} | ||
|
||
public static function tableName(): string | ||
{ | ||
return 'settings_model'; | ||
} | ||
|
||
public function loadFromData(array $data = [], array $exclude = []): void | ||
{ | ||
parent::loadFromData($data, ['settings', 'action']); | ||
$this->settings = isset($data['settings']) ? json_decode($data['settings'], true) : []; | ||
} | ||
|
||
protected function saveUpdate(array $values = []): bool | ||
{ | ||
// agregamos a la propiedad settings las propiedades que hay en el modelo | ||
// y que nos vienen de la request/inputs | ||
foreach ($this->settings as $key => $value) { | ||
$this->settings[$key] = empty($this->{$key}) ? null : $this->{$key}; | ||
} | ||
|
||
if (is_array($this->settings)) { | ||
$this->settings = json_encode($this->settings); | ||
} | ||
|
||
return parent::saveUpdate($values); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<table> | ||
<column> | ||
<name>id</name> | ||
<type>serial</type> | ||
<null>NO</null> | ||
</column> | ||
<column> | ||
<name>classnamemodel</name> | ||
<type>text</type> | ||
</column> | ||
<column> | ||
<name>idmodel</name> | ||
<type>integer</type> | ||
</column> | ||
<column> | ||
<name>idempresa</name> | ||
<type>integer</type> | ||
</column> | ||
<column> | ||
<name>settings</name> | ||
<type>text</type> | ||
</column> | ||
<constraint> | ||
<name>settings_model_pkey</name> | ||
<type>PRIMARY KEY (id)</type> | ||
</constraint> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<view> | ||
<columns> | ||
<group name="default" valign="bottom" numcolumns="12"> | ||
<column name="name" display="none" order="0"> | ||
<widget type="text" fieldname="name" readonly="true" required="true"/> | ||
</column> | ||
<column name="company" order="110"> | ||
<widget type="select" fieldname="idempresa" required="true"> | ||
<values source="empresas" fieldcode="idempresa" fieldtitle="nombrecorto"></values> | ||
</widget> | ||
</column> | ||
<column name="warehouse" order="120"> | ||
<widget type="select" fieldname="codalmacen" onclick="EditAlmacen" required="true"> | ||
<values source="almacenes" fieldcode="codalmacen" fieldtitle="nombre"/> | ||
</widget> | ||
</column> | ||
<column name="serie" numcolumns="3" order="130"> | ||
<widget type="select" fieldname="codserie" onclick="EditSerie"> | ||
<values source="series" fieldcode="codserie" fieldtitle="descripcion"/> | ||
</widget> | ||
</column> | ||
<column name="currency" numcolumns="3" order="140"> | ||
<widget type="select" fieldname="coddivisa" onclick="EditDivisa" icon="fas fa-money-bill-alt"> | ||
<values source="divisas" fieldcode="coddivisa" fieldtitle="descripcion"/> | ||
</widget> | ||
</column> | ||
<column name="payment-method" numcolumns="3" order="150"> | ||
<widget type="select" fieldname="codpago" onclick="EditFormaPago"> | ||
<values source="formaspago" fieldcode="codpago" fieldtitle="descripcion"/> | ||
</widget> | ||
</column> | ||
</group> | ||
</columns> | ||
</view> |