Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
En00x committed Sep 27, 2015
1 parent b8506ad commit a28115a
Show file tree
Hide file tree
Showing 17 changed files with 422 additions and 128 deletions.
89 changes: 89 additions & 0 deletions css/admin_general.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#ts_head {
width: calc(100% - 20px);
max-width: 800px;
text-align: center;
font-size: 30px;
}

#ts_load {
display: flex;
width: calc(100% - 20px);
max-width: 800px;
align-items: center;
justify-content: center;
}

#add_form {
width: calc(100% - 20px);
max-width: 800px;
}

#add_form table {
width: 100%;
box-sizing: border-box !important;
border-collapse: separate !important;
border-spacing: 0 !important;
}

#add_form table tr {
line-height: 3;
}

h3 {
margin-top: 5px;
color: red;
}


/* Thanks to css-spinners.com */
@-moz-keyframes three-quarters-loader {
0% {
-moz-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@-webkit-keyframes three-quarters-loader {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes three-quarters-loader {
0% {
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
/* :not(:required) hides this rule from IE9 and below */
.three-quarters-loader:not(:required) {
-moz-animation: three-quarters-loader 1250ms infinite linear;
-webkit-animation: three-quarters-loader 1250ms infinite linear;
animation: three-quarters-loader 1250ms infinite linear;
border: 8px solid #2faadd;
border-right-color: transparent;
border-radius: 50%;
box-sizing: border-box;
display: inline-block;
position: relative;
overflow: hidden;
text-indent: -9999px;
width: 50px;
height: 50px;
visibility: hidden;
}
File renamed without changes.
18 changes: 18 additions & 0 deletions includes/admin/general-save.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
// Zugriff einschränken
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
// Um $wpdb nutzen zu können
global $wpdb;

$opt1 = sanitize_text_field($_POST["opt1"]);
$opt2 = sanitize_text_field($_POST["opt2"]);
$opt3 = sanitize_text_field($_POST["opt3"]);
$datepicker = sanitize_text_field($_POST["datepicker"]);

$wpdb->query($wpdb->prepare("UPDATE wp_sts_options SET ts_value = CASE
WHEN ts_option = 'opt_field_1' THEN %s
WHEN ts_option = 'opt_field_2' THEN %s
WHEN ts_option = 'opt_field_3' THEN %s
WHEN ts_option = 'datepicker' THEN %s
END", $opt1, $opt2, $opt3, $datepicker));
?>
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ function USERS_callback() {
wp_die();
}
add_action( 'wp_ajax_USERS', 'USERS_callback' );

function SAVE_callback() {
include_once(TS_DIR.'includes/admin/general-save.php');
wp_die();
}
add_action( 'wp_ajax_SAVE', 'SAVE_callback' );

function GENERAL_LOAD_callback() {
include_once(TS_DIR.'includes/admin/options-general.php');
wp_die();
}
add_action( 'wp_ajax_GENERAL_LOAD', 'GENERAL_LOAD_callback' );
?>
54 changes: 54 additions & 0 deletions includes/admin/options-general.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
// Zugriff einschränken
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
// Um $wpdb nutzen zu können
global $wpdb;

$opt1 = $wpdb->get_var("SELECT ts_value FROM wp_sts_options WHERE ts_option = 'opt_field_1'");
$opt2 = $wpdb->get_var("SELECT ts_value FROM wp_sts_options WHERE ts_option = 'opt_field_2'");
$opt3 = $wpdb->get_var("SELECT ts_value FROM wp_sts_options WHERE ts_option = 'opt_field_3'");
$datepicker = $wpdb->get_var("SELECT ts_value FROM wp_sts_options WHERE ts_option = 'datepicker'");
?>
<h1 id="ts_head"><?php _e('General Options', 'simple-support-ticket-system'); ?></h1>
<div id="ts_load"><div class="three-quarters-loader"></div></div>
<div id="ts_content">
<form id="add_form" onsubmit="addChanges();return false;">
<table>
<tr>
<td>
<?php _e('Title Optional Field 1:', 'simple-support-ticket-system'); ?>
</td>
<td>
<input id="add_opt1" type="text" size="32" maxlength="50" name="opt1" value="<?php echo $opt1; ?>">
</td>
<tr>
<tr>
<td>
<?php _e('Title Optional Field 2:', 'simple-support-ticket-system'); ?>
</td>
<td>
<input id="add_opt2" type="text" size="32" maxlength="50" name="opt2" value="<?php echo $opt2; ?>">
</td>
</tr>
<tr>
<td>
<?php _e('Title Optional Field 3:', 'simple-support-ticket-system'); ?>
</td>
<td>
<input id="add_opt3" type="text" size="32" maxlength="50" name="opt3" value="<?php echo $opt3; ?>">
</td>
</tr>
<tr>
<td>
<?php _e('Title Datepicker Field:', 'simple-support-ticket-system'); ?>
</td>
<td>
<input id="add_datepicker"type="text" size="32" maxlength="50" name="datepick" value="<?php echo $datepicker; ?>">
</td>
</tr>
</table>
<hr>
<h3><?php _e('An empty Title will hide this Field in the Submit-Form', 'simple-support-ticket-system'); ?></h3>
<p class="submit"><input class="button button-primary" type="submit" value="<?php _e('Save Settings', 'simple-support-ticket-system'); ?>"></input></p>
</form>
</div>
2 changes: 1 addition & 1 deletion includes/admin/options-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<?php _e('Last name:', 'simple-support-ticket-system'); ?><br>
<input id="add_lastname" type="text" size="24" maxlength="30" name="name"><br><br>

<?php _e('Admin', 'simple-support-ticket-system'); ?>:
<?php _e('Admin:', 'simple-support-ticket-system'); ?>
<input id="add_admin" type="checkbox" name="admin" value="1"><br>

<p class="submit"><input class="button button-primary" type="submit" value="<?php _e('Add user', 'simple-support-ticket-system'); ?>"></input></p>
Expand Down
6 changes: 3 additions & 3 deletions includes/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@
</td>
<td style="text-align:right">
<?php
if(isset($row->termin))
if(isset($row->datepicker))
{
_e('Appointment', 'simple-support-ticket-system');
echo ": <b>" . esc_html($row->termin) . "</b>";
echo $wpdb->get_var("SELECT ts_value FROM wp_sts_options WHERE ts_option = 'datepicker'");
echo ": <b>" . esc_html($row->datepicker) . "</b>";
}
?>
</td>
Expand Down
15 changes: 15 additions & 0 deletions includes/db-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,20 @@

$wpdb->query("UPDATE wp_sts_options SET ts_value = '102' WHERE ts_option = 'db_version'");
}
if($db_version < 103) {
$wpdb->query("ALTER TABLE wp_sts_tickets
ADD datepicker VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
;");

$wpdb->query("ALTER TABLE wp_sts_options MODIFY ts_value VARCHAR(50)");

$wpdb->query("INSERT INTO wp_sts_options (ts_option, ts_value) VALUES
('opt_field_1', 'Optional Field 1 (Change in Settings)'),
('opt_field_2', 'Optional Field 2 (Change in Settings)'),
('opt_field_3', 'Optional Field 3 (Change in Settings)'),
('datepicker', 'Datepicker Field (Change in Settings)')");

$wpdb->query("UPDATE wp_sts_options SET ts_value = '103' WHERE ts_option = 'db_version'");
}
}
?>
42 changes: 25 additions & 17 deletions includes/form.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
<?php
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
global $wpdb;

$opt1 = $wpdb->get_var("SELECT ts_value FROM wp_sts_options WHERE ts_option = 'opt_field_1'");
$opt2 = $wpdb->get_var("SELECT ts_value FROM wp_sts_options WHERE ts_option = 'opt_field_2'");
$opt3 = $wpdb->get_var("SELECT ts_value FROM wp_sts_options WHERE ts_option = 'opt_field_3'");
$datepicker = $wpdb->get_var("SELECT ts_value FROM wp_sts_options WHERE ts_option = 'datepicker'");

if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$form_name = $current_user->user_lastname . ', ' . $current_user->user_firstname;
$form_mail = $current_user->user_email;
$readonly = 'readonly';
} else if (isset($_COOKIE["ts_username"])) {
$user = $_COOKIE["ts_username"];
$form_name = $wpdb->get_var("SELECT name FROM wp_sts_login WHERE username = '$user'");
$form_mail = $wpdb->get_var("SELECT mail FROM wp_sts_login WHERE username = '$user'");
$readonly = 'readonly';
} else {
$form_mail = '';
$form_name = '';
$readonly = '';
}
?>
<div id="form_content">
Expand All @@ -21,28 +29,30 @@
<form id="ticket" onsubmit="submitTicket();return false;">
<div>
<span class="required2"><?php _e('Name:', 'simple-support-ticket-system'); ?></span>
<input id="add_name" name="name" class="required" required="required" type="text" value="<?php echo $form_name; ?>"/>
<input id="add_name" name="name" class="required" required="required" type="text" value="<?php echo $form_name; ?>" <?php echo $readonly; ?>/>
<span class="required2"><?php _e('E-Mail:', 'simple-support-ticket-system'); ?></span>
<input id="add_mail" name="mail" class="required" required="required" type="email" value="<?php echo $form_mail; ?>"/>
<span><?php _e('Optional Field 1:', 'simple-support-ticket-system'); ?></span>
<input id="add_telefon" name="telefon" type="text" />
<span><?php _e('Optional Field 2:', 'simple-support-ticket-system'); ?></span>
<input id="add_raum" name="raum" type="text" />
<span><?php _e('Optional Field 3:', 'simple-support-ticket-system'); ?></span>
<input id="add_rechner" name="rechner" type="text" />
<input id="add_mail" name="mail" class="required" required="required" type="email" value="<?php echo $form_mail; ?>" <?php echo $readonly; ?>/>
<?php if($opt1 != ''){ ?>
<span><?php echo esc_html($opt1) ?></span>
<input id="add_telefon" name="telefon" type="text" />
<?php }
if($opt2 != ''){ ?>
<span><?php echo esc_html($opt2) ?></span>
<input id="add_raum" name="raum" type="text" />
<?php }
if($opt3 != ''){ ?>
<span><?php echo esc_html($opt3) ?></span>
<input id="add_rechner" name="rechner" type="text" />
<?php } ?>
</div>
<div>
<span class="required2"><?php _e('Title:', 'simple-support-ticket-system'); ?></span>
<input id="add_title" name="title" class="required" required="required" maxLength="50" type="text" />
<span class="required2"><?php _e('Problem:', 'simple-support-ticket-system'); ?></span>
<textarea id="add_problem" name="problem" class="required" required="required"></textarea>
<!--div style="margin-bottom: 20px"><input type="checkbox" name="status" value="yes"> <?php _e('Status information by E-Mail', 'simple-support-ticket-system'); ?></input></div-->
<?php
// Terminfeld wenn eingeloggt
if(isset($_COOKIE["ts_username"]))
{
?>
<span><?php _e('Appointment:', 'simple-support-ticket-system'); ?></span>
<?php if($datepicker != ''){ ?>
<span><?php echo esc_html($datepicker) ?></span>
<input id="add_termin" name="termin" type="text" type="text" maxLength="10" class="form-control">
<script>
jQuery(document).ready(function() {
Expand All @@ -54,9 +64,7 @@
});
});
</script>
<?php
}
?>
<?php } ?>
<input id="rcheck" type="text" name="rcheck" />
<input type="submit" id="go" value="<?php _e('Report problem', 'simple-support-ticket-system'); ?>" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion includes/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
if($termin != NULL)
{
$time = strtotime($termin);
$wpdb->query($wpdb->prepare("UPDATE wp_sts_tickets SET termin=%s, termin_timestamp=%s WHERE id='$id->id'", $termin, $time));
$wpdb->query($wpdb->prepare("UPDATE wp_sts_tickets SET datepicker=%s WHERE id='$id->id'", $termin));
}
if($status != NULL)
{
Expand Down
6 changes: 3 additions & 3 deletions includes/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@
</td>
<td style="text-align:right">
<?php
if(isset($row->termin))
if(isset($row->datepicker))
{
_e('Appointment', 'simple-support-ticket-system');
echo ": <b>" . esc_html($row->termin) . "</b>";
echo $wpdb->get_var("SELECT ts_value FROM wp_sts_options WHERE ts_option = 'datepicker'");
echo ": <b>" . esc_html($row->datepicker) . "</b>";
}
?>
</td>
Expand Down
33 changes: 33 additions & 0 deletions js/options-general.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
jQuery(document).ready(function() {
// Ladeanimation
jQuery(document)
.ajaxStart(function () {
jQuery('.three-quarters-loader').css('visibility', 'visible');
})
.ajaxStop(function () {
jQuery('.three-quarters-loader').css('visibility', 'hidden');
});
});

function addChanges() {
var opt1 = jQuery('#add_opt1').val();
var opt2 = jQuery('#add_opt2').val();
var opt3 = jQuery('#add_opt3').val();
var datepicker = jQuery('#add_datepicker').val();

var data = {
'action': 'SAVE',
'opt1': opt1,
'opt2': opt2,
'opt3': opt3,
'datepicker': datepicker,
};

jQuery.post(ajax_object.ajax_url, data, function() {
var data2 = {'action': 'GENERAL_LOAD'};
jQuery.post(ajax_object.ajax_url, data2, function(response) {
var final_data = jQuery(response).find('#ajax_form').html();
jQuery('#ajax_form').html(final_data);
});
});
}
Binary file modified languages/simple-support-ticket-system-de_DE.mo
Binary file not shown.
Loading

0 comments on commit a28115a

Please sign in to comment.