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.
157 righe
7.1 KiB
157 righe
7.1 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
$error = true; |
|
if (isset($_SESSION["utente"]) && !empty($_GET["sezione"]) && !empty($_GET["codice_elemento"]) && !empty($_GET["destinatari"])) { |
|
if ($_SESSION["utente"]->permission($_GET["sezione"],$_GET["codice_elemento"])) { |
|
if (is_numeric($_GET["destinatari"])) { |
|
$destinatari = [$_GET["destinatari"]]; |
|
} else if (strpos($_GET["destinatari"],"token:") === 0) { |
|
$token = str_replace("token:","",$_GET["destinatari"]); |
|
if (!empty($token) && !empty($_SESSION["exportoperatori"][$token])) { |
|
if (strpos($token,"getContent") === 0) { |
|
$destinatari = $_SESSION["exportoperatori"][$token]; |
|
} else { |
|
$first = reset($_SESSION["exportoperatori"][$token]); |
|
if (isset($first["ragione_sociale"])) { |
|
$destinatari = array_column($_SESSION["exportoperatori"][$token],"codice"); |
|
} else { |
|
$destinatari = array_keys($_SESSION["exportoperatori"][$token]); |
|
} |
|
} |
|
} |
|
} else if (strpos($_GET["destinatari"],"pec:") === 0) { |
|
$token = str_replace("pec:","",$_GET["destinatari"]); |
|
if (!empty($token) && !empty($_SESSION["pecDestinatariComunicazione"][$token])) { |
|
$destinarioPEC = true; |
|
$destinatari = $_SESSION["pecDestinatariComunicazione"][$token]; |
|
} |
|
} else if (filter_var($_GET["destinatari"], FILTER_VALIDATE_EMAIL)) { |
|
$destinarioPEC = true; |
|
$destinatari = $_GET["destinatari"]; |
|
} |
|
if (!empty($destinatari) && empty($destinarioPEC) && is_array($destinatari) && !isset($destinatari["codice"])) { |
|
$codici = []; |
|
$pec = []; |
|
$tmp = $destinatari; |
|
$destinatari = []; |
|
foreach($tmp AS $t) { |
|
if (is_numeric($t)) { |
|
$codici[] = $t; |
|
} else if (filter_var($t, FILTER_VALIDATE_EMAIL)) { |
|
$pec[] = $t; |
|
} |
|
} |
|
if (!empty($codici)) { |
|
$destinatari = oeManager::getOE($codici); |
|
if (!isset($destinatari["codice"])) { |
|
uasort($destinatari, function($a, $b) { |
|
return strtolower($a['ragione_sociale']) <=> strtolower($b['ragione_sociale']); |
|
}); |
|
} |
|
} |
|
if (!empty($pec)) { |
|
$destinatari = array_merge($destinatari,$pec); |
|
} |
|
} |
|
if (!empty($destinatari)) { |
|
if (isset($destinatari["codice"]) || (!empty($destinarioPEC) && !is_array($destinatari))) { $destinatari = [$destinatari]; } |
|
$error = false; |
|
$get_sezione = purify($_GET["sezione"]); |
|
$get_codice_elemento = purify($_GET["codice_elemento"] ?? 0); |
|
$get_sub_elemento = purify($_GET["sub_elemento"] ?? 0); |
|
$get_codice_pec = purify($_GET["codice_pec"] ?? 0); |
|
if (!$_SESSION["utente"]->readOnly) { ?> |
|
<form action="/backend/comunicazioni/send.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_pec" type="hidden" name="codice_pec" value="<?= (int) $get_codice_pec ?>"> |
|
<div class="form-group"> |
|
<label for="oggetto"><?= __("oggetto") ?></label> |
|
<input name="oggetto" id="oggetto" class="form-control" title="<?= __("oggetto") ?>" rel="S;0;0;A"> |
|
</div> |
|
<div class="form-group"> |
|
<label for="corpo"><?= __("Messaggio") ?></label> |
|
<textarea name="corpo" id="corpo" class="ckeditor_full" title="<?= __("Messaggio") ?>" rel="S;0;0;A"></textarea> |
|
</div> |
|
<div class="card mb-2"> |
|
<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("comunicazione"); ?> |
|
</div> |
|
</div> |
|
<div class="card"> |
|
<div class="card-header"> |
|
<span data-target="#msgDestinatari" class="card-title"> |
|
<span class="fa fa-users"></span> <?= __("Destinatari") ?> (<span id="msgDestinatariCount"><?= count($destinatari) ?></span>) |
|
</span> |
|
</div> |
|
<div class="card-body collapse" id="msgDestinatari"> |
|
<table class="table table-striped table-hover"> |
|
<thead> |
|
<tr> |
|
<? if (empty($destinarioPEC)) { ?> |
|
<th><?= __("Codice fiscale") ?></th> |
|
<th><?= __("Denominazione") ?></th> |
|
<th><?= __("PEC") ?></th> |
|
<? } else { ?> |
|
<th><?= __("PEC") ?></th> |
|
<? } ?> |
|
<? if (count($destinatari) > 1) { ?><th></th><? } ?> |
|
</tr> |
|
</thead> |
|
<tbody> |
|
<? |
|
foreach($destinatari AS $oe) { |
|
?> |
|
<tr class="msgDestinatario"> |
|
<? if (!empty($oe["ragione_sociale"])) { ?> |
|
<td> |
|
<input type="hidden" name="destinatari[]" value="<?= $oe["codice"] ?>"> |
|
<?= $oe["codice_fiscale_impresa"] ?> |
|
</td> |
|
<td><?= $oe["ragione_sociale"] ?></td> |
|
<td><?= $oe["pec"] ?></td> |
|
<? } else { ?> |
|
<td> |
|
<input type="hidden" name="destinatari[]" value="<?= $oe ?>"> |
|
<?= $oe ?> |
|
</td> |
|
<? } ?> |
|
<? if (count($destinatari) > 1) { ?> |
|
<td class="text-right"> |
|
<button class="btn btn-sm btn-danger" onClick="$(this).parent().parent().remove(); $('#msgDestinatariCount').html($('.msgDestinatario').length);"> |
|
<span class="fa fa-times"></span> |
|
</button> |
|
</td> |
|
<? } ?> |
|
</tr> |
|
<? |
|
} |
|
?> |
|
</tbody> |
|
</table> |
|
</div> |
|
</div> |
|
<button class="mt-2 btn btn-block btn-success" onClick="return confirm('<?= __("Sei sicuro di voler procedere?") ?>');"> |
|
<span class="fa fa-paper-plane"></span> <?= __("Invia") ?> |
|
</button> |
|
</form> |
|
<? |
|
} else { |
|
alertManager::printAlertBox(__("Impossibile procedere")); |
|
} |
|
} |
|
} |
|
} |
|
if ($error) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} |
|
?>
|