Support for adding custom service type
This commit is contained in:
parent
abb395505f
commit
848c4aad96
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
include_once '../../core.php';
|
||||
init_class();
|
||||
$user->requirelogin(false);
|
||||
|
||||
if(isset($_POST["type"])){
|
||||
$type = $_POST["type"];
|
||||
$risultato = $database->exec("INSERT INTO `%PREFIX%_type` (`name`) VALUES (:name);", false, [":name" => $type]);
|
||||
$user->log("Aggiunta tipologia intervento", $user->auth->getUserId(), $user->auth->getUserId(), date("d/m/Y"), date("H:i.s"));
|
||||
}
|
|
@ -1,18 +1,14 @@
|
|||
<?php
|
||||
error_reporting(-1);
|
||||
echo("prova");
|
||||
|
||||
include_once '../../core.php';
|
||||
init_class();
|
||||
var_dump("prova2");
|
||||
$user->requirelogin(false);
|
||||
$user->online_time_update();
|
||||
|
||||
if(isset($_POST["change_id"]) && $_POST["dispo"] == 1 /* && $_POST["token_list"] == $_SESSION['token_list'] */){
|
||||
$risultato = $database->exec("UPDATE `%PREFIX%_profiles` SET `available` = '1' WHERE `%PREFIX%_profiles`.`id` = :id;", false, [":id" => $_POST["change_id"]]);
|
||||
$user->log("Attivazione disponibilita'", $_POST["change_id"], $user->auth->getUserId(), date("d/m/Y"), date("H:i.s"));
|
||||
$risultato = $database->exec("UPDATE `%PREFIX%_profiles` SET `available` = '1' WHERE `%PREFIX%_profiles`.`id` = :id;", false, [":id" => $_POST["change_id"]]);
|
||||
$user->log("Attivazione disponibilita'", $_POST["change_id"], $user->auth->getUserId(), date("d/m/Y"), date("H:i.s"));
|
||||
} else if(isset($_POST["change_id"]) && $_POST["dispo"] == 0 /* && $_POST["token_list"] == $_SESSION['token_list'] */){
|
||||
$risultato = $database->exec("UPDATE `%PREFIX%_profiles` SET `available` = '0' WHERE `%PREFIX%_profiles`.`id` = :id;", false, [":id" => $_POST["change_id"]]);
|
||||
$user->log("Rimozione disponibilita'", $_POST["change_id"], $user->auth->getUserId(), date("d/m/Y"), date("H:i.s"));
|
||||
$risultato = $database->exec("UPDATE `%PREFIX%_profiles` SET `available` = '0' WHERE `%PREFIX%_profiles`.`id` = :id;", false, [":id" => $_POST["change_id"]]);
|
||||
$user->log("Rimozione disponibilita'", $_POST["change_id"], $user->auth->getUserId(), date("d/m/Y"), date("H:i.s"));
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -100,10 +100,11 @@
|
|||
<br>
|
||||
<label><b>{{ 'Service type'|t }}</b></label>
|
||||
<br>
|
||||
<select name='type' class="tipi">
|
||||
<select name='type' class="types">
|
||||
{% for type in service.types %}
|
||||
<option value='{{ type.name }}'>{{ type.name }}</option>
|
||||
{% endfor %}
|
||||
<option value='add_new'>{{ 'Add type...'|t }}</option>
|
||||
</select>
|
||||
<br>
|
||||
<input id="modalità" type="hidden" value="{{ service.modalità }}" name="mod"></input>
|
||||
|
@ -113,6 +114,29 @@
|
|||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$( ".types" ).change(function() {
|
||||
var type = "";
|
||||
$( ".types option:selected" ).each(function() {
|
||||
type = $( this ).val();
|
||||
});
|
||||
console.log(type);
|
||||
if(type == "add_new"){
|
||||
new_type = prompt("{{ 'Insert type name:'|t }}");
|
||||
if(!new_type) return;
|
||||
$.ajax({
|
||||
url: "resources/ajax/ajax_add_type.php",
|
||||
method: "POST",
|
||||
data: {
|
||||
type: new_type
|
||||
},
|
||||
success: function (data) {
|
||||
$('option:last-of-type').before($('<option>').val(new_type).text(new_type));
|
||||
$('option[value='+new_type+']').prop('selected', 'selected').change();
|
||||
toastr.success(`{{ "Type '%s' added successfully."|t|format('${new_type}') }}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
{% if service.modalità == "edit" %}
|
||||
$.each('{{ values.chief }}'.split(','), function (index, value) {
|
||||
$('.chief-' + value).prop('checked', true);
|
||||
|
@ -127,6 +151,14 @@
|
|||
$('#notes').val('{{ values.notes }}');
|
||||
{% endif %}
|
||||
$('form').submit(function () {
|
||||
var type = "";
|
||||
$( ".types option:selected" ).each(function() {
|
||||
type = $( this ).val();
|
||||
});
|
||||
if(type == "add_new"){
|
||||
toastr.error("{{ 'You must select a valid service type!'|t }}");
|
||||
return false;
|
||||
}
|
||||
var progressivo_valido = /^[0-9/]{3,6}$/
|
||||
var progressivo = $('#progressivo').val();
|
||||
if (!progressivo_valido.test(progressivo)) {
|
||||
|
|
|
@ -85,5 +85,9 @@ return [
|
|||
"Wrong password" => "Wrong password",
|
||||
"Email not verified" => "Email not verified",
|
||||
"Wrong username" => "Wrong username",
|
||||
"Too many requests" => "Too many requests"
|
||||
"Too many requests" => "Too many requests",
|
||||
"Add type..." => "Add type...",
|
||||
"Insert type name:" => "Insert type name:",
|
||||
"Type '%s' added successfully." => "Type '%s' added successfully.",
|
||||
"You must select a valid service type!" => "You must select a valid service type!"
|
||||
];
|
||||
|
|
|
@ -85,5 +85,9 @@ return [
|
|||
"Wrong password" => "Password errata",
|
||||
"Email not verified" => "Indirizzo email non verificato",
|
||||
"Wrong username" => "Username errato",
|
||||
"Too many requests" => "Troppi tentativi effettuati"
|
||||
"Too many requests" => "Troppi tentativi effettuati",
|
||||
"Add type..." => "Aggiungi tipologia...",
|
||||
"Insert type name:" => "Inserisci nome della tipologia:",
|
||||
"Type '%s' added successfully." => "Tipologia '%s' aggiunta con successo.",
|
||||
"You must select a valid service type!" => "Devi selezionare una tipologia di intervento valida!"
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue