mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-24 23:37:51 +01:00
Merge remote-tracking branch 'refs/remotes/origin/master'
This commit is contained in:
commit
a1bc26c46c
@ -19,6 +19,7 @@
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
use Models\Module;
|
||||
use Modules\Contratti\Stato;
|
||||
|
||||
$block_edit = $record['is_completato'];
|
||||
$data_accettazione = $record['data_accettazione'] ? strtotime((string) $record['data_accettazione']) : '';
|
||||
@ -36,8 +37,24 @@ echo '
|
||||
<input type="hidden" name="id_record" value="'.$id_record.'">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-2 offset-md-10">
|
||||
{[ "type": "select", "label": "'.tr('Stato').'", "name": "idstato", "required": 1, "values": "query=SELECT `co_staticontratti`.`id`, `title` as `descrizione`, `colore` AS _bgcolor_ FROM `co_staticontratti` LEFT JOIN `co_staticontratti_lang` ON (`co_staticontratti`.`id` = `co_staticontratti_lang`.`id_record` AND `co_staticontratti_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') ORDER BY `title`", "value": "$idstato$", "class": "unblockable" ]}
|
||||
<div class="col-md-2 offset-md-10">';
|
||||
if (setting('Cambia automaticamente stato contratti fatturati')) {
|
||||
$id_stato_fatt = Stato::where('name', 'Fatturato')->first()->id;
|
||||
$id_stato_parz_fatt = Stato::where('name', 'Parzialmente fatturato')->first()->id;
|
||||
|
||||
if ($contratto->stato->id == $id_stato_fatt || $contratto->stato->id == $id_stato_parz_fatt) {
|
||||
echo '
|
||||
{[ "type": "select", "label": "'.tr('Stato').'", "name": "idstato", "required": 1, "values": "query=SELECT `co_staticontratti`.`id`, `title` as `descrizione`, `colore` AS _bgcolor_ FROM `co_staticontratti` LEFT JOIN `co_staticontratti_lang` ON (`co_staticontratti`.`id` = `co_staticontratti_lang`.`id_record` AND `co_staticontratti_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') ORDER BY `title`", "value": "$idstato$", "class": "unblockable" ]}';
|
||||
} else {
|
||||
echo '
|
||||
{[ "type": "select", "label": "'.tr('Stato').'", "name": "idstato", "required": 1, "values": "query=SELECT `co_staticontratti`.`id`, `title` as `descrizione`, `colore` AS _bgcolor_ FROM `co_staticontratti` LEFT JOIN `co_staticontratti_lang` ON (`co_staticontratti`.`id` = `co_staticontratti_lang`.`id_record` AND `co_staticontratti_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `co_staticontratti`.`id` NOT IN ('.implode(',', [$id_stato_fatt, $id_stato_parz_fatt]).') ORDER BY `title`", "value": "$idstato$", "class": "unblockable" ]}';
|
||||
}
|
||||
} else {
|
||||
echo '
|
||||
{[ "type": "select", "label": "'.tr('Stato').'", "name": "idstato", "required": 1, "values": "query=SELECT `co_staticontratti`.`id`, `title` as `descrizione`, `colore` AS _bgcolor_ FROM `co_staticontratti` LEFT JOIN `co_staticontratti_lang` ON (`co_staticontratti`.`id` = `co_staticontratti_lang`.`id_record` AND `co_staticontratti_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') ORDER BY `title`", "value": "$idstato$", "class": "unblockable" ]}
|
||||
</div>';
|
||||
}
|
||||
echo '
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -230,32 +230,33 @@ class Contratto extends Document
|
||||
{
|
||||
parent::triggerEvasione($trigger);
|
||||
|
||||
$righe = $this->getRighe();
|
||||
if (setting('Cambia automaticamente stato contratti fatturati')) {
|
||||
$righe = $this->getRighe();
|
||||
$qta_evasa = $righe->sum('qta_evasa');
|
||||
$qta = $righe->sum('qta');
|
||||
$parziale = $qta != $qta_evasa;
|
||||
|
||||
$qta_evasa = $righe->sum('qta_evasa');
|
||||
$qta = $righe->sum('qta');
|
||||
$parziale = $qta != $qta_evasa;
|
||||
// Impostazione del nuovo stato
|
||||
if ($qta_evasa == 0) {
|
||||
$descrizione = 'In lavorazione';
|
||||
$codice_intervento = 'OK';
|
||||
} else {
|
||||
$descrizione = $parziale ? 'Parzialmente fatturato' : 'Fatturato';
|
||||
$codice_intervento = 'FAT';
|
||||
}
|
||||
|
||||
// Impostazione del nuovo stato
|
||||
if ($qta_evasa == 0) {
|
||||
$descrizione = 'In lavorazione';
|
||||
$codice_intervento = 'OK';
|
||||
} else {
|
||||
$descrizione = $parziale ? 'Parzialmente fatturato' : 'Fatturato';
|
||||
$codice_intervento = 'FAT';
|
||||
}
|
||||
$stato = Stato::where('name', $descrizione)->first()->id;
|
||||
$this->stato()->associate($stato);
|
||||
$this->save();
|
||||
|
||||
$stato = Stato::where('name', $descrizione)->first()->id;
|
||||
$this->stato()->associate($stato);
|
||||
$this->save();
|
||||
|
||||
// Trasferimento degli interventi collegati
|
||||
$interventi = $this->interventi;
|
||||
$stato_intervento = \Modules\Interventi\Stato::where('codice', $codice_intervento)->first();
|
||||
foreach ($interventi as $intervento) {
|
||||
if ($intervento->stato->is_completato == 1) {
|
||||
$intervento->stato()->associate($stato_intervento);
|
||||
$intervento->save();
|
||||
// Trasferimento degli interventi collegati
|
||||
$interventi = $this->interventi;
|
||||
$stato_intervento = \Modules\Interventi\Stato::where('codice', $codice_intervento)->first();
|
||||
foreach ($interventi as $intervento) {
|
||||
if ($intervento->stato->is_completato == 1) {
|
||||
$intervento->stato()->associate($stato_intervento);
|
||||
$intervento->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -228,3 +228,9 @@ UPDATE `zz_settings` SET `is_user_setting` = '1' WHERE `zz_settings`.`nome` = 'N
|
||||
UPDATE `zz_settings` SET `is_user_setting` = '1' WHERE `zz_settings`.`nome` = 'Sistema di firma ';
|
||||
UPDATE `zz_settings` SET `is_user_setting` = '1' WHERE `zz_settings`.`nome` = 'Inizio periodo calendario';
|
||||
UPDATE `zz_settings` SET `is_user_setting` = '1' WHERE `zz_settings`.`nome` = 'Fine periodo calendario';
|
||||
|
||||
-- Aggiunta impostazione cambio stato contratti fatturati
|
||||
INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `created_at`, `updated_at`, `order`, `is_user_setting`) VALUES (NULL, 'Cambia automaticamente stato contratti fatturati', '1', 'boolean', '1', 'Contratti', NULL, NULL, NULL, '0');
|
||||
INSERT INTO `zz_settings_lang` (`id`, `id_lang`, `id_record`, `title`, `help`) VALUES
|
||||
(NULL, '1', (SELECT `zz_settings`.`id` FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Cambia automaticamente stato contratti fatturati'), 'Cambia automaticamente stato contratti fatturati', ''),
|
||||
(NULL, '2', (SELECT `zz_settings`.`id` FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Cambia automaticamente stato contratti fatturati'), 'Automatically change the status of billed contracts', '');
|
Loading…
x
Reference in New Issue
Block a user