This commit is contained in:
MatteoPistorello 2023-01-25 16:39:10 +01:00
commit b848bedd80
8 changed files with 93 additions and 74 deletions

View File

@ -98,7 +98,9 @@ const JS = gulp.parallel(() => {
'dropzone/dist/dropzone.js',
'autonumeric/dist/autoNumeric.min.js',
'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
'fullcalendar/dist/fullcalendar.js',
'fullcalendar-scheduler/index.global.js',
'@fullcalendar/moment/index.global.js',
'@fullcalendar/core/locales/it.global.js',
'geocomplete/jquery.geocomplete.js',
'inputmask/dist/min/jquery.inputmask.bundle.min.js',
'jquery-form/src/jquery.form.js',
@ -161,7 +163,6 @@ const CSS = gulp.parallel(() => {
'dropzone/dist/dropzone.css',
'eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
'font-awesome/css/font-awesome.min.css',
'fullcalendar/dist/fullcalendar.css',
'parsleyjs/src/parsley.css',
'select2/dist/css/select2.min.css',
'sweetalert2/dist/sweetalert2.css',
@ -208,7 +209,6 @@ function srcCSS() {
const print = gulp.src([
config.development + '/' + config.paths.css + '/print/*.{css,scss,less,styl}',
config.nodeDirectory + '/fullcalendar/fullcalendar.print.css',
], {
allowEmpty: true
})

View File

@ -162,8 +162,10 @@ switch (post('op')) {
Combinazione::sincronizzaVarianti($articolo);
// Leggo la quantità attuale per capire se l'ho modificata
$old_qta = $record['qta'];
$movimento = $qta - $old_qta;
// TODO: gestire la movimentazione manuale per sede
$id_sede = 0;
$old_qta = $articolo->getGiacenze(post('data_movimento'));
$movimento = $qta - $old_qta[$id_sede][0];
$qta_manuale = post('qta_manuale');
if (!empty($qta_manuale)) {

View File

@ -285,20 +285,29 @@ class Articolo extends Model
/**
* Restituisce le giacenze per sede dell'articolo.
*
* @param $data Indica la data fino alla quale calcolare le giacenze totali. Di default tutte
*
* @return array
*/
public function getGiacenze()
public function getGiacenze($data = null)
{
return $this->movimenti()
$movimenti = $this->movimenti()
->select(
'idsede',
database()->raw('SUM(qta) AS qta')
)->groupBy(['idsede'])
->get()
)->groupBy(['idsede']);
if (!empty($data)) {
$movimenti = $movimenti->where('data', '<=', \Carbon\Carbon::parse($data)->format('Y-m-d'));
}
$movimenti = $movimenti->get()
->mapToGroups(function ($item, $key) {
return [$item->idsede => (float) $item->attributes['qta']];
})
->toArray();
return $movimenti;
}
/**

View File

@ -67,6 +67,10 @@ class CSV extends CSVImporter
'field' => 'qta',
'label' => 'Quantità',
],
[
'field' => 'data_qta',
'label' => 'Data inventario',
],
[
'field' => 'um',
'label' => 'Unit&agrave; di misura',
@ -309,7 +313,7 @@ class CSV extends CSVImporter
$articolo->attivo = 1;
// Esportazione della quantità indicata
$qta_registrata = (float) ($record['qta']);
$nuova_qta = (float) ($record['qta']);
$nome_sede = $record['nome_sede'];
// Aggiornamento dettaglio prezzi
@ -406,10 +410,10 @@ class CSV extends CSVImporter
}
if( isset($record['qta']) ) {
$giacenze = $articolo->getGiacenze();
$qta_movimento = $qta_registrata - $giacenze[$id_sede][0];
$giacenze = $articolo->getGiacenze($record['data_qta']);
$qta_movimento = $nuova_qta - $giacenze[$id_sede][0];
$articolo->movimenta($qta_movimento, tr('Movimento da importazione'), new Carbon(), false, [
$articolo->movimenta($qta_movimento, tr('Movimento da importazione'), new Carbon($record['data_qta']), true, [
'idsede' => $id_sede,
]);
}

View File

@ -105,12 +105,14 @@ switch (filter('op')) {
$results[] = [
'id' => $sessione['id'],
'idintervento' => $sessione['idintervento'],
'idtecnico' => $sessione['idtecnico'],
'title' => (($sessione['is_completato']) ? '<i class="fa fa-lock" aria-hidden="true"></i>' : '').' '.(($sessione['have_attachments']) ? '<i class="fa fa-paperclip" aria-hidden="true"></i>' : '').($sessione['is_completato'] || $sessione['have_attachments'] ? '<br>' : '').'<b>Int. '.$sessione['codice'].'</b> '.$sessione['cliente'].'<br><b>'.tr('Tecnici').':</b> '.$sessione['nome_tecnico'],
'start' => $sessione['orario_inizio'],
'end' => $sessione['orario_fine'],
'link' => base_path().'/editor.php?id_module='.$modulo_interventi->id.'&id_record='.$sessione['idintervento'],
'extendedProps' => [
'link' => base_path().'/editor.php?id_module='.$modulo_interventi->id.'&id_record='.$sessione['idintervento'],
'idintervento' => $sessione['idintervento'],
'idtecnico' => $sessione['idtecnico'],
],
'backgroundColor' => $backgroundcolor,
'textColor' => color_inverse($backgroundcolor),
'borderColor' => empty($bordercolor) ? '#FFFFFF' : $bordercolor,
@ -190,13 +192,15 @@ switch (filter('op')) {
foreach ($alldays as $evento) {
$results[] = [
'id' => $modulo_eventi->id.'_'.$evento['id'],
'idintervento' => $evento['id'],
'idtecnico' => '',
'title' => '<b>'.tr('Evento').':</b> '.$evento['nome'].'<br>
<b>'.tr('Festività').':</b> '.($evento['is_bank_holiday'] ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>'),
'start' => $evento['data'],
'end' => $evento['data'],
'url' => base_path().'/editor.php?id_module='.$modulo_eventi->id.'&id_record='.$evento['id'],
'extendedProps' => [
'link' => base_path().'/editor.php?id_module='.$modulo_eventi->id.'&id_record='.$evento['id'],
'idintervento' => $evento['id'],
'idtecnico' => '',
],
'backgroundColor' => '#ffebcd',
'textColor' => color_inverse('#ffebcd'),
'borderColor' => '#ffebcd',
@ -435,7 +439,7 @@ switch (filter('op')) {
}
echo '
<div class="fc-event fc-event-'.$class.'" data-id="'.$sessione['id'].'" data-idcontratto="'.$sessione['idcontratto'].'" data-ref="'.$sessione['ref'].'" data-id_tecnico="'.$sessione['id_tecnico'].'">'.($sessione['ref'] == 'intervento' ? Modules::link($modulo_riferimento, $id_riferimento, '<i class="fa fa-wrench"></i>', null, 'title="'.tr('Visualizza scheda').'" class="btn btn-'.$class.' btn-xs pull-right"') : Modules::link($modulo_riferimento, $id_riferimento, '<i class="fa fa-file-text-o"></i>', null, 'title="'.tr('Visualizza scheda').'" class="btn btn-'.$class.' btn-xs pull-right"')).'
<div id="id-'.$sessione['id'].'" class="fc-event fc-event-'.$class.'" data-id="'.$sessione['id'].'" data-idcontratto="'.$sessione['idcontratto'].'" data-ref="'.$sessione['ref'].'" data-id_tecnico="'.$sessione['id_tecnico'].'">'.($sessione['ref'] == 'intervento' ? Modules::link($modulo_riferimento, $id_riferimento, '<i class="fa fa-wrench"></i>', null, 'title="'.tr('Visualizza scheda').'" class="btn btn-'.$class.' btn-xs pull-right"') : Modules::link($modulo_riferimento, $id_riferimento, '<i class="fa fa-file-text-o"></i>', null, 'title="'.tr('Visualizza scheda').'" class="btn btn-'.$class.' btn-xs pull-right"')).'
<b>'.$sessione['ragione_sociale'].'</b>
<br>'.dateFormat($sessione['data_richiesta']).' ('.$sessione['tipo_intervento'].')
<div class="request">'.(!empty($sessione['richiesta']) ? ' - '.$sessione['richiesta'] : '').'</div>

View File

@ -329,11 +329,11 @@ WHERE (SELECT COUNT(*) FROM in_interventi_tecnici WHERE in_interventi_tecnici.id
$vista = setting('Vista dashboard');
if ($vista == 'mese') {
$def = 'month';
$def = 'dayGridMonth';
} elseif ($vista == 'giorno') {
$def = 'agendaDay';
$def = 'timeGridWeek';
} elseif ($vista == 'settimana') {
$def = 'agendaWeek';
$def = 'listWeek';
} else {
$def = 'listWeek';
}
@ -342,7 +342,8 @@ $modulo_interventi = Modules::get('Interventi');
echo '
<script type="text/javascript">
globals.dashboard = {
var Draggable = FullCalendar.Draggable;
globals.dashboard = {
load_url: "'.$structure->fileurl('ajax.php').'?id_module='.$id_module.'",
style: "'.$def.'",
show_sunday: '.intval(setting('Visualizzare la domenica sul calendario')).',
@ -351,11 +352,6 @@ echo '
write_permission: '.intval($modulo_interventi->permission == 'rw').',
tooltip: '.intval(setting('Utilizzare i tooltip sul calendario')).',
calendar: null,
/* timeFormat: {
hour: "2-digit",
minute: "2-digit",
hour12: false
}, */
timeFormat: "H:mm",
select: {
title: "'.tr('Aggiungi intervento').'",
@ -419,7 +415,7 @@ echo '
$("#elenco-promemoria").html(data);
$("#external-events .fc-event").each(function () {
$(this).draggable({
new Draggable( document.getElementById( $(this).attr("id") ), {
zIndex: 999,
revert: true,
revertDuration: 0,
@ -427,7 +423,7 @@ echo '
title: $.trim($(this).text()),
stick: false
}
});
} );
});
});
}
@ -445,7 +441,7 @@ echo '
session_set_array("dashboard,idstatiintervento", id).then(function () {
aggiorna_contatore("#dashboard_stati");
globals.dashboard.calendar.fullCalendar("refetchEvents"); //.refetchEvents()
globals.dashboard.calendar.refetchEvents();
});
});
@ -455,7 +451,7 @@ echo '
session_set_array("dashboard,idtipiintervento", id).then(function () {
aggiorna_contatore("#dashboard_tipi");
globals.dashboard.calendar.fullCalendar("refetchEvents"); //.refetchEvents()
globals.dashboard.calendar.refetchEvents();
});
});
@ -465,7 +461,7 @@ echo '
session_set_array("dashboard,idtecnici", id).then(function () {
aggiorna_contatore("#dashboard_tecnici");
globals.dashboard.calendar.fullCalendar("refetchEvents"); //.refetchEvents()
globals.dashboard.calendar.refetchEvents();
});
});
@ -475,7 +471,7 @@ echo '
session_set_array("dashboard,idzone", id).then(function () {
aggiorna_contatore("#dashboard_zone");
globals.dashboard.calendar.fullCalendar("refetchEvents"); //.refetchEvents()
globals.dashboard.calendar.refetchEvents();
});
});
@ -509,23 +505,23 @@ echo '
var calendarElement = document.getElementById("calendar");
var clickCnt = 0;
var calendar = $(calendarElement).fullCalendar({
/* plugins: [interactionPlugin, dayGridPlugin, timeGridPlugin], */
var calendar = new FullCalendar.Calendar(calendarElement, {
//plugins: [adaptivePlugin, momentPlugin, dayGridPlugin, timeGridPlugin],
/* locales: allLocales, */
locale: globals.locale,
slotEventOverlap: false,
schedulerLicenseKey: "GPL-My-Project-Is-Open-Source",
hiddenDays: globals.dashboard.show_sunday ? [] : [0],
header: {
headerToolbar: {
left: "prev,next today",
center: "title",
right: "month,agendaWeek,agendaDay,listWeek"
right: "dayGridMonth,timeGridWeek,listWeek"
},
timeFormat: globals.dashboard.timeFormat,
slotLabelFormat: globals.dashboard.timeFormat,
slotDuration: "00:15:00",
snapDuration: globals.snapDuration,
defaultView: globals.dashboard.style,
initialView: "dayGridMonth",
minTime: globals.dashboard.start_time,
maxTime: globals.dashboard.end_time,
lazyFetching: true,
@ -542,26 +538,26 @@ echo '
},
droppable: globals.dashboard.write_permission,
drop: function (date) { // info
// let date = info.date;
drop: function (info) {
let date = info.date;
let data = moment(date).format("YYYY-MM-DD");
let ora_dal = moment(date).format("HH:mm");
let ora_al = moment(date).add(1, "hours").format("HH:mm");
let ref = $(this).data("ref");
let ref = info.draggedEl.dataset.ref;
let name;
if (ref === "promemoria") {
name = "idcontratto_riga";
} else {
name = "id_intervento";
}
openModal(globals.dashboard.drop.title, globals.dashboard.drop.url + "&data=" + data + "&orario_inizio=" + ora_dal + "&orario_fine=" + ora_al + "&ref=dashboard&idcontratto=" + $(this).data("idcontratto") + "&" + name + "=" + $(this).data("id") + "&id_tecnico=" + $(this).data("id_tecnico"));
openModal(globals.dashboard.drop.title, globals.dashboard.drop.url + "&data=" + data + "&orario_inizio=" + ora_dal + "&orario_fine=" + ora_al + "&ref=dashboard&idcontratto=" + info.draggedEl.dataset.idcontratto + "&" + name + "=" + info.draggedEl.dataset.id + "&id_tecnico=" + info.draggedEl.dataset.id_tecnico);
// Ricaricamento dei dati alla chiusura del modal
$(this).remove();
$("#modals > div").on("hidden.bs.modal", function () {
globals.dashboard.calendar.fullCalendar("refetchEvents"); //.refetchEvents()
globals.dashboard.calendar.refetchEvents();
let mese = $("#mese-promemoria").val();
carica_interventi_da_pianificare(mese);
@ -569,11 +565,11 @@ echo '
},
selectable: globals.dashboard.write_permission,
select: function (start, end, allDay) { // info
// let start = info.start;
// let end = info.end;
select: function (info) { // info
let start = info.start;
let end = info.end;
let intero_giorno = !start.hasTime() && !end.hasTime();
let intero_giorno = !start.hasTime && !end.hasTime;
if (intero_giorno !== true || globals.dashboard.informazioni_aggiuntive==0) {
let data = moment(start).format("YYYY-MM-DD");
let data_fine = moment(end).format("YYYY-MM-DD");
@ -581,7 +577,7 @@ echo '
let orario_fine = moment(end).format("HH:mm");
// Fix selezione di un giorno avanti per vista mensile
if (globals.dashboard.calendar.fullCalendar("getView").name == "month") {
if (globals.dashboard.calendar.view == "dayGridMonth") {
data_fine = moment(end).subtract(1, "days").format("YYYY-MM-DD");
}
@ -590,8 +586,8 @@ echo '
},
editable: globals.dashboard.write_permission,
eventDrop: function (event, delta, revertFunc) {// info
// let event = info.event;
eventDrop: function (info) {// info
let event = info.event;
if (event.allDay !== true) {
let start = event.start;
@ -599,7 +595,7 @@ echo '
$.post(globals.dashboard.load_url, {
op: "modifica_intervento",
id: event.id,
idintervento: event.idintervento,
idintervento: event.extendedProps.idintervento,
timeStart: moment(start).format("YYYY-MM-DD HH:mm"),
timeEnd: moment(end).format("YYYY-MM-DD HH:mm")
}, function (data, responseType) {
@ -612,22 +608,22 @@ echo '
}
if (data !== "ok") {
revertFunc(); // info.revert();
info.revert();
}
});
} else {
revertFunc();
info.revert();
}
},
eventResize: function (event, delta, revertFunc) { // info
// let event = info.event;
eventResize: function (info) {
let event = info.event;
let start = event.start;
let end = (event.end!=null ? event.end : event.start);
$.post(globals.dashboard.load_url, {
op: "modifica_intervento",
id: event.id,
idintervento: event.idintervento,
idintervento: event.extendedProps.idintervento,
timeStart: moment(start).format("YYYY-MM-DD HH:mm"),
timeEnd: moment(end).format("YYYY-MM-DD HH:mm")
}, function (data, responseType) {
@ -640,7 +636,7 @@ echo '
}
if (data !== "ok") {
revertFunc(); // info.revert();
info.revert();
}
});
@ -649,7 +645,7 @@ echo '
if(isMobile() && setting('Utilizzare i tooltip sul calendario')){
echo '
eventClick: function(info) {
let link = info.link;
let link = info.event.extendedProps.link;
let element = $(this);
clickCnt++;
if (clickCnt === 1) {
@ -666,18 +662,20 @@ if(isMobile() && setting('Utilizzare i tooltip sul calendario')){
}else{
echo '
eventClick: function(info) {
let link = info.link;
location.href = link;
info.jsEvent.preventDefault();
location.href = info.event.extendedProps.link;
},';
}
echo '
// eventPositioned: function (info) {
eventAfterRender: function (event, element) {
// let event = info.event;
// let element = $(info.el);
element.find(".fc-title, .fc-list-item-title").html(event.title);
let id_record = event.idintervento;
eventContent: function (info) {
return { html: "<div style=\"width:100%; background:" + info.event.backgroundColor + ";\">" + info.event.title + "</div>" };
},
eventDidMount: function(info){
let element = $(info.el);
let id_record = info.event.extendedProps.idintervento;
if (globals.dashboard.tooltip == 1) {
element.tooltipster({
@ -700,7 +698,7 @@ echo '
$.post(globals.dashboard.load_url, {
op: "tooltip_info",
id_record: id_record,
allDay: event.allDay,
allDay: info.event.allDay,
}, function (data, response) {
instance.content(data);
@ -711,6 +709,7 @@ echo '
});
}
},
events: {
url: globals.dashboard.load_url + "&op=interventi_periodo",
type: "GET",
@ -720,7 +719,7 @@ echo '
}
});
//calendar.render();
calendar.render();
globals.dashboard.calendar = calendar;
}

View File

@ -2,6 +2,7 @@
"private": true,
"main": "gulpfile.js",
"dependencies": {
"@fullcalendar/moment": "^6.0.3",
"admin-lte": "^2.4.18",
"autocompleter": "^6.1.1",
"autonumeric": "^4.6.0",
@ -20,7 +21,7 @@
"dropzone": "^5.7.2",
"eonasdan-bootstrap-datetimepicker": "^4.17.49",
"font-awesome": "^4.7.0",
"fullcalendar": "^3.10.5",
"fullcalendar-scheduler": "^6.0.3",
"geocomplete": "^1.7.0",
"hotkeys-js": "^3.8.5",
"html5sortable": "^0.13.2",

View File

@ -63,7 +63,7 @@ class App
'i18n/parsleyjs/|lang|.min.js',
'i18n/select2/|lang|.min.js',
'i18n/moment/|lang|.min.js',
'i18n/fullcalendar/|lang|.min.js',
'i18n/@fullcalendar/|lang|.min.js',
],
];