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