mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-18 20:40:36 +01:00
Merge branch 'master' into master
This commit is contained in:
commit
21b88129b8
@ -46,7 +46,7 @@ try {
|
||||
// Richiesta GET (ottenimento elementi)
|
||||
case 'GET':
|
||||
// Risorsa specificata
|
||||
if (!empty($request)) {
|
||||
if (count($request) > 1) {
|
||||
$result = $api->retrieve($request);
|
||||
}
|
||||
|
||||
|
@ -583,6 +583,9 @@ input.small-width {
|
||||
.callout a{
|
||||
text-decoration: none;
|
||||
}
|
||||
.dropdown-menu{
|
||||
min-width: 130px;
|
||||
}
|
||||
/*fix per tabs editor */
|
||||
.nav-tabs-custom > .nav-tabs > li{
|
||||
border-top: 3px solid #ddd;
|
||||
|
@ -5,6 +5,7 @@ $db_host = '|host|';
|
||||
$db_username = '|username|';
|
||||
$db_password = '|password|';
|
||||
$db_name = '|database|';
|
||||
//$port = '|port|';
|
||||
|
||||
// Percorso della cartella di backup
|
||||
$backup_dir = __DIR__.'/backup/';
|
||||
|
6
core.php
6
core.php
@ -127,7 +127,11 @@ $dbo = Database::getConnection();
|
||||
// Controllo sulla presenza dei permessi di accesso basilari
|
||||
$continue = $dbo->isInstalled() && !Update::isUpdateAvailable() && (Auth::check() || API::isAPIRequest());
|
||||
|
||||
if (!$continue && getURLPath() != slashes(ROOTDIR.'/index.php')) {
|
||||
if (!empty($skip_permissions)) {
|
||||
Permissions::skip();
|
||||
}
|
||||
|
||||
if (!$continue && getURLPath() != slashes(ROOTDIR.'/index.php') && !Permissions::getSkip()) {
|
||||
if (Auth::check()) {
|
||||
Auth::logout();
|
||||
}
|
||||
|
@ -9,11 +9,11 @@ if (Auth::check()) {
|
||||
</aside><!-- /.content-wrapper -->
|
||||
|
||||
<footer class="main-footer">
|
||||
<a class="hidden-xs" href="https://www.openstamanager.com" title="'.tr('Il gestionale open source per l\'assistenza tecnica e la fatturazione').'." target="_blank"><strong>'.tr('OpenSTAManager').'</strong></a>
|
||||
<span class="pull-right hidden-xs">
|
||||
<strong>'.tr('Versione').' '.$version.'</strong>
|
||||
<strong>'.tr('Versione').'</strong> '.$version.'
|
||||
<small class="text-muted">('.(!empty($revision) ? $revision : tr('In sviluppo')).')</small>
|
||||
</span>
|
||||
'.tr('OpenSTAManager').'
|
||||
</footer>
|
||||
|
||||
<div class="modal fade" id="bs-popup" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="true"></div>
|
||||
|
@ -483,7 +483,7 @@ if (empty($creation) && (!file_exists('config.inc.php') || !$valid_config)) {
|
||||
// PARAMETRI
|
||||
echo '
|
||||
<div id="step-3">
|
||||
<a href="http://www.openstamanager.com/contattaci/?subject=Assistenza%20installazione%20OSM" target="_blank" ><img class="pull-right" width="32" src="'.$img.'/help.png" alt="'.tr('Aiuto').'" title="'.tr('Contatta il nostro help-desk').'"/></a>
|
||||
<a href="https://www.openstamanager.com/contattaci/?subject=Assistenza%20installazione%20OSM" target="_blank" ><img class="pull-right" width="32" src="'.$img.'/help.png" alt="'.tr('Aiuto').'" title="'.tr('Contatta il nostro help-desk').'"/></a>
|
||||
|
||||
<p>'.tr('Non hai ancora configurato OpenSTAManager').'.</p>
|
||||
<p><small class="help-block">'.tr('Configura correttamente il software con i seguenti parametri (modificabili successivamente dal file _FILE_)', [
|
||||
|
@ -19,7 +19,8 @@ if (!empty($id_plugin)) {
|
||||
|
||||
echo '
|
||||
<h4>
|
||||
'.$element['name'];
|
||||
<span class="'.(!empty($element['help']) ? ' tip' : '').'"'.(!empty($element['help']) ? ' title="'.prepareToField($element['help']).'" data-position="bottom"' : '').' >
|
||||
'.$element['title'].(!empty($element['help']) ? ' <i class="fa fa-question-circle-o"></i>' : '').'</span>';
|
||||
|
||||
if (file_exists($docroot.'/plugins/'.$element['directory'].'/add.php')) {
|
||||
echo '
|
||||
@ -141,6 +142,8 @@ if (!empty($module_options) && $module_options != 'menu' && $module_options != '
|
||||
|
||||
<tfoot>
|
||||
<tr>';
|
||||
echo '
|
||||
<td></td>';
|
||||
foreach ($total['fields'] as $key => $field) {
|
||||
echo '
|
||||
<td></td>';
|
||||
|
@ -176,7 +176,7 @@ if (Auth::check()) {
|
||||
<div id="tiny-loader" style="display:none;"></div>
|
||||
|
||||
<header class="main-header">
|
||||
<a href="https://www.openstamanager.com" class="logo" target="_blank">
|
||||
<a href="https://www.openstamanager.com" class="logo" title="'.tr('Il gestionale open source per l\'assistenza tecnica e la fatturazione').'" target="_blank">
|
||||
<!-- mini logo for sidebar mini 50x50 pixels -->
|
||||
<span class="logo-mini">'.tr('OSM').'</span>
|
||||
<!-- logo for regular state and mobile devices -->
|
||||
|
@ -720,7 +720,7 @@ function start_datatables() {
|
||||
}
|
||||
},
|
||||
footerCallback: function (row, data, start, end, display) {
|
||||
var i = 0;
|
||||
var i = -1;
|
||||
this.api().columns().every(function () {
|
||||
if (sum.summable[i] != undefined) {
|
||||
$(this.footer()).addClass("text-right");
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$upload_dir = $docroot.'/files/'.Modules::get('Articoli')['directory'];
|
||||
|
||||
switch (post('op')) {
|
||||
case 'update':
|
||||
$codice = post('codice');
|
||||
|
@ -25,7 +25,7 @@ switch ($resource) {
|
||||
($fatture[$i]['n2_fattura'] != '') ? $n_fattura = $fatture[$i]['n2_fattura'] : $n_fattura = $fatture[$i]['n_fattura'];
|
||||
|
||||
$id_module = Modules::get('Fatture di vendita')['id'];
|
||||
echo "<tr><td class='first_cell text-left'><a href='".ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fattura num. ".$n_fattura."</a></td>\n";
|
||||
echo "<tr><td class='first_cell text-left'><a href='".ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fatt. n. ".$n_fattura."</a></td>\n";
|
||||
|
||||
echo "<td class='table_cell text-left'>".Translator::dateToLocale($fatture[$i]['data_fattura'])."</td>\n";
|
||||
echo "<td class='table_cell text-right'>".Translator::numberToLocale($fatture[$i]['costo_unitario'])." €</td></tr>\n";
|
||||
@ -55,7 +55,7 @@ switch ($resource) {
|
||||
($fatture[$i]['n2_fattura'] != '') ? $n_fattura = $fatture[$i]['n2_fattura'] : $n_fattura = $fatture[$i]['n_fattura'];
|
||||
|
||||
$id_module = Modules::get('Fatture di vendita')['id'];
|
||||
echo "<tr><td class='first_cell text-left'><a href='".ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fattura num. ".$n_fattura."</a></td>\n";
|
||||
echo "<tr><td class='first_cell text-left'><a href='".ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fatt. n. ".$n_fattura."</a></td>\n";
|
||||
|
||||
echo "<td class='table_cell text-left'>".Translator::dateToLocale($fatture[$i]['data_fattura'])."</td>\n";
|
||||
echo "<td class='table_cell text-right'>".Translator::numberToLocale($fatture[$i]['costo_unitario'])." €</td></tr>\n";
|
||||
@ -85,7 +85,7 @@ switch ($resource) {
|
||||
($fatture[$i]['n2_fattura'] != '') ? $n_fattura = $fatture[$i]['n2_fattura'] : $n_fattura = $fatture[$i]['n_fattura'];
|
||||
|
||||
$id_module = Modules::get('Fatture di acquisto')['id'];
|
||||
echo "<tr><td class='first_cell text-left'><a href='".ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fattura num. ".$n_fattura."</a></td>\n";
|
||||
echo "<tr><td class='first_cell text-left'><a href='".ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fatt. n. ".$n_fattura."</a></td>\n";
|
||||
|
||||
echo "<td class='table_cell text-left'>".Translator::dateToLocale($fatture[$i]['data_fattura'])."</td>\n";
|
||||
echo "<td class='table_cell text-right'>".Translator::numberToLocale($fatture[$i]['costo_unitario'])." €</td></tr>\n";
|
||||
|
@ -46,13 +46,22 @@ $_SESSION['superselect']['id_categoria'] = $records[0]['id_categoria'];
|
||||
{[ "type": "number", "label": "<?php echo tr('Quantità'); ?>", "name": "qta", "required": 1, "value": "$qta$", "readonly": 1, "decimals": "qta", "min-value": "undefined" ]}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
{[ "type": "checkbox", "label": "<?php echo tr('Modifica quantità manualmente'); ?>", "name": "qta_manuale", "value": 0, "help": "<?php echo tr('Seleziona per modificare manualmente la quantità'); ?>", "placeholder": "<?php echo tr('Quantità manuale'); ?>" ]}
|
||||
{[ "type": "checkbox", "label": "<?php echo tr('Modifica quantità manualmente'); ?>", "name": "qta_manuale", "value": 0, "help": "<?php echo tr('Seleziona per modificare manualmente la quantità'); ?>", "placeholder": "<?php echo tr('Quantità manuale'); ?>", "extra": "<?php echo ($records[0]['servizio']) ? 'disabled': ''; ?>" ]}
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$('#qta_manuale').click(function(){
|
||||
$("#qta").attr("readonly", !$('#qta_manuale').is(":checked"));
|
||||
});
|
||||
$( document ).ready(function() {
|
||||
|
||||
$('#servizio').click(function(){
|
||||
$("#qta_manuale").attr("disabled", $('#servizio').is(":checked"));
|
||||
});
|
||||
|
||||
|
||||
$('#qta_manuale').click(function(){
|
||||
$("#qta").attr("readonly", !$('#qta_manuale').is(":checked"));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@ -132,7 +141,7 @@ $_SESSION['superselect']['id_categoria'] = $records[0]['id_categoria'];
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "checkbox", "label": "<?php echo tr('Questo articolo è un servizio'); ?>", "name": "servizio", "value": "$servizio$", "help": "", "placeholder": "<?php echo tr('Servizio'); ?>" ]}
|
||||
{[ "type": "checkbox", "label": "<?php echo tr('Questo articolo è un servizio'); ?>", "name": "servizio", "value": "$servizio$", "help": "<?php echo tr('Le quantità non saranno considerate'); ?>", "placeholder": "<?php echo tr('Servizio'); ?>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -22,13 +22,13 @@ echo '
|
||||
// Data di partenza
|
||||
echo '
|
||||
<div class="col-md-3">
|
||||
{[ "type": "date", "label": "'.tr('Data dal').'", "name": "data_inizio", "required": 1, "class": "text-center", "value": "-now-" ]}
|
||||
{[ "type": "date", "label": "'.tr('Data dal').'", "name": "data_inizio", "required": 1, "maxlength": 10, "value": "-now-" ]}
|
||||
</div>';
|
||||
|
||||
// Data di fine
|
||||
echo '
|
||||
<div class="col-md-3">
|
||||
{[ "type": "date", "label": "'.tr('Data al').'", "name": "data_fine", "value": "", "min-date": "-now-" ]}
|
||||
{[ "type": "date", "label": "'.tr('Data al').'", "name": "data_fine", "value": "", "maxlength": 10, "min-date": "-now-" ]}
|
||||
</div>';
|
||||
|
||||
echo '
|
||||
|
@ -32,57 +32,73 @@ include_once __DIR__.'/../../core.php';
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- TECNICI -->
|
||||
<div class="panel panel-primary">
|
||||
<!-- TECNICI + MAGAZZINO AUTOMEZZO -->
|
||||
<div class="row">
|
||||
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h3 class="panel-title"><?php echo tr('Tecnici responsabili automezzo'); ?></h3>
|
||||
<!--TECNICI -->
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3 class="panel-title"><?php echo tr('Tecnici responsabili automezzo'); ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h3 class="panel-title"><?php echo tr('Magazzino automezzo'); ?></h3>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12" >
|
||||
<form action="<?php echo $rootdir; ?>/editor.php?id_module=<?php echo Modules::get('Automezzi')['id']; ?>&id_record=<?php echo $id_record; ?>" id="updatetech-form" method="post" role="form">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>">
|
||||
<input type="hidden" name="op" value="">
|
||||
|
||||
<?php
|
||||
include $docroot.'/modules/automezzi/row-list-tecnici.php';
|
||||
?>
|
||||
</form>
|
||||
|
||||
<a href="javascript:;" class="btn btn-sm btn-success pull-right" title="Aggiorna date" onclick="$('#updatetech-form input[name=op]').val('savetech'); $('#updatetech-form').submit();"><i class="fa fa-edit"></i> <?php echo tr('Salva date'); ?></a>
|
||||
|
||||
<div class="pull-left">
|
||||
<a class="btn btn-sm btn-primary" data-href="<?php echo $rootdir; ?>/modules/automezzi/add_tecnico.php?idautomezzo=<?php echo $id_record; ?>" data-toggle="modal" data-title="Aggiungi tecnico" data-target="#bs-popup"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi tecnico'); ?></a><br>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6" style="border-right:1px solid #DDD;">
|
||||
<form action="<?php echo $rootdir; ?>/editor.php?id_module=<?php echo Modules::get('Automezzi')['id']; ?>&id_record=<?php echo $id_record; ?>" id="updatetech-form" method="post" role="form">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>">
|
||||
<input type="hidden" name="op" value="">
|
||||
|
||||
<?php
|
||||
include $docroot.'/modules/automezzi/row-list-tecnici.php';
|
||||
?>
|
||||
</form>
|
||||
|
||||
<a href="javascript:;" class="btn btn-sm btn-success pull-right" title="Aggiorna date" onclick="$('#updatetech-form input[name=op]').val('savetech'); $('#updatetech-form').submit();"><i class="fa fa-edit"></i> <?php echo tr('Salva date'); ?></a>
|
||||
|
||||
<div class="pull-left">
|
||||
<a class="btn btn-sm btn-primary" data-href="<?php echo $rootdir; ?>/modules/automezzi/add_tecnico.php?idautomezzo=<?php echo $id_record; ?>" data-toggle="modal" data-title="Aggiungi tecnico" data-target="#bs-popup"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi tecnico'); ?></a><br>
|
||||
<!-- MAGAZZINO AUTOMEZZO -->
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3 class="panel-title"><?php echo tr('Magazzino automezzo'); ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<?php
|
||||
include $docroot.'/modules/automezzi/row-list-articoli.php';
|
||||
?>
|
||||
|
||||
<div class="col-md-6">
|
||||
<?php
|
||||
include $docroot.'/modules/automezzi/row-list-articoli.php';
|
||||
?>
|
||||
|
||||
<div class="pull-left">
|
||||
<a class="btn btn-sm btn-primary" data-href="<?php echo $rootdir; ?>/modules/automezzi/add_articolo.php?idautomezzo=<?php echo $id_record; ?>" data-toggle="modal" data-title="Aggiungi articoli" data-target="#bs-popup"><i class="fa fa-plus"></i> <?php echo tr('Articolo magazzino'); ?></a><br>
|
||||
<div class="pull-left">
|
||||
<a class="btn btn-sm btn-primary" data-href="<?php echo $rootdir; ?>/modules/automezzi/add_articolo.php?idautomezzo=<?php echo $id_record; ?>" data-toggle="modal" data-title="Aggiungi articoli" data-target="#bs-popup"><i class="fa fa-plus"></i> <?php echo tr('Articolo magazzino'); ?></a><br>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a class="btn btn-danger ask" data-backto="record-list">
|
||||
|
@ -30,13 +30,13 @@ if (!empty($rs_art)) {
|
||||
// Data di inizio
|
||||
echo '
|
||||
<td>
|
||||
{[ "type": "date", "name": "data_inizio['.$r['id'].']", "required": 1, "class": "text-center", "value": "'.$r['data_inizio'].'", "extra": "" ]}
|
||||
{[ "type": "date", "name": "data_inizio['.$r['id'].']", "required": 1, "maxlength": 10, "value": "'.$r['data_inizio'].'", "extra": "" ]}
|
||||
</td>';
|
||||
|
||||
// Data di fine
|
||||
echo '
|
||||
<td>
|
||||
{[ "type": "date", "name": "data_fine['.$r['id'].']", "class": "text-center", "value": "'.$r['data_fine'].'", "min-date": "'.$r['data_inizio'].'", "extra": "" ]}
|
||||
{[ "type": "date", "name": "data_fine['.$r['id'].']", "maxlength": 10, "value": "'.$r['data_fine'].'", "min-date": "'.$r['data_inizio'].'", "extra": "" ]}
|
||||
</td>';
|
||||
|
||||
// Pulsanti per aggiornamento date tecnici
|
||||
|
@ -19,15 +19,23 @@ echo '
|
||||
// Data
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "date", "label": "'.tr('Data').'", "name": "data", "required": 1, "class": "text-center", "value": "-now-", "extra": "" ]}
|
||||
</div>';
|
||||
|
||||
// Tipo di documento
|
||||
echo '
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Tipo di fattura').'", "name": "idtipodocumento", "required": 1, "values": "query=SELECT * FROM co_tipidocumento WHERE dir=\'entrata\'", "extra": "" ]}
|
||||
</div>';
|
||||
|
||||
|
||||
// Sezionale
|
||||
echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module='.Modules::get('Fatture di vendita')['id'].' ORDER BY name", "value":"'.$_SESSION['m'.Modules::get('Fatture di vendita')['id']]['id_segment'].'", "extra": "" ]}
|
||||
</div>
|
||||
|
||||
</div>';
|
||||
|
||||
// Note
|
||||
|
@ -65,7 +65,7 @@ elseif ($get['op'] == 'del_pianificazione') {
|
||||
|
||||
// Creazione fattura pianificata
|
||||
elseif ($get['op'] == 'addfattura') {
|
||||
include $docroot.'/modules/fatture/modutil.php';
|
||||
include_once $docroot.'/modules/fatture/modutil.php';
|
||||
|
||||
$idpianificazione = $get['idpianificazione'];
|
||||
$descrizione = post('note');
|
||||
@ -78,20 +78,31 @@ elseif ($get['op'] == 'addfattura') {
|
||||
$idanagrafica = $rs[0]['idanagrafica'];
|
||||
|
||||
$dir = 'entrata';
|
||||
$idconto = get_var('Conto predefinito fatture di vendita');
|
||||
$numero = get_new_numerofattura($data);
|
||||
$id_segment = post('id_segment');
|
||||
$numero_esterno = get_new_numerosecondariofattura($data);
|
||||
|
||||
// Tipo di pagamento + banca predefinite dall'anagrafica
|
||||
$query = 'SELECT id, (SELECT idbanca_vendite FROM an_anagrafiche WHERE idanagrafica = '.prepare($idanagrafica).') AS idbanca FROM co_pagamenti WHERE id = (SELECT idpagamento_vendite AS pagamento FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica).')';
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$idpagamento = $rs[0]['id'];
|
||||
$idbanca = $rs[0]['idbanca'];
|
||||
|
||||
// Tipo di pagamento predefinito dall'anagrafica
|
||||
$query = 'SELECT id FROM co_pagamenti WHERE id=(SELECT idpagamento_vendite FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica).')';
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$idpagamento = $rs[0]['id'];
|
||||
// Se la fattura è di vendita e non è stato associato un pagamento predefinito al cliente leggo il pagamento dalle impostazioni
|
||||
if ($dir == 'entrata' && $idpagamento == '') {
|
||||
$idpagamento = get_var('Tipo di pagamento predefinito');
|
||||
}
|
||||
|
||||
// Se non è stato associato un pagamento predefinito al cliente leggo il pagamento dalle impostazioni
|
||||
if ($idpagamento == '') {
|
||||
$idpagamento = get_var('Tipo di pagamento predefinito');
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO co_documenti(numero, numero_esterno, idanagrafica, idtipodocumento, idpagamento, data, idstatodocumento, note, idsede) VALUES ('.prepare($numero).', '.prepare($numero_esterno).', '.prepare($idanagrafica).', '.prepare($idtipodocumento).', '.prepare($idpagamento).', '.prepare($data).", (SELECT `id` FROM `co_statidocumento` WHERE `descrizione`='Bozza'), ".prepare($note).', (SELECT idsede_fatturazione FROM an_anagrafiche WHERE idanagrafica='.prpeare($idanagrafica).') )';
|
||||
// Se non è impostata la banca dell'anagrafica, uso quella del pagamento.
|
||||
if (empty($idbanca)) {
|
||||
// Banca predefinita del pagamento
|
||||
$query = 'SELECT id FROM co_banche WHERE id_pianodeiconti3 = (SELECT idconto_vendite FROM co_pagamenti WHERE id = '.prepare($idpagamento).')';
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$idbanca = $rs[0]['id'];
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO co_documenti(numero, numero_esterno, idanagrafica, idtipodocumento, idpagamento, data, idstatodocumento, note, idsede, id_segment, idconto, idbanca) VALUES ('.prepare($numero).', '.prepare($numero_esterno).', '.prepare($idanagrafica).', '.prepare($idtipodocumento).', '.prepare($idpagamento).', '.prepare($data).", (SELECT `id` FROM `co_statidocumento` WHERE `descrizione`='Bozza'), ".prepare($note).', (SELECT idsede_fatturazione FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica).'), '.prepare($id_segment).', '.prepare($idconto).', '.prepare($idbanca).' )';
|
||||
$dbo->query($query);
|
||||
$iddocumento = $dbo->lastInsertedID();
|
||||
|
||||
@ -322,7 +333,7 @@ else {
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Zone di cui pianificare la fatturazione').'", "name": "idzona[]", "value": "", "values": "query=SELECT id, descrizione FROM an_zone WHERE (id IN (SELECT idzona FROM an_sedi WHERE id IN (SELECT idsede FROM my_impianti WHERE id IN (SELECT idimpianto FROM co_ordiniservizio WHERE idcontratto='.prepare($id_record).')))) OR ( id=(SELECT idzona FROM an_anagrafiche WHERE idanagrafica=(SELECT idanagrafica FROM co_contratti WHERE id='.prepare($id_record).') AND idzona=an_zone.id) ) UNION SELECT 0, \'Altro\'", "multiple": 1, "extra": "onchange=\"$(this).find(\'option\').each( function(){ if( $(this).is(\':selected\') ){ $(\'#zona_\'+$(this).val()).removeClass(\'hide\'); }else{ $(\'#zona_\'+$(this).val()).addClass(\'hide\'); } });\"" ]}
|
||||
{[ "type": "select", "label": "'.tr('Zone per le quali pianificare la fatturazione').'", "name": "idzona[]", "value": "", "values": "query=SELECT id, descrizione FROM an_zone WHERE (id IN (SELECT idzona FROM an_sedi WHERE id IN (SELECT idsede FROM my_impianti WHERE id IN (SELECT idimpianto FROM co_ordiniservizio WHERE idcontratto='.prepare($id_record).')))) OR ( id=(SELECT idzona FROM an_anagrafiche WHERE idanagrafica=(SELECT idanagrafica FROM co_contratti WHERE id='.prepare($id_record).') AND idzona=an_zone.id) ) UNION SELECT 0, \'Altro\'", "multiple": 1, "extra": "onchange=\"$(this).find(\'option\').each( function(){ if( $(this).is(\':selected\') ){ $(\'#zona_\'+$(this).val()).removeClass(\'hide\'); }else{ $(\'#zona_\'+$(this).val()).addClass(\'hide\'); } });\"" ]}
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
|
@ -22,7 +22,8 @@ echo '
|
||||
<hr>';
|
||||
|
||||
// Righe inserite
|
||||
$qp = "SELECT *, (SELECT SUM(subtotale) FROM co_righe2_contratti WHERE idcontratto=co_ordiniservizio_pianificazionefatture.idcontratto) AS budget_contratto, DATE_FORMAT( data_scadenza, '%m-%Y') AS mese, (SELECT idanagrafica FROM co_contratti WHERE id=idcontratto) AS idcliente, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=(SELECT idanagrafica FROM co_contratti WHERE id=idcontratto)) AS ragione_sociale, (SELECT descrizione FROM an_zone WHERE id=co_ordiniservizio_pianificazionefatture.idzona) AS zona FROM co_ordiniservizio_pianificazionefatture WHERE idcontratto IN( SELECT id FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE pianificabile = 1) ) AND co_ordiniservizio_pianificazionefatture.iddocumento=0 ORDER BY DATE_FORMAT( data_scadenza, '%m-%Y') ASC, idcliente ASC";
|
||||
//idcontratto IN( SELECT id FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE pianificabile = 1) ) AND
|
||||
$qp = "SELECT *, (SELECT SUM(subtotale) FROM co_righe2_contratti WHERE idcontratto=co_ordiniservizio_pianificazionefatture.idcontratto) AS budget_contratto, DATE_FORMAT( data_scadenza, '%m-%Y') AS mese, (SELECT idanagrafica FROM co_contratti WHERE id=idcontratto) AS idcliente, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=(SELECT idanagrafica FROM co_contratti WHERE id=idcontratto)) AS ragione_sociale, (SELECT descrizione FROM an_zone WHERE id=co_ordiniservizio_pianificazionefatture.idzona) AS zona FROM co_ordiniservizio_pianificazionefatture WHERE co_ordiniservizio_pianificazionefatture.iddocumento=0 ORDER BY DATE_FORMAT( data_scadenza, '%m-%Y') ASC, idcliente ASC";
|
||||
$rsp = $dbo->fetchArray($qp);
|
||||
|
||||
if (!empty($rsp)) {
|
||||
@ -123,10 +124,9 @@ if (!empty($rsp)) {
|
||||
echo '
|
||||
<td>';
|
||||
if (empty($r['idintervento'])) {
|
||||
echo "
|
||||
<a class='btn btn-primary' title=\"Crea fattura\" onclick=\"launch_modal( 'Crea fattura', '".$rootdir.'/add.php?id_module='.Modules::get('Fatture di vendita')['id'].'&id_record='.$r['idcontratto'].'&idpianificazione='.$r['id'].'&importo='.$importo.'&n_rata='.$n_rata[$r['idzona']][$r['idcontratto']]."', '1' );\">
|
||||
<i class='fa fa-euro'></i>
|
||||
</a>";
|
||||
echo '<button type="button" class="btn btn-primary btn-sm" onclick="launch_modal( \'Crea fattura\', \''.$rootdir.'/modules/contratti/plugins/addfattura.php?idcontratto='.$r['idcontratto'].'&idpianificazione='.$r['id'].'&importo='.$importo.'&n_rata='.$n_rata[$r['idzona']][$r['idcontratto']].'\', 1 );">
|
||||
<i class="fa fa-euro"></i> Crea fattura
|
||||
</button>';
|
||||
}
|
||||
echo '
|
||||
</td>
|
||||
|
@ -682,12 +682,13 @@ if (get_var('Utilizzare i tooltip sul calendario') == '1') {
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#calendar').fullCalendar('option', 'contentHeight', 'auto');
|
||||
}
|
||||
});
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
$('#calendar').fullCalendar('option', 'contentHeight', 'auto');
|
||||
},
|
||||
events: {
|
||||
url: globals.rootdir + "/modules/dashboard/ajaxreq.php?op=get_current_month",
|
||||
|
@ -1235,6 +1235,10 @@ switch (post('op')) {
|
||||
if (!empty($id_record) && isset($post['idarticolo'])) {
|
||||
$idriga = post('idriga');
|
||||
$idarticolo = post('idarticolo');
|
||||
|
||||
// Leggo se la riga è collegata a un ddt, per aggiornargli lo stato
|
||||
$rs = $dbo->fetchArray('SELECT qta, descrizione, idarticolo, idddt, idiva FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND id='.prepare($idriga));
|
||||
$idddt = $rs[0]['idddt'];
|
||||
|
||||
if (!rimuovi_articolo_dafattura($idarticolo, $id_record, $idriga)) {
|
||||
$_SESSION['errors'][] = tr('Alcuni serial number sono già stati utilizzati!');
|
||||
@ -1243,6 +1247,15 @@ switch (post('op')) {
|
||||
}
|
||||
|
||||
if ($dbo->query('DELETE FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND id='.prepare($idriga))) {
|
||||
if( !empty($idddt) ){
|
||||
// Se nella fattura non c'é più il ddt rimosso, aggiorno lo stato del ddt in "Bozza"
|
||||
$rs = $dbo->fetchArray('SELECT id FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND idddt='.prepare($idddt));
|
||||
|
||||
if( sizeof($rs) == 0 ){
|
||||
$dbo->query('UPDATE dt_ddt SET idstatoddt=(SELECT id FROM dt_statiddt WHERE descrizione="Bozza") WHERE id = '.prepare($idddt));
|
||||
}
|
||||
}
|
||||
|
||||
// Ricalcolo inps, ritenuta e bollo
|
||||
if ($dir == 'entrata') {
|
||||
ricalcola_costiagg_fattura($id_record);
|
||||
@ -1363,6 +1376,7 @@ switch (post('op')) {
|
||||
// Se la riga è stata creata da un ordine, devo riportare la quantità evasa nella tabella degli ordini
|
||||
// al valore di prima, riaggiungendo la quantità che sto togliendo
|
||||
$rs = $dbo->fetchArray('SELECT qta, descrizione, idarticolo, idordine, idiva FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND id='.prepare($idriga));
|
||||
$idordine = $rs[0]['idordine'];
|
||||
|
||||
// Rimpiazzo la quantità negli ordini
|
||||
$dbo->query('UPDATE or_righe_ordini SET qta_evasa=qta_evasa-'.$rs[0]['qta'].' WHERE descrizione='.prepare($rs[0]['descrizione']).' AND idarticolo='.prepare($rs[0]['idarticolo']).' AND idordine='.prepare($rs[0]['idordine']).' AND idiva='.prepare($rs[0]['idiva']));
|
||||
@ -1370,6 +1384,7 @@ switch (post('op')) {
|
||||
// Se la riga è stata creata da un ddt, devo riportare la quantità evasa nella tabella dei ddt
|
||||
// al valore di prima, riaggiungendo la quantità che sto togliendo
|
||||
$rs = $dbo->fetchArray('SELECT qta, descrizione, idarticolo, idddt, idiva FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND id='.prepare($idriga));
|
||||
$idddt = $rs[0]['idddt'];
|
||||
|
||||
// Rimpiazzo la quantità nei ddt
|
||||
$dbo->query('UPDATE dt_righe_ddt SET qta_evasa=qta_evasa-'.$rs[0]['qta'].' WHERE descrizione='.prepare($rs[0]['descrizione']).' AND idarticolo='.prepare($rs[0]['idarticolo']).' AND idddt='.prepare($rs[0]['idddt']).' AND idiva='.prepare($rs[0]['idiva']));
|
||||
@ -1377,6 +1392,15 @@ switch (post('op')) {
|
||||
$query = 'DELETE FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND id='.prepare($idriga);
|
||||
|
||||
if ($dbo->query($query)) {
|
||||
if( !empty($idddt) ){
|
||||
// Se nella fattura non c'é più il ddt rimosso, aggiorno lo stato del ddt in "Bozza"
|
||||
$rs = $dbo->fetchArray('SELECT id FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND idddt='.prepare($idddt));
|
||||
|
||||
if( sizeof($rs) == 0 ){
|
||||
$dbo->query('UPDATE dt_ddt SET idstatoddt=(SELECT id FROM dt_statiddt WHERE descrizione="Bozza") WHERE id = '.prepare($idddt));
|
||||
}
|
||||
}
|
||||
|
||||
// Ricalcolo inps, ritenuta e bollo
|
||||
if ($dir == 'entrata') {
|
||||
ricalcola_costiagg_fattura($id_record);
|
||||
|
@ -11,7 +11,7 @@ function get_new_numerofattura($data)
|
||||
|
||||
if ($dir == 'uscita') {
|
||||
// recupero maschera per questo segmento
|
||||
$rs_maschera = $dbo->fetchArray("SELECT pattern FROM zz_segments WHERE id = '".$id_segment."'");
|
||||
$rs_maschera = $dbo->fetchArray('SELECT pattern FROM zz_segments WHERE id = '.prepare($id_segment));
|
||||
// esempio: ####/YY
|
||||
$maschera = $rs_maschera[0]['pattern'];
|
||||
|
||||
@ -19,13 +19,14 @@ function get_new_numerofattura($data)
|
||||
preg_match('/[#]+/', $maschera, $m1);
|
||||
preg_match('/[Y]+/', $maschera, $m2);
|
||||
|
||||
$query = "SELECT numero FROM co_documenti WHERE DATE_FORMAT(data,'%Y') = ".prepare(date('Y', strtotime($data)))." AND id_segment = '".$id_segment."'";
|
||||
$query = "SELECT numero FROM co_documenti WHERE DATE_FORMAT(data,'%Y') = ".prepare(date('Y', strtotime($data))).' AND id_segment = '.prepare($id_segment);
|
||||
|
||||
$pos1 = strpos($maschera, $m1[0]);
|
||||
if ($pos1 == 0):
|
||||
$query .= ' ORDER BY CAST(numero AS UNSIGNED) DESC LIMIT 0,1'; else:
|
||||
if ($pos1 == 0) {
|
||||
$query .= ' ORDER BY CAST(numero AS UNSIGNED) DESC LIMIT 0,1';
|
||||
} else {
|
||||
$query .= ' ORDER BY numero DESC LIMIT 0,1';
|
||||
endif;
|
||||
}
|
||||
|
||||
$rs_ultima_fattura = $dbo->fetchArray($query);
|
||||
|
||||
@ -51,7 +52,7 @@ function get_new_numerosecondariofattura($data)
|
||||
global $id_segment;
|
||||
|
||||
// recupero maschera per questo segmento
|
||||
$rs_maschera = $dbo->fetchArray("SELECT pattern FROM zz_segments WHERE id = '".$id_segment."'");
|
||||
$rs_maschera = $dbo->fetchArray('SELECT pattern FROM zz_segments WHERE id = '.prepare($id_segment));
|
||||
// esempio: ####/YY
|
||||
$maschera = $rs_maschera[0]['pattern'];
|
||||
|
||||
@ -59,16 +60,17 @@ function get_new_numerosecondariofattura($data)
|
||||
preg_match('/[#]+/', $maschera, $m1);
|
||||
preg_match('/[Y]+/', $maschera, $m2);
|
||||
|
||||
$query = "SELECT numero_esterno FROM co_documenti WHERE DATE_FORMAT(data,'%Y') = ".prepare(date('Y', strtotime($data)))." AND id_segment='".$id_segment."'";
|
||||
$query = "SELECT numero_esterno FROM co_documenti WHERE DATE_FORMAT(data,'%Y') = ".prepare(date('Y', strtotime($data))).' AND id_segment='.prepare($id_segment);
|
||||
// Marzo 2017
|
||||
// nel caso ci fossero lettere prima della maschera ### per il numero (es. FT-0001-2017)
|
||||
// è necessario l'ordinamento alfabetico "ORDER BY numero_esterno" altrimenti
|
||||
// nel caso di maschere del tipo 001-2017 è necessario l'ordinamento numerico "ORDER BY CAST(numero_esterno AS UNSIGNED)"
|
||||
$pos1 = strpos($maschera, $m1[0]);
|
||||
if ($pos1 == 0):
|
||||
$query .= ' ORDER BY CAST(numero_esterno AS UNSIGNED) DESC LIMIT 0,1'; else:
|
||||
if ($pos1 == 0) {
|
||||
$query .= ' ORDER BY CAST(numero_esterno AS UNSIGNED) DESC LIMIT 0,1';
|
||||
} else {
|
||||
$query .= ' ORDER BY numero_esterno DESC LIMIT 0,1';
|
||||
endif;
|
||||
}
|
||||
|
||||
$rs_ultima_fattura = $dbo->fetchArray($query);
|
||||
|
||||
@ -286,7 +288,7 @@ function aggiungi_movimento($iddocumento, $dir, $primanota = 0)
|
||||
// Lettura iva delle righe in fattura
|
||||
$query = 'SELECT iva FROM co_righe_documenti WHERE iddocumento='.prepare($iddocumento);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$iva_fattura = sum( array_column($rs, 'iva'), null, 2 ) + $iva_rivalsainps - $iva_indetraibile_fattura;
|
||||
$iva_fattura = sum(array_column($rs, 'iva'), null, 2) + $iva_rivalsainps - $iva_indetraibile_fattura;
|
||||
|
||||
// Imposto i segni + e - in base se la fattura è di acquisto o vendita
|
||||
if ($dir == 'uscita') {
|
||||
@ -450,11 +452,11 @@ function aggiungi_movimento($iddocumento, $dir, $primanota = 0)
|
||||
/**
|
||||
* Funzione per generare un nuovo codice per il mastrino.
|
||||
*/
|
||||
function get_new_idmastrino()
|
||||
function get_new_idmastrino($table = 'co_movimenti')
|
||||
{
|
||||
global $dbo;
|
||||
|
||||
$query = 'SELECT MAX(idmastrino) AS maxidmastrino FROM co_movimenti';
|
||||
$query = 'SELECT MAX(idmastrino) AS maxidmastrino FROM '.$table;
|
||||
$rs = $dbo->fetchArray($query);
|
||||
|
||||
return intval($rs[0]['maxidmastrino']) + 1;
|
||||
@ -756,10 +758,6 @@ function rimuovi_articolo_dafattura($idarticolo, $iddocumento, $idrigadocumento)
|
||||
return true;
|
||||
}
|
||||
|
||||
function rimuovi_riga($iddocumento, $idriga)
|
||||
{
|
||||
}
|
||||
|
||||
function aggiorna_sconto($tables, $fields, $id_record, $options = [])
|
||||
{
|
||||
$dbo = Database::getConnection();
|
||||
@ -778,17 +776,17 @@ function aggiorna_sconto($tables, $fields, $id_record, $options = [])
|
||||
|
||||
if (!empty($sconto[0]['sconto_globale'])) {
|
||||
if ($sconto[0]['tipo_sconto_globale'] == 'PRC') {
|
||||
$rs = $dbo->fetchArray('SELECT SUM(subtotale - sconto) AS imponibile, SUM(iva) AS iva FROM (SELECT '.$tables['row'].'.subtotale, '.$tables['row'].'.sconto, '.$tables['row'].'.iva FROM '.$tables['row'].' WHERE '.$fields['row'].'='.prepare($id_record).') AS t');
|
||||
$rs = $dbo->fetchArray('SELECT SUM(subtotale - sconto) AS imponibile, SUM(iva) AS iva FROM (SELECT '.$tables['row'].'.subtotale, '.$tables['row'].'.sconto, '.$tables['row'].'.iva FROM '.$tables['row'].' WHERE '.$fields['row'].'='.prepare($id_record).') AS t');
|
||||
$subtotale = $rs[0]['imponibile'];
|
||||
$iva += $rs[0]['iva'] / 100 * $sconto[0]['sconto_globale'];
|
||||
$subtotale = -$subtotale / 100 * $sconto[0]['sconto_globale'];
|
||||
|
||||
$descrizione = $descrizione.' '.Translator::numberToLocale($sconto[0]['sconto_globale']).'%';
|
||||
$descrizione = $descrizione.' '.Translator::numberToLocale($sconto[0]['sconto_globale']).'%';
|
||||
} else {
|
||||
$rs = $dbo->fetchArray('SELECT SUM(subtotale - sconto) AS imponibile, SUM(iva) AS iva FROM (SELECT '.$tables['row'].'.subtotale, '.$tables['row'].'.sconto, '.$tables['row'].'.iva FROM '.$tables['row'].' WHERE '.$fields['row'].'='.prepare($id_record).') AS t');
|
||||
$rs = $dbo->fetchArray('SELECT SUM(subtotale - sconto) AS imponibile, SUM(iva) AS iva FROM (SELECT '.$tables['row'].'.subtotale, '.$tables['row'].'.sconto, '.$tables['row'].'.iva FROM '.$tables['row'].' WHERE '.$fields['row'].'='.prepare($id_record).') AS t');
|
||||
$subtotale = $rs[0]['imponibile'];
|
||||
$iva += $sconto[0]['sconto_globale'] * $rs[0]['iva'] / $subtotale;
|
||||
|
||||
$iva += $sconto[0]['sconto_globale'] * $rs[0]['iva'] / $subtotale;
|
||||
|
||||
$subtotale = -$sconto[0]['sconto_globale'];
|
||||
}
|
||||
|
||||
@ -849,3 +847,28 @@ function seriali_non_rimuovibili($field, $id_riga, $dir)
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
function calcola_sconto($data)
|
||||
{
|
||||
if ($data['tipo'] == 'PRC') {
|
||||
$result = 0;
|
||||
|
||||
$price = floatval($data['prezzo']);
|
||||
|
||||
$percentages = explode('+', $data['sconto']);
|
||||
foreach ($percentages as $percentage) {
|
||||
$discount = $price / 100 * floatval($percentage);
|
||||
|
||||
$result += $discount;
|
||||
$price -= $discount;
|
||||
}
|
||||
} else {
|
||||
$result = floatval($data['sconto']);
|
||||
}
|
||||
|
||||
if (!empty($data['qta'])) {
|
||||
$result = $result * $data['qta'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ $can_edit_prezzi = (in_array('Amministratori', $gruppi)) || (get_var('Mostra i p
|
||||
$idriga = get('idriga');
|
||||
$idautomezzo = (get('idautomezzo') == 'undefined') ? '' : get('idautomezzo');
|
||||
|
||||
$_SESSION['superselect']['idintervento'] = get('id_record');
|
||||
|
||||
// Lettura idanagrafica cliente e percentuale di sconto/rincaro in base al listino
|
||||
$rs = $dbo->fetchArray('SELECT idanagrafica FROM in_interventi WHERE id='.prepare($id_record));
|
||||
|
||||
|
@ -106,7 +106,7 @@ echo '
|
||||
<!-- SCONTO -->
|
||||
<div class="row">
|
||||
<div class="col-md-4 pull-right">
|
||||
{[ "type": "number", "label": "'.tr('Sconto incondizionato').'", "name": "sconto_globale", "value": "'.$sconto.'", "icon-after": "choice|untprc|'.$tipo_sconto.'", "extra": "'.$readonly.'" ]}
|
||||
{[ "type": "number", "label": "'.tr('Sconto incondizionato').'", "name": "sconto_globale", "value": "'.$sconto.'", "icon-after": "choice|untprc|'.$tipo_sconto.'|'.$readonly.'", "extra": "'.$readonly.'" ]}
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
|
@ -216,7 +216,7 @@ if (!empty($rs2)) {
|
||||
<td style="border-right:1px solid #aaa;">';
|
||||
if ($user['idanagrafica'] == 0 || $show_costi) {
|
||||
echo '
|
||||
{[ "type": "number", "name": "sconto['.$id.']", "value": "'.$sconto_unitario.'", "icon-after": "choice|untprc|'.$tipo_sconto.'", "class": "small-width", "extra": "'.$readonly.'" ]}';
|
||||
{[ "type": "number", "name": "sconto['.$id.']", "value": "'.$sconto_unitario.'", "icon-after": "choice|untprc|'.$tipo_sconto.'|'.$readonly.'", "class": "small-width", "extra": "'.$readonly.'" ]}';
|
||||
} else {
|
||||
echo '
|
||||
<input type="hidden" name="sconto['.$id.']" value="'.Translator::numberToLocale($sconto_unitario).'" />
|
||||
@ -231,7 +231,7 @@ if (!empty($rs2)) {
|
||||
<td style="border-right:1px solid #aaa;">';
|
||||
if ($user['idanagrafica'] == 0 || $show_costi) {
|
||||
echo '
|
||||
{[ "type": "number", "name": "scontokm['.$id.']", "value": "'.$scontokm_unitario.'", "icon-after": "choice|untprc|'.$tipo_scontokm.'", "class": "small-width", "extra": "'.$readonly.'" ]}';
|
||||
{[ "type": "number", "name": "scontokm['.$id.']", "value": "'.$scontokm_unitario.'", "icon-after": "choice|untprc|'.$tipo_scontokm.'|'.$readonly.'", "class": "small-width", "extra": "'.$readonly.'" ]}';
|
||||
} else {
|
||||
echo '
|
||||
<input type="hidden" name="scontokm['.$id.']" value="'.Translator::numberToLocale($scontokm_unitario).'" />
|
||||
|
51
modules/modelli_primanota/actions.php
Normal file
51
modules/modelli_primanota/actions.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
include_once $docroot.'/modules/fatture/modutil.php';
|
||||
|
||||
switch (post('op')) {
|
||||
case 'add':
|
||||
$idmastrino = get_new_idmastrino('co_movimenti_modelli');
|
||||
$descrizione = post('descrizione');
|
||||
|
||||
for ($i = 0; $i < sizeof($post['idconto']); ++$i) {
|
||||
$idconto = post('idconto')[$i];
|
||||
$query = 'INSERT INTO co_movimenti_modelli(idmastrino, descrizione, idconto) VALUES('.prepare($idmastrino).', '.prepare($descrizione).', '.prepare($idconto).')';
|
||||
if ($dbo->query($query)) {
|
||||
$id_record = $dbo->lastInsertedID();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'editriga':
|
||||
$idmastrino = post('idmastrino');
|
||||
$descrizione = post('descrizione');
|
||||
|
||||
// Eliminazione prima nota
|
||||
$dbo->query('DELETE FROM co_movimenti_modelli WHERE idmastrino='.prepare($idmastrino));
|
||||
|
||||
for ($i = 0; $i < sizeof($post['idconto']); ++$i) {
|
||||
$idconto = post('idconto')[$i];
|
||||
$query = 'INSERT INTO co_movimenti_modelli(idmastrino, descrizione, idconto) VALUES('.prepare($idmastrino).', '.prepare($descrizione).', '.prepare($idconto).')';
|
||||
if ($dbo->query($query)) {
|
||||
$id_record = $dbo->lastInsertedID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$idmastrino = post('idmastrino');
|
||||
|
||||
if ($idmastrino != '') {
|
||||
// Eliminazione prima nota
|
||||
$dbo->query('DELETE FROM co_movimenti_modelli WHERE idmastrino='.prepare($idmastrino));
|
||||
|
||||
$_SESSION['infos'][] = tr('Movimento eliminato!');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
76
modules/modelli_primanota/add.php
Normal file
76
modules/modelli_primanota/add.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
?><form action="<?php echo ROOTDIR ?>/editor.php?id_module=<?php echo Modules::get('Modelli prima nota')['id']; ?>" method="post" id="add-form">
|
||||
<input type="hidden" name="op" value="add">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "required": 1, "value": "<?php echo $descrizione; ?>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
// Salvo l'elenco conti in un array (per non fare il ciclo ad ogni riga)
|
||||
|
||||
/*
|
||||
Form di aggiunta riga movimento
|
||||
*/
|
||||
echo '
|
||||
<table class="table table-striped table-condensed table-hover table-bordered"
|
||||
<tr>
|
||||
<th>'.tr('Conto').'</th>
|
||||
</tr>';
|
||||
|
||||
for ($i = 0; $i < 10; ++$i) {
|
||||
|
||||
($i<=1) ? $required = 1 : $required = 0;
|
||||
// Conto
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
{[ "type": "select", "name": "idconto['.$i.']", "value": "';
|
||||
if ($i == 0) {
|
||||
echo $idconto_controparte;
|
||||
} elseif ($i == 1) {
|
||||
echo $idconto_aziendale;
|
||||
}
|
||||
echo '", "ajax-source": "conti", "required": "'.$required.'" ]}
|
||||
</td>';
|
||||
|
||||
echo '
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
?>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready( function(){
|
||||
$('select').on('change', function(){
|
||||
if($(this).parent().parent().find('input[disabled]').length != 1){
|
||||
if($(this).val()) {
|
||||
$(this).parent().parent().find('input').prop("disabled", false);
|
||||
}
|
||||
else{
|
||||
$(this).parent().parent().find('input').prop("disabled", true);
|
||||
$(this).parent().parent().find('input').val("");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</form>
|
||||
|
94
modules/modelli_primanota/edit.php
Normal file
94
modules/modelli_primanota/edit.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
?><form action="" method="post" id="edit-form">
|
||||
<input type="hidden" name="op" value="editriga">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>">
|
||||
<input type="hidden" name="idmastrino" value="<?php echo $records[0]['idmastrino']; ?>">
|
||||
<input type="hidden" name="iddocumento" value="<?php echo $records[0]['iddocumento']; ?>">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "text", "label": "<?php echo tr('Causale predefinita'); ?>", "name": "descrizione", "required": 1, "value": "$descrizione$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
$conti3 = []; // contenitore conti di terzo livello
|
||||
$idmastrino = $records[0]['idmastrino'];
|
||||
|
||||
// Salvo l'elenco conti in un array (per non fare il ciclo ad ogni riga)
|
||||
$query2 = 'SELECT * FROM co_pianodeiconti2';
|
||||
$conti2 = $dbo->fetchArray($query2);
|
||||
for ($x = 0; $x < sizeof($conti2); ++$x) {
|
||||
$query3 = 'SELECT * FROM co_pianodeiconti3 WHERE idpianodeiconti2='.prepare($conti2[$x]['id']);
|
||||
$rs3 = $dbo->fetchArray($query3);
|
||||
for ($y = 0; $y < sizeof($rs3); ++$y) {
|
||||
// Creo un array con le descrizioni dei conti di livello 3 che ha come indice l'id del livello2 e del livello3
|
||||
$conti3[$rs3[$y]['idpianodeiconti2']][$y]['id'] = $rs3[$y]['id'];
|
||||
$conti3[$rs3[$y]['idpianodeiconti2']][$y]['descrizione'] = $conti2[$x]['numero'].'.'.$rs3[$y]['numero'].' '.$rs3[$y]['descrizione'];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Form di modifica riga movimento
|
||||
*/
|
||||
// Lettura movimenti del mastrino selezionato
|
||||
$query = 'SELECT * FROM co_movimenti_modelli WHERE idmastrino='.prepare($records[0]['idmastrino']);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$n = sizeof($rs);
|
||||
|
||||
echo '
|
||||
<table class="table table-striped table-condensed table-hover table-bordered"
|
||||
<tr>
|
||||
<th>'.tr('Conto').'</th>
|
||||
</tr>';
|
||||
|
||||
for ($i = 0; $i < 10; ++$i) {
|
||||
|
||||
($i<=1) ? $required = 1 : $required = 0;
|
||||
|
||||
// Conto
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
{[ "type": "select", "name": "idconto['.$i.']", "value": "'.$rs[$i]['idconto'].'", "ajax-source": "conti", "required": "'.$required.'" ]}
|
||||
</td>';
|
||||
|
||||
echo '
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// Totale per controllare sbilancio
|
||||
|
||||
// Verifica sbilancio
|
||||
echo '
|
||||
</table>';
|
||||
?>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready( function(){
|
||||
$('select').on('change', function(){
|
||||
if($(this).parent().parent().find('input[disabled]').length != 1){
|
||||
if($(this).val()) {
|
||||
$(this).parent().parent().find('input').prop("disabled", false);
|
||||
}
|
||||
else{
|
||||
$(this).parent().parent().find('input').prop("disabled", true);
|
||||
$(this).parent().parent().find('input').val("");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</form>
|
||||
|
||||
<a class="btn btn-danger ask" data-backto="record-list" data-idmastrino="<?php echo $records[0]['idmastrino']; ?>">
|
||||
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
||||
</a>
|
7
modules/modelli_primanota/init.php
Normal file
7
modules/modelli_primanota/init.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
if (isset($id_record)) {
|
||||
$records = $dbo->fetchArray('SELECT * FROM co_movimenti_modelli WHERE id='.prepare($id_record));
|
||||
}
|
@ -4,7 +4,21 @@ include_once __DIR__.'/../../../core.php';
|
||||
|
||||
switch ($resource) {
|
||||
case 'impianti':
|
||||
if (isset($superselect['idanagrafica'])) {
|
||||
if( isset($superselect['idintervento']) ){
|
||||
$query = 'SELECT id, CONCAT(matricola, " - ", nome) AS descrizione FROM my_impianti INNER JOIN my_impianti_interventi ON my_impianti.id=my_impianti_interventi.idimpianto |where| ORDER BY idsede';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = 'id='.prepare($element);
|
||||
}
|
||||
|
||||
$where[] = 'my_impianti_interventi.idintervento='.prepare($superselect['idintervento']);
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = 'nome LIKE '.prepare('%'.$search.'%');
|
||||
$search_fields[] = 'matricola LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
}
|
||||
elseif (isset($superselect['idanagrafica'])) {
|
||||
$query = 'SELECT id, CONCAT(matricola, " - ", nome) AS descrizione FROM my_impianti |where| ORDER BY idsede';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
|
@ -100,13 +100,34 @@ if ($module['name'] == 'Ordini cliente') {
|
||||
</div>
|
||||
|
||||
<div class="pull-right">
|
||||
|
||||
<!-- Stampe -->
|
||||
<?php if ($records[0]['stato'] != 'Evaso') {
|
||||
?>
|
||||
<a class="btn btn-info" data-href="<?php echo $rootdir; ?>/modules/fatture/crea_documento.php?id_module=<?php echo $id_module; ?>&&id_record=<?php echo $id_record; ?>&documento=ddt" data-toggle="modal" data-title="Crea ddt" data-target="#bs-popup" ><i class="fa fa-magic"></i> Crea ddt da ordine...</i></a>
|
||||
<a class="btn btn-info" data-href="<?php echo $rootdir; ?>/modules/fatture/crea_documento.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>&documento=fattura" data-toggle="modal" data-title="Crea fattura" data-target="#bs-popup" ><i class="fa fa-magic"></i> Crea fattura da ordine...</i></a>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
|
||||
if ($records[0]['stato'] != 'Evaso') {
|
||||
|
||||
echo '
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-info dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||
<i class="fa fa-magic"></i> '.tr('Crea subito').'
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li>
|
||||
<a data-href="'.$rootdir.'/modules/fatture/crea_documento.php?id_module='.$id_module.'&id_record='.$id_record.'&documento=ddt" data-toggle="modal" data-title="'.tr('Crea ddt').'" data-target="#bs-popup"><i class="fa fa-file-o"></i> '.tr('ddt').'
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a data-href="'.$rootdir.'/modules/fatture/crea_documento.php?id_module='.$id_module.'&id_record='.$id_record.'&documento=fattura" data-toggle="modal" data-title="'.tr('Crea fattura').'" data-target="#bs-popup"><i class="fa fa-file"></i> '.tr('fattura').'
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>';
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
@ -14,10 +14,8 @@ switch (post('op')) {
|
||||
$costo_orario = $rs[0]['costo_orario'];
|
||||
$costo_diritto_chiamata = $rs[0]['costo_diritto_chiamata'];
|
||||
|
||||
$campo = ($dir == 'entrata') ? 'idpagamento_vendite' : 'idpagamento_acquisti';
|
||||
|
||||
// Verifico se c'è già un agente o un metodo di pagamento collegato all'anagrafica cliente, così lo imposto già
|
||||
$q = 'SELECT idagente, '.$campo.' AS idpagamento FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica);
|
||||
$q = 'SELECT idagente, idpagamento_vendite AS idpagamento FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica);
|
||||
$rs = $dbo->fetchArray($q);
|
||||
$idagente = $rs[0]['idagente'];
|
||||
$idpagamento = $rs[0]['idpagamento'];
|
||||
|
@ -90,6 +90,19 @@ switch (post('op')) {
|
||||
$dbo->query("UPDATE in_interventi SET idstatointervento=(SELECT idstatointervento FROM in_statiintervento WHERE descrizione='Fatturato') WHERE id IN (SELECT idintervento FROM co_preventivi_interventi WHERE idpreventivo=".prepare($rs2[$j]['idpreventivo']).')');
|
||||
}
|
||||
}
|
||||
|
||||
//Creo il modello di prima nota
|
||||
|
||||
if(post('crea_modello')=='1'){
|
||||
$idmastrino = get_new_idmastrino('co_movimenti_modelli');
|
||||
|
||||
for ($i = 0; $i < sizeof($post['idconto']); ++$i) {
|
||||
$idconto = post('idconto')[$i];
|
||||
$query = 'INSERT INTO co_movimenti_modelli(idmastrino, descrizione, idconto) VALUES('.prepare($idmastrino).', '.prepare($descrizione).', '.prepare($idconto).')';
|
||||
$dbo->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'editriga':
|
||||
|
@ -6,6 +6,7 @@ include_once __DIR__.'/../../core.php';
|
||||
<input type="hidden" name="op" value="add">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="iddocumento" value="<?php echo get('iddocumento'); ?>">
|
||||
<input type="hidden" name="crea_modello" id="crea_modello" value="0">
|
||||
|
||||
<?php
|
||||
$idconto = get('idconto');
|
||||
@ -108,6 +109,12 @@ include_once __DIR__.'/../../core.php';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "select", "label": "<?php echo tr('Modello primanota'); ?>", "id": "modello_primanota", "required": 0, "values": "query=SELECT idmastrino AS id, descrizione FROM co_movimenti_modelli GROUP BY idmastrino", "value": "" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
@ -115,7 +122,7 @@ include_once __DIR__.'/../../core.php';
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('Causale'); ?>", "name": "descrizione", "required": 1, "value": "<?php echo $descrizione; ?>" ]}
|
||||
{[ "type": "text", "label": "<?php echo tr('Causale'); ?>", "name": "descrizione", "id": "desc", "required": 1, "value": "<?php echo $descrizione; ?>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -145,7 +152,7 @@ include_once __DIR__.'/../../core.php';
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
{[ "type": "select", "name": "idconto['.$i.']", "value": "';
|
||||
{[ "type": "select", "name": "idconto['.$i.']", "id": "conto'.$i.'", "value": "';
|
||||
if ($i == 0) {
|
||||
echo $idconto_controparte;
|
||||
} elseif ($i == 1) {
|
||||
@ -222,7 +229,8 @@ include_once __DIR__.'/../../core.php';
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
|
||||
<button type='button' class="btn btn-primary" id='btn_crea_modello'><i class="fa fa-plus"></i> <?php echo tr('Aggiungi e crea modello'); ?></button>
|
||||
<button type="submit" class="btn btn-primary" id='btn_submit'><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -239,7 +247,7 @@ include_once __DIR__.'/../../core.php';
|
||||
}
|
||||
else{
|
||||
$(this).parent().parent().find('input').prop("disabled", true);
|
||||
$(this).parent().parent().find('input').val("");
|
||||
$(this).parent().parent().find('input').val("0.00");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -296,11 +304,11 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
if(bilancio == 0){
|
||||
$("#testo_aggiuntivo").removeClass('text-danger').html("");
|
||||
$("button[type=submit]").removeClass('hide');
|
||||
$("#btn_submit").removeClass('hide');
|
||||
}
|
||||
else{
|
||||
$("#testo_aggiuntivo").addClass('text-danger').html("sbilancio di " + bilancio.toLocale() + " €" );
|
||||
$("button[type=submit]").addClass('hide');
|
||||
$("#btn_submit").addClass('hide');
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,6 +318,36 @@ include_once __DIR__.'/../../core.php';
|
||||
$("select[id*=idconto]").click( function(){
|
||||
$("input[id*=dare][value!=''], input[id*=avere][value!='']").keyup();
|
||||
});
|
||||
|
||||
|
||||
$('#modello_primanota').change(function(){
|
||||
var idmastrino = $(this).val();
|
||||
|
||||
if(idmastrino!=''){
|
||||
$('#btn_crea_modello').hide();
|
||||
var causale = $(this).find('option:selected').text();
|
||||
|
||||
$('#desc').val(causale);
|
||||
|
||||
$.get('<?=$rootdir?>/ajax_complete.php?op=get_conti&idmastrino='+idmastrino, function(data){
|
||||
var conti = data.split(',');
|
||||
for(i=0;i<conti.length;i++){
|
||||
var conto = conti[i].split(';');
|
||||
var option = $("<option selected></option>").val(conto[0]).text(conto[1]);
|
||||
$('#conto'+i).selectReset();
|
||||
$('#conto'+i).append(option).trigger('change');
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$('#btn_crea_modello').show();
|
||||
}
|
||||
});
|
||||
|
||||
$('#btn_crea_modello').click(function(){
|
||||
$("#crea_modello").val("1");
|
||||
$("#add-form").submit();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</form>
|
||||
|
20
modules/primanota/ajax/complete.php
Normal file
20
modules/primanota/ajax/complete.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../../core.php';
|
||||
|
||||
switch ($resource) {
|
||||
|
||||
case 'get_conti':
|
||||
$idmastrino = get('idmastrino');
|
||||
$conti = array();
|
||||
$rs_conti = $dbo->fetchArray("SELECT *, (SELECT descrizione FROM co_pianodeiconti3 WHERE id=co_movimenti_modelli.idconto) AS descrizione_conto FROM co_movimenti_modelli WHERE idmastrino=".prepare($idmastrino)." GROUP BY id");
|
||||
|
||||
for($i=0;$i<sizeof($rs_conti);$i++){
|
||||
$conti[$i] = $rs_conti[$i]['idconto'].";".$rs_conti[$i]['descrizione_conto'];
|
||||
}
|
||||
|
||||
echo implode(',', $conti);
|
||||
|
||||
break;
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ include_once __DIR__.'/../../core.php';
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "number", "label": "<?php echo tr('Indetraibile'); ?>", "name": "indetraibile", "value": "", "icon-after": "<i class=\"fa fa-usd\"></i>" ]}
|
||||
{[ "type": "number", "label": "<?php echo tr('Indetraibile'); ?>", "name": "indetraibile", "value": "", "icon-after": "<i class=\"fa fa-percent\"></i>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -93,6 +93,7 @@ switch (filter('op')) {
|
||||
|
||||
if (check_query($post['query'][$c])) {
|
||||
$array = [
|
||||
'name' => $post['name'][$c],
|
||||
'idgruppo' => $post['gruppo'][$c],
|
||||
'idmodule' => $id_record,
|
||||
'clause' => $post['query'][$c],
|
||||
|
@ -217,7 +217,7 @@ if (!empty($options) && $options != 'custom') {
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="text-right">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="button" class="btn btn-info" id="add"><i class="fa fa-plus"></i> '.tr('Aggiungi nuovo campo').'</button>
|
||||
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> '.tr('Salva').'</button>
|
||||
</div>
|
||||
@ -351,8 +351,8 @@ if (!empty($options) && $options != 'custom') {
|
||||
echo '">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
<a data-toggle="collapse" href="#additional-'.$additional['id'].'">'.tr('Filtro _NUM_', [
|
||||
'_NUM_' => $num,
|
||||
<a data-toggle="collapse" href="#additional-'.$additional['id'].'">'.tr('Filtro: _NAME_', [
|
||||
'_NAME_' => $additional['name'],
|
||||
]).'</a>
|
||||
</h3>';
|
||||
if ($editable) {
|
||||
@ -368,16 +368,25 @@ if (!empty($options) && $options != 'custom') {
|
||||
echo '
|
||||
</div>
|
||||
<div id="additional-'.$additional['id'].'" class="box-body collapse">
|
||||
<div class="row">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "'.tr('Query').'", "name": "query['.$num.']", "value": "'.prepareToField($additional['clause']).'"';
|
||||
if (!$editable) {
|
||||
echo ', "readonly": "1"';
|
||||
}
|
||||
echo ' ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<input type="hidden" value="'.$additional['id'].'" name="id['.$num.']">
|
||||
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "'.tr('Name').'", "name": "name['.$num.']", "value": "'.$additional['name'].'" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "textarea", "label": "'.tr('Query').'", "name": "query['.$num.']", "value": "'.prepareToField($additional['clause']).'"';
|
||||
if (!$editable) {
|
||||
echo ', "readonly": "1"';
|
||||
}
|
||||
echo ' ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "'.tr('Gruppo').'", "name": "gruppo['.$num.']", "values": "query=SELECT id, nome AS descrizione FROM zz_groups ORDER BY id ASC", "value": "'.$additional['idgruppo'].'"';
|
||||
@ -402,8 +411,8 @@ if (!empty($options) && $options != 'custom') {
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="text-right">
|
||||
<button type="button" class="btn btn-info" id="add"><i class="fa fa-plus"></i> '.tr('Aggiungi nuovo filtro').'</button>
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="button" class="btn btn-info" id="add_filter"><i class="fa fa-plus"></i> '.tr('Aggiungi nuovo filtro').'</button>
|
||||
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> '.tr('Salva').'</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -419,11 +428,18 @@ if (!empty($options) && $options != 'custom') {
|
||||
<h3 class="box-title">'.tr('Nuovo filtro').'</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "'.tr('Query').'", "name": "query[-id-]" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<input type="hidden" value="" name="id[-id-]">
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "textarea", "label": "'.tr('Query').'", "name": "query[-id-]" ]}
|
||||
{[ "type": "text", "label": "'.tr('Nome').'", "name": "name[-id-]" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
@ -431,7 +447,7 @@ if (!empty($options) && $options != 'custom') {
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "'.tr('Posizione').'", "name": "position[-id-]", "list=\"0\":\"'.tr('WHERE').'\",\"1\": \"'.tr('HAVING').'\"" ]}
|
||||
{[ "type": "select", "label": "'.tr('Posizione').'", "name": "position[-id-]", "values": "list=\"0\":\"'.tr('WHERE').'\",\"1\": \"'.tr('HAVING').'\"", "value": "" ]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
30
src/API.php
30
src/API.php
@ -75,7 +75,8 @@ class API extends \Util\Singleton
|
||||
$select = !empty($request['display']) ? explode(',', substr($request['display'], 1, -1)) : $select;
|
||||
|
||||
// Ricerca personalizzata
|
||||
foreach ((array) $request['filter'] as $key => $value) {
|
||||
$values = isset($request['filter']) ? (array) $request['filter'] : [];
|
||||
foreach ($values as $key => $value) {
|
||||
// Rimozione delle parentesi
|
||||
$value = substr($value, 1, -1);
|
||||
|
||||
@ -84,13 +85,14 @@ class API extends \Util\Singleton
|
||||
}
|
||||
|
||||
// Ordinamento personalizzato
|
||||
foreach ((array) $request['order'] as $value) {
|
||||
$values = isset($request['order']) ? (array) $request['order'] : [];
|
||||
foreach ($values as $value) {
|
||||
$pieces = explode('|', $value);
|
||||
$order[] = empty($pieces[1]) ? $pieces[0] : [$pieces[0] => $pieces[1]];
|
||||
}
|
||||
|
||||
// Paginazione automatica dell'API
|
||||
$page = (int) $request['page'] ?: 0;
|
||||
$page = isset($request['page']) ? (int) $request['page'] : 0;
|
||||
$length = Settings::get('Lunghezza pagine per API');
|
||||
|
||||
$database = Database::getConnection();
|
||||
@ -105,13 +107,22 @@ class API extends \Util\Singleton
|
||||
// Esecuzione delle operazioni personalizzate
|
||||
$filename = DOCROOT.'/modules/'.$resources[$resource].'/api/'.$kind.'.php';
|
||||
include $filename;
|
||||
} elseif (!in_array($resource, explode(',', Settings::get('Tabelle escluse per la sincronizzazione API automatica')))) {
|
||||
} elseif (
|
||||
!in_array($resource, explode(',', Settings::get('Tabelle escluse per la sincronizzazione API automatica')))
|
||||
&& $database->fetchNum('SHOW TABLES WHERE `Tables_in_'.$database->getDatabaseName().'` = '.prepare($resource))
|
||||
) {
|
||||
$table = $resource;
|
||||
|
||||
// Individuazione della colonna AUTO_INCREMENT per l'ordinamento automatico
|
||||
if (empty($order)) {
|
||||
$order[] = $database->fetchArray('SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '.prepare($table)." AND EXTRA LIKE '%AUTO_INCREMENT%' AND TABLE_SCHEMA = ".prepare($database->getDatabaseName()))[0]['COLUMN_NAME'];
|
||||
$column = $database->fetchArray('SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '.prepare($table)." AND EXTRA LIKE '%AUTO_INCREMENT%' AND TABLE_SCHEMA = ".prepare($database->getDatabaseName()));
|
||||
|
||||
if (!empty($column)) {
|
||||
$order[] = $column[0]['COLUMN_NAME'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return self::error('notFound');
|
||||
}
|
||||
|
||||
// Generazione automatica delle query
|
||||
@ -250,6 +261,9 @@ class API extends \Util\Singleton
|
||||
if (!is_array(self::$resources)) {
|
||||
$resources = [];
|
||||
|
||||
// Ignore dei warning
|
||||
$resource = '';
|
||||
|
||||
// File nativi
|
||||
$files = glob(DOCROOT.'/modules/*/api/{retrieve,create,update,delete}.php', GLOB_BRACE);
|
||||
|
||||
@ -272,7 +286,7 @@ class API extends \Util\Singleton
|
||||
$module = basename(dirname(dirname($operation)));
|
||||
$kind = basename($operation, '.php');
|
||||
|
||||
$resources[$kind] = (array) $resources[$kind];
|
||||
$resources[$kind] = isset($resources[$kind]) ? (array) $resources[$kind] : [];
|
||||
|
||||
// Individuazione delle operazioni
|
||||
$api = include $operation;
|
||||
@ -371,6 +385,10 @@ class API extends \Util\Singleton
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' && empty($request)) {
|
||||
$request = Filter::getGET();
|
||||
}
|
||||
|
||||
if (empty($request['token'])) {
|
||||
$request['token'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ class App
|
||||
'search' => $search,
|
||||
'slow' => $slow,
|
||||
'format' => $format,
|
||||
'summable' => [],
|
||||
'summable' => $summable,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,9 @@ class Auth extends \Util\Singleton
|
||||
if (API::isAPIRequest()) {
|
||||
$token = API::getRequest()['token'];
|
||||
|
||||
$id = $database->fetchArray('SELECT `id_utente` FROM `zz_tokens` WHERE `token` = '.prepare($token))[0]['id_utente'];
|
||||
$user = $database->fetchArray('SELECT `id_utente` FROM `zz_tokens` WHERE `enabled` = 1 AND `token` = '.prepare($token));
|
||||
|
||||
$id = !empty($user) ? $user[0]['id_utente'] : null;
|
||||
}
|
||||
// Controllo sulla sessione attiva
|
||||
elseif (!empty($_SESSION['id_utente'])) {
|
||||
|
@ -56,7 +56,10 @@ class Database extends Util\Singleton
|
||||
$host = $temp[0];
|
||||
$port = !empty($temp[1]) ? $temp[1] : null;
|
||||
}
|
||||
|
||||
|
||||
//possibilità di specificare una porta per il servizio mysql diversa dalla standard 3306
|
||||
$port = (!empty(App::getConfig()['port'])) ? App::getConfig()['port'] : $port;
|
||||
|
||||
$this->host = $host;
|
||||
if (!empty($port) && is_int($port * 1)) {
|
||||
$this->port = $port;
|
||||
|
@ -55,8 +55,28 @@ class DateHandler implements HandlerInterface
|
||||
|
||||
// Generazione del codice HTML di default
|
||||
if (empty($result)) {
|
||||
$result = '
|
||||
if (empty($values['label'])) {
|
||||
$result = '
|
||||
<div class="form-group">';
|
||||
}
|
||||
|
||||
if (empty($values['icon-before']) || empty($values['icon-after'])) {
|
||||
$result .= '
|
||||
<div class="input-group">';
|
||||
}
|
||||
|
||||
$result .= '
|
||||
<input |attr|>';
|
||||
|
||||
if (empty($values['icon-before']) || empty($values['icon-after'])) {
|
||||
$result .= '
|
||||
</div>';
|
||||
}
|
||||
|
||||
if (empty($values['label'])) {
|
||||
$result .= '
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -124,6 +124,7 @@ class HTMLWrapper implements WrapperInterface
|
||||
|
||||
$pieces = explode('|', $string);
|
||||
$type = $pieces[1];
|
||||
$extra = $pieces[3];
|
||||
|
||||
if ($type == 'untprc') {
|
||||
$choices = [
|
||||
@ -155,7 +156,7 @@ class HTMLWrapper implements WrapperInterface
|
||||
|
||||
$value = (empty($pieces[2]) || !in_array($pieces[2], array_column($choices, 'id'))) ? $choices[0]['id'] : $pieces[2];
|
||||
|
||||
$result = '{[ "type": "select", "name": "tipo_'.prepareToField($values['name']).'", "value": "'.prepareToField($value).'", "values": '.json_encode($choices).', "class": "no-search" ]}';
|
||||
$result = '{[ "type": "select", "name": "tipo_'.prepareToField($values['name']).'", "value": "'.prepareToField($value).'", "values": '.json_encode($choices).', "class": "no-search", "extra": "'.$extra.'" ]}';
|
||||
|
||||
$result = \HTMLBuilder\HTMLBuilder::replace($result);
|
||||
|
||||
|
@ -42,17 +42,17 @@ $default_header$
|
||||
</td>
|
||||
<td colspan="2" style="height:10mm;padding-top:2mm;">
|
||||
<p class="small-bold">'.tr('Banca di appoggio', [], ['upper' => true]).'</p>
|
||||
<p>$f_appoggiobancario$</p>
|
||||
<p>$appoggiobancario$</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="height:10mm;padding-top:2mm;">
|
||||
<p class="small-bold">'.tr('IBAN').'</p>
|
||||
<p>$f_codiceiban$</p>
|
||||
<p>$codiceiban$</p>
|
||||
</td>
|
||||
<td colspan="2" style="height:10mm;padding-top:2mm;">
|
||||
<p class="small-bold">'.tr('BIC').'</p>
|
||||
<p>$f_bic$</p>
|
||||
<p>$bic$</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -12,13 +12,21 @@ $records = $dbo->fetchArray('SELECT *,
|
||||
(SELECT descrizione FROM dt_porto WHERE id=idporto) AS porto,
|
||||
(SELECT descrizione FROM dt_aspettobeni WHERE id=idaspettobeni) AS aspettobeni,
|
||||
(SELECT descrizione FROM dt_spedizione WHERE id=idspedizione) AS spedizione,
|
||||
(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=idvettore) AS vettore
|
||||
(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=idvettore) AS vettore,
|
||||
(SELECT id FROM co_banche WHERE id=idbanca) AS id_banca,
|
||||
(SELECT nome FROM co_banche WHERE id=idbanca) AS nome_banca,
|
||||
(SELECT iban FROM co_banche WHERE id=idbanca) AS iban_banca,
|
||||
(SELECT bic FROM co_banche WHERE id=idbanca) AS bic_banca
|
||||
FROM co_documenti WHERE id='.prepare($id_record));
|
||||
|
||||
$records[0]['rivalsainps'] = floatval($records[0]['rivalsainps']);
|
||||
$records[0]['ritenutaacconto'] = floatval($records[0]['ritenutaacconto']);
|
||||
$records[0]['bollo'] = floatval($records[0]['bollo']);
|
||||
|
||||
$nome_banca = $records[0]['nome_banca'];
|
||||
$iban_banca = $records[0]['iban_banca'];
|
||||
$bic_banca = $records[0]['bic_banca'];
|
||||
|
||||
$module_name = ($records[0]['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto';
|
||||
|
||||
$id_cliente = $records[0]['idanagrafica'];
|
||||
@ -69,6 +77,9 @@ $custom = [
|
||||
'n_colli' => !empty($records[0]['n_colli']) ? $records[0]['n_colli'] : '',
|
||||
'spedizione' => $records[0]['spedizione'],
|
||||
'vettore' => $records[0]['vettore'],
|
||||
'appoggiobancario' => $nome_banca,
|
||||
'codiceiban' => $iban_banca,
|
||||
'bic' => $bic_banca,
|
||||
];
|
||||
|
||||
// Accesso solo a:
|
||||
|
@ -13,4 +13,51 @@ ALTER TABLE `an_anagrafiche` ADD `pec` VARCHAR(255) NOT NULL AFTER `email`;
|
||||
ALTER TABLE `an_nazioni` ADD `iso2` VARCHAR(2) NOT NULL AFTER `nome`;
|
||||
|
||||
-- ISO 2 per ITALIA (https://it.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
||||
UPDATE `an_nazioni` SET `iso2` = 'IT' WHERE `an_nazioni`.`nome` = 'ITALIA';
|
||||
UPDATE `an_nazioni` SET `iso2` = 'IT' WHERE `an_nazioni`.`nome` = 'ITALIA';
|
||||
|
||||
-- Aggiunto name per i filtri
|
||||
ALTER TABLE `zz_group_module` ADD `name` VARCHAR(255) NOT NULL AFTER `idmodule`;
|
||||
|
||||
UPDATE `zz_group_module` SET `name` = 'Mostra interventi ai tecnici coinvolti' WHERE `zz_group_module`.`id` = 1;
|
||||
UPDATE `zz_group_module` SET `name` = 'Mostra interventi ai clienti coinvolti' WHERE `zz_group_module`.`id` = 5;
|
||||
|
||||
-- Abilito plugin Pianificazione fatturazione in contratti
|
||||
UPDATE `zz_plugins` SET `enabled` = '1' WHERE `zz_plugins`.`name` = 'Pianificazione fatturazione';
|
||||
|
||||
-- Abilito widget Rate contrattuali in dashboard
|
||||
UPDATE `zz_widgets` SET `enabled` = '1' WHERE `zz_widgets`.`name` = 'Rate contrattuali';
|
||||
|
||||
-- Help text per i plugins
|
||||
ALTER TABLE `zz_plugins` ADD `help` VARCHAR(255) NOT NULL AFTER `directory`;
|
||||
|
||||
-- Help text per plugin Ddt del cliente
|
||||
UPDATE `zz_plugins` SET `help` = 'Righe ddt del cliente. I ddt senza righe non saranno visualizzati.' WHERE `zz_plugins`.`name` = 'Ddt del cliente';
|
||||
|
||||
-- Creazione tablla per modelli primanota
|
||||
CREATE TABLE IF NOT EXISTS `co_movimenti_modelli` (
|
||||
`id` int(11) NOT NULL,
|
||||
`idmastrino` int(11) NOT NULL,
|
||||
`descrizione` text NOT NULL,
|
||||
`idconto` int(11) NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE `co_movimenti_modelli` ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `co_movimenti_modelli` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
-- Modulo modelli primanota
|
||||
INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Modelli prima nota', 'Modelli prima nota', 'modelli_primanota', 'SELECT |select| FROM `co_movimenti_modelli` WHERE 1=1 GROUP BY `idmastrino` HAVING 2=2', '', 'fa fa-angle-right', '2.4.1', '2.4.1', '1', '40', '1', '1');
|
||||
|
||||
INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `enabled`, `summable`, `default`) VALUES (NULL, (SELECT id FROM zz_modules WHERE name='Modelli prima nota'), 'id', 'co_movimenti_modelli.id', '0', '1', '0', '0', NULL, NULL, '0', '0', '1');
|
||||
INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `enabled`, `summable`, `default`) VALUES (NULL, (SELECT id FROM zz_modules WHERE name='Modelli prima nota'), 'Causale predefinita', 'co_movimenti_modelli.descrizione', '1', '1', '0', '0', NULL, NULL, '1', '0', '1');
|
||||
|
||||
INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) VALUES
|
||||
(1, (SELECT id FROM `zz_views` WHERE id_module=(SELECT id FROM zz_modules WHERE name='Modelli prima nota') AND name='id' )),
|
||||
(1, (SELECT id FROM `zz_views` WHERE id_module=(SELECT id FROM zz_modules WHERE name='Modelli prima nota') AND name='Causale predefinita' )),
|
||||
(2, (SELECT id FROM `zz_views` WHERE id_module=(SELECT id FROM zz_modules WHERE name='Modelli prima nota') AND name='id' )),
|
||||
(2, (SELECT id FROM `zz_views` WHERE id_module=(SELECT id FROM zz_modules WHERE name='Modelli prima nota') AND name='Causale predefinita' )),
|
||||
(3, (SELECT id FROM `zz_views` WHERE id_module=(SELECT id FROM zz_modules WHERE name='Modelli prima nota') AND name='id' )),
|
||||
(3, (SELECT id FROM `zz_views` WHERE id_module=(SELECT id FROM zz_modules WHERE name='Modelli prima nota') AND name='Causale predefinita' )),
|
||||
(4, (SELECT id FROM `zz_views` WHERE id_module=(SELECT id FROM zz_modules WHERE name='Modelli prima nota') AND name='id' )),
|
||||
(4, (SELECT id FROM `zz_views` WHERE id_module=(SELECT id FROM zz_modules WHERE name='Modelli prima nota') AND name='Causale predefinita' ));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user