mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-23 06:47:40 +01:00
Merge branch 'master' of https://github.com/devcode-it/openstamanager
This commit is contained in:
commit
5d536fa1e6
@ -10,6 +10,7 @@ return [
|
|||||||
'modules/fatture' => 'Modules\Fatture',
|
'modules/fatture' => 'Modules\Fatture',
|
||||||
'modules/ordini' => 'Modules\Ordini',
|
'modules/ordini' => 'Modules\Ordini',
|
||||||
'modules/preventivi' => 'Modules\Preventivi',
|
'modules/preventivi' => 'Modules\Preventivi',
|
||||||
|
'modules/contratti' => 'Modules\Contratti',
|
||||||
'modules/interventi' => 'Modules\Interventi',
|
'modules/interventi' => 'Modules\Interventi',
|
||||||
'plugins/exportFE' => 'Plugins\ExportFE',
|
'plugins/exportFE' => 'Plugins\ExportFE',
|
||||||
'plugins/importFE' => 'Plugins\ImportFE',
|
'plugins/importFE' => 'Plugins\ImportFE',
|
||||||
|
2
core.php
2
core.php
@ -117,7 +117,7 @@ if (App::debug()) {
|
|||||||
'message' => $exception->getMessage(),
|
'message' => $exception->getMessage(),
|
||||||
'file' => $exception->getFile(),
|
'file' => $exception->getFile(),
|
||||||
'line' => $exception->getLine(),
|
'line' => $exception->getLine(),
|
||||||
'trace' => null,
|
'trace' => $exception->getTraceAsString(),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class Anagrafica extends Model
|
|||||||
$new_numero = $rs[0]['max_numero'] + 1;
|
$new_numero = $rs[0]['max_numero'] + 1;
|
||||||
$new_numero = str_pad($new_numero, 6, '0', STR_PAD_LEFT);
|
$new_numero = str_pad($new_numero, 6, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
$database->query('INSERT INTO co_pianodeiconti3(numero, descrizione, idpianodeiconti2, can_delete, can_edit) VALUES('.prepare($new_numero).', '.prepare(post('ragione_sociale')).", (SELECT id FROM co_pianodeiconti2 WHERE descrizione='Crediti clienti e crediti diversi'), 1, 1)");
|
$database->query('INSERT INTO co_pianodeiconti3(numero, descrizione, idpianodeiconti2, can_delete, can_edit) VALUES('.prepare($new_numero).', '.prepare($anagrafica->ragione_sociale).", (SELECT id FROM co_pianodeiconti2 WHERE descrizione='Crediti clienti e crediti diversi'), 1, 1)");
|
||||||
$idconto = $database->lastInsertedID();
|
$idconto = $database->lastInsertedID();
|
||||||
|
|
||||||
// Collegamento conto
|
// Collegamento conto
|
||||||
@ -90,7 +90,7 @@ class Anagrafica extends Model
|
|||||||
$new_numero = $rs[0]['max_numero'] + 1;
|
$new_numero = $rs[0]['max_numero'] + 1;
|
||||||
$new_numero = str_pad($new_numero, 6, '0', STR_PAD_LEFT);
|
$new_numero = str_pad($new_numero, 6, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
$database->query('INSERT INTO co_pianodeiconti3(numero, descrizione, idpianodeiconti2, can_delete, can_edit) VALUES('.prepare($new_numero).', '.prepare(post('ragione_sociale')).", (SELECT id FROM co_pianodeiconti2 WHERE descrizione='Debiti fornitori e debiti diversi'), 1, 1)");
|
$database->query('INSERT INTO co_pianodeiconti3(numero, descrizione, idpianodeiconti2, can_delete, can_edit) VALUES('.prepare($new_numero).', '.prepare($anagrafica->ragione_sociale).", (SELECT id FROM co_pianodeiconti2 WHERE descrizione='Debiti fornitori e debiti diversi'), 1, 1)");
|
||||||
$idconto = $database->lastInsertedID();
|
$idconto = $database->lastInsertedID();
|
||||||
|
|
||||||
// Collegamento conto
|
// Collegamento conto
|
||||||
|
@ -2,40 +2,24 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/../../core.php';
|
include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
|
use Modules\Anagrafiche\Anagrafica;
|
||||||
|
use Modules\Contratti\Components\Articolo;
|
||||||
|
use Modules\Contratti\Components\Riga;
|
||||||
|
use Modules\Contratti\Contratto;
|
||||||
|
|
||||||
switch (post('op')) {
|
switch (post('op')) {
|
||||||
case 'add':
|
case 'add':
|
||||||
$idanagrafica = post('idanagrafica');
|
$idanagrafica = post('idanagrafica');
|
||||||
$nome = post('nome');
|
$nome = post('nome');
|
||||||
|
|
||||||
// Verifico se c'è già un agente collegato all'anagrafica cliente, così lo imposto già
|
$anagrafica = Anagrafica::find($idanagrafica);
|
||||||
$q = 'SELECT idagente FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica);
|
|
||||||
$rs = $dbo->fetchArray($q);
|
|
||||||
$idagente = $rs[0]['idagente'];
|
|
||||||
|
|
||||||
// Codice contratto: calcolo il successivo in base al formato specificato
|
$contratto = Contratto::build($anagrafica, $nome);
|
||||||
$rs = $dbo->fetchArray('SELECT numero FROM co_contratti ORDER BY id DESC LIMIT 0,1');
|
$id_record = $contratto->id;
|
||||||
$numero = Util\Generator::generate(setting('Formato codice contratti'), $rs[0]['numero']);
|
|
||||||
|
|
||||||
// Uso il tipo di pagamento specificato in anagrafica se c'è, altrimenti quello di default
|
flash()->info(tr('Aggiunto contratto numero _NUM_!', [
|
||||||
$rsa = $dbo->fetchArray('SELECT idpagamento_vendite AS idpagamento FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
'_NUM_' => $contratto['numero'],
|
||||||
|
]));
|
||||||
$idpagamento = (!empty($rsa[0]['idpagamento'])) ? $rsa[0]['idpagamento'] : setting('Tipo di pagamento predefinito');
|
|
||||||
|
|
||||||
if (post('idanagrafica') !== null) {
|
|
||||||
$dbo->query('INSERT INTO co_contratti(idanagrafica, nome, numero, idagente, idpagamento, idstato, data_bozza) VALUES ('.prepare($idanagrafica).', '.prepare($nome).', '.prepare($numero).', '.prepare($idagente).', '.prepare($idpagamento).", (SELECT `id` FROM `co_staticontratti` WHERE `descrizione`='Bozza'), NOW())");
|
|
||||||
$id_record = $dbo->lastInsertedID();
|
|
||||||
|
|
||||||
// Aggiunta associazioni costi unitari al contratto
|
|
||||||
$rsi = $dbo->fetchArray('SELECT * FROM in_tipiintervento WHERE (costo_orario!=0 OR costo_km!=0 OR costo_diritto_chiamata!=0)');
|
|
||||||
|
|
||||||
for ($i = 0; $i < sizeof($rsi); ++$i) {
|
|
||||||
$dbo->query('INSERT INTO co_contratti_tipiintervento(idcontratto, idtipointervento, costo_ore, costo_km, costo_dirittochiamata, costo_ore_tecnico, costo_km_tecnico, costo_dirittochiamata_tecnico) VALUES('.prepare($id_record).', '.prepare($rsi[$i]['idtipointervento']).', '.prepare($rsi[$i]['costo_orario']).', '.prepare($rsi[$i]['costo_km']).', '.prepare($rsi[$i]['costo_diritto_chiamata']).', '.prepare($rsi[$i]['costo_orario_tecnico']).', '.prepare($rsi[$i]['costo_km_tecnico']).', '.prepare($rsi[$i]['costo_diritto_chiamata_tecnico']).')');
|
|
||||||
}
|
|
||||||
|
|
||||||
flash()->info(tr('Aggiunto contratto numero _NUM_!', [
|
|
||||||
'_NUM_' => $numero,
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ if ($record['stato'] == 'Emessa') {
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{[ "type": "text", "label": "<?php echo tr('Identificatore Documento'); ?>", "help": "<?php echo tr("<span>Obbligatorio per valorizzare CIG/CUP. È possible inserire: </span><ul><li>N. determina</li><li>RDO</li><li>Ordine MEPA</li></ul>"); ?>","name": "id_documento_fe", "required": 0, "value": "$id_documento_fe$", "maxlength": 20 ]}
|
{[ "type": "text", "label": "<?php echo tr('Identificatore Documento'); ?>", "help": "<?php echo tr('<span>Obbligatorio per valorizzare CIG/CUP. È possible inserire: </span><ul><li>N. determina</li><li>RDO</li><li>Ordine MEPA</li></ul>'); ?>","name": "id_documento_fe", "required": 0, "value": "$id_documento_fe$", "maxlength": 20 ]}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
|
@ -32,7 +32,7 @@ $result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita');
|
|||||||
// Aggiunta sconto di default da listino per le vendite
|
// Aggiunta sconto di default da listino per le vendite
|
||||||
$listino = $dbo->fetchArray('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($idanagrafica));
|
$listino = $dbo->fetchArray('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($idanagrafica));
|
||||||
|
|
||||||
if( $listino[0]['prc_guadagno'] > 0 ){
|
if ($listino[0]['prc_guadagno'] > 0) {
|
||||||
$result['sconto_unitario'] = $listino[0]['prc_guadagno'];
|
$result['sconto_unitario'] = $listino[0]['prc_guadagno'];
|
||||||
$result['tipo_sconto'] = 'PRC';
|
$result['tipo_sconto'] = 'PRC';
|
||||||
}
|
}
|
||||||
|
58
modules/contratti/src/Components/Articolo.php
Normal file
58
modules/contratti/src/Components/Articolo.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contratti\Components;
|
||||||
|
|
||||||
|
use Common\Components\Article;
|
||||||
|
use Modules\Articoli\Articolo as Original;
|
||||||
|
use Modules\Contratti\Contratto;
|
||||||
|
|
||||||
|
class Articolo extends Article
|
||||||
|
{
|
||||||
|
use RelationTrait;
|
||||||
|
|
||||||
|
protected $table = 'co_righe_contratti';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crea un nuovo articolo collegato ad una contratto.
|
||||||
|
*
|
||||||
|
* @param Contratto $contratto
|
||||||
|
* @param Original $articolo
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function build(Contratto $contratto, Original $articolo)
|
||||||
|
{
|
||||||
|
$model = parent::build($contratto, $articolo);
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function movimenta($qta)
|
||||||
|
{
|
||||||
|
$contratto = $this->contratto;
|
||||||
|
$tipo = $contratto->tipo;
|
||||||
|
|
||||||
|
$numero = $contratto->numero_esterno ?: $contratto->numero;
|
||||||
|
$data = $contratto->data;
|
||||||
|
|
||||||
|
$carico = ($tipo->dir == 'entrata') ? tr('Ripristino articolo da _TYPE_ _NUM_') : tr('Carico magazzino da _TYPE_ numero _NUM_');
|
||||||
|
$scarico = ($tipo->dir == 'entrata') ? tr('Scarico magazzino per _TYPE_ numero _NUM_') : tr('Rimozione articolo da _TYPE_ _NUM_');
|
||||||
|
|
||||||
|
$qta = ($tipo->dir == 'uscita') ? -$qta : $qta;
|
||||||
|
$movimento = ($qta < 0) ? $carico : $scarico;
|
||||||
|
|
||||||
|
$movimento = replace($movimento, [
|
||||||
|
'_TYPE_' => $tipo->descrizione,
|
||||||
|
'_NUM_' => $numero,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->articolo->movimenta(-$qta, $movimento, $data, false, [
|
||||||
|
'iddocumento' => $contratto->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDirection()
|
||||||
|
{
|
||||||
|
return $this->contratto->tipo->dir;
|
||||||
|
}
|
||||||
|
}
|
27
modules/contratti/src/Components/Descrizione.php
Normal file
27
modules/contratti/src/Components/Descrizione.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contratti\Components;
|
||||||
|
|
||||||
|
use Common\Components\Description;
|
||||||
|
use Modules\Contratti\Contratto;
|
||||||
|
|
||||||
|
class Descrizione extends Description
|
||||||
|
{
|
||||||
|
use RelationTrait;
|
||||||
|
|
||||||
|
protected $table = 'co_righe_contratti';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crea una nuova riga collegata ad una contratto.
|
||||||
|
*
|
||||||
|
* @param Contratto $contratto
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function build(Contratto $contratto)
|
||||||
|
{
|
||||||
|
$model = parent::build($contratto);
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
}
|
23
modules/contratti/src/Components/RelationTrait.php
Normal file
23
modules/contratti/src/Components/RelationTrait.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contratti\Components;
|
||||||
|
|
||||||
|
use Modules\Contratti\Contratto;
|
||||||
|
|
||||||
|
trait RelationTrait
|
||||||
|
{
|
||||||
|
public function getParentID()
|
||||||
|
{
|
||||||
|
return 'idcontratto';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function parent()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Contratto::class, $this->getParentID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function contratto()
|
||||||
|
{
|
||||||
|
return $this->parent();
|
||||||
|
}
|
||||||
|
}
|
27
modules/contratti/src/Components/Riga.php
Normal file
27
modules/contratti/src/Components/Riga.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contratti\Components;
|
||||||
|
|
||||||
|
use Common\Components\Row;
|
||||||
|
use Modules\Contratti\Contratto;
|
||||||
|
|
||||||
|
class Riga extends Row
|
||||||
|
{
|
||||||
|
use RelationTrait;
|
||||||
|
|
||||||
|
protected $table = 'co_righe_contratti';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crea una nuova riga collegata ad una contratto.
|
||||||
|
*
|
||||||
|
* @param Contratto $contratto
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function build(Contratto $contratto)
|
||||||
|
{
|
||||||
|
$model = parent::build($contratto);
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
}
|
33
modules/contratti/src/Components/Sconto.php
Normal file
33
modules/contratti/src/Components/Sconto.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contratti\Components;
|
||||||
|
|
||||||
|
use Common\Components\Discount;
|
||||||
|
use Modules\Contratti\Contratto;
|
||||||
|
|
||||||
|
class Sconto extends Discount
|
||||||
|
{
|
||||||
|
use RelationTrait;
|
||||||
|
|
||||||
|
protected $table = 'co_righe_contratti';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crea una nuovo sconto globale collegato alla contratto, oppure restituisce quello esistente.
|
||||||
|
*
|
||||||
|
* @param Contratto $contratto
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function build(Contratto $contratto)
|
||||||
|
{
|
||||||
|
$model = $contratto->scontoGlobale;
|
||||||
|
|
||||||
|
if ($model == null) {
|
||||||
|
$model = parent::build();
|
||||||
|
|
||||||
|
$model->setContratto($contratto);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
}
|
157
modules/contratti/src/Contratto.php
Normal file
157
modules/contratti/src/Contratto.php
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contratti;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Common\Document;
|
||||||
|
use Modules\Anagrafiche\Anagrafica;
|
||||||
|
use Modules\Interventi\TipoSessione;
|
||||||
|
use Traits\RecordTrait;
|
||||||
|
use Util\Generator;
|
||||||
|
|
||||||
|
class Contratto extends Document
|
||||||
|
{
|
||||||
|
use RecordTrait;
|
||||||
|
|
||||||
|
protected $table = 'co_contratti';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crea un nuovo contratto.
|
||||||
|
*
|
||||||
|
* @param Anagrafica $anagrafica
|
||||||
|
* @param string $nome
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function build(Anagrafica $anagrafica, $nome)
|
||||||
|
{
|
||||||
|
$model = parent::build();
|
||||||
|
|
||||||
|
$stato_documento = Stato::where('descrizione', 'Bozza')->first();
|
||||||
|
|
||||||
|
$id_anagrafica = $anagrafica->id;
|
||||||
|
$id_agente = $anagrafica->idagente;
|
||||||
|
|
||||||
|
$id_pagamento = $anagrafica->idpagamento_vendite;
|
||||||
|
if (empty($id_pagamento)) {
|
||||||
|
$id_pagamento = setting('Tipo di pagamento predefinito');
|
||||||
|
}
|
||||||
|
|
||||||
|
$model->anagrafica()->associate($anagrafica);
|
||||||
|
$model->stato()->associate($stato_documento);
|
||||||
|
|
||||||
|
$model->numero = static::getNextNumero();
|
||||||
|
|
||||||
|
// Salvataggio delle informazioni
|
||||||
|
$model->nome = $nome;
|
||||||
|
$model->data_bozza = Carbon::now();
|
||||||
|
|
||||||
|
if (!empty($id_agente)) {
|
||||||
|
$model->idagente = $id_agente;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($id_pagamento)) {
|
||||||
|
$model->idpagamento = $id_pagamento;
|
||||||
|
}
|
||||||
|
|
||||||
|
$model->save();
|
||||||
|
|
||||||
|
$model->fixTipiSessioni();
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fixTipiSessioni()
|
||||||
|
{
|
||||||
|
$database = database();
|
||||||
|
$database->query('DELETE FROM co_contratti_tipiintervento WHERE idcontratto = '.prepare($this->id));
|
||||||
|
|
||||||
|
// Aggiunta associazioni costi unitari al contratto
|
||||||
|
$tipi = TipoSessione::where('costo_orario', '<>', 0)
|
||||||
|
->where('costo_km', '<>', 0)
|
||||||
|
->where('costo_diritto_chiamata', '<>', 0)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($tipi as $tipo) {
|
||||||
|
$database->insert('co_contratti_tipiintervento', [
|
||||||
|
'idcontratto' => $this->id,
|
||||||
|
'idtipointervento' => $tipo->id,
|
||||||
|
'costo_ore' => $tipo->costo_orario,
|
||||||
|
'costo_km' => $tipo->costo_km,
|
||||||
|
'costo_dirittochiamata' => $tipo->costo_diritto_chiamata,
|
||||||
|
'costo_ore_tecnico' => $tipo->costo_orario_tecnico,
|
||||||
|
'costo_km_tecnico' => $tipo->costo_km_tecnico,
|
||||||
|
'costo_dirittochiamata_tecnico' => $tipo->costo_diritto_chiamata_tecnico,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restituisce il nome del modulo a cui l'oggetto è collegato.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModuleAttribute()
|
||||||
|
{
|
||||||
|
return 'Contratti';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateSconto()
|
||||||
|
{
|
||||||
|
// Aggiornamento sconto
|
||||||
|
aggiorna_sconto([
|
||||||
|
'parent' => 'co_preventivi',
|
||||||
|
'row' => 'co_righe_preventivi',
|
||||||
|
], [
|
||||||
|
'parent' => 'id',
|
||||||
|
'row' => 'idcontratto',
|
||||||
|
], $this->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function anagrafica()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Anagrafica::class, 'idanagrafica');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stato()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Stato::class, 'idstato');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function articoli()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Components\Articolo::class, 'idcontratto');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function righe()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Components\Riga::class, 'idcontratto');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function descrizioni()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Components\Descrizione::class, 'idcontratto');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scontoGlobale()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Components\Sconto::class, 'idcontratto');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Metodi statici
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calcola il nuovo numero di contratto.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getNextNumero()
|
||||||
|
{
|
||||||
|
$maschera = setting('Formato codice contratti');
|
||||||
|
|
||||||
|
$ultimo = Generator::getPreviousFrom($maschera, 'co_contratti', 'numero');
|
||||||
|
$numero = Generator::generate($maschera, $ultimo);
|
||||||
|
|
||||||
|
return $numero;
|
||||||
|
}
|
||||||
|
}
|
15
modules/contratti/src/Stato.php
Normal file
15
modules/contratti/src/Stato.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contratti;
|
||||||
|
|
||||||
|
use Common\Model;
|
||||||
|
|
||||||
|
class Stato extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'co_staticontratti';
|
||||||
|
|
||||||
|
public function preventivi()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Contratto::class, 'idstato');
|
||||||
|
}
|
||||||
|
}
|
@ -31,7 +31,7 @@ switch (post('op')) {
|
|||||||
|
|
||||||
flash()->info(tr('Aggiunto ddt in _TYPE_ numero _NUM_!', [
|
flash()->info(tr('Aggiunto ddt in _TYPE_ numero _NUM_!', [
|
||||||
'_TYPE_' => $dir,
|
'_TYPE_' => $dir,
|
||||||
'_NUM_' => $numero,
|
'_NUM_' => $ddt->numero,
|
||||||
]));
|
]));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -116,7 +116,7 @@ $_SESSION['superselect']['idanagrafica'] = $record['idanagrafica'];
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
{[ "type": "select", "label": "<?php echo tr('Porto'); ?>", "name": "idporto", "placeholder": "-", "help": "<?php echo tr("<ul><li>Franco: pagamento del trasporto a carico del mittente</li> <li>Assegnato pagamento del trasporto a carico del destinatario</li> </ul>"); ?>", "values": "query=SELECT id, descrizione FROM dt_porto ORDER BY descrizione ASC", "value": "$idporto$", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
|
{[ "type": "select", "label": "<?php echo tr('Porto'); ?>", "name": "idporto", "placeholder": "-", "help": "<?php echo tr('<ul><li>Franco: pagamento del trasporto a carico del mittente</li> <li>Assegnato pagamento del trasporto a carico del destinatario</li> </ul>'); ?>", "values": "query=SELECT id, descrizione FROM dt_porto ORDER BY descrizione ASC", "value": "$idporto$", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
|
@ -38,7 +38,7 @@ $result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita');
|
|||||||
// Aggiunta sconto di default da listino per le vendite
|
// Aggiunta sconto di default da listino per le vendite
|
||||||
$listino = $dbo->fetchArray('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_'.($dir == 'uscita' ? 'acquisti' : 'vendite').'=mg_listini.id WHERE idanagrafica='.prepare($idanagrafica));
|
$listino = $dbo->fetchArray('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_'.($dir == 'uscita' ? 'acquisti' : 'vendite').'=mg_listini.id WHERE idanagrafica='.prepare($idanagrafica));
|
||||||
|
|
||||||
if( $listino[0]['prc_guadagno'] > 0 ){
|
if ($listino[0]['prc_guadagno'] > 0) {
|
||||||
$result['sconto_unitario'] = $listino[0]['prc_guadagno'];
|
$result['sconto_unitario'] = $listino[0]['prc_guadagno'];
|
||||||
$result['tipo_sconto'] = 'PRC';
|
$result['tipo_sconto'] = 'PRC';
|
||||||
}
|
}
|
||||||
|
@ -520,7 +520,7 @@ include $docroot.'/modules/fatture/row-list.php';
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ($dir == 'entrata') {
|
if ($dir == 'entrata') {
|
||||||
echo '
|
echo '
|
||||||
<div class="alert alert-info text-center">'.tr('Per allegare un documento alla fattura elettronica caricare il file specificando come categoria "Fattura Elettronica"').'.</div>';
|
<div class="alert alert-info text-center">'.tr('Per allegare un documento alla fattura elettronica caricare il file specificando come categoria "Fattura Elettronica"').'.</div>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -47,7 +47,7 @@ $result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita');
|
|||||||
// Aggiunta sconto di default da listino per le vendite
|
// Aggiunta sconto di default da listino per le vendite
|
||||||
$listino = $dbo->fetchArray('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_'.($dir == 'uscita' ? 'acquisti' : 'vendite').'=mg_listini.id WHERE idanagrafica='.prepare($idanagrafica));
|
$listino = $dbo->fetchArray('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_'.($dir == 'uscita' ? 'acquisti' : 'vendite').'=mg_listini.id WHERE idanagrafica='.prepare($idanagrafica));
|
||||||
|
|
||||||
if( $listino[0]['prc_guadagno'] > 0 ){
|
if ($listino[0]['prc_guadagno'] > 0) {
|
||||||
$result['sconto_unitario'] = $listino[0]['prc_guadagno'];
|
$result['sconto_unitario'] = $listino[0]['prc_guadagno'];
|
||||||
$result['tipo_sconto'] = 'PRC';
|
$result['tipo_sconto'] = 'PRC';
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ switch (post('op')) {
|
|||||||
$id_record = $ordine->id;
|
$id_record = $ordine->id;
|
||||||
|
|
||||||
flash()->info(tr('Aggiunto ordine numero _NUM_!', [
|
flash()->info(tr('Aggiunto ordine numero _NUM_!', [
|
||||||
'_NUM_' => $numero,
|
'_NUM_' => $ordine->numero,
|
||||||
]));
|
]));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -38,7 +38,7 @@ $result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita');
|
|||||||
// Aggiunta sconto di default da listino per le vendite
|
// Aggiunta sconto di default da listino per le vendite
|
||||||
$listino = $dbo->fetchArray('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_'.($dir == 'uscita' ? 'acquisti' : 'vendite').'=mg_listini.id WHERE idanagrafica='.prepare($idanagrafica));
|
$listino = $dbo->fetchArray('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_'.($dir == 'uscita' ? 'acquisti' : 'vendite').'=mg_listini.id WHERE idanagrafica='.prepare($idanagrafica));
|
||||||
|
|
||||||
if( $listino[0]['prc_guadagno'] > 0 ){
|
if ($listino[0]['prc_guadagno'] > 0) {
|
||||||
$result['sconto_unitario'] = $listino[0]['prc_guadagno'];
|
$result['sconto_unitario'] = $listino[0]['prc_guadagno'];
|
||||||
$result['tipo_sconto'] = 'PRC';
|
$result['tipo_sconto'] = 'PRC';
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ $result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita');
|
|||||||
// Aggiunta sconto di default da listino per le vendite
|
// Aggiunta sconto di default da listino per le vendite
|
||||||
$listino = $dbo->fetchArray('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($idanagrafica));
|
$listino = $dbo->fetchArray('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($idanagrafica));
|
||||||
|
|
||||||
if( $listino[0]['prc_guadagno'] > 0 ){
|
if ($listino[0]['prc_guadagno'] > 0) {
|
||||||
$result['sconto_unitario'] = $listino[0]['prc_guadagno'];
|
$result['sconto_unitario'] = $listino[0]['prc_guadagno'];
|
||||||
$result['tipo_sconto'] = 'PRC';
|
$result['tipo_sconto'] = 'PRC';
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,13 @@ if (!empty($tecnici)) {
|
|||||||
<tr>
|
<tr>
|
||||||
<th>'.$tecnico['ragione_sociale'].'</th>
|
<th>'.$tecnico['ragione_sociale'].'</th>
|
||||||
<th>'.tr('Attività').'</th>
|
<th>'.tr('Attività').'</th>
|
||||||
<th>'.tr('Addebito orario').' <span class="tip" title="'.tr("Addebito al cliente").'"><i class="fa fa-question-circle-o"></i></span></th>
|
<th>'.tr('Addebito orario').' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||||
<th>'.tr('Addebito km').' <span class="tip" title="'.tr("Addebito al cliente").'"><i class="fa fa-question-circle-o"></i></span></th>
|
<th>'.tr('Addebito km').' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||||
<th>'.tr('Addebito diritto ch.').' <span class="tip" title="'.tr("Addebito al cliente").'"><i class="fa fa-question-circle-o"></i></span></th>
|
<th>'.tr('Addebito diritto ch.').' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||||
|
|
||||||
<th>'.tr('Costo orario').' <span class="tip" title="'.tr("Costo interno").'"><i class="fa fa-question-circle-o"></i></span></th>
|
<th>'.tr('Costo orario').' <span class="tip" title="'.tr('Costo interno').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||||
<th>'.tr('Costo km').' <span class="tip" title="'.tr("Costo interno").'"><i class="fa fa-question-circle-o"></i></span></th>
|
<th>'.tr('Costo km').' <span class="tip" title="'.tr('Costo interno').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||||
<th>'.tr('Costo diritto ch.').' <span class="tip" title="'.tr("Costo interno").'"><i class="fa fa-question-circle-o"></i></span></th>
|
<th>'.tr('Costo diritto ch.').' <span class="tip" title="'.tr('Costo interno').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||||
<th width="40"></th>
|
<th width="40"></th>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
|
@ -141,17 +141,19 @@ echo '
|
|||||||
<i class="fa fa-download"></i> '.tr('Scarica').'
|
<i class="fa fa-download"></i> '.tr('Scarica').'
|
||||||
</a>';
|
</a>';
|
||||||
|
|
||||||
|
$file = $generated ? Models\Upload::where('filename', $fattura_pa->getFilename())->where('id_record', $id_record)->first() : null;
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
|
||||||
<i class="fa fa-arrow-right fa-fw text-muted"></i>
|
<i class="fa fa-arrow-right fa-fw text-muted"></i>
|
||||||
|
|
||||||
<a href="'.ROOTDIR.'/plugins/exportFE/view.php?id_record='.$id_record.'" class="btn btn-info btn-lg '.($generated ? '' : 'disabled').'" target="_blank" '.($generated ? '' : 'disabled').'>
|
<a href="'.ROOTDIR.'/view.php?file_id='.($file ? $file->id : null).'" class="btn btn-info btn-lg '.($generated ? '' : 'disabled').'" target="_blank" '.($generated ? '' : 'disabled').'>
|
||||||
<i class="fa fa-eye"></i> '.tr('Visualizza').'
|
<i class="fa fa-eye"></i> '.tr('Visualizza').'
|
||||||
</a>';
|
</a>';
|
||||||
|
|
||||||
$send = Interaction::isEnabled() && $generated && $record['codice_stato_fe'] == 'GEN';
|
$send = Interaction::isEnabled() && $generated && $record['codice_stato_fe'] == 'GEN';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
|
||||||
<i class="fa fa-arrow-right fa-fw text-muted"></i>
|
<i class="fa fa-arrow-right fa-fw text-muted"></i>
|
||||||
|
|
||||||
|
@ -465,9 +465,10 @@ class FatturaElettronica
|
|||||||
if (!empty($anagrafica['provincia']) && $anagrafica->nazione->iso2 == 'IT') {
|
if (!empty($anagrafica['provincia']) && $anagrafica->nazione->iso2 == 'IT') {
|
||||||
$result['Provincia'] = strtoupper($anagrafica['provincia']);
|
$result['Provincia'] = strtoupper($anagrafica['provincia']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($anagrafica->nazione->iso2))
|
if (!empty($anagrafica->nazione->iso2)) {
|
||||||
$result['Nazione'] = $anagrafica->nazione->iso2;
|
$result['Nazione'] = $anagrafica->nazione->iso2;
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
include_once __DIR__.'/init.php';
|
|
||||||
|
|
||||||
// XML
|
|
||||||
$xml = new DOMDocument();
|
|
||||||
$xml->loadXML($fattura_pa->toXML());
|
|
||||||
|
|
||||||
// XSL
|
|
||||||
$xsl = new DOMDocument();
|
|
||||||
$xsl->load(__DIR__.'/src/stylesheet-1.2.1.xsl');
|
|
||||||
|
|
||||||
// XSLT
|
|
||||||
$xslt = new XSLTProcessor();
|
|
||||||
$xslt->importStylesheet($xsl);
|
|
||||||
|
|
||||||
echo $xslt->transformToXML($xml);
|
|
@ -13,7 +13,7 @@ class MessageHandler extends AbstractProcessingHandler
|
|||||||
{
|
{
|
||||||
protected function write(array $record)
|
protected function write(array $record)
|
||||||
{
|
{
|
||||||
if (isAjaxRequest()) {
|
if (\Whoops\Util\Misc::isAjaxRequest()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,18 @@ class HTMLBuilder
|
|||||||
$json = self::decode($value, 'manager');
|
$json = self::decode($value, 'manager');
|
||||||
$class = self::getManager($json['name']);
|
$class = self::getManager($json['name']);
|
||||||
|
|
||||||
$result = !empty($class) ? $class->manage($json) : '';
|
$result = '';
|
||||||
|
try {
|
||||||
|
$result = !empty($class) ? $class->manage($json) : '';
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
logger()->error($exception->getMessage(), [
|
||||||
|
'code' => $exception->getCode(),
|
||||||
|
'message' => $exception->getMessage(),
|
||||||
|
'file' => $exception->getFile(),
|
||||||
|
'line' => $exception->getLine(),
|
||||||
|
'trace' => $exception->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// Ricorsione
|
// Ricorsione
|
||||||
if ($depth < self::$max_recursion) {
|
if ($depth < self::$max_recursion) {
|
||||||
@ -121,7 +132,19 @@ class HTMLBuilder
|
|||||||
|
|
||||||
foreach ($handlers[0] as $value) {
|
foreach ($handlers[0] as $value) {
|
||||||
$json = self::decode($value, 'handler');
|
$json = self::decode($value, 'handler');
|
||||||
$result = self::generate($json);
|
|
||||||
|
$result = null;
|
||||||
|
try {
|
||||||
|
$result = self::generate($json);
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
logger()->error($exception->getMessage(), [
|
||||||
|
'code' => $exception->getCode(),
|
||||||
|
'message' => $exception->getMessage(),
|
||||||
|
'file' => $exception->getFile(),
|
||||||
|
'line' => $exception->getLine(),
|
||||||
|
'trace' => $exception->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// Ricorsione
|
// Ricorsione
|
||||||
if ($depth < self::$max_recursion) {
|
if ($depth < self::$max_recursion) {
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace HTMLBuilder\Manager;
|
namespace HTMLBuilder\Manager;
|
||||||
|
|
||||||
|
use Models\Upload;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gestione allegati.
|
* Gestione allegati.
|
||||||
*
|
*
|
||||||
@ -77,13 +79,14 @@ class FileManager implements ManagerInterface
|
|||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
foreach ($rs as $r) {
|
foreach ($rs as $r) {
|
||||||
$extension = pathinfo($r['original'])['extension'];
|
$file = Upload::find($r['id']);
|
||||||
|
|
||||||
$result .= '
|
$result .= '
|
||||||
<tr>
|
<tr>
|
||||||
<td align="left">
|
<td align="left">
|
||||||
<a href="'.ROOTDIR.'/'.$directory.'/'.$r['filename'].'" target="_blank">
|
<a href="'.ROOTDIR.'/'.$directory.'/'.$r['filename'].'" target="_blank">
|
||||||
<i class="fa fa-external-link"></i> '.$r['name'].'
|
<i class="fa fa-external-link"></i> '.$r['name'].'
|
||||||
</a> ('.$extension.')'.'
|
</a> ('.$file->extension.')'.'
|
||||||
</td>
|
</td>
|
||||||
<td>'.\Translator::timestampToLocale($r['created_at']).'</td>
|
<td>'.\Translator::timestampToLocale($r['created_at']).'</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
@ -92,31 +95,11 @@ class FileManager implements ManagerInterface
|
|||||||
</a>';
|
</a>';
|
||||||
|
|
||||||
// Anteprime supportate dal browser
|
// Anteprime supportate dal browser
|
||||||
$supported_extensions = ['pdf', 'jpg', 'png', 'gif', 'jpeg', 'bmp'];
|
if ($file->hasPreview()) {
|
||||||
if (in_array(strtolower($extension), $supported_extensions)) {
|
|
||||||
$result .= "
|
|
||||||
<div class='hide-it-off-screen' id='view-".$r['id']."'>";
|
|
||||||
|
|
||||||
if ($extension == 'pdf') {
|
|
||||||
$result .= '
|
|
||||||
<iframe src="'.\Prints::getPDFLink($directory.'/'.$r['filename']).'" frameborder="0" width="100%" height="550"></iframe>';
|
|
||||||
} else {
|
|
||||||
$result .= '
|
|
||||||
<img src="'.ROOTDIR.'/'.$directory.'/'.$r['filename'].'" width="100%"></img>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$result .= '
|
$result .= '
|
||||||
</div>';
|
<button class="btn btn-xs btn-info" data-target="#bs-popup2" type="button" data-title="'.prepareToField($r['name']).' <small style=\'color:white\'><i>('.$r['filename'].')</i></small>" data-href="'.ROOTDIR.'/view.php?file_id='.$r['id'].'">
|
||||||
|
|
||||||
$result .= '
|
|
||||||
<button class="btn btn-xs btn-info" data-target="#bs-popup2" type="button" data-title="'.prepareToField($r['name']).' <small><em>('.$r['filename'].')</em></small>" data-href="#view-'.$r['id'].'">
|
|
||||||
<i class="fa fa-eye"></i>
|
<i class="fa fa-eye"></i>
|
||||||
</button>';
|
</button>';
|
||||||
} elseif (strtolower($extension) == 'xml') {
|
|
||||||
$result .= '
|
|
||||||
<a class="btn btn-xs btn-info" href="'.ROOTDIR.'/plugins/exportFE/view.php?id_record='.$r['id_record'].'" target="_blank">
|
|
||||||
<i class="fa fa-eye"></i>
|
|
||||||
</a>';
|
|
||||||
} else {
|
} else {
|
||||||
$result .= '
|
$result .= '
|
||||||
<button class="btn btn-xs btn-default disabled" title="'.tr('Anteprima file non disponibile').'" disabled>
|
<button class="btn btn-xs btn-default disabled" title="'.tr('Anteprima file non disponibile').'" disabled>
|
||||||
|
@ -13,6 +13,66 @@ class Upload extends Model
|
|||||||
return $this->attributes['category'] ?: 'Generale';
|
return $this->attributes['category'] ?: 'Generale';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getExtensionAttribute()
|
||||||
|
{
|
||||||
|
$pos = strrpos($this->filename, '.');
|
||||||
|
|
||||||
|
if (!$pos) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$extension = substr($this->filename, $pos + 1);
|
||||||
|
|
||||||
|
return strtolower($extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFilepathAttribute()
|
||||||
|
{
|
||||||
|
$parent = $this->plugin ?: $this->module;
|
||||||
|
|
||||||
|
return $parent->upload_directory.'/'.$this->filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isImage()
|
||||||
|
{
|
||||||
|
$list = ['jpg', 'png', 'gif', 'jpeg', 'bmp'];
|
||||||
|
|
||||||
|
return in_array($this->extension, $list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isFatturaElettronica()
|
||||||
|
{
|
||||||
|
return $this->extension == 'xml' && strtolower($this->category) == 'fattura elettronica';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isPDF()
|
||||||
|
{
|
||||||
|
return $this->extension == 'pdf';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasPreview()
|
||||||
|
{
|
||||||
|
return $this->isImage() || $this->isFatturaElettronica() || $this->isPDF();
|
||||||
|
}
|
||||||
|
|
||||||
/* Relazioni Eloquent */
|
/* Relazioni Eloquent */
|
||||||
|
|
||||||
public function module()
|
public function module()
|
||||||
|
@ -100,7 +100,7 @@ class Generator
|
|||||||
$values = array_column($replaces, 'regex');
|
$values = array_column($replaces, 'regex');
|
||||||
|
|
||||||
$pattern = preg_replace('/#{1,}/', '#', $pattern);
|
$pattern = preg_replace('/#{1,}/', '#', $pattern);
|
||||||
$pattern = preg_quote($pattern, '/');
|
$pattern = str_replace('\\#','#',preg_quote($pattern, '/'));
|
||||||
$pattern = str_replace(array_keys($replaces), array_values($values), $pattern);
|
$pattern = str_replace(array_keys($replaces), array_values($values), $pattern);
|
||||||
|
|
||||||
// Individuazione dei valori
|
// Individuazione dei valori
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Modules\Anagrafiche\Anagrafica;
|
|
||||||
use Modules\Fatture\Fattura;
|
|
||||||
use Modules\Fatture\Tipo;
|
|
||||||
|
|
||||||
class FatturaTest extends \Codeception\Test\Unit
|
|
||||||
{
|
|
||||||
public function testCreate()
|
|
||||||
{
|
|
||||||
$data = date('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
$id_anagrafica = 1;
|
|
||||||
$id_tipo = 2;
|
|
||||||
$id_segment = 1;
|
|
||||||
|
|
||||||
$anagrafica = Anagrafica::find($id_anagrafica);
|
|
||||||
$tipo = Tipo::find($id_tipo);
|
|
||||||
|
|
||||||
$fattura = Fattura::build($anagrafica, $tipo, $data, $id_segment);
|
|
||||||
|
|
||||||
$this->assertEquals($fattura->idanagrafica, 1);
|
|
||||||
$this->assertEquals($fattura->idtipodocumento, 2);
|
|
||||||
$this->assertEquals($fattura->id_segment, 1);
|
|
||||||
$this->assertEquals($fattura->data, $data);
|
|
||||||
}
|
|
||||||
}
|
|
70
tests/unit/GeneratorTest.php
Normal file
70
tests/unit/GeneratorTest.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Util\Generator;
|
||||||
|
|
||||||
|
class GeneratorTest extends \Codeception\Test\Unit
|
||||||
|
{
|
||||||
|
public function testNumbersWithPrefix()
|
||||||
|
{
|
||||||
|
$this->test(null, '|TEST');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNumbersWithSuffix()
|
||||||
|
{
|
||||||
|
$this->test('|TEST');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCommonNumbers()
|
||||||
|
{
|
||||||
|
$this->test();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDates()
|
||||||
|
{
|
||||||
|
$this->test('/YYYY');
|
||||||
|
$this->test('/yy');
|
||||||
|
|
||||||
|
$this->test(null, 'YYYY-');
|
||||||
|
$this->test(null, 'yy-');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function test($prefix = null, $suffix = null)
|
||||||
|
{
|
||||||
|
$date = date('Y-m-d H:i:s');
|
||||||
|
$info = Generator::dateToPattern($date);
|
||||||
|
|
||||||
|
// Individuazione valori relativi a suffisso e prefisso
|
||||||
|
$prefix_value = Generator::complete($prefix, $info);
|
||||||
|
$suffix_value = Generator::complete($suffix, $info);
|
||||||
|
|
||||||
|
$step = 3;
|
||||||
|
|
||||||
|
// Pattern di base con numero di caratteri incrementale
|
||||||
|
$pattern = $prefix.'#'.$suffix;
|
||||||
|
|
||||||
|
$previous = null;
|
||||||
|
for ($i = 0; $i < 10000; $i = $i + $step) {
|
||||||
|
$value = $prefix_value.$this->pad($i + 1, $length).$suffix_value;
|
||||||
|
$this->assertEquals($value, Generator::generate($pattern, $previous, $step, $info));
|
||||||
|
|
||||||
|
$previous = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pattern con padding
|
||||||
|
$length = 5;
|
||||||
|
$pattern = $prefix.str_repeat('#', $length).$suffix;
|
||||||
|
|
||||||
|
$previous = null;
|
||||||
|
for ($i = 0; $i < 10000; $i = $i + $step) {
|
||||||
|
$value = $prefix_value.$this->pad($i + 1, $length).$suffix_value;
|
||||||
|
$this->assertEquals($value, Generator::generate($pattern, $previous, $step, $info));
|
||||||
|
|
||||||
|
$previous = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function pad($number, $length)
|
||||||
|
{
|
||||||
|
return str_pad($number, $length, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
}
|
@ -8,8 +8,3 @@ foreach ($namespaces as $path => $namespace) {
|
|||||||
Autoload::addNamespace($namespace.'\\', __DIR__.'/../../'.$path.'/custom/src');
|
Autoload::addNamespace($namespace.'\\', __DIR__.'/../../'.$path.'/custom/src');
|
||||||
Autoload::addNamespace($namespace.'\\', __DIR__.'/../../'.$path.'/src');
|
Autoload::addNamespace($namespace.'\\', __DIR__.'/../../'.$path.'/src');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Individuazione dei percorsi di base
|
|
||||||
App::definePaths(__DIR__.'/../..');
|
|
||||||
|
|
||||||
database();
|
|
||||||
|
59
view.php
Normal file
59
view.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once __DIR__.'/core.php';
|
||||||
|
|
||||||
|
$file_id = filter('file_id');
|
||||||
|
|
||||||
|
$file = Models\Upload::find($file_id);
|
||||||
|
|
||||||
|
if (empty($file)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$link = ROOTDIR.'/'.$file->filepath;
|
||||||
|
|
||||||
|
if ($file->isFatturaElettronica()) {
|
||||||
|
$content = file_get_contents(DOCROOT.'/'.$file->filepath);
|
||||||
|
|
||||||
|
// XML
|
||||||
|
$xml = new DOMDocument();
|
||||||
|
$xml->loadXML($content);
|
||||||
|
|
||||||
|
// XSL
|
||||||
|
$xsl = new DOMDocument();
|
||||||
|
$xsl->load(__DIR__.'/assets/src/xml/fe-stylesheet-1.2.1.xsl');
|
||||||
|
|
||||||
|
// XSLT
|
||||||
|
$xslt = new XSLTProcessor();
|
||||||
|
$xslt->importStylesheet($xsl);
|
||||||
|
|
||||||
|
echo $xslt->transformToXML($xml);
|
||||||
|
} else {
|
||||||
|
echo '
|
||||||
|
<style>
|
||||||
|
body, iframe, img{
|
||||||
|
border: 0;
|
||||||
|
margin: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
iframe{
|
||||||
|
width:100%;
|
||||||
|
height:100%;
|
||||||
|
min-height: 500px;
|
||||||
|
}
|
||||||
|
</style>';
|
||||||
|
|
||||||
|
if ($file->isImage()) {
|
||||||
|
echo '
|
||||||
|
<img src="'.$link.'"></img>';
|
||||||
|
} else {
|
||||||
|
if ($file->isPDF()) {
|
||||||
|
$src = \Prints::getPDFLink($file->filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<iframe src="'.($link ?: $src).'">
|
||||||
|
<a src="'.$link.'">'.tr('Il browser non supporta i contenuti iframe: clicca qui per raggiungere il file originale').'</a>
|
||||||
|
</iframe>';
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user