Controlli su scheda anagrafica
Se l'anagrafica è stata eliminata disabilito anche i relativi utenti. Blocco tutti i campi e mostro messaggio eliminazione.
This commit is contained in:
parent
52fb10a456
commit
6d084f1d67
|
@ -265,8 +265,14 @@ switch (post('op')) {
|
|||
if (!str_contains($records[0]['idtipianagrafica'], $id_azienda)) {
|
||||
$dbo->query('UPDATE an_anagrafiche SET deleted = 1 WHERE idanagrafica = '.prepare($id_record).Modules::getAdditionalsQuery($id_module));
|
||||
|
||||
// Se l'anagrafica è collegata ad un utente lo disabilito
|
||||
$dbo->query('UPDATE zz_users SET enabled = 0 WHERE idanagrafica = '.prepare($id_record).Modules::getAdditionalsQuery($id_module));
|
||||
|
||||
|
||||
$_SESSION['infos'][] = tr('Anagrafica eliminata!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,9 @@ if (!$cliente) {
|
|||
}
|
||||
|
||||
?>
|
||||
|
||||
<form action="" method="post" id="edit-form" >
|
||||
<fieldset <?php echo (!$records[0]['deleted']) ? '' : 'disabled'; ?> >
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="op" value="update">
|
||||
|
||||
|
@ -419,15 +421,21 @@ if (!empty($google)) {
|
|||
?>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{( "name": "filelist_and_upload", "id_module": "<?php echo $id_module; ?>", "id_record": "<?php echo $id_record; ?>" )}
|
||||
|
||||
<?php
|
||||
|
||||
//fatture, ddt, preventivi, contratti, ordini, interventi collegati a questa anagrafica
|
||||
if (!$records[0]['deleted']){
|
||||
|
||||
//fatture, ddt, preventivi, contratti, ordini, interventi, utenti collegati a questa anagrafica
|
||||
$elementi = $dbo->fetchArray('SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idanagrafica` = '.prepare($id_record).')
|
||||
|
||||
UNION
|
||||
SELECT `zz_users`.`id`, `zz_users`.`created_at` AS data, `zz_users`.`username` AS numero, 0 AS `numero_esterno`, "Utente" AS tipo_documento, 0 AS `dir` FROM `zz_users` WHERE `zz_users`.`idanagrafica` = '.prepare($id_record).'
|
||||
|
||||
UNION
|
||||
SELECT `or_ordini`.`id`, `or_ordini`.`data`, `or_ordini`.`numero`, `or_ordini`.`numero_esterno`, `or_tipiordine`.`descrizione` AS tipo_documento, `or_tipiordine`.`dir` FROM `or_ordini` JOIN `or_tipiordine` ON `or_tipiordine`.`id` = `or_ordini`.`idtipoordine` WHERE `or_ordini`.`idanagrafica` = '.prepare($id_record).'
|
||||
|
||||
|
@ -453,7 +461,7 @@ if (!empty($elementi)) {
|
|||
<ul>';
|
||||
|
||||
foreach ($elementi as $elemento) {
|
||||
$descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [
|
||||
$descrizione = tr('_DOC_ _NUM_ del _DATE_', [
|
||||
'_DOC_' => $elemento['tipo_documento'],
|
||||
'_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($elemento['data']),
|
||||
|
@ -461,7 +469,10 @@ if (!empty($elementi)) {
|
|||
|
||||
//se non è un preventivo è un ddt o una fattura
|
||||
//se non è un ddt è una fattura.
|
||||
if (in_array($elemento['tipo_documento'], ['Intervento'])) {
|
||||
if (in_array($elemento['tipo_documento'], ['Utente'])) {
|
||||
$modulo = 'Utenti e permessi';
|
||||
}
|
||||
elseif (in_array($elemento['tipo_documento'], ['Intervento'])) {
|
||||
$modulo = 'Interventi';
|
||||
}
|
||||
elseif (in_array($elemento['tipo_documento'], ['Preventivo'])) {
|
||||
|
@ -505,6 +516,13 @@ if (!str_contains($records[0]['idtipianagrafica'], $id_azienda)) {
|
|||
<div class=\'alert alert-warning\' >'.tr('Questa è l\'anagrafica "Azienda" e non è possibile eliminarla').'.</div>';
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
echo '
|
||||
<div class=\'alert alert-danger\' >'.tr('Questa anagrafica è stata eliminata').'.</div>';
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
|
|
@ -17,8 +17,14 @@ if ($self_edit) {
|
|||
$idgruppo = intval(filter('idgruppo'));
|
||||
$id_utente = filter('id_utente');
|
||||
|
||||
//gruppo della selezione
|
||||
$nome_gruppo = $dbo->fetchArray('SELECT nome FROM zz_groups WHERE id='.prepare($idgruppo))[0]['nome'];
|
||||
$nome_gruppo = substr($nome_gruppo, 0, -1).'o';
|
||||
$gruppi = [
|
||||
'Clienti' => 'Cliente',
|
||||
'Tecnici' => 'Tecnico',
|
||||
'Agenti' => 'Agente',
|
||||
];
|
||||
$nome_gruppo = $gruppi[$nome_gruppo];
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue