diff --git a/include/common/importa.php b/include/common/importa.php
index e78b288e7..543e4c648 100755
--- a/include/common/importa.php
+++ b/include/common/importa.php
@@ -157,7 +157,7 @@ if (!empty($options['create_document'])) {
echo '
- {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT * FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')", "value": "'.$stato_predefinito.'" ]}
+ {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT `dt_statiddt`.*, `dt_statiddt_lang`.`name` AS descrizione FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')", "value": "'.$stato_predefinito.'" ]}
diff --git a/modules/ddt/actions.php b/modules/ddt/actions.php
index bb691541a..f33637252 100755
--- a/modules/ddt/actions.php
+++ b/modules/ddt/actions.php
@@ -733,7 +733,7 @@ if (!empty($id_record) && setting('Cambia automaticamente stato ordini fatturati
$rs = $dbo->fetchArray('SELECT `idordine` FROM `dt_righe_ddt` WHERE `idddt`='.prepare($id_record).' AND `idordine`!=0');
for ($i = 0; $i < sizeof($rs); ++$i) {
- $stato = (new StatoOrdine())->getByField('name', get_stato_ordine($rs[$i]['idordine']));
- $dbo->query('UPDATE `or_ordini` SET `idstatoordine`='.prepare($stato).'") WHERE `id` = '.prepare($rs[$i]['idordine']));
+ $stato = StatoOrdine::find(get_stato_ordine($rs[$i]['idordine']))->id;
+ $dbo->query('UPDATE `or_ordini` SET `idstatoordine`='.prepare($stato).' WHERE `id` = '.prepare($rs[$i]['idordine']));
}
}
diff --git a/modules/ddt/edit.php b/modules/ddt/edit.php
index 5ca7a36f7..b37650635 100755
--- a/modules/ddt/edit.php
+++ b/modules/ddt/edit.php
@@ -21,6 +21,7 @@ use Models\Module;
use Models\Plugin;
use Modules\Anagrafiche\Anagrafica;
use Modules\Anagrafiche\Sede;
+use Modules\DDT\Stato;
include_once __DIR__.'/../../core.php';
@@ -112,18 +113,24 @@ if ($righe_vuote) {
getByField('name', 'Fatturato', Models\Locale::getPredefined()->id);
+ $id_stato_parz_fatt = (new Stato())->getByField('name', 'Parzialmente fatturato', Models\Locale::getPredefined()->id);
+
+ if ($ordine->stato->id == $id_stato_fatt || $ordine->stato->id == $id_stato_parz_fatt) {
?>
- {[ "type": "select", "label": "", "name": "idstatoddt", "required": 1, "values": "query=SELECT *, `dt_statiddt_lang`.`name` as descrizione, `colore` AS _bgcolor_ FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang`= id); ?>) ORDER BY `name`", "value": "$idstatoddt$", "extra": "readonly", "class": "unblockable" ]}
+ {[ "type": "select", "label": "", "name": "idstatoddt", "required": 1, "values": "query=SELECT `dt_statiddt`.*, `dt_statiddt_lang`.`name` as descrizione, `colore` AS _bgcolor_ FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang`= id); ?>) ORDER BY `name`", "value": "$idstatoddt$", "extra": "readonly", "class": "unblockable" ]}
getByField('name', 'Bozza', Models\Locale::getPredefined()->id);
+ $id_stato_evaso = (new Stato())->getByField('name', 'Evaso', Models\Locale::getPredefined()->id);
+ $id_stato_parz_evaso = (new Stato())->getByField('name', 'Parzialmente evaso', Models\Locale::getPredefined()->id);
?>
- {[ "type": "select", "label": "", "name": "idstatoddt", "required": 1, "values": "query=SELECT *, `dt_statiddt_lang`.`name` as descrizione, `colore` AS _bgcolor_ FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang`= id); ?>) WHERE `name` IN('Bozza', 'Evaso', 'Parzialmente evaso') ORDER BY `name`", "value": "$idstatoddt$", "class": "unblockable" ]}
+ {[ "type": "select", "label": "", "name": "idstatoddt", "required": 1, "values": "query=SELECT `dt_statiddt`.*, `dt_statiddt_lang`.`name` as descrizione, `colore` AS _bgcolor_ FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang`= id); ?>) WHERE `dt_statiddt`.`id` IN () ORDER BY `name`", "value": "$idstatoddt$", "class": "unblockable" ]}
- {[ "type": "select", "label": "", "name": "idstatoddt", "required": 1, "values": "query=SELECT *, `colore` AS _bgcolor_, `dt_statiddt_lang`.`name` as descrizione FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang`= id); ?>) ORDER BY `name`", "value": "$idstatoddt$", "class": "unblockable" ]}
+ {[ "type": "select", "label": "", "name": "idstatoddt", "required": 1, "values": "query=SELECT `dt_statiddt`.*, `colore` AS _bgcolor_, `dt_statiddt_lang`.`name` as descrizione FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang`= id); ?>) ORDER BY `name`", "value": "$idstatoddt$", "class": "unblockable" ]}
diff --git a/modules/ddt/init.php b/modules/ddt/init.php
index e99732ead..cfde731f4 100755
--- a/modules/ddt/init.php
+++ b/modules/ddt/init.php
@@ -24,7 +24,7 @@ use Modules\DDT\DDT;
$azienda = Anagrafica::find(setting('Azienda predefinita'));
-$module_name = $module ? $module->getTranslation('name') : '';
+$module_name = $module ? $module->getTranslation('name', Models\Locale::getPredefined()->id) : '';
if ($module_name == 'Ddt di acquisto') {
$dir = 'uscita';
@@ -35,7 +35,8 @@ if ($module_name == 'Ddt di acquisto') {
if (isset($id_record)) {
$ddt = DDT::with('tipo', 'stato')->find($id_record);
- $record = $dbo->fetchOne('SELECT `dt_ddt`.*,
+ $record = $dbo->fetchOne('SELECT
+ `dt_ddt`.*,
`dt_ddt`.`id` AS idddt,
`dt_statiddt_lang`.`name` AS `stato`,
`dt_statiddt`.`completato` AS `flag_completato`,
diff --git a/modules/ordini/crea_documento.php b/modules/ordini/crea_documento.php
index 3cc9f4da7..a989dd047 100755
--- a/modules/ordini/crea_documento.php
+++ b/modules/ordini/crea_documento.php
@@ -27,10 +27,10 @@ use Modules\Ordini\Ordine;
$documento = Ordine::find($id_record);
-$module = Module::find($documento->module);
+$module = Module::find((new Module())->getByField('name', $documento->module, Models\Locale::getPredefined()->id));
if (get('documento') == 'fattura') {
- $final_module = $module->getTranslation('name') == 'Ordini cliente' ? 'Fatture di vendita' : 'Fatture di acquisto';
+ $final_module = $module->getTranslation('name', \Models\Locale::getPredefined()->id) == 'Ordini cliente' ? 'Fatture di vendita' : 'Fatture di acquisto';
$op = 'add_documento';
$tipo_documento_finale = Fattura::class;
} elseif (get('documento') == 'ordine_fornitore') {
@@ -39,10 +39,10 @@ if (get('documento') == 'fattura') {
$tipo_documento_finale = Ordine::class;
} elseif (get('documento') == 'intervento') {
$final_module = 'Interventi';
- $op = $module->getTranslation('name') == 'Ordini cliente' ? 'add_documento' : 'add_intervento';
+ $op = $module->getTranslation('name', \Models\Locale::getPredefined()->id) == 'Ordini cliente' ? 'add_documento' : 'add_intervento';
$tipo_documento_finale = Intervento::class;
} else {
- $final_module = $module->getTranslation('name') == 'Ordini cliente' ? 'Ddt di vendita' : 'Ddt di acquisto';
+ $final_module = $module->getTranslation('name', \Models\Locale::getPredefined()->id) == 'Ordini cliente' ? 'Ddt di vendita' : 'Ddt di acquisto';
$op = 'add_ordine';
$tipo_documento_finale = DDT::class;
}
diff --git a/modules/ordini/edit.php b/modules/ordini/edit.php
index 2944a8c18..cfc51dfe9 100755
--- a/modules/ordini/edit.php
+++ b/modules/ordini/edit.php
@@ -77,6 +77,7 @@ if ($righe_vuote) {
$id_stato_parz_evaso = (new Stato())->getByField('name', 'Parzialmente evaso', Models\Locale::getPredefined()->id);
$id_stato_fatt = (new Stato())->getByField('name', 'Fatturato', Models\Locale::getPredefined()->id);
$id_stato_parz_fatt = (new Stato())->getByField('name', 'Parzialmente fatturato', Models\Locale::getPredefined()->id);
+ $id_stato_accettato = (new Stato())->getByField('name', 'Accettato', Models\Locale::getPredefined()->id);
if ($ordine->stato->id == $id_stato_fatt || $ordine->stato->id == $id_stato_parz_fatt || $ordine->stato->id == $id_stato_evaso || $ordine->stato->id == $id_stato_parz_evaso) {
?>
@@ -84,7 +85,7 @@ if ($righe_vuote) {
- {[ "type": "select", "label": "", "name": "idstatoordine", "required": 1, "values": "query=SELECT `or_statiordine`.*, `or_statiordine_lang`.`name` as descrizione, `colore` AS _bgcolor_ FROM `or_statiordine` LEFT JOIN `or_statiordine_lang` ON (`or_statiordine_lang`.`id_record` = `or_statiordine`.`id` AND `or_statiordine_lang`.`id_lang` = id); ?>) WHERE (`is_fatturabile` = 0 AND `name` != 'Fatturato' || `name` = 'Accettato') ORDER BY `name`", "value": "$idstatoordine$", "class": "unblockable" ]}
+ {[ "type": "select", "label": "", "name": "idstatoordine", "required": 1, "values": "query=SELECT `or_statiordine`.*, `or_statiordine_lang`.`name` as descrizione, `colore` AS _bgcolor_ FROM `or_statiordine` LEFT JOIN `or_statiordine_lang` ON (`or_statiordine_lang`.`id_record` = `or_statiordine`.`id` AND `or_statiordine_lang`.`id_lang` = id); ?>) WHERE (`is_fatturabile` = 0 AND `or_statiordine`.`id` != || `or_statiordine`.`id` = ) ORDER BY `name`", "value": "$idstatoordine$", "class": "unblockable" ]}
getTranslation('name'), ['Parzialmente fatturato', 'Fatturato']) && $trigger->getDocument() instanceof DDT) {
+ } elseif (!in_array($stato_attuale->getTranslation('name', \Models\Locale::getPredefined()->id), ['Parzialmente fatturato', 'Fatturato']) && $trigger->getDocument() instanceof DDT) {
$descrizione = $parziale ? 'Parzialmente evaso' : 'Evaso';
} else {
$descrizione = $parziale ? 'Parzialmente fatturato' : 'Fatturato';
}
- $stato = (new Stato())->getByField('name', $descrizione);
+ $stato = (new Stato())->getByField('name', $descrizione, \Models\Locale::getPredefined()->id);
$this->stato()->associate($stato);
$this->save();
}