87 lines
3.1 KiB
PHP
87 lines
3.1 KiB
PHP
<?php namespace App\Controllers;
|
|
|
|
use App\Libraries\Crud;
|
|
|
|
|
|
class Articoli extends CRUDController {
|
|
|
|
// Tab: Articoli = ['arIDarticolo', 'arCode', 'arIDcategoria', 'arIDplace', 'arNome', 'arDescrizione', 'arDataAcquisto', 'arEuro', 'arCreatedAt', 'arUpdatedAt', 'arDeletedAt'];
|
|
|
|
protected $crud;
|
|
|
|
function __construct() {
|
|
|
|
$params = [
|
|
'table' => 'Articoli',
|
|
'dev' => false,
|
|
'fields' => $this->field_options(),
|
|
'form_title_add' => 'Add Articolo',
|
|
'form_title_update' => 'Edit Articolo',
|
|
'form_submit' => 'Add',
|
|
'table_title' => 'Pagina per la tabella Articoli',
|
|
'form_submit_update' => 'Update',
|
|
'base' => '',
|
|
'UpdatedAt' => 'arUpdatedAt',
|
|
'DeletedAt' => 'arDeletedAt',
|
|
];
|
|
|
|
$this->crud = new Crud($params, service('request'));
|
|
}// __construct
|
|
|
|
|
|
protected function field_options() {
|
|
|
|
$fields = [];
|
|
$fields['arIDarticolo'] = ['label' => 'ID', 'helper' => 'Identificativo univoco del record nel database'];
|
|
$fields['arCode'] = ['label' => 'Codice', 'helper' => 'Codice identificativo dell\'articolo (5 caratteri)', 'required' => true, 'unique' => [true, 'arCode']];
|
|
$fields['arIDcategoria'] = [
|
|
'label' => 'Categoria',
|
|
'required' => true,
|
|
'type' => 'dropdown',
|
|
'relation' => [
|
|
'table'=> 'Categorie',
|
|
'primary_key' => 'caIDcategoria',
|
|
'display' => ['caCode', 'caNome'],
|
|
'order_by' => 'caCode',
|
|
'order' => 'ASC'
|
|
]
|
|
];
|
|
$fields['arIDplace'] = [
|
|
'label' => 'Posizione',
|
|
'required' => true,
|
|
'type' => 'dropdown',
|
|
'relation' => [
|
|
'table'=> 'Posizioni',
|
|
'primary_key' => 'psIDplace',
|
|
'display' => ['psCode', 'psDescrizione'],
|
|
'order_by' => 'psCode',
|
|
'order' => 'ASC'
|
|
]
|
|
];
|
|
$fields['arNome'] = ['label' => 'Nome', 'helper' => 'Nome dell\'articolo (max 32 caratteri)', 'required' => true];
|
|
$fields['arDescrizione'] = ['label' => 'Descrizione', 'helper' => 'Descrizione esaustiva dell\'articolo', 'required' => true];
|
|
$fields['arDataAcquisto'] = ['label' => 'Data Acquisto', 'helper' => 'Data di acquisto dell\'articolo', 'required' => true, 'type' => 'date'];
|
|
$fields['arEuro'] = ['label' => 'Valore', 'helper' => 'Valore stimato dell\'articolo in €', 'required' => true];
|
|
$fields['arCreatedAt'] = ['label' => 'Created At', 'helper' => 'Data di creazione del record relativo nel database', 'only_edit'=> true];
|
|
$fields['arUpdatedAt'] = ['label' => 'Updated At', 'helper' => 'Timestamp dell\'ultimo aggiornamento del record nel database', 'type' => 'unset'];
|
|
$fields['arDeletedAt'] = ['label' => 'Deleted At', 'helper' => 'Data di cancellazione del record relativo nel database', 'type' => 'unset'];
|
|
|
|
return $fields;
|
|
}// field_options
|
|
|
|
|
|
public function index() { return $this->CRUD_view(['arIDarticolo', 'arCode', 'arIDcategoria', 'arIDplace', 'arNome', 'arDescrizione', 'arDataAcquisto', 'arEuro', 'arCreatedAt', 'arUpdatedAt', 'arDeletedAt']); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
// Auto CRUD terminato
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
}
|