mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-03-12 01:00:13 +01:00
Bugfix distribuiti
This commit is contained in:
parent
4298e84d90
commit
621477fd7f
1
core.php
1
core.php
@ -96,6 +96,7 @@ if (!API::isAPIRequest()) {
|
||||
// Disabilita la segnalazione degli errori (se il debug è disabilitato)
|
||||
if (!App::debug()) {
|
||||
error_reporting(0);
|
||||
ini_set("display_errors", 0);
|
||||
}
|
||||
|
||||
// Imposta il formato di salvataggio dei log
|
||||
|
@ -60,11 +60,14 @@ if (!isset($options['edit_articolo']) || !empty($options['edit_articolo'])) {
|
||||
session_set("superselect,idarticolo", $(this).val(), 0);
|
||||
$data = $(this).selectData();
|
||||
|
||||
var id_conto = $data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').';
|
||||
|
||||
$("#prezzo").val($data.prezzo_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').');
|
||||
$("#descrizione_riga").val($data.descrizione);
|
||||
$("#idiva").selectSet($data.idiva_vendita, $data.iva_vendita);
|
||||
$("#idconto").selectSetNew($data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').', $data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').'_title);
|
||||
console.log($data);
|
||||
if(id_conto) {
|
||||
$("#idconto").selectSetNew(id_conto, $data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').'_title);
|
||||
}
|
||||
$("#um").selectSetNew($data.um, $data.um);
|
||||
}';
|
||||
|
||||
|
@ -13,15 +13,21 @@ WHERE `an_tipianagrafiche`.`descrizione` = 'Azienda' AND `an_anagrafiche`.`delet
|
||||
$has_user = $dbo->fetchNum('SELECT `id` FROM `zz_users`') != 0;
|
||||
|
||||
$settings = [
|
||||
'Regime Fiscale',
|
||||
'Tipo Cassa',
|
||||
'Conto predefinito fatture di vendita',
|
||||
'Conto predefinito fatture di acquisto',
|
||||
'Regime Fiscale' => true,
|
||||
'Tipo Cassa' => true,
|
||||
'Conto predefinito fatture di vendita' => true,
|
||||
'Conto predefinito fatture di acquisto' => true,
|
||||
"Percentuale ritenuta d'acconto" => false,
|
||||
"Causale ritenuta d'acconto" => false,
|
||||
];
|
||||
|
||||
if (!empty(setting('Regime Fiscale'))) {
|
||||
$settings["Causale ritenuta d'acconto"] = true;
|
||||
}
|
||||
|
||||
$has_settings = true;
|
||||
foreach ($settings as $setting) {
|
||||
if (empty(setting($setting))) {
|
||||
foreach ($settings as $setting => $required) {
|
||||
if (empty(setting($setting)) && $required) {
|
||||
$has_settings = false;
|
||||
break;
|
||||
}
|
||||
@ -72,7 +78,7 @@ if (post('action') == 'init') {
|
||||
}
|
||||
|
||||
if (!$has_settings) {
|
||||
foreach ($settings as $setting) {
|
||||
foreach ($settings as $setting => $required) {
|
||||
$setting = Settings::get($setting);
|
||||
|
||||
Settings::setValue($setting['nome'], post('setting')[$setting['id']]);
|
||||
@ -176,10 +182,10 @@ if (!$has_settings) {
|
||||
|
||||
<div class="panel-body">';
|
||||
|
||||
foreach ($settings as $setting) {
|
||||
foreach ($settings as $setting => $required) {
|
||||
echo '
|
||||
<div class="col-md-6">
|
||||
'.Settings::input($setting, true).'
|
||||
'.Settings::input($setting, $required).'
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ include_once __DIR__.'/../../../core.php';
|
||||
|
||||
switch ($resource) {
|
||||
case 'articoli':
|
||||
$query = 'SELECT mg_articoli.*, (SELECT CONCAT(numero, " ", descrizione) FROM co_pianodeiconti3 WHERE co_pianodeiconti3.id = idconto_vendita) AS idconto_vendita_title, (SELECT CONCAT(numero, " ", descrizione) FROM co_pianodeiconti3 WHERE co_pianodeiconti3.id = idconto_acquisto) AS idconto_acquisto_title, co_iva.descrizione AS iva_vendita FROM mg_articoli LEFT OUTER JOIN co_iva ON mg_articoli.idiva_vendita=co_iva.id |where| ORDER BY mg_articoli.id_categoria ASC, mg_articoli.id_sottocategoria ASC';
|
||||
$query = 'SELECT mg_articoli.*, (SELECT CONCAT(co_pianodeiconti2.numero, ".", co_pianodeiconti3.numero, " ", co_pianodeiconti3.descrizione) FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE co_pianodeiconti3.id = idconto_vendita) AS idconto_vendita_title, (SELECT CONCAT(co_pianodeiconti2.numero, ".", co_pianodeiconti3.numero, " ", co_pianodeiconti3.descrizione) FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE co_pianodeiconti3.id = idconto_acquisto) AS idconto_acquisto_title, co_iva.descrizione AS iva_vendita FROM mg_articoli LEFT OUTER JOIN co_iva ON mg_articoli.idiva_vendita=co_iva.id |where| ORDER BY mg_articoli.id_categoria ASC, mg_articoli.id_sottocategoria ASC';
|
||||
|
||||
$idiva_predefinita = setting('Iva predefinita');
|
||||
$rs = $dbo->fetchArray('SELECT descrizione FROM co_iva WHERE id='.prepare($idiva_predefinita));
|
||||
|
@ -7,7 +7,7 @@ switch (post('op')) {
|
||||
$descrizione = post('descrizione');
|
||||
|
||||
// Verifico che il nome non sia duplicato
|
||||
$count = $dbo->fetchNum('SELECT descrizione FROM zz_documenti_categorie WHERE descrizione='.prepare($descrizione).' AND deleted = 0');
|
||||
$count = $dbo->fetchNum('SELECT descrizione FROM zz_documenti_categorie WHERE descrizione='.prepare($descrizione).' AND deleted_at IS NULL');
|
||||
if ($count != 0) {
|
||||
flash()->error(tr('Categoria _NAME_ già esistente!', [
|
||||
'_NAME_' => $descrizione,
|
||||
@ -27,7 +27,7 @@ switch (post('op')) {
|
||||
|
||||
if (isset($_POST['descrizione'])) {
|
||||
// Verifico che il nome non sia duplicato
|
||||
$count = $dbo->fetchNum('SELECT descrizione FROM zz_documenti_categorie WHERE descrizione='.prepare($descrizione).' AND deleted = 0');
|
||||
$count = $dbo->fetchNum('SELECT descrizione FROM zz_documenti_categorie WHERE descrizione='.prepare($descrizione).' AND deleted_at IS NULL');
|
||||
if ($count != 0) {
|
||||
flash()->error(tr('Categoria _NAME_ già esistente!', [
|
||||
'_NAME_' => $descrizione,
|
||||
@ -45,7 +45,7 @@ switch (post('op')) {
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$dbo->query('UPDATE zz_documenti_categorie SET deleted=1 WHERE id = '.prepare($id_record));
|
||||
$dbo->query('UPDATE zz_documenti_categorie SET deleted_at = NOW() WHERE id = '.prepare($id_record));
|
||||
|
||||
flash()->info(tr('Categoria docimenti eliminata!'));
|
||||
|
||||
|
@ -8,7 +8,7 @@ switch (filter('op')) {
|
||||
|
||||
if (isset($descrizione)) {
|
||||
if ($dbo->fetchNum('SELECT * FROM `dt_causalet` WHERE `descrizione`='.prepare($descrizione).' AND `id`!='.prepare($id_record)) == 0) {
|
||||
$predefined = post('dt_causalet');
|
||||
$predefined = post('predefined');
|
||||
if (!empty($predefined)) {
|
||||
$dbo->query('UPDATE dt_porto SET predefined = 0');
|
||||
}
|
||||
|
@ -495,9 +495,13 @@ switch (post('op')) {
|
||||
$articolo->id_iva = post('idiva');
|
||||
$articolo->idconto = post('idconto');
|
||||
|
||||
$articolo->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto');
|
||||
$articolo->id_ritenuta_acconto = post('id_ritenuta_acconto');
|
||||
$articolo->id_rivalsa_inps = post('id_rivalsa_inps');
|
||||
if (post('id_ritenuta_acconto')) {
|
||||
$articolo->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto');
|
||||
$articolo->id_ritenuta_acconto = post('id_ritenuta_acconto');
|
||||
}
|
||||
if (post('id_rivalsa_inps')) {
|
||||
$articolo->id_rivalsa_inps = post('id_rivalsa_inps');
|
||||
}
|
||||
|
||||
$articolo->costo_unitario = post('prezzo');
|
||||
$articolo->qta = $qta;
|
||||
@ -529,9 +533,13 @@ switch (post('op')) {
|
||||
$riga->id_iva = post('idiva');
|
||||
$riga->idconto = post('idconto');
|
||||
|
||||
$riga->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto');
|
||||
$riga->id_ritenuta_acconto = post('id_ritenuta_acconto');
|
||||
$riga->id_rivalsa_inps = post('id_rivalsa_inps');
|
||||
if (post('id_ritenuta_acconto')) {
|
||||
$riga->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto');
|
||||
$riga->id_ritenuta_acconto = post('id_ritenuta_acconto');
|
||||
}
|
||||
if (post('id_rivalsa_inps')) {
|
||||
$riga->id_rivalsa_inps = post('id_rivalsa_inps');
|
||||
}
|
||||
|
||||
$riga->costo_unitario = post('prezzo');
|
||||
$riga->qta = $qta;
|
||||
|
@ -12,7 +12,7 @@ include_once __DIR__.'/../../core.php';
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "Categoria", "name": "idcategoria", "required": 1, "class": "", "values": "query=SELECT id, descrizione FROM zz_documenti_categorie WHERE deleted = 0", "value": "", "extra": "" ]}
|
||||
{[ "type": "select", "label": "Categoria", "name": "idcategoria", "required": 1, "class": "", "values": "query=SELECT id, descrizione FROM zz_documenti_categorie WHERE deleted_at IS NULL", "value": "", "extra": "" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
|
@ -28,7 +28,7 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "Categoria", "name": "idcategoria", "required": 1, "class": "", "values": "query=SELECT id, descrizione FROM zz_documenti_categorie WHERE deleted = 0", "value": "$idcategoria$", "extra": "" ]}
|
||||
{[ "type": "select", "label": "Categoria", "name": "idcategoria", "required": 1, "class": "", "values": "query=SELECT id, descrizione FROM zz_documenti_categorie WHERE deleted_at IS NULL", "value": "$idcategoria$", "extra": "" ]}
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -6,27 +6,28 @@ switch (post('op')) {
|
||||
case 'update':
|
||||
$pattern = str_contains(post('pattern'), '#') ? post('pattern') : '####';
|
||||
$predefined = post('predefined');
|
||||
$module = post('module');
|
||||
|
||||
if (empty(Modules::getSegments($id_module))) {
|
||||
if (empty(Modules::getSegments($module))) {
|
||||
$predefined = 1;
|
||||
}
|
||||
|
||||
if ($predefined) {
|
||||
$dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($id_module));
|
||||
$dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($module));
|
||||
}
|
||||
|
||||
$predefined_accredito = post('predefined_accredito');
|
||||
if ($predefined_accredito) {
|
||||
$dbo->query('UPDATE zz_segments SET predefined_accredito = 0 WHERE id_module = '.prepare($id_module));
|
||||
$dbo->query('UPDATE zz_segments SET predefined_accredito = 0 WHERE id_module = '.prepare($module));
|
||||
}
|
||||
|
||||
$predefined_addebito = post('predefined_addebito');
|
||||
if ($predefined_addebito) {
|
||||
$dbo->query('UPDATE zz_segments SET predefined_addebito = 0 WHERE id_module = '.prepare($id_module));
|
||||
$dbo->query('UPDATE zz_segments SET predefined_addebito = 0 WHERE id_module = '.prepare($module));
|
||||
}
|
||||
|
||||
$dbo->update('zz_segments', [
|
||||
'id_module' => post('module'),
|
||||
'id_module' => $module,
|
||||
'name' => post('name'),
|
||||
'clause' => post('clause'),
|
||||
'pattern' => $pattern,
|
||||
@ -44,7 +45,6 @@ switch (post('op')) {
|
||||
case 'add':
|
||||
$pattern = str_contains(post('pattern'), '#') ? post('pattern') : '####';
|
||||
$predefined = post('predefined');
|
||||
|
||||
$module = post('module');
|
||||
|
||||
if (empty(Modules::getSegments($module))) {
|
||||
@ -52,11 +52,11 @@ switch (post('op')) {
|
||||
}
|
||||
|
||||
if ($predefined) {
|
||||
$dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($id_module));
|
||||
$dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($module));
|
||||
}
|
||||
|
||||
$dbo->insert('zz_segments', [
|
||||
'id_module' => post('module'),
|
||||
'id_module' => $module,
|
||||
'name' => post('name'),
|
||||
'clause' => '1=1',
|
||||
'pattern' => $pattern,
|
||||
|
@ -25,9 +25,6 @@ include_once __DIR__.'/../../core.php';
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<?php
|
||||
//($record['n_sezionali']<2) ? $record['predefined']=1 : '';
|
||||
?>
|
||||
{[ "type": "checkbox", "label": "<?php echo tr('Predefinito'); ?>", "name": "predefined", "value": "$predefined$", "help": "<?php echo tr('Seleziona per rendere il segmento predefinito.'); ?>", "placeholder": "<?php echo tr('Segmento predefinito'); ?>", "extra": "<?php echo ($record['predefined']) ? 'readonly' : ''; ?>" ]}
|
||||
</div>
|
||||
|
||||
|
@ -17,6 +17,11 @@ switch (post('op')) {
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$predefined = post('predefined');
|
||||
if (!empty($predefined)) {
|
||||
$dbo->query('UPDATE zz_smtps SET predefined = 0');
|
||||
}
|
||||
|
||||
$dbo->update('zz_smtps', [
|
||||
'name' => post('name'),
|
||||
'note' => post('note'),
|
||||
@ -28,13 +33,9 @@ switch (post('op')) {
|
||||
'from_address' => post('from_address'),
|
||||
'encryption' => post('encryption'),
|
||||
'pec' => post('pec'),
|
||||
'main' => post('main'),
|
||||
'predefined' => $predefined,
|
||||
], ['id' => $id_record]);
|
||||
|
||||
if (!empty(post('main'))) {
|
||||
$dbo->query('UPDATE zz_smtps SET main = 0 WHERE id != '.prepare($id_record));
|
||||
}
|
||||
|
||||
flash()->info(tr('Informazioni salvate correttamente!'));
|
||||
|
||||
// Validazione indirizzo email mittente
|
||||
|
@ -24,7 +24,7 @@ include_once __DIR__.'/../../core.php';
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "checkbox", "label": "<?php echo tr('Indirizzo predefinito'); ?>", "name": "main", "value": "$main$", "help": "<?php echo tr('Account da utilizzare per l\'invio di tutte le email dal gestionale.'); ?>" ]}
|
||||
{[ "type": "checkbox", "label": "<?php echo tr('Indirizzo predefinito'); ?>", "name": "predefined", "value": "$predefined$", "help": "<?php echo tr('Account da utilizzare per l\'invio di tutte le email dal gestionale.'); ?>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
13
src/API.php
13
src/API.php
@ -143,11 +143,13 @@ class API extends \Util\Singleton
|
||||
$query = $database->select($table, $select, $where, $order, [], true);
|
||||
}
|
||||
|
||||
$response['records'] = $database->fetchArray($query.' LIMIT '.($page * $length).', '.$length, $parameters);
|
||||
$count = $database->fetchNum($query, $parameters);
|
||||
if (!empty($query)) {
|
||||
$response['records'] = $database->fetchArray($query.' LIMIT '.($page * $length).', '.$length, $parameters);
|
||||
$count = $database->fetchNum($query, $parameters);
|
||||
|
||||
$response['total-count'] = $count;
|
||||
$response['pages'] = ceil($count / $length);
|
||||
$response['total-count'] = $count;
|
||||
$response['pages'] = ceil($count / $length);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// Log dell'errore
|
||||
$logger = logger();
|
||||
@ -291,7 +293,8 @@ class API extends \Util\Singleton
|
||||
|
||||
foreach ($operations as $operation) {
|
||||
// Individua la tipologia e il modulo delle operazioni
|
||||
$module = basename(dirname(dirname($operation)));
|
||||
$path = explode('/api/', $operation)[0];
|
||||
$module = explode('modules/', $path)[1];
|
||||
$kind = basename($operation, '.php');
|
||||
|
||||
$resources[$kind] = isset($resources[$kind]) ? (array) $resources[$kind] : [];
|
||||
|
@ -211,11 +211,20 @@ $(document).ready(function(){
|
||||
};
|
||||
|
||||
$("#'.$attachment_id.' #upload").click(function(){
|
||||
$("#'.$attachment_id.' #upload-form").ajaxSubmit({
|
||||
$form = $("#'.$attachment_id.' #upload-form");
|
||||
|
||||
if($form.find("input[name=nome_allegato]").val() == "" || $form.find("input[name=blob]").val() == "") {
|
||||
swal({
|
||||
type: "error",
|
||||
title: "'.tr('Errore').'",
|
||||
text: "'.tr('Alcuni campi obbligatori non sono stati compilati correttamente.').'",
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$form.ajaxSubmit({
|
||||
url: globals.rootdir + "/actions.php",
|
||||
beforeSubmit: function(arr, $form, options) {
|
||||
return $form.find("input[name=nome_allegato]").val() && $form.find("input[name=blob]").val();
|
||||
},
|
||||
data: data,
|
||||
type: "post",
|
||||
uploadProgress: function(event, position, total, percentComplete) {
|
||||
|
@ -44,8 +44,8 @@ class Mail extends PHPMailer\PHPMailer\PHPMailer
|
||||
$result = MailAccount::get($account);
|
||||
|
||||
if (empty($return)) {
|
||||
$result = $accounts->first(function ($item) use ($group) {
|
||||
return !empty($item->main);
|
||||
$result = $accounts->first(function ($item) {
|
||||
return !empty($item->predefined);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,8 @@ return [
|
||||
'zz_fields',
|
||||
'zz_files',
|
||||
'zz_groups',
|
||||
'zz_group_module',
|
||||
'zz_group_view',
|
||||
'zz_logs',
|
||||
'zz_modules',
|
||||
'zz_operations',
|
||||
|
Loading…
x
Reference in New Issue
Block a user