mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 11:30:55 +01:00
Bugfix e miglioramenti
This commit is contained in:
parent
0ada351b64
commit
e10266d808
5
add.php
5
add.php
@ -43,6 +43,11 @@ $(document).ready(function(){
|
||||
|
||||
// Campi a fine form
|
||||
var last = form.find(".panel").last();
|
||||
|
||||
if (!last.length) {
|
||||
last = form.find(".box").last();
|
||||
}
|
||||
|
||||
if (!last.length) {
|
||||
last = form.find(".row").eq(-2);
|
||||
}
|
||||
|
@ -186,6 +186,11 @@ if (empty($record)) {
|
||||
|
||||
// Campi a fine form
|
||||
var last = form.find(".panel").last();
|
||||
|
||||
if (!last.length) {
|
||||
last = form.find(".box").last();
|
||||
}
|
||||
|
||||
if (!last.length) {
|
||||
last = form.find(".row").eq(-2);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ function aggiorna_sconto($tables, $fields, $id_record, $options = [])
|
||||
'desc_iva' => $rsi[0]['descrizione'],
|
||||
'iva' => -$iva,
|
||||
'sconto_globale' => 1,
|
||||
'#order' => '(SELECT IFNULL(MAX(`order`) + 1, 0) FROM '.$tables['row'].' AS t WHERE '.$fields['row'].'='.prepare($id_record).')',
|
||||
'order' => orderValue($tables['row'], $fields['row'], $id_record),
|
||||
];
|
||||
|
||||
$dbo->insert($tables['row'], $values);
|
||||
@ -293,3 +293,8 @@ function months()
|
||||
12 => tr('Dicembre'),
|
||||
];
|
||||
}
|
||||
|
||||
function orderValue($table, $field, $id)
|
||||
{
|
||||
return database()->fetchOne('SELECT IFNULL(MAX(`order`) + 1, 0) AS value FROM '.$table.' WHERE '.$field.' = '.prepare($id))['value'];
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ switch (post('op')) {
|
||||
}
|
||||
$id_segment = $_SESSION['module_'.$id_fatture]['id_segment'];
|
||||
|
||||
$stato = $dbo->fetchOne("SELECT `id` FROM `co_statidocumento` WHERE `descrizione` = 'Bozza'")['id'];
|
||||
$sede = $dbo->fetchOne('SELECT IFNULL(idsede_fatturazione, 0) AS id_sede FROM an_anagrafiche WHERE idanagrafica='.prepare($id_anagrafica))['id_sede'];
|
||||
|
||||
// Lettura righe selezionate
|
||||
foreach ($id_records as $id) {
|
||||
$id_anagrafica = $dbo->selectOne('dt_ddt', 'idanagrafica', ['id' => $id])['idanagrafica'];
|
||||
@ -70,8 +73,8 @@ switch (post('op')) {
|
||||
'idpagamento' => $idpagamento,
|
||||
'data' => $data,
|
||||
'id_segment' => $id_segment,
|
||||
'#idstatodocumento' => "(SELECT `id` FROM `co_statidocumento` WHERE `descrizione`='Bozza')",
|
||||
'#idsede' => 'IFNULL((SELECT idsede_fatturazione FROM an_anagrafiche WHERE idanagrafica='.prepare($id_anagrafica).'), 0)',
|
||||
'idstatodocumento' => $stato,
|
||||
'idsede' => $sede,
|
||||
]);
|
||||
|
||||
$id_documento = $dbo->lastInsertedID();
|
||||
@ -101,7 +104,7 @@ switch (post('op')) {
|
||||
'um' => $riga['um'],
|
||||
'qta' => $qta,
|
||||
'abilita_serial' => $riga['abilita_serial'],
|
||||
'#order' => '(SELECT IFNULL(MAX(`order`) + 1, 0) FROM co_righe_documenti AS t WHERE iddocumento='.prepare($id_documento).')',
|
||||
'order' => orderValue('co_righe_documenti', 'iddocumento', $id_documento),
|
||||
]);
|
||||
$id_riga_documento = $dbo->lastInsertedID();
|
||||
|
||||
|
@ -49,14 +49,13 @@ switch (post('op')) {
|
||||
$totale_imponibile = get_imponibile_fattura($id_record);
|
||||
$totale_fattura = get_totale_fattura($id_record);
|
||||
|
||||
$data = [];
|
||||
if ($dir == 'uscita') {
|
||||
$idrivalsainps = post('idrivalsainps');
|
||||
$idritenutaacconto = post('idritenutaacconto');
|
||||
$numero = prepare(post('numero'));
|
||||
} else {
|
||||
$idrivalsainps = 0;
|
||||
$idritenutaacconto = 0;
|
||||
$numero = '(SELECT t.numero FROM (SELECT * FROM co_documenti) t WHERE t.id = '.prepare($id_record).')';
|
||||
$data = [
|
||||
'numero' => post('numero'),
|
||||
'idrivalsainps' => post('idrivalsainps'),
|
||||
'idritenutaacconto' => post('idritenutaacconto'),
|
||||
];
|
||||
}
|
||||
|
||||
// Leggo la descrizione del pagamento
|
||||
@ -65,9 +64,8 @@ switch (post('op')) {
|
||||
$pagamento = $rs[0]['descrizione'];
|
||||
|
||||
// Query di aggiornamento
|
||||
$dbo->update('co_documenti', [
|
||||
$dbo->update('co_documenti', array_merge([
|
||||
'data' => post('data'),
|
||||
'#numero' => $numero,
|
||||
'numero_esterno' => post('numero_esterno'),
|
||||
'note' => post('note'),
|
||||
'note_aggiuntive' => post('note_aggiuntive'),
|
||||
@ -85,15 +83,13 @@ switch (post('op')) {
|
||||
'idvettore' => post('idvettore'),
|
||||
'idsede' => post('idsede'),
|
||||
'idconto' => post('idconto'),
|
||||
'idrivalsainps' => $idrivalsainps,
|
||||
'idritenutaacconto' => $idritenutaacconto,
|
||||
|
||||
'n_colli' => post('n_colli'),
|
||||
'bollo' => 0,
|
||||
'rivalsainps' => 0,
|
||||
'ritenutaacconto' => 0,
|
||||
'iva_rivalsainps' => 0,
|
||||
], ['id' => $id_record]);
|
||||
], $data), ['id' => $id_record]);
|
||||
|
||||
$query = 'SELECT descrizione FROM co_statidocumento WHERE id='.prepare($idstatodocumento);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@ -346,7 +342,7 @@ switch (post('op')) {
|
||||
'sconto' => $riga['sconto'],
|
||||
'sconto_unitario' => $riga['sconto_unitario'],
|
||||
'tipo_sconto' => $riga['tipo_sconto'],
|
||||
'#order' => '(SELECT IFNULL(MAX(`order`) + 1, 0) FROM co_righe_documenti AS t WHERE iddocumento='.prepare($id_record).')',
|
||||
'order' => orderValue('co_righe_documenti', 'iddocumento', $id_record),
|
||||
'idritenutaacconto' => setting("Percentuale ritenuta d'acconto"),
|
||||
'ritenutaacconto' => $ritenutaacconto,
|
||||
'idrivalsainps' => setting('Percentuale rivalsa INPS'),
|
||||
|
@ -63,8 +63,8 @@ switch ($resource) {
|
||||
|
||||
$dbo->insert('in_interventi', [
|
||||
'idintervento' => $idintervento,
|
||||
'#idanagrafica' => "(SELECT valore FROM zz_settings WHERE nome='Azienda predefinita')",
|
||||
'#data_richiesta' => 'NOW()',
|
||||
'idanagrafica' => setting('Azienda predefinita'),
|
||||
'data_richiesta' => \Carbon::now(),
|
||||
'richiesta' => $richiesta,
|
||||
'idtipointervento' => 0,
|
||||
'idstatointervento' => 'CALL',
|
||||
|
@ -81,6 +81,9 @@ switch (post('op')) {
|
||||
|
||||
$interventi = $dbo->fetchArray('SELECT *, IFNULL((SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE in_interventi_tecnici.idintervento = in_interventi.id), in_interventi.data_richiesta) AS data, in_statiintervento.descrizione AS stato FROM in_interventi INNER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento WHERE in_statiintervento.completato=1 AND in_interventi.id NOT IN (SELECT idintervento FROM co_righe_documenti WHERE idintervento IS NOT NULL) AND in_interventi.id NOT IN (SELECT idintervento FROM co_preventivi_interventi WHERE idintervento IS NOT NULL) AND in_interventi.id NOT IN (SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL) AND in_interventi.id IN ('.implode(',', $id_records).')');
|
||||
|
||||
$stato = $dbo->fetchOne("SELECT `id` FROM `co_statidocumento` WHERE `descrizione` = 'Bozza'")['id'];
|
||||
$sede = $dbo->fetchOne('SELECT IFNULL(idsede_fatturazione, 0) AS id_sede FROM an_anagrafiche WHERE idanagrafica='.prepare($id_anagrafica))['id_sede'];
|
||||
|
||||
// Lettura righe selezionate
|
||||
foreach ($interventi as $intervento) {
|
||||
$id_anagrafica = $intervento['idanagrafica'];
|
||||
@ -122,8 +125,8 @@ switch (post('op')) {
|
||||
'idpagamento' => $idpagamento,
|
||||
'data' => $data,
|
||||
'id_segment' => $id_segment,
|
||||
'#idstatodocumento' => "(SELECT `id` FROM `co_statidocumento` WHERE `descrizione`='Bozza')",
|
||||
'#idsede' => 'IFNULL((SELECT idsede_fatturazione FROM an_anagrafiche WHERE idanagrafica='.prepare($id_anagrafica).'), 0)',
|
||||
'idstatodocumento' => $stato,
|
||||
'idsede' => $sede,
|
||||
]);
|
||||
|
||||
$id_documento = $dbo->lastInsertedID();
|
||||
|
@ -450,7 +450,7 @@ function aggiungi_intervento_in_fattura($id_intervento, $id_fattura, $descrizion
|
||||
'rivalsainps' => $rivalsainps,
|
||||
'idritenutaacconto' => $id_ritenuta_acconto,
|
||||
'ritenutaacconto' => $ritenutaacconto,
|
||||
'#order' => '(SELECT IFNULL(MAX(`order`) + 1, 0) FROM co_righe_documenti AS t WHERE iddocumento='.prepare($id_fattura).')',
|
||||
'order' => orderValue('co_righe_documenti', 'iddocumento', $id_fattura),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -286,6 +286,21 @@ class FatturaElettronica
|
||||
// TODO: vari
|
||||
];
|
||||
|
||||
// Sconto globale
|
||||
if (!empty($documento['sconto_globale'])) {
|
||||
$sconto = [
|
||||
'Tipo' => $documento['sconto_globale'] > 0 ? 'SC' : 'MG',
|
||||
];
|
||||
|
||||
if ($riga['tipo_sconto_globale'] == 'PRC') {
|
||||
$sconto['Percentuale'] = $riga['sconto_globale'];
|
||||
} else {
|
||||
$sconto['Importo'] = $riga['sconto_globale'];
|
||||
}
|
||||
|
||||
$result['ScontoMaggiorazione'] = $sconto;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -334,7 +349,7 @@ class FatturaElettronica
|
||||
// Sconto
|
||||
if (!empty($riga['sconto'])) {
|
||||
$sconto = [
|
||||
'Tipo' => 'SC',
|
||||
'Tipo' => $riga['sconto'] > 0 ? 'SC' : 'MG',
|
||||
];
|
||||
|
||||
if ($riga['tipo_sconto'] == 'PRC') {
|
||||
|
@ -425,30 +425,16 @@ class Database extends Util\Singleton
|
||||
* @param string $table
|
||||
* @param array $array
|
||||
* @param array $conditions
|
||||
* @param bool $return
|
||||
*
|
||||
* @return string|array
|
||||
*/
|
||||
public function update($table, $array, $conditions, $return = false)
|
||||
public function update($table, $array, $conditions)
|
||||
{
|
||||
if (!is_string($table) || !is_array($array) || !is_array($conditions)) {
|
||||
throw new UnexpectedValueException();
|
||||
}
|
||||
|
||||
// Valori da aggiornare
|
||||
$update = [];
|
||||
foreach ($array as $key => $value) {
|
||||
$update[] = $this->quote($key).' = '.$this->prepareValue($key, $value);
|
||||
}
|
||||
|
||||
// Costruzione della query
|
||||
$query = 'UPDATE '.$this->quote($table).' SET '.implode($update, ', ').' WHERE '.$this->whereStatement($conditions);
|
||||
|
||||
if (!empty($return)) {
|
||||
return $query;
|
||||
} else {
|
||||
return $this->query($query);
|
||||
}
|
||||
return Capsule::table($table)->where($conditions)->update($array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user