This commit is contained in:
Pek5892 2022-10-11 10:28:27 +02:00
commit 45171b4b67
6 changed files with 46 additions and 15 deletions

View File

@ -27,6 +27,31 @@ class Referente extends Model
use SimpleModelTrait;
protected $table = 'an_referenti';
/**
* Crea un nuovo referente.
*
* @param string $nome
*
* @return self
*/
public static function build($idanagrafica, $nome, $idmansione, $idsede)
{
$model = new static();
$model->idanagrafica = $idanagrafica;
$model->nome = $nome;
$model->idmansione = $idmansione;
$model->idsede = $idsede;
$model->save();
return $model;
}
/**
* The attributes that aren't mass assignable.

View File

@ -135,7 +135,7 @@ if (!empty($note_accredito)) {
]);
echo '
<br>'.Modules::link('Fatture di vendita', $nota['id'], $text, $text);
<br>'.Modules::link( ($dir == 'entrata' ? 'Fatture di vendita' : 'Fatture di acquisto' ), $nota['id'], $text, $text);
}
echo '
</div>';

View File

@ -34,6 +34,7 @@ switch (post('op')) {
break;
case 'update':
$idanagrafica = post('idanagrafica');
$tipo = post('tipo');
$descrizione = post('descrizione');
$iddocumento = post('iddocumento') ?: 0;
@ -79,6 +80,7 @@ switch (post('op')) {
$id_scadenza = post('id_scadenza')[$id];
if (!empty($id_scadenza)) {
$database->update('co_scadenziario', [
'idanagrafica' => $idanagrafica,
'descrizione' => $descrizione,
'da_pagare' => $da_pagare,
'pagato' => $pagato,

View File

@ -31,6 +31,7 @@ echo '
<input type="hidden" name="tipo" value="'.$record['tipo'].'">
<input type="hidden" name="descrizione" value="'.$record['descrizione'].'">
<input type="hidden" name="iddocumento" value="'.$record['iddocumento'].'">
<input type="hidden" name="idanagrafica" value="'.$record['idanagrafica'].'">
<div class="panel panel-primary">
<div class="panel-heading">

View File

@ -474,7 +474,7 @@ $(document).ready(function() {
data: {
labels: months,
datasets: [
'.$dataset.'
'.($dataset? :'{ label: "", backgroundColor: "transparent", data: [ 0,0,0,0,0,0,0,0,0,0,0,0 ] }').'
]
},
options: {
@ -549,7 +549,6 @@ INNER JOIN an_tipianagrafiche_anagrafiche ON an_anagrafiche.idanagrafica=an_tipi
INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica
WHERE an_tipianagrafiche.descrizione = "Cliente" AND co_tipidocumento.dir = "entrata" AND an_anagrafiche.created_at BETWEEN '.prepare($start).' AND '.prepare($end).' GROUP BY YEAR(an_anagrafiche.created_at), MONTH(an_anagrafiche.created_at) ORDER BY YEAR(an_anagrafiche.created_at) ASC, MONTH(an_anagrafiche.created_at) ASC');
$clienti = Stats::monthly($clienti, $start, $end);
//Random color
$background = '#'.dechex(rand(256, 16777215));

View File

@ -19,26 +19,30 @@
include_once __DIR__.'/../../core.php';
use Modules\Anagrafiche\Referente;
$operazione = filter('op');
switch ($operazione) {
case 'addreferente':
if (!empty(post('nome'))) {
$opt_out_newsletter = post('disable_newsletter');
$dbo->insert('an_referenti', [
'idanagrafica' => $id_parent,
'nome' => post('nome'),
'idmansione' => post('idmansione'),
'telefono' => post('telefono'),
'email' => post('email'),
'idsede' => post('idsede'),
'enable_newsletter' => empty($opt_out_newsletter),
]);
$id_record = $dbo->lastInsertedID();
$nome = post('nome');
$idmansione = post('idmansione');
$idsede = post('idsede');
$opt_out_newsletter = post('disable_newsletter');
$referente = Referente::build($id_parent, $nome, $idmansione, $idsede);
$id_record = $referente->id;
$referente->telefono = post('telefono');
$referente->email = post('email');
$referente->enable_newsletter = empty($opt_out_newsletter);
$referente->save();
if (isAjaxRequest() && !empty($id_record)) {
echo json_encode(['id' => $id_record, 'text' => post('nome')]);
echo json_encode(['id' => $id_record, 'text' => $referente->nome]);
}
flash()->info(tr('Aggiunto nuovo referente!'));