openstamanager/plugins/notes.php

133 lines
5.2 KiB
PHP
Raw Permalink Normal View History

2019-07-30 16:50:10 +02:00
<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright (C) DevCode s.r.l.
2020-09-07 15:04:06 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2019-07-30 16:50:10 +02:00
include_once __DIR__.'/../core.php';
2021-08-04 16:42:49 +02:00
if (!empty($notes) && !$notes->isEmpty()) {
2019-07-30 16:50:10 +02:00
echo '
2024-05-16 18:02:50 +02:00
<div class="card card-info direct-chat direct-chat-info">
<div class="card-header with-border">
<h3 class="card-title">'.tr('Note interne').'</h3>
2019-07-30 16:50:10 +02:00
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body">
2019-07-30 16:50:10 +02:00
<div class="direct-chat-messages" style="height: 50vh">';
foreach ($notes as $nota) {
$utente = $nota->user;
$photo = $utente->photo;
echo '
<div class="direct-chat-msg '.($utente->id == $user->id ? 'right' : '').'" id="nota_'.$nota->id.'">
<div class="direct-chat-info clearfix">
<span class="direct-chat-name pull-left">'.$utente->nome_completo.'</span>
<span class="direct-chat-timestamp pull-right">
'.timestampFormat($nota->created_at).'
</span>
</div>';
if ($photo) {
echo '
<img class="direct-chat-img" src="'.$photo.'">';
} else {
echo '
2020-09-07 15:04:06 +02:00
2019-07-30 16:50:10 +02:00
<i class="fa fa-user-circle-o direct-chat-img fa-3x" alt="'.tr('OpenSTAManager').'"></i>';
}
echo '
<div class="direct-chat-text">
2024-05-16 18:02:50 +02:00
<div class="float-right d-none d-sm-inline">';
2019-07-30 16:50:10 +02:00
if (!empty($nota->notification_date)) {
echo '
2024-05-16 18:02:50 +02:00
<span class="badge badge-default tip" title="'.tr('Data di notifica').'" style="margin-right: 5px">
2019-07-30 16:50:10 +02:00
<i class="fa fa-bell"></i> '.dateFormat($nota->notification_date).'
</span>
2020-09-07 15:04:06 +02:00
<button type="button" class="btn btn-info btn-xs ask" data-op="rimuovi-notifica-nota" data-id_nota="'.$nota->id.'" data-msg="'.tr('Rimuovere la data di notifica da questa nota?').'" data-backto="record-edit" data-button="'.tr('Rimuovi').'" data-class="btn btn-lg btn-warning">
2019-07-30 16:50:10 +02:00
<i class="fa fa-eye"></i>
</button>';
}
if ($user->is_admin || $utente->id == $user->id) {
echo '
<button type="button" class="btn btn-danger btn-xs ask" data-op="rimuovi-nota" data-id_nota="'.$nota->id.'" data-msg="'.tr('Rimuovere questa nota?').'" data-backto="record-edit">
2019-07-30 16:50:10 +02:00
<i class="fa fa-trash-o"></i>
</button>';
}
echo '
</div>
'.$nota->content.'
</div>
</div>';
}
echo '
</div>
</div>
</div>';
} else {
echo '
2020-07-09 18:50:10 +02:00
<div class="alert alert-info" ><i class="fa fa-info-circle" ></i> <b>'.tr('Informazione:').'</b> '.tr('Non sono presenti note interne.').'</div>';
2019-07-30 16:50:10 +02:00
}
if ($structure->permission == 'rw') {
echo '
<form action="" method="post">
<input type="hidden" name="op" value="aggiungi-nota">
2019-07-30 16:50:10 +02:00
<input type="hidden" name="backto" value="record-edit">
2019-11-23 06:48:58 +01:00
<div class="row" >
2023-02-24 13:36:37 +01:00
<div class="col-md-12" >';
2023-08-04 14:54:28 +02:00
echo input([
2024-03-22 15:52:24 +01:00
'type' => 'ckeditor',
'label' => tr('Nuova nota'),
'name' => 'contenuto',
'required' => 1,
'class' => 'unblockable',
]);
2023-08-04 14:54:28 +02:00
echo '
2019-11-23 06:48:58 +01:00
</div>
<div class="col-md-4" >
{[ "type": "date", "label": "'.tr('Data di notifica').'", "name": "data_notifica", "class": "unblockable", "help": "'.tr('Eventuale data di notifica di un promemoria di questa nota.').'" ]}
</div>
</div>
2019-07-30 16:50:10 +02:00
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<button type="submit" class="btn btn-primary" disabled id="aggiungi_nota" >
2019-07-30 16:50:10 +02:00
<i class="fa fa-plus"></i> '.tr('Aggiungi').'
</button>
</div>
</div>
</form>';
}
echo '
<script>
var contenuto_nota = input("contenuto");
contenuto_nota.on("change", function() {
if (contenuto_nota.get() === "") {
$("#aggiungi_nota").prop("disabled", true);
} else {
$("#aggiungi_nota").prop("disabled", false);
}
});
</script>';