mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-18 04:20:50 +01:00
Miglioramento gestione revisioni preventivi a database e a video
This commit is contained in:
parent
24021354dc
commit
2e1b88c31b
@ -8,6 +8,19 @@ unset($_SESSION['superselect']['idsede_destinazione']);
|
|||||||
unset($_SESSION['superselect']['idanagrafica']);
|
unset($_SESSION['superselect']['idanagrafica']);
|
||||||
$_SESSION['superselect']['idanagrafica'] = $record['idanagrafica'];
|
$_SESSION['superselect']['idanagrafica'] = $record['idanagrafica'];
|
||||||
|
|
||||||
|
// Mostro un avviso se ci sono più revisioni del preventivo
|
||||||
|
if (count($preventivo->revisioni) > 0) {
|
||||||
|
echo '
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<i class="fa fa-info-circle"></i>
|
||||||
|
'.tr('Questo preventivo presenta _N_ revisioni',
|
||||||
|
[
|
||||||
|
'_N_' => count($preventivo->revisioni)
|
||||||
|
]).'
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
?><form action="" method="post" id="edit-form">
|
?><form action="" method="post" id="edit-form">
|
||||||
<input type="hidden" name="backto" value="record-edit">
|
<input type="hidden" name="backto" value="record-edit">
|
||||||
<input type="hidden" name="op" value="update">
|
<input type="hidden" name="op" value="update">
|
||||||
@ -22,7 +35,7 @@ $_SESSION['superselect']['idanagrafica'] = $record['idanagrafica'];
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
{[ "type": "text", "label": "<?php echo tr('Numero'); ?>", "name": "numero", "required": 1, "class": "text-center", "value": "$numero$" ]}
|
{[ "type": "text", "label": "<?php echo tr('Numero'); ?>", "name": "numero", "required": 1, "class": "text-center", "value": "$numero$", "icon-after": "<?php echo (count($preventivo->revisioni) > 1) ? tr('rev.').' '.$preventivo->numero_revision : '' ?>" ]}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
|
@ -265,8 +265,17 @@ class Preventivo extends Document
|
|||||||
return $this->data_bozza;
|
return $this->data_bozza;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRevisioniAttribute()
|
||||||
|
{
|
||||||
|
$revisioni = Preventivo::where('master_revision', '=', $this->master_revision)->get()->pluck('id')->toArray();
|
||||||
|
|
||||||
|
return $revisioni;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function setStatoAttribute($stato)
|
public function setStatoAttribute($stato)
|
||||||
{
|
{
|
||||||
$this->idstato = Stato::where('descrizione', $stato)->first()['id'];
|
$this->idstato = Stato::where('descrizione', $stato)->first()['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ foreach ($revisioni as $i => $revisione) {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
'.tr('Revisione _NUM_ creata il _DATE_ alle _TIME_', [
|
'.tr('Revisione _NUM_ creata il _DATE_ alle _TIME_', [
|
||||||
'_NUM_' => ($i + 1),
|
'_NUM_' => ($revisione['numero_revision']),
|
||||||
'_DATE_' => dateFormat($revisione['created_at']),
|
'_DATE_' => dateFormat($revisione['created_at']),
|
||||||
'_TIME_' => timeFormat($revisione['created_at']),
|
'_TIME_' => timeFormat($revisione['created_at']),
|
||||||
])."
|
])."
|
||||||
|
@ -11,7 +11,7 @@ echo '
|
|||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
<div class="text-center" style="height:5mm;">
|
<div class="text-center" style="height:5mm;">
|
||||||
<b>'.tr('Preventivo num. _NUM_ del _DATE_', [
|
<b>'.tr('Preventivo num. _NUM_ del _DATE_', [
|
||||||
'_NUM_' => $documento['numero'],
|
'_NUM_' => $documento['numero'].(count($documento->revisioni) > 1 ? ' '.tr('rev.').' '.$documento->numero_revision : ''),
|
||||||
'_DATE_' => Translator::dateToLocale($documento['data_bozza']),
|
'_DATE_' => Translator::dateToLocale($documento['data_bozza']),
|
||||||
], ['upper' => true]).'</b>
|
], ['upper' => true]).'</b>
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,7 +8,7 @@ echo '
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h4 class="text-bold">'.tr('Consuntivo', [], ['upper' => true]).'</h4>
|
<h4 class="text-bold">'.tr('Consuntivo', [], ['upper' => true]).'</h4>
|
||||||
<b>'.tr('Preventivo num. _NUM_ del _DATE_', [
|
<b>'.tr('Preventivo num. _NUM_ del _DATE_', [
|
||||||
'_NUM_' => $documento['numero'],
|
'_NUM_' => $documento['numero'].(count($documento->revisioni) > 1 ? ' '.tr('rev.').' '.$documento->numero_revision : ''),
|
||||||
'_DATE_' => Translator::dateToLocale($documento['data_bozza']),
|
'_DATE_' => Translator::dateToLocale($documento['data_bozza']),
|
||||||
], ['upper' => true]).'</b>
|
], ['upper' => true]).'</b>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,3 +13,17 @@ foreach ($files as $key => $value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete($files);
|
delete($files);
|
||||||
|
|
||||||
|
// Calcolo nuovo campo "numero_revision" per ciascun preventivo
|
||||||
|
$preventivi = $dbo->fetchArray('SELECT * FROM co_preventivi ORDER BY id ASC');
|
||||||
|
|
||||||
|
foreach ($preventivi as $preventivo) {
|
||||||
|
// Calcolo il numero preventivo in modo sequenziale in base alla creazione
|
||||||
|
$revisioni = $dbo->fetchArray('SELECT id FROM co_preventivi WHERE master_revision = '.prepare($preventivo['id']).' AND id > '.prepare($preventivo['id']).' ORDER BY id ASC');
|
||||||
|
|
||||||
|
$numero_revision = 1;
|
||||||
|
|
||||||
|
foreach ($revisioni as $revisione) {
|
||||||
|
$dbo->query('UPDATE co_preventivi SET numero_revision='.prepare($numero_revision++).' WHERE id='.$revisione['id']);
|
||||||
|
}
|
||||||
|
}
|
@ -504,3 +504,6 @@ UPDATE `co_statipreventivi` SET `is_revisionabile` = 1 WHERE `is_completato` = 0
|
|||||||
|
|
||||||
-- Spostamento moduli "Stati preventivi" e "Stati contratti" sotto "Tabelle"
|
-- Spostamento moduli "Stati preventivi" e "Stati contratti" sotto "Tabelle"
|
||||||
UPDATE `zz_modules` SET `parent` = (SELECT `id` FROM (SELECT `id` FROM `zz_modules` WHERE `name` = 'Tabelle') AS `m` ) WHERE `name` IN('Stati dei preventivi', 'Stati dei contratti');
|
UPDATE `zz_modules` SET `parent` = (SELECT `id` FROM (SELECT `id` FROM `zz_modules` WHERE `name` = 'Tabelle') AS `m` ) WHERE `name` IN('Stati dei preventivi', 'Stati dei contratti');
|
||||||
|
|
||||||
|
-- Aggiunta campo per salvare il numero di revisione del preventivo
|
||||||
|
ALTER TABLE `co_preventivi` ADD `numero_revision` INT NOT NULL AFTER `default_revision`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user