1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-18 03:09:32 +01:00
openstamanager/modules/utenti/user.php

100 lines
2.5 KiB
PHP
Raw Normal View History

<?php
include_once __DIR__.'/../../core.php';
use Models\Group;
use Models\User;
2017-09-12 14:53:19 +02:00
Permissions::check('rw');
$id_utente = filter('id_utente');
$user = User::find($id_utente);
$utente = $user ? $user->toArray() : [];
// Gruppo della selezione
if (!empty($id_record)) {
$gruppo_utente = Group::find($id_record)->descrizione;
2018-06-26 14:30:26 +02:00
$gruppi = [
'Clienti' => 'Cliente',
'Tecnici' => 'Tecnico',
'Agenti' => 'Agente',
];
$gruppo = $gruppi[$gruppo_utente];
}
2017-09-12 14:53:19 +02:00
// Lettura sedi dell'utente già impostate
if (!empty($user)) {
$sedi = $dbo->fetchOne('SELECT GROUP_CONCAT(idsede) as sedi FROM zz_user_sedi WHERE id_user='.prepare($id_utente).' GROUP BY id_user')['sedi'];
}
echo '
<form action="" method="post" enctype="multipart/form-data" id="user_update">
<input type="hidden" name="op" value="update_user">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="id_utente" value="'.$utente['id'].'">';
include $structure->filepath('components/photo.php');
include $structure->filepath('components/base.php');
2019-07-25 17:20:24 +02:00
if (!empty($user)) {
echo '
<div class="row">
<div class="col-md-12">
2019-07-30 16:51:33 +02:00
{[ "type": "checkbox", "label": "'.tr('Cambia password').'", "name": "change_password", "value": "0" ]}
2019-07-25 17:20:24 +02:00
</div>
</div>
<script>
2019-07-30 16:51:33 +02:00
$(function() {
$("#password").attr("disabled", true);
$("#submit-button").attr("disabled", false).removeClass("disabled");
});
2019-07-25 17:20:24 +02:00
$("#change_password").change(function() {
if (this.checked) {
$("#password").attr("disabled", false);
$("#password").change();
} else {
$("#password").attr("disabled", true);
$("#submit-button").attr("disabled", false).removeClass("disabled");
}
})
</script>';
}
include $structure->filepath('components/password.php');
echo '
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<button type="button" onclick="submitCheck()" class="btn btn-primary" id="submit-button">';
if (empty($user)) {
echo '
<i class="fa fa-plus"></i> '.tr('Aggiungi');
} else {
echo '
<i class="fa fa-edit"></i> '.tr('Modifica');
}
echo '
</button>
</div>
</div>
</form>
<script>
function submitCheck() {
var username = parseInt($("#username").attr("valid"));
if(username) {
$("#user_update").submit();
}
}
</script>
2019-07-26 18:05:19 +02:00
<script>$(document).ready(init)</script>';