Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
121 righe
5.6 KiB
121 righe
5.6 KiB
<? |
|
$error = true; |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
if (!empty($_SESSION["utente"]) && !empty($_SESSION["ente"]) && !empty($_GET["sezione"]) && !empty($_GET["codice_elemento"])) { |
|
$get_sezione = purify($_GET["sezione"]); |
|
$get_codice_elemento = purify($_GET["codice_elemento"] ?? 0); |
|
$get_sub_elemento = purify($_GET["sub_elemento"] ?? 0); |
|
$get_codice_ente = purify($_GET["ente"] ?? 0); |
|
if (Communicator::checkPermission($get_sezione,$get_codice_elemento,$get_sub_elemento)) { |
|
$error = false; |
|
$messaggi = Communicator::listInitiativeChat($get_sezione,$get_codice_elemento,false,$get_sub_elemento); |
|
$col = "col-12"; |
|
if (!empty($_GET["fromList"])) { |
|
$detailsModulo = Communicator::sezioniSpeciali()[$get_sezione] ?? null; |
|
if (!empty($detailsModulo["directLink"])) { |
|
$directLink = $detailsModulo["directLink"]; |
|
$_keys = ["elemento"=>$get_codice_elemento,"sub_elemento"=>$get_sub_elemento]; |
|
foreach($_keys AS $_key=>$_value) { |
|
$directLink = str_replace("{##--{$_key}--##}",$_value,$directLink); |
|
} |
|
} |
|
if (!empty($directLink)) { |
|
?> |
|
<div class="text-right"> |
|
<a href="<?= $directLink ?>" class="btn btn-sm btn-primary"><?= __("Vai ai dettagli") ?></a> |
|
</div> |
|
<? |
|
} |
|
} |
|
?> |
|
<div class="row"> |
|
<? |
|
if (!empty($messaggi)) { |
|
$col = "col-12 col-lg-5"; |
|
?> |
|
<div class="col-12 col-lg-7"> |
|
<? |
|
$check = $pdo->prepare("SELECT codice FROM r_chat WHERE codice_messaggio = :codice_messaggio AND codice_utente = :codice_utente"); |
|
$check->bindValue(":codice_utente",$_SESSION["utente"]->codice); |
|
$insert = $pdo->prepare("INSERT INTO r_chat (codice_messaggio, codice_utente) VALUES (:codice_messaggio , :codice_utente)"); |
|
$insert->bindValue(":codice_utente",$_SESSION["utente"]->codice); |
|
$updateLetto = $pdo->prepare("UPDATE r_chat SET letto = 'S' WHERE codice_messaggio = :codice_messaggio AND codice_utente = :codice_utente"); |
|
$updateLetto->bindValue(":codice_utente",$_SESSION["utente"]->codice); |
|
foreach($messaggi AS $msg) { |
|
$sender = ($msg["utente_modifica"] == $_SESSION["utente"]->codice) ? true : false; |
|
$user = Utente::getInfoFromID($msg["utente_modifica"]); |
|
if (empty($user)) { |
|
$user = [ |
|
"cognome" => "", |
|
"nome" => "" |
|
]; |
|
} |
|
?> |
|
<div class="col-11 my-1 card card-body p-2 <?= $sender ? "bg-light text-dark float-right" : "" ?>"> |
|
<?= $msg["corpo"] ?> |
|
<div class="text-right"> |
|
<small><span class="fa fa-user"></span> <?= $user["cognome"] . " " . $user["nome"] . " - " . mysql2datetime($msg["timestamp"]) ?></small> |
|
</div> |
|
</div> |
|
<div class="clearfix"></div> |
|
<? |
|
$check->bindValue(":codice_messaggio",$msg["codice"]); |
|
$check->execute(); |
|
if ($check->rowCount() == 0) { |
|
$insert->bindValue(":codice_messaggio",$msg["codice"]); |
|
$insert->execute(); |
|
} else { |
|
$updateLetto->bindValue(":codice_messaggio",$msg["codice"]); |
|
$updateLetto->execute(); |
|
} |
|
} |
|
?> |
|
</div> |
|
<? |
|
} |
|
?> |
|
<div class="<?= $col ?>"> |
|
<? if (!$_SESSION["utente"]->readOnly) { ?> |
|
<form action="/backend/comunicazioni/send-chat.php" method="post" rel="validate"> |
|
<input id="token" type="hidden" name="token" value="<?= tokenGen() ?>"> |
|
<input id="sezione" type="hidden" name="sezione" value="<?= $get_sezione ?>"> |
|
<input id="codice_elemento" type="hidden" name="codice_elemento" value="<?= $get_codice_elemento ?>"> |
|
<input id="sub_elemento" type="hidden" name="sub_elemento" value="<?= $get_sub_elemento ?>"> |
|
<input id="codice_ente" type="hidden" name="codice_ente" value="<?= $get_codice_ente ?>"> |
|
<div class="form-group"> |
|
<label for="corpo"><?= __("Messaggio") ?></label> |
|
<textarea name="corpo" id="corpo" class="ckeditor_simple" title="<?= __("Messaggio") ?>" rel="S;0;0;A"></textarea> |
|
</div> |
|
<div class="card"> |
|
<div class="card-header"> |
|
<span data-target="#msgAttachBody" class="card-title"> |
|
<span class="fa fa-paperclip"></span> <?= __("Allegati") ?> |
|
</span> |
|
</div> |
|
<div class="card-body collapse" id="msgAttachBody"> |
|
<? filesManager::printForm("public"); ?> |
|
</div> |
|
</div> |
|
<button class="mt-2 btn btn-block btn-success" onClick="return confirm('<?= __("Il messaggio sarà visibile da tutti gli utenti abilitati alla gestione della procedura. Sei sicuro di voler procedere?") ?>');"> |
|
<span class="fa fa-paper-plane"></span> <?= __("Invia") ?> |
|
</button> |
|
</form> |
|
<? |
|
addBypassCheckURL("/backend/comunicazioni/send-chat.php"); |
|
} else { |
|
alertManager::printAlertBox(__("Impossibile procedere")); |
|
} ?> |
|
</div> |
|
</div> |
|
<script> |
|
$("#badge-chat").html(""); |
|
</script> |
|
<? |
|
} |
|
} |
|
if ($error) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} |
|
?>
|