init commit
This commit is contained in:
43
src/snippets/172_registration_maxlength.php
Normal file
43
src/snippets/172_registration_maxlength.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_action('wp_enqueue_scripts', "hook_javascript_2");
|
||||||
|
function hook_javascript_2() {
|
||||||
|
if (page_id() === 222) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
if ( jQuery('.mepr-signup-form').length ) {
|
||||||
|
document.getElementById("user_first_name1").setAttribute('maxLength', '20');
|
||||||
|
document.getElementById("user_last_name1").setAttribute('maxLength', '20');
|
||||||
|
document.getElementById("mepr_telefon_mobil1").setAttribute('maxLength', '15');
|
||||||
|
document.getElementById("user_email1").setAttribute('maxLength', '50');
|
||||||
|
|
||||||
|
if( jQuery('#mepr_user_password1').length )
|
||||||
|
document.getElementById("mepr_user_password1").setAttribute('maxLength', '50');
|
||||||
|
|
||||||
|
if( jQuery('#mepr_user_password_confirm1').length )
|
||||||
|
document.getElementById("mepr_user_password_confirm1").setAttribute('maxLength', '50');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else if (page_id() === 986) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
if ( jQuery('.mepr-account-form').length ) {
|
||||||
|
document.getElementById("user_first_name").setAttribute('maxLength', '20');
|
||||||
|
document.getElementById("user_last_name").setAttribute('maxLength', '20');
|
||||||
|
document.getElementById("mepr_telefon_mobil").setAttribute('maxLength', '15');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
909
src/snippets/222_pikaday_modifications.php
Normal file
909
src/snippets/222_pikaday_modifications.php
Normal file
@@ -0,0 +1,909 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'ninja_forms_enqueue_scripts', 'my_pikaday_modifications' );
|
||||||
|
function my_pikaday_modifications() {
|
||||||
|
if(page_id() === 222) {
|
||||||
|
|
||||||
|
// PHP VARS
|
||||||
|
$is_user_logged_in = is_user_logged_in();
|
||||||
|
if( $is_user_logged_in ) {
|
||||||
|
$balance = mycred_return_users_balance();
|
||||||
|
|
||||||
|
if( get_own_nonpremium_requests() )
|
||||||
|
$i_nonpremium_requests = count(get_own_nonpremium_requests());
|
||||||
|
else
|
||||||
|
$i_nonpremium_requests = 0;
|
||||||
|
|
||||||
|
php_console_log('Balance php: ' . $balance);
|
||||||
|
php_console_log('i_nonpremium_requests php: ' . $i_nonpremium_requests);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
var first_selected_date;
|
||||||
|
var first_selected_date_rounded;
|
||||||
|
var first_selected_time;
|
||||||
|
var second_selected_date;
|
||||||
|
var myOptsCpy;
|
||||||
|
var myOpts;
|
||||||
|
var appointment_type;
|
||||||
|
var standorte_type;
|
||||||
|
var customDatePickerStuff;
|
||||||
|
var datepickerObj = {
|
||||||
|
1: {},
|
||||||
|
2: {}
|
||||||
|
};
|
||||||
|
var cannot_afford_button_bound = false;
|
||||||
|
var bookingTextTable = init_bookingTextTable();
|
||||||
|
|
||||||
|
var is_user_logged_in = "<?php echo $is_user_logged_in ?>";
|
||||||
|
if( is_user_logged_in ) {
|
||||||
|
var mycred_user_balance = "<?php echo $balance ?>";
|
||||||
|
var i_nonpremium_requests = "<?php echo $i_nonpremium_requests ?>";
|
||||||
|
console.log('Balance from js: ' + mycred_user_balance);
|
||||||
|
}
|
||||||
|
|
||||||
|
// DOCUMENT READY
|
||||||
|
jQuery(document).ready(function() {
|
||||||
|
customDatePickerStuff = Marionette.Object.extend({
|
||||||
|
initialize: function() {
|
||||||
|
//console.log('Marionette initialize...');
|
||||||
|
this.listenTo(Backbone.Radio.channel('pikaday'), 'init', this.modifyDatepicker);
|
||||||
|
},
|
||||||
|
modifyDatepicker: function(dateObject, fieldModel) {
|
||||||
|
wait_for_element('ninja-page-id', 'create_destroy_datepicker', dateObject);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
new customDatePickerStuff();
|
||||||
|
});
|
||||||
|
|
||||||
|
// ON CHANGE MULTI PART
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
jQuery(document).on( 'nfFormReady', function( e, layoutView ) {
|
||||||
|
// first time ready
|
||||||
|
let ninja_page_id = jQuery('#ninja-page-id')[0].value;
|
||||||
|
console.log('paooo ' + ninja_page_id);
|
||||||
|
|
||||||
|
if( ninja_page_id == -1 ) {
|
||||||
|
appointment_type = jQuery('input[name=nf-field-101]:checked', '#nf-field-101-wrap').val();
|
||||||
|
console.log('appointment_type: ' + appointment_type);
|
||||||
|
jQuery('#nf-field-101-wrap input').on('change', function() {
|
||||||
|
appointment_type = jQuery('input[name=nf-field-101]:checked', '#nf-field-101-wrap').val();
|
||||||
|
console.log('appointment_type: ' + appointment_type);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nfRadio.channel( 'nfMP' ).on('change:part', function() {
|
||||||
|
console.log('appointment_type: ' + appointment_type);
|
||||||
|
|
||||||
|
let ninja_page_id = jQuery('#ninja-page-id')[0].value;
|
||||||
|
|
||||||
|
// RESET BOOKING TEXT TABLE
|
||||||
|
reset_booking_text_table(ninja_page_id);
|
||||||
|
|
||||||
|
if( ninja_page_id == -1 ) {
|
||||||
|
jQuery('#nf-field-101-wrap input').on('change', function() {
|
||||||
|
appointment_type = jQuery('input[name=nf-field-101]:checked', '#nf-field-101-wrap').val();
|
||||||
|
console.log('appointment_type: ' + appointment_type);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 1 ) {
|
||||||
|
// ON CHANGE START-UHRZEIT
|
||||||
|
jQuery('select#nf-field-57').on('change', function() {
|
||||||
|
console.log('changed 57 to ' + this.value);
|
||||||
|
let uhrzeit = jQuery( "#nf-field-57 option:selected" ).text();
|
||||||
|
bookingTextTable['start-datum']['value_uhrzeit'] = uhrzeit;
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
});
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 2 ) {
|
||||||
|
// ON CHANGE END-UHRZEIT
|
||||||
|
jQuery('select#nf-field-53').on('change', function() {
|
||||||
|
console.log('changed 53 to ' + this.value);
|
||||||
|
let uhrzeit = jQuery( "#nf-field-53 option:selected" ).text();
|
||||||
|
bookingTextTable['end-datum']['value_uhrzeit'] = uhrzeit;
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
if( appointment_type == 'sofort' ) {
|
||||||
|
console.log('SOFORT AND 2');
|
||||||
|
let dateObj = next_businessDay_dateObj();
|
||||||
|
dateObj = roundMinutes(dateObj, 'object');
|
||||||
|
let start_uhrzeit = dateObj.getHours() + ':' + (dateObj.getMinutes()<10?'0':'') + dateObj.getMinutes();
|
||||||
|
let start_datum = german_date_string(dateObj);
|
||||||
|
bookingTextTable['start-datum']['value'] = start_datum;
|
||||||
|
bookingTextTable['start-datum']['value_uhrzeit'] = start_uhrzeit;
|
||||||
|
}
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 3 ) {
|
||||||
|
// ON CHANGE DIENSTLEISTUNG
|
||||||
|
let ausgewaehlt = jQuery( "#nf-field-50 option:selected" ).text();
|
||||||
|
if( ausgewaehlt == 'Bitte auswählen...' ) {
|
||||||
|
bookingTextTable['dienstleistung']['value'] = '-';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ausgewaehlt = trim_string(ausgewaehlt, 43);
|
||||||
|
bookingTextTable['dienstleistung']['value'] = ausgewaehlt;
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery('select#nf-field-50').on('change', function() {
|
||||||
|
console.log('changed 50 to ' + this.value);
|
||||||
|
let ausgewaehlt = jQuery( "#nf-field-50 option:selected" ).text();
|
||||||
|
if( ausgewaehlt == 'Bitte auswählen...' ) {
|
||||||
|
bookingTextTable['dienstleistung']['value'] = '-';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ausgewaehlt = trim_string(ausgewaehlt, 43);
|
||||||
|
bookingTextTable['dienstleistung']['value'] = ausgewaehlt;
|
||||||
|
}
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
});
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 4 ) {
|
||||||
|
// ON CHANGE STANDORTE
|
||||||
|
standorte_type = jQuery('input[name=nf-field-113]:checked', '#nf-field-113-wrap').val();
|
||||||
|
jQuery('#nf-field-113-wrap input').on('change', function() {
|
||||||
|
standorte_type = jQuery('input[name=nf-field-113]:checked', '#nf-field-113-wrap').val();
|
||||||
|
});
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 5 ) {
|
||||||
|
var venuesChecked = new Array();
|
||||||
|
jQuery("#modal-5e6603a34d72d .checkbox-venue").change(function() {
|
||||||
|
if(this.checked) {
|
||||||
|
venuesChecked.push(this.value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
removeA(venuesChecked, this.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof venuesChecked !== 'undefined' && venuesChecked.length > 0) {
|
||||||
|
let value = venuesChecked.length + ' erfolgreich ausgewählt';
|
||||||
|
bookingTextTable['standorte']['value'] = value;
|
||||||
|
}
|
||||||
|
else if (typeof venuesChecked !== 'undefined' && venuesChecked.length == 0) {
|
||||||
|
let value = '-';
|
||||||
|
bookingTextTable['standorte']['value'] = value;
|
||||||
|
}
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 6 ) {
|
||||||
|
// ON CHANGE STANDORTE
|
||||||
|
if( standorte_type == 'berlinweit' ) {
|
||||||
|
bookingTextTable['standorte']['value'] = 'Berlinweit';
|
||||||
|
}
|
||||||
|
else if( standorte_type == 'standorte-auswaehlen' ) {
|
||||||
|
//bookingTextTable['standorte']['value'] = 'Berlinweit';
|
||||||
|
}
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
|
||||||
|
// MAKE IT RAIN
|
||||||
|
jQuery('#nf-field-59').on('click', function() {
|
||||||
|
makeItRain();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function indicator_bookingTextTable(ninja_page_id) {
|
||||||
|
console.log('here');
|
||||||
|
jQuery('.indicator').each(function(i, obj) {
|
||||||
|
obj.innerHTML = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
if( ninja_page_id == 1 )
|
||||||
|
jQuery('#start-datum .indicator').append('<i class="fas fa-long-arrow-alt-right"></i>');
|
||||||
|
else if( ninja_page_id == 2 )
|
||||||
|
jQuery('#end-datum .indicator').append('<i class="fas fa-long-arrow-alt-right"></i>');
|
||||||
|
else if( ninja_page_id == 3 )
|
||||||
|
jQuery('#dienstleistung .indicator').append('<i class="fas fa-long-arrow-alt-right"></i>');
|
||||||
|
else if( ninja_page_id == 4 )
|
||||||
|
jQuery('#standorte .indicator').append('<i class="fas fa-long-arrow-alt-right"></i>');
|
||||||
|
else if( ninja_page_id == 5 )
|
||||||
|
jQuery('#standorte .indicator').append('<i class="fas fa-long-arrow-alt-right"></i>');
|
||||||
|
}
|
||||||
|
|
||||||
|
function init_bookingTextTable() {
|
||||||
|
return {
|
||||||
|
'start-datum': {
|
||||||
|
'label': 'Start-Datum:',
|
||||||
|
'value': '-',
|
||||||
|
'value_uhrzeit': '-',
|
||||||
|
},
|
||||||
|
'end-datum': {
|
||||||
|
'label': 'End-Datum:',
|
||||||
|
'value': '-',
|
||||||
|
'value_uhrzeit': '-',
|
||||||
|
},
|
||||||
|
'dienstleistung': {
|
||||||
|
'label': 'Dienstleistung:',
|
||||||
|
'value': '-',
|
||||||
|
},
|
||||||
|
'standorte': {
|
||||||
|
'label': 'Bürgerämter:',
|
||||||
|
'value': '-',
|
||||||
|
},
|
||||||
|
'preis': {
|
||||||
|
'label': 'Preis:',
|
||||||
|
'value': '-',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function reset_booking_text_table(ninja_page_id) {
|
||||||
|
if( ninja_page_id == -1 ) {
|
||||||
|
jQuery('#booking-text .pp-sub-heading p')[0].textContent = 'Terminsnipe ist dein Portal für die smarte Terminsuche. Bleib\' im Bett, auf der Couch, oder lade deine Mutter zum Essen ein. Schluss mit Warteschleifen. Mach\' was Besseres mit deiner Zeit. Wir übernehmen das.';
|
||||||
|
bookingTextTable = init_bookingTextTable();
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 1 ) {
|
||||||
|
bookingTextTable = init_bookingTextTable();
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 2 ) {
|
||||||
|
bookingTextTable['end-datum']['value'] = '-';
|
||||||
|
bookingTextTable['end-datum']['value_uhrzeit'] = '-';
|
||||||
|
bookingTextTable['dienstleistung']['value'] = '-';
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 3 ) {
|
||||||
|
bookingTextTable['dienstleistung']['value'] = '-';
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 4 ) {
|
||||||
|
bookingTextTable['standorte']['value'] = '-';
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 5 ) {
|
||||||
|
bookingTextTable['standorte']['value'] = '-';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function refresh_booking_text_table(ninja_page_id) {
|
||||||
|
// TABLE
|
||||||
|
let innerHTML = '<table id="booking-text-table">';
|
||||||
|
if ( is_user_logged_in ) {
|
||||||
|
innerHTML = innerHTML + '<tr id="preis">\
|
||||||
|
<td class="indicator"></td><td class="min"></td><td></td>\
|
||||||
|
</tr>';
|
||||||
|
}
|
||||||
|
innerHTML = innerHTML + '<tr id="start-datum">\
|
||||||
|
<td class="indicator"></td><td class="min"></td><td><span id="start-datum-value"></span> <span id="start-uhrzeit-value"></span></td>\
|
||||||
|
</tr>\
|
||||||
|
<tr id="end-datum">\
|
||||||
|
<td class="indicator"></td><td class="min"></td><td><span id="end-datum-value"></span> <span id="end-uhrzeit-value"></span></td>\
|
||||||
|
</tr>\
|
||||||
|
<tr id="dienstleistung">\
|
||||||
|
<td class="indicator"></td><td class="min"></td><td></td>\
|
||||||
|
</tr>\
|
||||||
|
<tr id="standorte">\
|
||||||
|
<td class="indicator"></td><td class="min"></td><td></td>\
|
||||||
|
</tr>\
|
||||||
|
</table>';
|
||||||
|
jQuery('#booking-text .pp-sub-heading p')[0].innerHTML = innerHTML;
|
||||||
|
|
||||||
|
// PREIS
|
||||||
|
if ( is_user_logged_in ) {
|
||||||
|
jQuery('#booking-text-table #preis td')[1].textContent = bookingTextTable['preis']['label'];
|
||||||
|
jQuery('#booking-text-table #preis td')[2].innerHTML = bookingTextTable['preis']['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// START-DATUM
|
||||||
|
jQuery('#booking-text-table #start-datum td')[1].textContent = bookingTextTable['start-datum']['label'];
|
||||||
|
jQuery('#start-datum-value')[0].textContent = bookingTextTable['start-datum']['value'];
|
||||||
|
if( bookingTextTable['start-datum']['value'] != '-' ) {
|
||||||
|
jQuery('#start-uhrzeit-value')[0].textContent = bookingTextTable['start-datum']['value_uhrzeit'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// END-DATUM
|
||||||
|
jQuery('#booking-text-table #end-datum td')[1].textContent = bookingTextTable['end-datum']['label'];
|
||||||
|
jQuery('#end-datum-value')[0].textContent = bookingTextTable['end-datum']['value'];
|
||||||
|
if( bookingTextTable['end-datum']['value'] != '-' ) {
|
||||||
|
jQuery('#end-uhrzeit-value')[0].textContent = bookingTextTable['end-datum']['value_uhrzeit'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// DIENSTLEISTUNG
|
||||||
|
jQuery('#booking-text-table #dienstleistung td')[1].textContent = bookingTextTable['dienstleistung']['label'];
|
||||||
|
jQuery('#booking-text-table #dienstleistung td')[2].textContent = bookingTextTable['dienstleistung']['value'];
|
||||||
|
|
||||||
|
// STANDORTE
|
||||||
|
jQuery('#booking-text-table #standorte td')[1].textContent = bookingTextTable['standorte']['label'];
|
||||||
|
jQuery('#booking-text-table #standorte td')[2].textContent = bookingTextTable['standorte']['value'];
|
||||||
|
|
||||||
|
// INDICATOR
|
||||||
|
indicator_bookingTextTable(ninja_page_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function german_date_string(dateObj) {
|
||||||
|
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', };
|
||||||
|
return dateObj.toLocaleDateString("de-DE");
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_destroy_datepicker(selector, dateObject) {
|
||||||
|
console.log('in create_destroy_datepicker');
|
||||||
|
let ninja_page_id = jQuery('#ninja-page-id')[0].value;
|
||||||
|
|
||||||
|
if (ninja_page_id == 1 && typeof datepickerObj[1]['dateObject'] != "undefined") {
|
||||||
|
console.log('dateObject1 already defined');
|
||||||
|
|
||||||
|
dateObject.pikaday.destroy(); // WE DONT NEED A NEW PIKADAY
|
||||||
|
apply_custom_datepicker_changes(ninja_page_id, dateObject); // SHOW & SET DEFAULT VALUE
|
||||||
|
}
|
||||||
|
else if (ninja_page_id == 2 && typeof datepickerObj[2]['dateObject'] != "undefined") {
|
||||||
|
console.log('dateObject2 already defined');
|
||||||
|
|
||||||
|
dateObject.pikaday.destroy(); // WE DONT NEED A NEW PIKADAY
|
||||||
|
apply_custom_datepicker_changes(ninja_page_id, dateObject); // SHOW & SET DEFAULT VALUE
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('creating and saving dateObject' + ninja_page_id + ' now...');
|
||||||
|
// SAVE DATEPICKER OBJ
|
||||||
|
datepickerObj[ninja_page_id]['dateObject'] = dateObject;
|
||||||
|
apply_custom_datepicker_changes(ninja_page_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function next_businessDay_dateObj() {
|
||||||
|
let server_time = new Date();
|
||||||
|
//let server_time = new Date("April 22, 2020 08:15:00");
|
||||||
|
console.log('server_time: ' + server_time);
|
||||||
|
|
||||||
|
if (server_time.getHours() < businessHoursObj['start']['hours']) {
|
||||||
|
console.log('Before ' + businessHoursObj['start']['hours'] + ' o clock');
|
||||||
|
var dateObj = next_business_day_with_time(server_time, businessHoursObj['start']['hours'], businessHoursObj['start']['minutes'], businessHoursObj['start']['seconds']);
|
||||||
|
}
|
||||||
|
else if (server_time.getHours() >= businessHoursObj['end']['hours']) {
|
||||||
|
console.log('After ' + businessHoursObj['end']['hours'] + ' o clock');
|
||||||
|
let tomorrow = addDays(server_time, 1);
|
||||||
|
var dateObj = next_business_day_with_time(tomorrow, businessHoursObj['start']['hours'], businessHoursObj['start']['minutes'], businessHoursObj['start']['seconds']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('Between ' + businessHoursObj['start']['hours'] + '-' + businessHoursObj['end']['hours'] + ' o clock');
|
||||||
|
dateObj = cloneDate(server_time);
|
||||||
|
if( isWeekend(dateObj) ) {
|
||||||
|
let tomorrow = addDays(dateObj, 1);
|
||||||
|
var dateObj = next_business_day_with_time(tomorrow, businessHoursObj['start']['hours'], businessHoursObj['start']['minutes'], businessHoursObj['start']['seconds']);
|
||||||
|
dateObj = roundMinutes(dateObj, 'object');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dateObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
function cloneDate(date) {
|
||||||
|
return new Date(date.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
function next_business_day_with_time(dateObj, hours, minutes, seconds) {
|
||||||
|
if( !isWeekend(dateObj) ) {
|
||||||
|
console.log('isWeekend: 0');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('isWeekend: 1');
|
||||||
|
dateObj = get_next_business_day(dateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
dateObj.setHours(hours);
|
||||||
|
dateObj.setMinutes(minutes);
|
||||||
|
dateObj.setSeconds(seconds);
|
||||||
|
|
||||||
|
return dateObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_next_business_day(dateObj) {
|
||||||
|
let cloneDateObj = cloneDate(dateObj);
|
||||||
|
var i = 0;
|
||||||
|
while( isWeekend(cloneDateObj) ) {
|
||||||
|
i++;
|
||||||
|
cloneDateObj = addDays(cloneDateObj, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return addDays(dateObj, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addDays(date, days) {
|
||||||
|
var result = new Date(date);
|
||||||
|
result.setDate(result.getDate() + days);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isWeekend(dateObj) {
|
||||||
|
var day = dateObj.getDay();
|
||||||
|
|
||||||
|
return (day === 6) || (day === 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DateDiff(d1, d2, fswitch) {
|
||||||
|
//console.log('Comparing:');
|
||||||
|
//console.log(d1);
|
||||||
|
//console.log(d2);
|
||||||
|
|
||||||
|
if (fswitch == 'inDays') {
|
||||||
|
var t2 = d2.getTime();
|
||||||
|
var t1 = d1.getTime();
|
||||||
|
|
||||||
|
return parseInt((t2-t1)/(24*3600*1000));
|
||||||
|
}
|
||||||
|
else if (fswitch == 'inWeeks') {
|
||||||
|
var t2 = d2.getTime();
|
||||||
|
var t1 = d1.getTime();
|
||||||
|
|
||||||
|
return parseInt((t2-t1)/(24*3600*1000*7));
|
||||||
|
}
|
||||||
|
else if (fswitch == 'inMonths') {
|
||||||
|
var d1Y = d1.getFullYear();
|
||||||
|
var d2Y = d2.getFullYear();
|
||||||
|
var d1M = d1.getMonth();
|
||||||
|
var d2M = d2.getMonth();
|
||||||
|
|
||||||
|
return (d2M+12*d2Y)-(d1M+12*d1Y);
|
||||||
|
}
|
||||||
|
else if (fswitch == 'inYears') {
|
||||||
|
return d2.getFullYear()-d1.getFullYear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_premium_day(date) {
|
||||||
|
let i = DateDiff(new Date(), date, 'inDays');
|
||||||
|
let is_premium_day = 0;
|
||||||
|
for (var key in fastsnipeObj) {
|
||||||
|
if (fastsnipeObj.hasOwnProperty(key)) {
|
||||||
|
let day_end = fastsnipeObj[key]['day_end'] - 2;
|
||||||
|
if (i <= day_end) {
|
||||||
|
is_premium_day = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_premium_day;
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_premium(date, price = null) {
|
||||||
|
let can_afford;
|
||||||
|
let is_premium = is_premium_day(date);
|
||||||
|
if ( is_premium ) {
|
||||||
|
is_premium = 1;
|
||||||
|
if ( !price ) {
|
||||||
|
price = get_fastsnipe_price(date);
|
||||||
|
}
|
||||||
|
can_afford = can_afford_fastsnipe(price);
|
||||||
|
if ( !can_afford ) {
|
||||||
|
can_afford = 0;
|
||||||
|
}
|
||||||
|
else if ( can_afford ) {
|
||||||
|
can_afford = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('No premium day');
|
||||||
|
}
|
||||||
|
|
||||||
|
return [can_afford, price, is_premium];
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_premium_after(can_afford, selector1, selector2, is_premium, price, ninja_page_id) {
|
||||||
|
if( is_premium ) {
|
||||||
|
if( can_afford ) {
|
||||||
|
console.log('User can purchase');
|
||||||
|
}
|
||||||
|
else if( !can_afford ) {
|
||||||
|
if( can_afford === 0 ) {
|
||||||
|
console.log('User has too few coins.');
|
||||||
|
jQuery('#cannot-afford-modal').click();
|
||||||
|
|
||||||
|
if ( ninja_page_id == 1 ) {
|
||||||
|
jQuery( "#cannot-afford-modal-close" ).click(function() {
|
||||||
|
setTimeout(function(){
|
||||||
|
jQuery('#' + selector2).click();
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if ( ninja_page_id == 2 ) {
|
||||||
|
if( !cannot_afford_button_bound ) {
|
||||||
|
jQuery( ".uabb-modal-close" ).click(function() {
|
||||||
|
jQuery('.nf-previous').click();
|
||||||
|
});
|
||||||
|
jQuery( "#cannot-afford-modal-close" ).click(function() {
|
||||||
|
jQuery('.uabb-modal-close').click();
|
||||||
|
jQuery('#nf-label-class-field-101-1').click();
|
||||||
|
jQuery('.nf-next').click();
|
||||||
|
});
|
||||||
|
cannot_afford_button_bound = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( jQuery('#' + selector2).length ) {
|
||||||
|
jQuery('#' + selector2)[0].value = '';
|
||||||
|
}
|
||||||
|
allow_next(0, selector1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('No premium day');
|
||||||
|
if( i_nonpremium_requests >= 1 ) {
|
||||||
|
console.log('User already has 1 ongoing free snipe');
|
||||||
|
jQuery('#nonpremium-limit-modal').click();
|
||||||
|
jQuery( "#nonpremium-limit-close" ).click(function() {
|
||||||
|
jQuery('.uabb-modal-close').click();
|
||||||
|
setTimeout(function(){
|
||||||
|
jQuery('#' + selector2).click();
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
if ( jQuery('#' + selector2).length ) {
|
||||||
|
jQuery('#' + selector2)[0].value = '';
|
||||||
|
}
|
||||||
|
allow_next(0, selector1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function can_afford_fastsnipe(price) {
|
||||||
|
let can_afford = 0;
|
||||||
|
let diff = mycred_user_balance - price;
|
||||||
|
console.log('price: ' + price);
|
||||||
|
console.log('diff: ' + diff);
|
||||||
|
if ( diff >= 0 ) {
|
||||||
|
can_afford = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return can_afford;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_fastsnipe_price(date) {
|
||||||
|
let price = undefined;
|
||||||
|
let i = DateDiff(new Date(), date, 'inDays');
|
||||||
|
for (var key in fastsnipeObj) {
|
||||||
|
if (fastsnipeObj.hasOwnProperty(key)) {
|
||||||
|
let day_end = fastsnipeObj[key]['day_end'] - 2;
|
||||||
|
if (i <= day_end) {
|
||||||
|
price = fastsnipeObj[key]['price'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
function apply_custom_datepicker_changes(ninja_page_id) {
|
||||||
|
console.log('in apply_custom_datepicker_changes');
|
||||||
|
var dateObject = datepickerObj[ninja_page_id]['dateObject'];
|
||||||
|
var show_datepicker;
|
||||||
|
console.log(dateObject);
|
||||||
|
|
||||||
|
if (ninja_page_id == 1) {
|
||||||
|
var single_text_id = 'nf-field-190';
|
||||||
|
}
|
||||||
|
else if (ninja_page_id == 2) {
|
||||||
|
var single_text_id = 'nf-field-189';
|
||||||
|
}
|
||||||
|
|
||||||
|
// CONFIG
|
||||||
|
dateObject.pikaday._o.maxDate = pikaday_maxDate();
|
||||||
|
dateObject.pikaday._o.disableWeekends = true;
|
||||||
|
dateObject.pikaday._o.numberOfMonths = 3;
|
||||||
|
dateObject.pikaday._o.firstDay = 1;
|
||||||
|
dateObject.pikaday._o.i18n = {
|
||||||
|
previousMonth: 'Vormonat',
|
||||||
|
nextMonth: 'Nächster Monat',
|
||||||
|
months: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
|
||||||
|
weekdays: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
|
||||||
|
weekdaysShort: ['So.', 'Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.']
|
||||||
|
};
|
||||||
|
dateObject.pikaday._o.onOpen = function() {
|
||||||
|
console.log('onOpen');
|
||||||
|
|
||||||
|
var rect = document.getElementById('booking-text').getBoundingClientRect();
|
||||||
|
//console.log(rect.top, rect.right, rect.bottom, rect.left);
|
||||||
|
let left = rect.left + 55;
|
||||||
|
let top = rect.top - 0;
|
||||||
|
jQuery('.pika-single').css({
|
||||||
|
left: left + 'px',
|
||||||
|
top: top + 'px'
|
||||||
|
});
|
||||||
|
|
||||||
|
// IF LOGGED IN: COLORIZE DATES
|
||||||
|
if( is_user_logged_in ) {
|
||||||
|
if( ninja_page_id != 2 ) {
|
||||||
|
console.log('colorizing...');
|
||||||
|
colorize_pikaday_spans();
|
||||||
|
inject_pikaday_legend("//div[contains(@class, 'pika-single') and not(contains(@class, 'is-hidden'))]", 'label');
|
||||||
|
}
|
||||||
|
else if( ninja_page_id == 2 ) {
|
||||||
|
if( appointment_type == 'sofort' ) {
|
||||||
|
//let dateObj = new Date();
|
||||||
|
|
||||||
|
let dateObj = next_businessDay_dateObj();
|
||||||
|
console.log('modified date: ' + dateObj.toString());
|
||||||
|
|
||||||
|
pika_change_bg_color(dateObj.getUTCDate(), dateObj.getUTCMonth()+1, dateObj.getUTCFullYear(), 'lightgrey');
|
||||||
|
inject_pikaday_legend("//div[contains(@class, 'pika-single') and not(contains(@class, 'is-hidden'))]", 'start_end');
|
||||||
|
}
|
||||||
|
else if( appointment_type == 'zeitraum' ) {
|
||||||
|
let dateObj = first_selected_date;
|
||||||
|
pika_change_bg_color(dateObj.getUTCDate()+1, dateObj.getUTCMonth()+1, dateObj.getUTCFullYear(), 'lightgrey');
|
||||||
|
inject_pikaday_legend("//div[contains(@class, 'pika-single') and not(contains(@class, 'is-hidden'))]", 'start_end');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (ninja_page_id == 1) {
|
||||||
|
console.log('----------');
|
||||||
|
show_datepicker = 1;
|
||||||
|
|
||||||
|
defaultPart('nf-field-190', dateObject); // INJECT TEXT BUTTON, allow_next(0)
|
||||||
|
//appointment_type = 'zeitraum'; // TYPE
|
||||||
|
set_start_time_for_today('nf-field-57', dateObject); // SET DATE AND TIME
|
||||||
|
|
||||||
|
// ON SELECT
|
||||||
|
dateObject.pikaday._o.onSelect = function() {
|
||||||
|
first_selected_date = dateObject.pikaday.getDate();
|
||||||
|
on_select_single_day_logic('nf-field-57', first_selected_date, dateObject);
|
||||||
|
jQuery( '#nf-field-190' ).val( dateObject.pikaday.toString('YYYY-MM-DD') ).trigger( 'change' ); // WRITE SELECTED DATE INTO TEXT LINE
|
||||||
|
allow_next(1, 'nf-field-190-wrap');
|
||||||
|
|
||||||
|
// IF LOGGED IN: CHECK DAY AGAINST COINS BALANCE
|
||||||
|
if ( is_user_logged_in ) {
|
||||||
|
let [can_afford, price, is_premium] = check_premium(first_selected_date);
|
||||||
|
bookingTextTable['preis']['value'] = price + ' <img src="http://zinomedia.de/terminsnipe/wp-content/uploads/sites/6/2020/03/630865.svg" alt="fastcoins">';
|
||||||
|
console.log('can_afford: ' + can_afford + ' | price: ' + price + ' | is_premium: ' + is_premium);
|
||||||
|
check_premium_after(can_afford, 'nf-field-190-wrap', 'nf-field-190', is_premium, price, ninja_page_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BOOKING-TEXT-TABLE
|
||||||
|
let start_datum = german_date_string(first_selected_date);
|
||||||
|
let start_uhrzeit = jQuery( "#nf-field-57 option:selected" ).text();
|
||||||
|
bookingTextTable['start-datum']['value'] = start_datum;
|
||||||
|
bookingTextTable['start-datum']['value_uhrzeit'] = start_uhrzeit;
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
};
|
||||||
|
|
||||||
|
// TIME ON CHANGE
|
||||||
|
jQuery('#nf-field-57').on('change', function() {
|
||||||
|
first_selected_time = this.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (ninja_page_id == 2) {
|
||||||
|
console.log('----------');
|
||||||
|
|
||||||
|
// TYPE
|
||||||
|
//if (!appointment_type)
|
||||||
|
// appointment_type = 'sofort';
|
||||||
|
|
||||||
|
if ( appointment_type == 'sofort' ) {
|
||||||
|
console.log('sofort fired');
|
||||||
|
set_start_time_for_today('nf-field-53', dateObject);
|
||||||
|
show_datepicker = 1;
|
||||||
|
if ( is_user_logged_in ) {
|
||||||
|
let [can_afford, price, is_premium] = check_premium(new Date(), fastsnipeObj[1]['price']);
|
||||||
|
console.log('can_afford: ' + can_afford + ' | price: ' + price + ' | is_premium: ' + is_premium);
|
||||||
|
show_datepicker = can_afford;
|
||||||
|
check_premium_after(can_afford, 'nf-field-190-wrap', 'nf-field-190', is_premium, price, ninja_page_id );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (appointment_type == 'zeitraum') {
|
||||||
|
console.log('zeitraum fired');
|
||||||
|
dateObject.pikaday._o.minDate = first_selected_date;
|
||||||
|
show_datepicker = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultPart('nf-field-189', dateObject); // INJECT TEXT BUTTON, allow_next(0)
|
||||||
|
|
||||||
|
jQuery("#nf-field-53").val(jQuery("#nf-field-53 option:last").val()); // SELECT LAST OPTION
|
||||||
|
|
||||||
|
// EVENTS
|
||||||
|
dateObject.pikaday._o.onSelect = function() {
|
||||||
|
second_selected_date = dateObject.pikaday.getDate();
|
||||||
|
|
||||||
|
if (appointment_type == 'zeitraum') {
|
||||||
|
if (second_selected_date.setHours(0, 0, 0, 0) == first_selected_date.setHours(0, 0, 0, 0) && same_day(first_selected_date, new Date())) {
|
||||||
|
console.log('Same dates picked and dates are today');
|
||||||
|
setTimeRange('nf-field-53', first_selected_time, '18', 2); // OFFSET 2 = ONE HOUR LATER
|
||||||
|
} else if (second_selected_date.setHours(0, 0, 0, 0) == first_selected_date.setHours(0, 0, 0, 0) && !same_day(first_selected_date, new Date())) {
|
||||||
|
console.log('Same dates picked and but dates are not today');
|
||||||
|
setTimeRange('nf-field-53', first_selected_time, '18', 2); // OFFSET 2 = ONE HOUR LATER
|
||||||
|
} else {
|
||||||
|
setTimeRange('nf-field-53', '07', '18');
|
||||||
|
}
|
||||||
|
} else if (appointment_type == 'sofort') {
|
||||||
|
on_select_single_day_logic('nf-field-53', second_selected_date, dateObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery("#nf-field-53").val(jQuery("#nf-field-53 option:last").val()); // SELECT LAST OPTION
|
||||||
|
jQuery( '#nf-field-189' ).val( dateObject.pikaday.toString('YYYY-MM-DD') ).trigger( 'change' ); // WRITE SELECTED DATE INTO TEXT LINE
|
||||||
|
allow_next(1, 'nf-field-189-wrap');
|
||||||
|
|
||||||
|
// IF LOGGED IN: CHECK DAY AGAINST COINS BALANCE
|
||||||
|
if ( appointment_type == 'sofort' ) {
|
||||||
|
if ( is_user_logged_in ) {
|
||||||
|
let [can_afford, price, is_premium] = check_premium(new Date(), fastsnipeObj[1]['price']);
|
||||||
|
console.log('can_afford: ' + can_afford + ' | price: ' + price + ' | is_premium: ' + is_premium);
|
||||||
|
check_premium_after(can_afford, 'nf-field-189-wrap', 'nf-field-189', is_premium, price);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BOOKING-TEXT-TABLE
|
||||||
|
let end_datum = german_date_string(second_selected_date);
|
||||||
|
let end_uhrzeit = jQuery( "#nf-field-53 option:selected" ).text();
|
||||||
|
bookingTextTable['end-datum']['value'] = end_datum;
|
||||||
|
bookingTextTable['end-datum']['value_uhrzeit'] = end_uhrzeit;
|
||||||
|
refresh_booking_text_table(ninja_page_id);
|
||||||
|
if ( is_user_logged_in ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ADJUST / RELOAD CALENDAR
|
||||||
|
dateObject.pikaday.adjustCalendars();
|
||||||
|
if (show_datepicker)
|
||||||
|
dateObject.pikaday.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function allow_next(bool, selector) {
|
||||||
|
// DEFAULT
|
||||||
|
jQuery('#' + selector).removeClass('nf-fail nf-error nf-pass');
|
||||||
|
jQuery(".nf-next").css("pointer-events", "auto");
|
||||||
|
|
||||||
|
if (bool == 1) {
|
||||||
|
jQuery('#' + selector).addClass('nf-pass');
|
||||||
|
jQuery(".nf-next").css("pointer-events", "auto");
|
||||||
|
} else if (bool == 0) {
|
||||||
|
jQuery('#' + selector).addClass('nf-fail nf-error');
|
||||||
|
jQuery(".nf-next").css("pointer-events", "none");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTimeRange(selector, startTime, endTime, offsetStart = 0, offsetEnd = 0) {
|
||||||
|
console.log('startTime: ' + startTime + '\tendTime: ' + endTime + '\toffsetStart: ' + offsetStart + '\toffsetEnd: ' + offsetEnd);
|
||||||
|
// GET OPTIONS
|
||||||
|
if (!myOptsCpy) {
|
||||||
|
var options = jQuery('#' + selector)[0].options
|
||||||
|
myOpts = Array.prototype.slice.call(options);
|
||||||
|
}
|
||||||
|
myOptsCpy = myOpts;
|
||||||
|
|
||||||
|
// GET INDICES
|
||||||
|
for (var i = 0; i < myOpts.length; i++) {
|
||||||
|
if (myOpts[i].value == startTime) {
|
||||||
|
var startIndex = i + offsetStart;
|
||||||
|
//console.log('startIndex @ ' + startIndex);
|
||||||
|
}
|
||||||
|
if (myOpts[i].value == endTime) {
|
||||||
|
var endIndex = i + offsetEnd;
|
||||||
|
//console.log('endIndex @index ' + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startIndex > myOpts.length)
|
||||||
|
startIndex = myOpts.length;
|
||||||
|
|
||||||
|
if (endIndex > myOpts.length)
|
||||||
|
endIndex = myOpts.length
|
||||||
|
|
||||||
|
if (endIndex < startIndex) {
|
||||||
|
endIndex = myOpts.length;
|
||||||
|
startIndex = myOpts.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// REMOVE ALL UNWANTED
|
||||||
|
myOptsCpy = myOptsCpy.slice(startIndex, endIndex + 1);
|
||||||
|
|
||||||
|
// CLEAR
|
||||||
|
jQuery('#' + selector)[0].options.length = 0;
|
||||||
|
|
||||||
|
// FILL
|
||||||
|
for (i = 0; i < myOptsCpy.length; i++) {
|
||||||
|
jQuery('#' + selector).append(
|
||||||
|
jQuery("<option></option>")
|
||||||
|
.text(myOptsCpy[i].text)
|
||||||
|
.val(myOptsCpy[i].value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
first_selected_time = myOptsCpy[0].value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_select_single_day_logic(selector, selected_date, dateObject) {
|
||||||
|
if (same_day(selected_date, new Date())) {
|
||||||
|
console.log('Selected same day');
|
||||||
|
set_start_time_for_today(selector, dateObject);
|
||||||
|
} else {
|
||||||
|
console.log('Another day selected');
|
||||||
|
setTimeRange(selector, '07', '18');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function defaultPart(selector, dateObject) {
|
||||||
|
jQuery('#' + selector)[0].value = '';
|
||||||
|
allow_next(0, selector + '-wrap');
|
||||||
|
jQuery('#' + selector).click(function() {
|
||||||
|
dateObject.pikaday.show();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_start_time_for_today(selector, dateObject) {
|
||||||
|
// SERVER TIME
|
||||||
|
var server_time = new Date();
|
||||||
|
//var server_time = new Date("March 5, 2020 11:15:00");
|
||||||
|
//console.log('server_time: ' + server_time);
|
||||||
|
|
||||||
|
// TODAY
|
||||||
|
var today = new Date(new Date().setDate(new Date().getDate() - 1));
|
||||||
|
|
||||||
|
if (server_time.getHours() < 7) { // BEFORE 7:00
|
||||||
|
//console.log('Before 7:00');
|
||||||
|
var pikaday_minDate = today;
|
||||||
|
} else if (server_time.getHours() >= 18) { // AFTER 18:00 -> SELECT NEW DAY
|
||||||
|
//console.log('After 18:00');
|
||||||
|
var pikaday_minDate = today.setDate(today.getDate() + 1);
|
||||||
|
} else { // SELECT CURRENT DAY WITH CURRENT TIME
|
||||||
|
//console.log('Between 7:00 - 18:00');
|
||||||
|
var pikaday_minDate = today;
|
||||||
|
|
||||||
|
var start_time = roundMinutes(server_time);
|
||||||
|
//console.log('start_time: ' + start_time);
|
||||||
|
|
||||||
|
// DEFINE TIME RANGE
|
||||||
|
setTimeRange(selector, start_time, '18');
|
||||||
|
}
|
||||||
|
|
||||||
|
// PIKADAY START DAY
|
||||||
|
dateObject.pikaday._o.minDate = pikaday_minDate;
|
||||||
|
//console.log('pikaday_minDate: ' + pikaday_minDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
function same_day(d1, d2) {
|
||||||
|
return d1.getFullYear() === d2.getFullYear() &&
|
||||||
|
d1.getMonth() === d2.getMonth() &&
|
||||||
|
d1.getDate() === d2.getDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
function roundMinutes(date, fswitch = null) {
|
||||||
|
if (date.getMinutes() < 30) {
|
||||||
|
//console.log('Fill up to :30');
|
||||||
|
var rounded_date = date;
|
||||||
|
rounded_date.setMinutes(30);
|
||||||
|
} else if (date.getMinutes() >= 30) {
|
||||||
|
//console.log('Fill up to :00 next hour');
|
||||||
|
var rounded_date = date;
|
||||||
|
rounded_date.setMinutes(0);
|
||||||
|
rounded_date.setHours(rounded_date.getHours() + 1);
|
||||||
|
}
|
||||||
|
rounded_date.setSeconds(0);
|
||||||
|
first_selected_date_rounded = rounded_date;
|
||||||
|
|
||||||
|
if( !fswitch )
|
||||||
|
return date2start_time(rounded_date);
|
||||||
|
else if( fswitch == 'object' )
|
||||||
|
return rounded_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
function date2start_time(date) {
|
||||||
|
if (date.getMinutes() == 0)
|
||||||
|
var start_time = date.getHours();
|
||||||
|
else if (date.getMinutes() == 30)
|
||||||
|
var start_time = date.getHours() + '-' + date.getMinutes();
|
||||||
|
|
||||||
|
return start_time;
|
||||||
|
}
|
||||||
|
// END JAVASCRIPT
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
115
src/snippets/3497_pikaday.php
Normal file
115
src/snippets/3497_pikaday.php
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_pikaday_legend' );
|
||||||
|
function my_pikaday_legend() {
|
||||||
|
if(page_id() === 3497) {
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
var picker = new Pikaday(
|
||||||
|
{
|
||||||
|
field: document.getElementById('datepicker'),
|
||||||
|
bound: false,
|
||||||
|
container: document.getElementById('pikaday-container'),
|
||||||
|
disableWeekends: true,
|
||||||
|
numberOfMonths: 3,
|
||||||
|
firstDay: 1,
|
||||||
|
minDate: new Date(new Date().setDate(new Date().getDate())),
|
||||||
|
maxDate: pikaday_maxDate(),
|
||||||
|
|
||||||
|
i18n: {
|
||||||
|
previousMonth: 'Vormonat',
|
||||||
|
nextMonth: 'Nächster Monat',
|
||||||
|
months: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
|
||||||
|
weekdays: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
|
||||||
|
weekdaysShort: ['So.', 'Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.']
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
inject_pikaday_legend('//div[@id="pikaday-legende"]', 'price');
|
||||||
|
colorize_pikaday_spans();
|
||||||
|
//set_pikaday_spans_legend();
|
||||||
|
});
|
||||||
|
|
||||||
|
function get_start_end_span(nextDay, startDay, endDay) {
|
||||||
|
let start = new Date(nextDay.getTime());
|
||||||
|
let end = new Date(nextDay.getTime());
|
||||||
|
start.setDate(start.getDate() - startDay);
|
||||||
|
end.setDate(end.getDate() - endDay);
|
||||||
|
let start_span = start.getUTCDate() + '.' + (start.getUTCMonth() + 1);
|
||||||
|
let end_span = end.getUTCDate() + '.' + (end.getUTCMonth() + 1);
|
||||||
|
|
||||||
|
return [start_span, end_span];
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_pikaday_spans_legend() {
|
||||||
|
let start_span_one, end_span_one, start_span_two, end_span_two, start_span_three, end_span_three, start_span_four, end_span_four, start_span_five, end_span_five;
|
||||||
|
|
||||||
|
let highestKey = Object.keys(fastsnipeObj).reduce(function(a, b){ return fastsnipeObj[a] > fastsnipeObj[b] ? a : b });
|
||||||
|
let highestDay = fastsnipeObj[highestKey]['day_end'] - 1;
|
||||||
|
for (i = 0; i <= highestDay; i++) {
|
||||||
|
let nextDay = new Date();
|
||||||
|
nextDay.setDate(nextDay.getDate() + i);
|
||||||
|
let month = nextDay.getUTCMonth() + 1; //months from 1-12
|
||||||
|
let day = nextDay.getUTCDate();
|
||||||
|
let year = nextDay.getUTCFullYear();
|
||||||
|
|
||||||
|
|
||||||
|
if (i >= fastsnipeObj[1]['day_end'] && i <= fastsnipeObj[2]['day_end']-1) { // category 1
|
||||||
|
if (!start_span_one) {
|
||||||
|
[start_span_one, end_span_one] = get_start_end_span(nextDay, 7, 1);
|
||||||
|
jQuery('#start_one')[0].textContent = start_span_one;
|
||||||
|
jQuery('#end_one')[0].textContent = end_span_one;
|
||||||
|
jQuery('#category-1')[0].textContent = fastsnipeObj[1]['price'];
|
||||||
|
jQuery('.color-category-one').css('background-color', fastsnipeObj[1]['color']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i >= fastsnipeObj[2]['day_end'] && i <= fastsnipeObj[3]['day_end']-1) { // category 2
|
||||||
|
if (!start_span_two) {
|
||||||
|
[start_span_two, end_span_two] = get_start_end_span(nextDay, 7, 1);
|
||||||
|
jQuery('#start_two')[0].textContent = start_span_two;
|
||||||
|
jQuery('#end_two')[0].textContent = end_span_two;
|
||||||
|
jQuery('#category-2')[0].textContent = fastsnipeObj[2]['price'];
|
||||||
|
jQuery('.color-category-two').css('background-color', fastsnipeObj[2]['color']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i >= fastsnipeObj[3]['day_end'] && i <= fastsnipeObj[4]['day_end']-1) { // category 3
|
||||||
|
if (!start_span_three) {
|
||||||
|
[start_span_three, end_span_three] = get_start_end_span(nextDay, 7, 1);
|
||||||
|
jQuery('#start_three')[0].textContent = start_span_three;
|
||||||
|
jQuery('#end_three')[0].textContent = end_span_three;
|
||||||
|
jQuery('#category-3')[0].textContent = fastsnipeObj[3]['price'];
|
||||||
|
jQuery('.color-category-three').css('background-color', fastsnipeObj[3]['color']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (i >= fastsnipeObj[4]['day_end'] && i <= fastsnipeObj[5]['day_end']-1) { // category 4
|
||||||
|
if (!start_span_four) {
|
||||||
|
[start_span_four, end_span_four] = get_start_end_span(nextDay, 14, 1);
|
||||||
|
jQuery('#start_four')[0].textContent = start_span_four;
|
||||||
|
jQuery('#end_four')[0].textContent = end_span_four;
|
||||||
|
jQuery('#category-4')[0].textContent = fastsnipeObj[4]['price'];
|
||||||
|
jQuery('.color-category-four').css('background-color', fastsnipeObj[4]['color']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == fastsnipeObj[5]['day_end']-1) {
|
||||||
|
if (!start_span_five) {
|
||||||
|
[start_span_five, end_span_five] = get_start_end_span(nextDay, 21, 0);
|
||||||
|
jQuery('#start_five')[0].textContent = start_span_five;
|
||||||
|
jQuery('#end_five')[0].textContent = end_span_five;
|
||||||
|
jQuery('#category-5')[0].textContent = fastsnipeObj[5]['price'];
|
||||||
|
jQuery('.color-category-five').css('background-color', fastsnipeObj[5]['color']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/snippets/980_dash_redirect.php
Normal file
15
src/snippets/980_dash_redirect.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_dash_redirect' );
|
||||||
|
function my_dash_redirect() {
|
||||||
|
if(page_id() === 980) {
|
||||||
|
$parts = parse_url(current_url());
|
||||||
|
if ($parts['query']) { // REDIRECT WITH ARGS
|
||||||
|
$url = 'http://zinomedia.de/terminsnipe/dash/aktiv&' . $parts['query'];
|
||||||
|
redirect($url);
|
||||||
|
}
|
||||||
|
else { // REDIRECT NO ARGS
|
||||||
|
redirect('http://zinomedia.de/terminsnipe/dash/aktiv');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/snippets/add_free_premium_booking.php
Normal file
33
src/snippets/add_free_premium_booking.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_add_freemium_indicator' );
|
||||||
|
function my_add_freemium_indicator() {
|
||||||
|
if ( !is_user_logged_in() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
jQuery(document).on( 'nfFormReady', function( e, layoutView ) {
|
||||||
|
add_freemium_indicator();
|
||||||
|
nfRadio.channel( 'nfMP' ).on('change:part', function() {
|
||||||
|
add_freemium_indicator();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function add_freemium_indicator() {
|
||||||
|
console.log('adding indicator...');
|
||||||
|
let ninja_page_id = jQuery('#ninja-page-id')[0].value;
|
||||||
|
if( ninja_page_id == -1 ) {
|
||||||
|
let textContent = jQuery('#nf-label-class-field-101-0')[0].textContent;
|
||||||
|
jQuery('#nf-label-class-field-101-0')[0].textContent = textContent + ' (Premium)';
|
||||||
|
let textContent2 = jQuery('#nf-label-class-field-101-1')[0].textContent;
|
||||||
|
jQuery('#nf-label-class-field-101-1')[0].textContent = textContent2 + ' (Free/Premium)';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
222
src/snippets/appointment_control_buttons.php
Normal file
222
src/snippets/appointment_control_buttons.php
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_aktive_snipes_buttons' );
|
||||||
|
function my_aktive_snipes_buttons() {
|
||||||
|
if(page_id() === 975) { // aktive-snipes
|
||||||
|
if (isset($_GET["d"])) {
|
||||||
|
$category = 'requests';
|
||||||
|
[$bool, $redirect] = db_delete_own_post_by_requestid_category($category, $_GET["d"]);
|
||||||
|
if ($redirect)
|
||||||
|
redirect($redirect);
|
||||||
|
else
|
||||||
|
redirect('.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
show_button_container();
|
||||||
|
confirm_modal('#button-delete-appointment', 'id', 'Löschen', 'Termin wirklich stoppen und löschen?<br><br>Bei Premium-Snipes werden dir deine FastCoins wieder gutgeschrieben.', 'Ja', 'Abbrechen', '_self');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(page_id() === 978) { // inaktive-snipes
|
||||||
|
if (isset($_GET["d"])) {
|
||||||
|
$category = 'expired';
|
||||||
|
[$bool, $redirect] = db_delete_own_post_by_requestid_category($category, $_GET["d"]);
|
||||||
|
if ($redirect)
|
||||||
|
redirect($redirect);
|
||||||
|
else
|
||||||
|
redirect('.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
show_button_container();
|
||||||
|
confirm_modal('#button-delete-appointment', 'id', 'Löschen', 'Termin wirklich löschen?<br><br>Bei Premium-Snipes werden dir deine FastCoins wieder gutgeschrieben.', 'Ja', 'Abbrechen', '_self');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(page_id() === 965) { // meine-snipes
|
||||||
|
if (isset($_GET["d"])) {
|
||||||
|
$category = 'appointment';
|
||||||
|
db_delete_own_post_by_requestid_category($category, $_GET["d"]);
|
||||||
|
redirect('.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
show_button_container();
|
||||||
|
confirm_modal('#button-delete-appointment', 'id', 'Löschen', 'Termin wirklich löschen?<br><br>Bei erfolgreichen Premium-Snipes werden keine FastCoins gutgeschrieben.', 'Ja', 'Abbrechen', '_self');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(page_id() === 986) { // account
|
||||||
|
if (isset($_GET["d"])) {
|
||||||
|
php_console_log('deleting account...');
|
||||||
|
api_delete_account();
|
||||||
|
wp_logout();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
button_change_account();
|
||||||
|
//show_button_container();
|
||||||
|
confirm_modal('#button-delete-account', 'id', 'Account löschen', 'Account endgültig löschen?<br><br>Bitte beachte, dass alle deine Daten, sowie alle aktiven Suchen und erfolgreiche Snipes gelöscht werden.<br><br>FastCoins kannst du ggfs. vorher an Freunde senden, da sie sonst verloren gehen.<br>Rückerstattungen sind nicht möglich.', 'Ja', 'Abbrechen', '_self');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function button_change_account() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
jQuery('#button-account-change').click(function() {
|
||||||
|
jQuery('.mepr-account-form ').show();
|
||||||
|
jQuery('.fl-node-5e6bb58413fa7,.fl-node-5e63bb5062a0c,.fl-node-5e6bb5bc08bf1,.fl-node-5e6bb1c31677c,#button-appointment-container').hide();
|
||||||
|
jQuery('.mepr-account-form').append('<a style="padding: 10px 75px 10px 75px !important; margin: 0 0 0 0 !important;" class="appointment-control" href="http://zinomedia.de/terminsnipe/dash/account/">Abbrechen</a>')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_delete_account() {
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
|
||||||
|
// The data to send to the API
|
||||||
|
$postData = array(
|
||||||
|
'WP_ID' => $user->ID,
|
||||||
|
'event' => 'restapi-delete-user',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create the context for the request
|
||||||
|
$context = stream_context_create(array(
|
||||||
|
'http' => array(
|
||||||
|
'method' => 'POST',
|
||||||
|
'header' => "Content-Type: application/json\r\n",
|
||||||
|
'content' => json_encode($postData)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
// Send the request
|
||||||
|
$response = file_get_contents('https://terminsnipe:y9aFwUO7htuyKMaaPQWu@service.berlin.de.zinomedia.de/www/src/terminsnipe_controller.pl', FALSE, $context);
|
||||||
|
|
||||||
|
// Check for errors
|
||||||
|
if($response === FALSE){
|
||||||
|
die('Error');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode the response
|
||||||
|
$responseData = json_decode($response, TRUE);
|
||||||
|
|
||||||
|
// Print the date from the response
|
||||||
|
echo $responseData['published'];
|
||||||
|
dump_to_file('/var/www/lab/newfile.txt', $responseData);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_button_container() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
jQuery('#button-appointment-container').ready(function() {
|
||||||
|
jQuery('#button-appointment-container').css('display', 'flex');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function db_delete_own_post_by_requestid_category($category, $request_id) {
|
||||||
|
// CHECK IF POST IS FROM USER WHO WANTS TO DELETE IT
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
$data = array(
|
||||||
|
'tag1' => $request_id,
|
||||||
|
'category' => $category,
|
||||||
|
);
|
||||||
|
$postslist = get_own_posts_by_tag_and_category($data);
|
||||||
|
|
||||||
|
if (!empty($postslist)) {
|
||||||
|
php_console_log('Post belongs to user');
|
||||||
|
|
||||||
|
// DELETE FROM DB
|
||||||
|
if ($category === 'requests') {
|
||||||
|
$table = 'request';
|
||||||
|
}
|
||||||
|
else if ($category === 'expired') {
|
||||||
|
$table = 'request';
|
||||||
|
}
|
||||||
|
else if ($category === 'appointment') {
|
||||||
|
$table = 'appointments';
|
||||||
|
}
|
||||||
|
|
||||||
|
$wpdb = connect_to_server('zinomedia');
|
||||||
|
$status = $wpdb->delete( $table, array( 'ID' => $_GET["d"] ) );
|
||||||
|
|
||||||
|
if ($category === 'requests' || $category === 'expired') {
|
||||||
|
[$bool, $redirect] = refund_coins($postslist, $user);
|
||||||
|
return [$bool, $redirect];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (empty($postslist)) {
|
||||||
|
php_console_log('Post does NOT belong to user');
|
||||||
|
|
||||||
|
return [0, null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function refund_coins($postslist, $user) {
|
||||||
|
$postmeta = get_post_meta( $postslist[0]->ID );
|
||||||
|
if( $postmeta['is_premium'][0] ) {
|
||||||
|
$balance_before_refund = mycred_return_users_balance();
|
||||||
|
mycred_add( 'booking_manually_cancelled', $user->ID, $postmeta['price'][0], 'Cancellation by user, refund points' );
|
||||||
|
$redirect = 'http://zinomedia.de/terminsnipe/?uccr&price=' . $postmeta['price'][0] . '&bbr=' . $balance_before_refund;
|
||||||
|
return [1, $redirect];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return [0, null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirm_modal($button_id, $data_attribute, $title, $msg, $true, $false, $open) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
var data_attribute = "<?php echo $data_attribute ?>";
|
||||||
|
var button = "<?php echo $button_id ?>";
|
||||||
|
var id = jQuery(button).data(data_attribute);
|
||||||
|
var redirect = '.?d=' + id;
|
||||||
|
|
||||||
|
jQuery(button).ready(function() {
|
||||||
|
jQuery(button).click(function() {
|
||||||
|
Confirm("<?php echo $title ?>", "<?php echo $msg ?>", "<?php echo $true ?>", "<?php echo $false ?>", redirect, "<?php echo $open ?>");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_own_posts_by_tag_and_category($data) {
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
$args = array(
|
||||||
|
'tax_query' => array(
|
||||||
|
'relation' => 'AND',
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'post_tag',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $data['tag1'],
|
||||||
|
'include_children' => false
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'post_tag',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $user->user_nicename,
|
||||||
|
'include_children' => false
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'category',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $data['category'],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$postslist = get_posts( $args );
|
||||||
|
|
||||||
|
return $postslist;
|
||||||
|
}
|
||||||
20
src/snippets/confetti.php
Normal file
20
src/snippets/confetti.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_confetti' );
|
||||||
|
function my_confetti() {
|
||||||
|
if(page_id() === 222) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
var s = document.createElement('script');
|
||||||
|
s.setAttribute("id", "confettijs");
|
||||||
|
s.type = "text/javascript";
|
||||||
|
s.src = "https://service.berlin.de.zinomedia.de/www/lib/confetti.js";
|
||||||
|
jQuery("body").append(s);
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
55
src/snippets/custom_email_mpr.php
Normal file
55
src/snippets/custom_email_mpr.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'mepr-wp-mail-subject', function( $subject, $recipients, $message, $headers ) {
|
||||||
|
if ( strpos( $subject, '[Bürgeramt Terminsnipe | Sofort. Termin. Berlinweit.] Set Your New Password') !== false ) {
|
||||||
|
$matches_name = array();
|
||||||
|
preg_match('/Hi (.+?)\,/', $message, $matches_name);
|
||||||
|
|
||||||
|
$subject = "Willkommen bei Terminsnipe, los geht's!";
|
||||||
|
}
|
||||||
|
else if ( strpos( $subject, '[Bürgeramt Terminsnipe | Sofort. Termin. Berlinweit.] Your new Password') !== false ) {
|
||||||
|
$subject = 'Du hast dein Passwort erfolgreich geändert';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $subject;
|
||||||
|
}, 11, 4 );
|
||||||
|
|
||||||
|
add_filter( 'mepr-wp-mail-message', function( $message, $recipients, $subject, $headers ) {
|
||||||
|
if ( strpos( $subject, "Willkommen bei Terminsnipe, los geht's!") !== false ) {
|
||||||
|
$matches = array();
|
||||||
|
preg_match('/href="(.+?)"/', $message, $matches);
|
||||||
|
|
||||||
|
$matches_name = array();
|
||||||
|
preg_match('/Hi (.+?)\,/', $message, $matches_name);
|
||||||
|
|
||||||
|
$message = '<html>
|
||||||
|
<body>
|
||||||
|
<h1>Willkommen bei den Terminsnipern, ' . $matches_name[1] . '!</h1>
|
||||||
|
<p>Klicke auf den unten stehenden Link, erstelle dein Passwort und werde Teil des Snipe-Hypes! Ab jetzt nie wieder Warteschleife am Bürgertelefon. Nie wieder außerhalb der Telefonzeiten. Nie wieder Chatbot Bobbi. Du bestimmst die Regeln, wir erledigen den Rest.</p>
|
||||||
|
<p>Hier legst du ein Passwort fest: <a href="' . $matches[1] . '">Jetzt Passwort erstellen</a></p>
|
||||||
|
<p>Übrigens: FastCoins sind unsere smarte und sichere Bezahlmethode für Premium-Zeiträume. Hast du es nicht so eilig? Dann schnappe dir einen Free-Termin. Du bestimmst die Regeln, wir erledigen den Rest.</p>
|
||||||
|
</body>
|
||||||
|
</html>';
|
||||||
|
}
|
||||||
|
else if ( strpos( $subject, 'Du hast dein Passwort erfolgreich geändert') !== false ) {
|
||||||
|
$matches = array();
|
||||||
|
preg_match('/You can now login here: (.+?)</', $message, $matches);
|
||||||
|
|
||||||
|
$matches_name = array();
|
||||||
|
preg_match('/(.+?)\,/', $message, $matches_name);
|
||||||
|
|
||||||
|
$matches_email = array();
|
||||||
|
preg_match('/Username: (.+?) /', $message, $matches_email);
|
||||||
|
|
||||||
|
$message = '<p>
|
||||||
|
High Five, ' . trim($matches_name[1]) . '!
|
||||||
|
<br/><br/>
|
||||||
|
Du hast dein Passwort erfolgreich geändert:</p>
|
||||||
|
<p>
|
||||||
|
Benutzername: ' . $matches_email[1] . '<br/>
|
||||||
|
Password: *** Erfolgreich geändert ***</p>
|
||||||
|
<p>Hier kannst du dich direkt einloggen: <a href="' . $matches[1] . '">Jetzt einloggen</a></p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $message;
|
||||||
|
}, 11, 4 );
|
||||||
240
src/snippets/failed_request_creation_logged_out.php
Normal file
240
src/snippets/failed_request_creation_logged_out.php
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_failed_request_logged_out' );
|
||||||
|
function my_failed_request_logged_out() {
|
||||||
|
if(page_id() === 222 && isset($_GET["frlo"])) {
|
||||||
|
// CHECK IF ALL PARAMETER ARE PRESENT
|
||||||
|
if( isset($_GET['SWITCH_TERMINTYPE']) &&
|
||||||
|
isset($_GET['SERVICE_ID']) &&
|
||||||
|
isset($_GET['WOCHENTAG_START']) &&
|
||||||
|
isset($_GET['UHRZEIT_START']) &&
|
||||||
|
isset($_GET['WOCHENTAG_END']) &&
|
||||||
|
isset($_GET['UHRZEIT_END']) &&
|
||||||
|
isset($_GET['SWITCH_STANDORTE']) &&
|
||||||
|
isset($_GET['STANDORTE']) &&
|
||||||
|
isset($_GET['WP_ID']) &&
|
||||||
|
isset($_GET['event']) )
|
||||||
|
{
|
||||||
|
// PRINT PARAMETER
|
||||||
|
foreach ($_GET as $k=>$v) {
|
||||||
|
php_console_log('k: ' . $k . ' v: ' . $v);
|
||||||
|
}
|
||||||
|
|
||||||
|
// DIENSTLEISTUNG
|
||||||
|
$wpdb = connect_to_server('zinomedia');
|
||||||
|
$dienstleistung = $wpdb->get_var('SELECT NAME FROM services WHERE ID = ' . $_GET['SERVICE_ID']);
|
||||||
|
php_console_log('Dienstleistung: ' . $dienstleistung );
|
||||||
|
|
||||||
|
// DATETIMES
|
||||||
|
if (isset($_GET['SWITCH_TERMINTYPE']) && $_GET['SWITCH_TERMINTYPE'] == 'zeitraum') {
|
||||||
|
$datetime_from = create_date($_GET['WOCHENTAG_START'], $_GET['UHRZEIT_START']);
|
||||||
|
$datetime_to = create_date($_GET['WOCHENTAG_END'], $_GET['UHRZEIT_END']);
|
||||||
|
}
|
||||||
|
else if (isset($_GET['SWITCH_TERMINTYPE']) && $_GET['SWITCH_TERMINTYPE'] == 'sofort') {
|
||||||
|
$timestamp = time();
|
||||||
|
$dt = new DateTime("now", new DateTimeZone('Europe/Berlin'));
|
||||||
|
$dt->setTimestamp($timestamp);
|
||||||
|
$datetime_from = $dt->format('Y-m-d H:i:s');
|
||||||
|
$datetime_to = create_date($_GET['WOCHENTAG_END'], $_GET['UHRZEIT_END']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BUERGERAEMTER
|
||||||
|
$buergeraemter = create_buergeraemter();
|
||||||
|
|
||||||
|
// CREATE APPOINTMENT
|
||||||
|
php_console_log('datetime_from after: ' . $datetime_from);
|
||||||
|
php_console_log('datetime_to after: ' . $datetime_to);
|
||||||
|
$data = array(
|
||||||
|
'category' => 'request-failed-logged-out',
|
||||||
|
'request' => array(
|
||||||
|
'BUERGERAEMTER' => $buergeraemter,
|
||||||
|
'WP_ID' => $_GET['WP_ID'],
|
||||||
|
'SERVICE_ID' => $_GET['SERVICE_ID'],
|
||||||
|
'DIENSTLEISTUNG' => $dienstleistung,
|
||||||
|
'DATETIME_FROM' => $datetime_from,
|
||||||
|
'DATETIME_TO' => $datetime_to,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$post_content = create_post_content($data);
|
||||||
|
$post_content = trim(preg_replace('/\s+/', ' ', $post_content));
|
||||||
|
|
||||||
|
// PUT APPOINTMENT ON PAGE
|
||||||
|
js_manipulate_html($post_content);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
php_console_log('Not all GET data present');
|
||||||
|
close_modal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function close_modal() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
jQuery('.uabb-close-icon').ready(function() {
|
||||||
|
jQuery('.uabb-close-icon').click();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_buergeraemter() {
|
||||||
|
$wpdb = connect_to_server('zinomedia');
|
||||||
|
|
||||||
|
// SWITCH berlinweit OR standorte-auswaehlen
|
||||||
|
if (isset($_GET['SWITCH_STANDORTE']) && $_GET['SWITCH_STANDORTE'] == 'berlinweit') {
|
||||||
|
// GET VENUE NAMES FROM DB
|
||||||
|
$rows = $wpdb->get_results( "
|
||||||
|
Select
|
||||||
|
venues.NAME
|
||||||
|
From
|
||||||
|
services Inner Join
|
||||||
|
mapping_services On mapping_services.SERVICE_ID = services.ID Inner Join
|
||||||
|
venues On mapping_services.VENUE_ID = venues.ID
|
||||||
|
Where
|
||||||
|
services.ID = $_GET[SERVICE_ID]
|
||||||
|
", ARRAY_N );
|
||||||
|
|
||||||
|
// ACCUMULATE TO ONE ARRAY
|
||||||
|
$buergeraemter = array();
|
||||||
|
foreach ($rows as $array) {
|
||||||
|
array_push($buergeraemter, $array[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isset($_GET['SWITCH_STANDORTE']) && $_GET['SWITCH_STANDORTE'] == 'standorte-auswaehlen') {
|
||||||
|
// CREATE ARRAY WITH VENUE_IDs FROM STRING
|
||||||
|
$buergeraemter_get = explode(',',$_GET['STANDORTE']);
|
||||||
|
|
||||||
|
// CREATE SQL QUERY STRING WITH VENUE IDs
|
||||||
|
$i = 0;
|
||||||
|
$len = count($buergeraemter_get);
|
||||||
|
foreach ($buergeraemter_get as $venue_id) {
|
||||||
|
$venue_query .= 'venues.ID = ' . $venue_id;
|
||||||
|
if ($i !== $len - 1) {
|
||||||
|
// last
|
||||||
|
$venue_query .= ' Or ';
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET VENUE NAMES FROM DB
|
||||||
|
$rows = $wpdb->get_results( "
|
||||||
|
Select venues.NAME From venues Where ($venue_query)
|
||||||
|
", ARRAY_N );
|
||||||
|
|
||||||
|
// ACCUMULATE TO ONE ARRAY
|
||||||
|
$buergeraemter = array();
|
||||||
|
foreach ($rows as $array) {
|
||||||
|
array_push($buergeraemter, $array[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $buergeraemter;
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_date($day, $time) {
|
||||||
|
$datetime = $day . ' ' . $time;
|
||||||
|
if (strpos($time, '-') !== false) {
|
||||||
|
$format = 'Y-m-d H-i';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$format = 'Y-m-d H';
|
||||||
|
}
|
||||||
|
$datetime = DateTime::createFromFormat($format, $datetime);
|
||||||
|
$datetime = $datetime->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
return $datetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
function js_manipulate_html($post_content) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
jQuery('#dein-termin .fl-html')[0].innerHTML = '<?php echo $post_content ?>';
|
||||||
|
|
||||||
|
// JQUERY FOR APPOINTMENT
|
||||||
|
var maxRows = 5;
|
||||||
|
jQuery('.paginated-table').each(function () {
|
||||||
|
var cTable = jQuery(this);
|
||||||
|
var cRows = cTable.find('tr:gt(0)');
|
||||||
|
var cRowCount = cRows.size();
|
||||||
|
|
||||||
|
if (cRowCount > 10) {
|
||||||
|
jQuery(".paginated-table-div").css({"height": "260px"});
|
||||||
|
}
|
||||||
|
else if (cRowCount <= 10) {
|
||||||
|
jQuery(".prev-table,.next-table").hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cRowCount < maxRows) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cRows.each(function (i) {
|
||||||
|
jQuery(this).find('td:first').text(function (j, val) {
|
||||||
|
return (i + 1) + " - " + val;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
cRows.filter(':gt(' + (maxRows - 1) + ')').hide();
|
||||||
|
|
||||||
|
var cPrev = jQuery('.prev-table');
|
||||||
|
var cNext = jQuery('.next-table');
|
||||||
|
|
||||||
|
cPrev.addClass('disabled');
|
||||||
|
|
||||||
|
cPrev.click(function () {
|
||||||
|
console.log('prev clicked');
|
||||||
|
var cFirstVisible = cRows.index(cRows.filter(':visible'));
|
||||||
|
|
||||||
|
if (cPrev.hasClass('disabled')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cRows.hide();
|
||||||
|
if (cFirstVisible - maxRows - 1 > 0) {
|
||||||
|
cRows.filter(':lt(' + cFirstVisible + '):gt(' + (cFirstVisible - maxRows - 1) + ')').show();
|
||||||
|
} else {
|
||||||
|
cRows.filter(':lt(' + cFirstVisible + ')').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cFirstVisible - maxRows <= 0) {
|
||||||
|
cPrev.addClass('disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
cNext.removeClass('disabled');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
cNext.click(function () {
|
||||||
|
var cFirstVisible = cRows.index(cRows.filter(':visible'));
|
||||||
|
|
||||||
|
if (cNext.hasClass('disabled')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cRows.hide();
|
||||||
|
cRows.filter(':lt(' + (cFirstVisible + 2 * maxRows) + '):gt(' + (cFirstVisible + maxRows - 1) + ')').show();
|
||||||
|
|
||||||
|
if (cFirstVisible + 2 * maxRows >= cRows.size()) {
|
||||||
|
cNext.addClass('disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
cPrev.removeClass('disabled');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
630
src/snippets/global_helper_functions.php
Normal file
630
src/snippets/global_helper_functions.php
Normal file
@@ -0,0 +1,630 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
class HelperFunctions {
|
||||||
|
|
||||||
|
function declareGlobalsFn () {
|
||||||
|
// Functions declared inside a function have global scope
|
||||||
|
|
||||||
|
function mycred_return_users_balance() {
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
return mycred_get_users_balance( $user_id );
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_own_nonpremium_requests() {
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
$data = array(
|
||||||
|
'tags' => array ( $user->user_nicename ),
|
||||||
|
'category' => 'requests',
|
||||||
|
'meta_key' => 'is_premium',
|
||||||
|
'meta_value' => 0,
|
||||||
|
);
|
||||||
|
|
||||||
|
return get_posts_by_tag_category_postmeta($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_own_premium_requests() {
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
$data = array(
|
||||||
|
'tags' => array ( $user->user_nicename ),
|
||||||
|
'category' => 'requests',
|
||||||
|
'meta_key' => 'is_premium',
|
||||||
|
'meta_value' => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
return get_posts_by_tag_category_postmeta($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_posts_by_tag_category_postmeta($data) {
|
||||||
|
$args = array(
|
||||||
|
'tax_query' => array(
|
||||||
|
'relation' => 'AND',
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'post_tag',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $data['tags'],
|
||||||
|
'include_children' => false
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'category',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $data['category'],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'meta_query' => array(
|
||||||
|
array(
|
||||||
|
'key' => $data['meta_key'],
|
||||||
|
'value' => $data['meta_value'],
|
||||||
|
'compare' => '=',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$postslist = get_posts( $args );
|
||||||
|
|
||||||
|
return $postslist;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_fastsnipeObj() {
|
||||||
|
return array(
|
||||||
|
1 => array(
|
||||||
|
'price' => 2250,
|
||||||
|
'day_end' => 7,
|
||||||
|
'color' => '#f8dd4d',
|
||||||
|
),
|
||||||
|
2 => array(
|
||||||
|
'price' => 1800,
|
||||||
|
'day_end' => 14,
|
||||||
|
'color' => 'hotpink',
|
||||||
|
),
|
||||||
|
3 => array(
|
||||||
|
'price' => 1100,
|
||||||
|
'day_end' => 21,
|
||||||
|
'color' => '#fd9f02',
|
||||||
|
),
|
||||||
|
4 => array(
|
||||||
|
'price' => 500,
|
||||||
|
'day_end' => 35,
|
||||||
|
'color' => '#87cefa',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function subtract_fastcoins_by_start_date( $fastsnipeObj, $termintype_switch, $wochentag_start_text = null ) {
|
||||||
|
[$bool, $user_balance, $price, $is_premium] = check_premium( $fastsnipeObj, $termintype_switch, $wochentag_start_text );
|
||||||
|
// bool 1 - enough coins for booking
|
||||||
|
// bool 0 - not enough cons for booking
|
||||||
|
// bool null - no premium date
|
||||||
|
|
||||||
|
if ( $bool ) {
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
mycred_subtract( 'fastsnipe', $user_id, $price, 'Forms booking completed' );
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$bool, $user_balance, $price, $is_premium];
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_premium( $fastsnipeObj, $fswitch, $wochentag_start_text ) {
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
$user_balance = mycred_get_users_balance( $user_id );
|
||||||
|
|
||||||
|
if ( $fswitch == 'zeitraum' ) {
|
||||||
|
$i = DateDiffFromNow($wochentag_start_text);
|
||||||
|
}
|
||||||
|
else if ( $fswitch == 'sofort' ) {
|
||||||
|
$i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $price = get_premium_price($fastsnipeObj, $i) ) {
|
||||||
|
$is_premium = 1;
|
||||||
|
if ( can_afford($user_balance, $price) ) {
|
||||||
|
$bool = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$bool = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$is_premium = 0;
|
||||||
|
$bool = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($bool, $user_balance, $price, $is_premium);
|
||||||
|
}
|
||||||
|
|
||||||
|
function can_afford($user_balance, $price) {
|
||||||
|
$can_afford = 0;
|
||||||
|
$diff = $user_balance-$price;
|
||||||
|
if( $diff >= 0 ) {
|
||||||
|
$can_afford = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $can_afford;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_premium_price($fastsnipeObj, $i) {
|
||||||
|
$price = 0;
|
||||||
|
foreach ($fastsnipeObj as $key => $value) {
|
||||||
|
$day_end = $fastsnipeObj[$key]['day_end'] - 2;
|
||||||
|
if ($i <= $day_end) {
|
||||||
|
$price = $fastsnipeObj[$key]['price'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $price;
|
||||||
|
}
|
||||||
|
|
||||||
|
function DateDiffFromNow($d2) {
|
||||||
|
$d1 = new DateTime();
|
||||||
|
$d2 = new DateTime($d2);
|
||||||
|
$dDiff = $d1->diff($d2);
|
||||||
|
return $dDiff->format('%r%a');
|
||||||
|
}
|
||||||
|
|
||||||
|
function user_has_snipes_in_category($category) {
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
$data = array(
|
||||||
|
'tags' => array ( $user->user_nicename ),
|
||||||
|
'category' => $category,
|
||||||
|
);
|
||||||
|
$postslist = get_posts_by_tag_and_category($data);
|
||||||
|
return count($postslist);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove_url_parameter() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
window.history.replaceState(null, null, window.location.pathname);
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_post_content($data) {
|
||||||
|
dump_to_file('/var/www/lab/newfile.txt', $data, 'clear');
|
||||||
|
|
||||||
|
// DATE, STATUS & TERMINDETAILS
|
||||||
|
if ($data[category] == 'requests') {
|
||||||
|
$date = createDate($data[request][DATETIME_FROM], $data[request][DATETIME_TO], $data[category]);
|
||||||
|
$status = '<p class="saving">Terminsuche läuft <span>.</span><span>.</span><span>.</span></p>';
|
||||||
|
$buttons = '
|
||||||
|
<div id="button-appointment-container">
|
||||||
|
<a data-id="' . $data['request']['REQUEST_ID'] . '" id="button-delete-appointment" class="appointment-control">Löschen & FastCoins zurückerhalten</a>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
else if ($data[category] == 'expired') {
|
||||||
|
$date = createDate($data[request][DATETIME_FROM], $data[request][DATETIME_TO], $data[category]);
|
||||||
|
$status = '<p>Terminsuche abgelaufen</p>';
|
||||||
|
$buttons = '
|
||||||
|
<div id="button-appointment-container">
|
||||||
|
<a data-id="' . $data['request']['REQUEST_ID'] . '" id="button-delete-appointment" class="appointment-control">Löschen & FastCoins zurückerhalten</a>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
else if ($data[category] == 'appointment') {
|
||||||
|
$date = createDate($data[request][DATETIME], null, $data[category]);
|
||||||
|
$status = '<p>Termin gefunden & gebucht</p>';
|
||||||
|
$buttons = '
|
||||||
|
<div id="button-appointment-container">
|
||||||
|
<a href="https://service.berlin.de/terminvereinbarung/termin/manage/" target="_blank" class="appointment-control">Termin selbst absagen</a>
|
||||||
|
<a data-id="' . $data['request']['REQUEST_ID'] . '" id="button-delete-appointment" class="appointment-control">Löschen</a>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
//TERMINDETAILS PROCESS ID & AUTH KEY
|
||||||
|
$termindetails = '<table class="termindetails"><tr>' .
|
||||||
|
'<td class="min">Vorgangsnummer:</td>' .
|
||||||
|
'<td>' .
|
||||||
|
$data[request]['PROCESS_ID'] .
|
||||||
|
'</td></tr>' .
|
||||||
|
'<tr><td class="min>Absagecode:</td>' .
|
||||||
|
'<td>' .
|
||||||
|
$data[request]['AUTH_KEY'] .
|
||||||
|
'</td></tr>' .
|
||||||
|
'</tr></table>';
|
||||||
|
}
|
||||||
|
else if ($data['category'] == 'request-failed-logged-out') {
|
||||||
|
php_console_log('failed appointment');
|
||||||
|
$date = createDate($data[request][DATETIME_FROM], $data[request][DATETIME_TO], $data[category]);
|
||||||
|
$status = '<p>Du bist nicht angemeldet :*(<br>Registriere dich jetzt</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// BUERGERAEMTER LIST
|
||||||
|
$buergeraemter = '<table class="paginated-table"><th></th><tbody>';
|
||||||
|
$count_buergeraemter = count($data['request']['BUERGERAEMTER']);
|
||||||
|
foreach($data[request]['BUERGERAEMTER'] as $buergeramt) {
|
||||||
|
$buergeraemter .= "<tr><td>$buergeramt</td></tr>";
|
||||||
|
}
|
||||||
|
$buergeraemter = $buergeraemter . '</tbody></table>';
|
||||||
|
|
||||||
|
// DIENSTLEISTUNG
|
||||||
|
$dienstleistung = $data[request]['DIENSTLEISTUNG'];
|
||||||
|
|
||||||
|
// CHECK IF PREMIUM POST
|
||||||
|
$fastsnipeObj = get_fastsnipeObj();
|
||||||
|
[$bool, $user_balance, $price, $is_premium] = check_premium( $fastsnipeObj, 'zeitraum', $data['request']['DATETIME_FROM'] );
|
||||||
|
|
||||||
|
// RESTRICT ACCESS TO POST BY USER
|
||||||
|
$post_content = add_rule_id($data, $post_content, 'beginning');
|
||||||
|
|
||||||
|
// CONTENT CONCATENATE
|
||||||
|
if ($buttons) {
|
||||||
|
$post_content .= $buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_content .= "<h4 class=\"heading-backend\">Status</h4>
|
||||||
|
<div class=\"status-div\">$status</div>";
|
||||||
|
|
||||||
|
if (strcmp('request-failed-logged-out', $data['category']) !== 0) {
|
||||||
|
$post_content .= "<h4 class=\"heading-backend\">Preis</h4>
|
||||||
|
<div class=\"preis-div\">$price <img src=\"http://zinomedia.de/terminsnipe/wp-content/uploads/sites/6/2020/03/630865.svg\" alt=\"fastcoin\"></div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_content .= "<h4 class=\"heading-backend\">Was?</h4>
|
||||||
|
<div class=\"dienstleistung-div\">$dienstleistung</div>";
|
||||||
|
|
||||||
|
if ($termindetails) {
|
||||||
|
$post_content .=
|
||||||
|
"<h4 class=\"heading-backend\">Termindetails</h4>
|
||||||
|
<div class=\"date-div\">$termindetails</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_content .=
|
||||||
|
"<h4 class=\"heading-backend\">Wann?</h4>
|
||||||
|
<div class=\"date-div\">$date</div>
|
||||||
|
<h4 class=\"heading-backend\">Wo?</h4>
|
||||||
|
<div class=\"paginated-table-div\">
|
||||||
|
<p>Insgesamt $count_buergeraemter Bürgerämter</p>
|
||||||
|
$buergeraemter
|
||||||
|
<span class=\"prev-table\">« zurück</span><span class=\"next-table\">weiter »</span>
|
||||||
|
</div>";
|
||||||
|
|
||||||
|
// RESTRICT ACCESS TO POST BY USER
|
||||||
|
$post_content = add_rule_id($data, $post_content, 'ending');
|
||||||
|
|
||||||
|
return $post_content;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDate($dateTimeString_from, $dateTimeString_to, $category) {
|
||||||
|
$monthDayNames = array (
|
||||||
|
'Jan' => 'Januar',
|
||||||
|
'Feb' => 'Februar',
|
||||||
|
'Mar' => 'März',
|
||||||
|
'Apr' => 'April',
|
||||||
|
'May' => 'Mai',
|
||||||
|
'Jun' => 'Juni',
|
||||||
|
'Jul' => 'Juli',
|
||||||
|
'Aug' => 'August',
|
||||||
|
'Sep' => 'September',
|
||||||
|
'Oct' => 'Oktober',
|
||||||
|
'Nov' => 'November',
|
||||||
|
'Dec' => 'Dezember',
|
||||||
|
'Mon' => 'Montag',
|
||||||
|
'Tue' => 'Dienstag',
|
||||||
|
'Wed' => 'Mittwoch',
|
||||||
|
'Thu' => 'Donnerstag',
|
||||||
|
'Fri' => 'Freitag',
|
||||||
|
'Sat' => 'Samstag',
|
||||||
|
'Sun' => 'Sonntag',
|
||||||
|
);
|
||||||
|
|
||||||
|
// CREATE DATE STRING
|
||||||
|
$datetime_from = new DateTime($dateTimeString_from);
|
||||||
|
if ($category == 'requests' || $category == 'expired' || $category == 'request-failed-logged-out') {
|
||||||
|
$datetime_to = new DateTime($dateTimeString_to);
|
||||||
|
if($datetime_from->format('d') == $datetime_to->format('d') && // SAME DAY BOOKINGS
|
||||||
|
$datetime_from->format('m') == $datetime_to->format('m') &&
|
||||||
|
$datetime_from->format('y') == $datetime_to->format('y')) {
|
||||||
|
$date = $monthDayNames[$datetime_from->format('D')] . ', ' .
|
||||||
|
$datetime_from->format('d') . '. ' .
|
||||||
|
$monthDayNames[$datetime_from->format('M')] . ' ' .
|
||||||
|
$datetime_from->format('Y') . ' von ' .
|
||||||
|
$datetime_from->format('H') . ':' .
|
||||||
|
$datetime_from->format('i') . ' Uhr bis ' .
|
||||||
|
$datetime_to->format('H') . ':' .
|
||||||
|
$datetime_to->format('i') . ' Uhr';
|
||||||
|
}
|
||||||
|
else { # TWO DIFFERENT DATETIME BOOKINGS
|
||||||
|
$date = '<table class="dateTable"><tr>' .
|
||||||
|
'<td>Von:</td>' .
|
||||||
|
'<td>' .
|
||||||
|
$monthDayNames[$datetime_from->format('D')] . ', ' .
|
||||||
|
$datetime_from->format('d') . '. ' .
|
||||||
|
$monthDayNames[$datetime_from->format('M')] . ' ' .
|
||||||
|
$datetime_from->format('Y') . ' ' .
|
||||||
|
$datetime_from->format('H') . ':' .
|
||||||
|
$datetime_from->format('i') . ' Uhr' .
|
||||||
|
'</td></tr>' .
|
||||||
|
'<tr><td>Bis:</td>' .
|
||||||
|
'<td>' .
|
||||||
|
$monthDayNames[$datetime_to->format('D')] . ', ' .
|
||||||
|
$datetime_to->format('d') . '. ' .
|
||||||
|
$monthDayNames[$datetime_to->format('M')] . ' ' .
|
||||||
|
$datetime_to->format('Y') . ' ' .
|
||||||
|
$datetime_to->format('H') . ':' .
|
||||||
|
$datetime_to->format('i') . ' Uhr' .
|
||||||
|
'</td></tr>' .
|
||||||
|
'</tr></table>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($category == 'appointment') {
|
||||||
|
$date = 'pao';
|
||||||
|
$date = $monthDayNames[$datetime_from->format('D')] . ', ' .
|
||||||
|
$datetime_from->format('d') . '. ' .
|
||||||
|
$monthDayNames[$datetime_from->format('M')] . ' ' .
|
||||||
|
$datetime_from->format('Y') . ' um ' .
|
||||||
|
$datetime_from->format('H') . ':' .
|
||||||
|
$datetime_from->format('i') . ' Uhr';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_rule_id($data, $post_content, $switch) {
|
||||||
|
if ($data['category'] == 'requests' || $data['category'] == 'expired' || $data['category'] == 'appointment') {
|
||||||
|
if ($switch == 'beginning') {
|
||||||
|
$rule_id = mpr_get_user_rule_id($data);
|
||||||
|
$post_content = '[mepr-show if="rule: ' . $rule_id . '"]';
|
||||||
|
}
|
||||||
|
else if ($switch == 'ending') {
|
||||||
|
$post_content .= '[/mepr-show]';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $post_content;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mpr_get_user_rule_id($data) {
|
||||||
|
global $wpdb;
|
||||||
|
$user_email = $data[user]->user_email;
|
||||||
|
$rule_id = $wpdb->get_var( "SELECT rule_id FROM wp_6_mepr_rule_access_conditions WHERE access_condition = '$user_email'" );
|
||||||
|
|
||||||
|
return $rule_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_child_of( $id ) {
|
||||||
|
return ( is_page() && $id === get_post()->post_parent );
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_menu_page() {
|
||||||
|
$id = 980;
|
||||||
|
//return ( is_page() && $id === get_post()->post_parent || page_id() === $id );
|
||||||
|
if ( is_page() && $id === get_post()->post_parent || page_id() === $id ) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_filter_tag($settings) {
|
||||||
|
// CURRENT USER OBJECT
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
|
||||||
|
// SET RIGHT CATEGORY
|
||||||
|
if(page_id() === 975) {
|
||||||
|
$category = 'requests';
|
||||||
|
}
|
||||||
|
else if(page_id() === 978) {
|
||||||
|
$category = 'expired';
|
||||||
|
}
|
||||||
|
else if(page_id() === 965) {
|
||||||
|
$category = 'appointment';
|
||||||
|
}
|
||||||
|
|
||||||
|
// CREATE TAG TO DISPLAY RIGHT CONTENT IN CONTENT GRID POSTS MODULE
|
||||||
|
$filter_tags = get_user_filter_tags($user);
|
||||||
|
$filter_tag = $filter_tags[$category];
|
||||||
|
|
||||||
|
// GET TERM ID BY TAG SLUG AND CHANGE tax_post_post_tag of CONTENT GRID
|
||||||
|
$tag = get_term_by('slug', $filter_tag, 'post_tag');
|
||||||
|
$settings->tax_post_post_tag = $tag->term_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function page_id() {
|
||||||
|
global $wp_query;
|
||||||
|
return $wp_query->post->ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
function php_console_log($data) {
|
||||||
|
$output = $data;
|
||||||
|
if (is_array($output)) {
|
||||||
|
$output = implode(',', $output);
|
||||||
|
}
|
||||||
|
echo "<script>console.log( '" . $output . "' );</script>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function current_url() {
|
||||||
|
return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirect($url, $statusCode = 303) {
|
||||||
|
header('Location: ' . $url, true, $statusCode);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
function connect_to_server($server) {
|
||||||
|
if ($server == 'zinomedia') {
|
||||||
|
return new wpdb('terminsnipe','dIHB6JLk0CBBx1p7','terminsnipe','localhost');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function dump_to_file($file, $data, $method = '') {
|
||||||
|
if ($method == 'clear') {
|
||||||
|
$f = @fopen($file, "r+");
|
||||||
|
if ($f !== false) {
|
||||||
|
ftruncate($f, 0);
|
||||||
|
fclose($f);
|
||||||
|
}
|
||||||
|
|
||||||
|
$timestamp = "\n[" . date('m/d/Y h:i:sa', time()) . "]\n";
|
||||||
|
file_put_contents($file, $timestamp, FILE_APPEND | LOCK_EX);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($data) || is_object($data)) {
|
||||||
|
$data = print_r($data, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($file, $data.PHP_EOL , FILE_APPEND | LOCK_EX);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sort_aoa_by_value($array, $value) {
|
||||||
|
$arr = array();
|
||||||
|
foreach ($array as $key => $item) {
|
||||||
|
$arr[$item[$value]][$key] = $item;
|
||||||
|
}
|
||||||
|
ksort($arr, SORT_NUMERIC);
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
function json_request($url, $data = array(), $method = 'POST', $header = '') {
|
||||||
|
$options = array(
|
||||||
|
'http' => array(
|
||||||
|
'method' => $method,
|
||||||
|
'content' => json_encode( $data ),
|
||||||
|
'header'=> $header
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$context = stream_context_create( $options );
|
||||||
|
$result = file_get_contents( $url, false, $context );
|
||||||
|
//$response = json_decode( $result );
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mbpr_restapi_delete_rule_by_title($data) {
|
||||||
|
$rule = get_page_by_title( $data[post_title], OBJECT, $data[post_type] );
|
||||||
|
if ($rule) {
|
||||||
|
$url = 'http://zinomedia.de/terminsnipe/wp-json/mp/v1/rules/' . $rule->ID;
|
||||||
|
$response = json_request( $url,
|
||||||
|
array(),
|
||||||
|
'DELETE',
|
||||||
|
"Content-Type: application/json\r\nAccept: application/json\r\nAuthorization: sKjdz2pUHx"
|
||||||
|
);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mbpr_restapi_add_rule($data) {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$data_request = array( 'rule_type' => $data[rule_type],
|
||||||
|
'unauth_excerpt_type' => $data[unauth_excerpt_type],
|
||||||
|
'rule_content' => $data[rule_content],
|
||||||
|
);
|
||||||
|
$response = json_request( 'http://zinomedia.de/terminsnipe/wp-json/mp/v1/rules',
|
||||||
|
$data_request,
|
||||||
|
'POST',
|
||||||
|
"Content-Type: application/json\r\nAccept: application/json\r\nAuthorization: sKjdz2pUHx"
|
||||||
|
);
|
||||||
|
$response_decoded = json_decode($response);
|
||||||
|
|
||||||
|
// RENAME POST BECAUSE API SETS NO TITLE
|
||||||
|
$wpdb->update(
|
||||||
|
'wp_6_posts',
|
||||||
|
array(
|
||||||
|
'post_title' => $data[post_title],
|
||||||
|
),
|
||||||
|
array( 'ID' => $response_decoded->id )
|
||||||
|
);
|
||||||
|
|
||||||
|
// FIX: MANUALLY ADD CORRECT RULE CONDITIONS
|
||||||
|
$wpdb->insert(
|
||||||
|
'wp_6_mepr_rule_access_conditions',
|
||||||
|
array(
|
||||||
|
'rule_id' => $response_decoded->id,
|
||||||
|
'access_type' => $data[access_type],
|
||||||
|
'access_operator' => $data[access_operator],
|
||||||
|
'access_condition' => $data[access_condition]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_posts_by_tag_and_category($data) {
|
||||||
|
$args = array(
|
||||||
|
'tax_query' => array(
|
||||||
|
'relation' => 'AND',
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'post_tag',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $data[tags],
|
||||||
|
'include_children' => false
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'category',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $data[category],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$postslist = get_posts( $args );
|
||||||
|
|
||||||
|
return $postslist;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_posts_by_tag($data) {
|
||||||
|
$args = array(
|
||||||
|
'post_status' => $data[post_status],
|
||||||
|
'tax_query' => array(
|
||||||
|
'relation' => 'AND',
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'post_tag',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $data[tags],
|
||||||
|
'include_children' => false
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$postslist = get_posts( $args );
|
||||||
|
|
||||||
|
return $postslist;
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_posts_by_tag_and_category($data) {
|
||||||
|
$postslist = get_posts_by_tag_and_category($data);
|
||||||
|
foreach ($postslist as $post) {
|
||||||
|
wp_delete_post( $post->ID, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_posts_by_tag($data) {
|
||||||
|
// Rework to use get_posts_by_tag if possible
|
||||||
|
$args = array(
|
||||||
|
'post_status' => 'any',
|
||||||
|
'tax_query' => array(
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'post_tag',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $data[tags],
|
||||||
|
'include_children' => true
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$postslist = get_posts( $args );
|
||||||
|
|
||||||
|
foreach ($postslist as $post) {
|
||||||
|
wp_delete_post( $post->ID, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_tag_by_slug($slug) {
|
||||||
|
$term = get_term_by('slug', $slug, 'post_tag');
|
||||||
|
wp_delete_term($term->term_id, 'post_tag');
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_filter_tags($user) {
|
||||||
|
$filter_tag = array();
|
||||||
|
$filter_tag[requests] = $user->user_nicename . '-r';
|
||||||
|
$filter_tag[expired] = $user->user_nicename . '-e';
|
||||||
|
$filter_tag[appointment] = $user->user_nicename . '-a';
|
||||||
|
return $filter_tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ob = new HelperFunctions();
|
||||||
|
$ob->declareGlobalsFn();
|
||||||
209
src/snippets/global_helper_functions_js.php
Normal file
209
src/snippets/global_helper_functions_js.php
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_global_helper_functions' );
|
||||||
|
function my_global_helper_functions() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
var businessHoursObj = {
|
||||||
|
'start': {
|
||||||
|
'hours': 07,
|
||||||
|
'minutes': 0,
|
||||||
|
'seconds': 0,
|
||||||
|
},
|
||||||
|
'end': {
|
||||||
|
'hours': 18,
|
||||||
|
'minutes': 0,
|
||||||
|
'seconds': 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var fastsnipeObj = {
|
||||||
|
1: {
|
||||||
|
'day_end': 7,
|
||||||
|
'color': '#f8dd4d',
|
||||||
|
'price': 2250,
|
||||||
|
'label': 'Premium',
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
'day_end': 14,
|
||||||
|
'color': 'hotpink',
|
||||||
|
'price': 1800,
|
||||||
|
'label': 'Premium',
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
'day_end': 21,
|
||||||
|
'color': '#fd9f02',
|
||||||
|
'price': 1100,
|
||||||
|
'label': 'Premium',
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
'day_end': 35,
|
||||||
|
'color': '#87cefa',
|
||||||
|
'price': 500,
|
||||||
|
'label': 'Premium',
|
||||||
|
},
|
||||||
|
5: {
|
||||||
|
'day_end': 57,
|
||||||
|
'color': 'darkseagreen',
|
||||||
|
'price': 0,
|
||||||
|
'label': 'Free',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
function Confirm(title, msg, $true, $false, $link, $open) {
|
||||||
|
var $content = "<div class='dialog-ovelay'>" +
|
||||||
|
"<div class='dialog'><header>" +
|
||||||
|
" <h3> " + title + " </h3> " +
|
||||||
|
"<i class='fa fa-close'></i>" +
|
||||||
|
"</header>" +
|
||||||
|
"<div class='dialog-msg'>" +
|
||||||
|
" <p> " + msg + " </p> " +
|
||||||
|
"</div>" +
|
||||||
|
"<footer>" +
|
||||||
|
"<div class='controls'>" +
|
||||||
|
" <button class='button doAction' id='true-button'>" + $true + "</button> " +
|
||||||
|
" <button class='button cancelAction' id='false-button'>" + $false + "</button> " +
|
||||||
|
"</div>" +
|
||||||
|
"</footer>" +
|
||||||
|
"</div>" +
|
||||||
|
"</div>";
|
||||||
|
jQuery('body').prepend($content);
|
||||||
|
jQuery('.doAction').click(function() {
|
||||||
|
if ($open === '_self') {
|
||||||
|
window.location.href = $link;
|
||||||
|
}
|
||||||
|
else if ($open === '_blank') {
|
||||||
|
window.open($link, '_blank');
|
||||||
|
}
|
||||||
|
jQuery(this).parents('.dialog-ovelay').fadeOut(400, function() {
|
||||||
|
jQuery(this).remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
jQuery('.cancelAction, .fa-close').click(function() {
|
||||||
|
jQuery(this).parents('.dialog-ovelay').fadeOut(400, function() {
|
||||||
|
jQuery(this).remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function inject_pikaday_legend(xpath, fswitch) {
|
||||||
|
//let pika_single = getElementByXpath("//div[contains(@class, 'pika-single') and not(contains(@class, 'is-hidden'))]");
|
||||||
|
let pika_single = getElementByXpath(xpath);
|
||||||
|
|
||||||
|
if( fswitch == 'price' || fswitch == 'label' ) {
|
||||||
|
let append_html = '<div id="table-pikaday-div"><table id="table-pikaday-legend"> <tr> <td><div class="color-div"></div></td> <td><div class="color-div"></div></td> <td><div class="color-div"></div></td> <td><div class="color-div"></div></td> <td><div class="color-div"></div></td> </tr></table></div>';
|
||||||
|
jQuery(pika_single).append(append_html);
|
||||||
|
for (var key in fastsnipeObj) {
|
||||||
|
if (fastsnipeObj.hasOwnProperty(key)) {
|
||||||
|
let selector = 'table-pikaday-legend td:nth-child(' + key + ')';
|
||||||
|
let price = fastsnipeObj[key]['price'];
|
||||||
|
let color = fastsnipeObj[key]['color'];
|
||||||
|
let label = fastsnipeObj[key]['label'];
|
||||||
|
|
||||||
|
if( fswitch == 'price' ) {
|
||||||
|
var innerHTML = '<div class="color-div" style="background: ' + color + '"></div><div class="period-price"><img src="http://zinomedia.de/terminsnipe/wp-content/uploads/sites/6/2020/03/630865.svg" alt="fastcoin"></div><span>' + price + '</span>';
|
||||||
|
}
|
||||||
|
else if( fswitch == 'label' ) {
|
||||||
|
var innerHTML = '<div class="color-div" style="background: ' + color + '"></div><span>' + label + '</span>';
|
||||||
|
}
|
||||||
|
jQuery('#' + selector)[0].innerHTML = innerHTML;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( fswitch == 'start_end' ) {
|
||||||
|
//let append_html = '<div id="table-pikaday-div"><table id="table-pikaday-legend-start-end" <tr> <td><div class="color-div"></div></td> <td><div class="color-div"></div></td> </tr></table></div>';
|
||||||
|
let append_html = '<div id="table-pikaday-div"><table id="table-pikaday-legend-start-end" style="width: 120px; margin: auto"> <tr> <td><div class="color-div"></div></td> </tr></table></div>';
|
||||||
|
jQuery(pika_single).append(append_html);
|
||||||
|
//let selector = 'table-pikaday-legend td:nth-child(' + key + ')';
|
||||||
|
jQuery('#table-pikaday-legend-start-end td:nth-child(1)')[0].innerHTML = "<div class=\"color-div\" style=\"background: lightgrey\"></div><span>Start-Datum</span>";
|
||||||
|
//jQuery('#table-pikaday-legend-start-end td:nth-child(2)')[0].innerHTML = "<div class=\"color-div\" style=\"background: #33aaff\"></div><span>End-Datum</span>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function colorize_pikaday_spans() {
|
||||||
|
let highestKey = Object.keys(fastsnipeObj).reduce(function(a, b){ return fastsnipeObj[a] > fastsnipeObj[b] ? a : b });
|
||||||
|
let highestDay = fastsnipeObj[highestKey]['day_end'] - 1;
|
||||||
|
for (i = 0; i <= highestDay; i++) {
|
||||||
|
let nextDay = new Date();
|
||||||
|
nextDay.setDate(nextDay.getDate() + i);
|
||||||
|
let month = nextDay.getUTCMonth() + 1; //months from 1-12
|
||||||
|
let day = nextDay.getUTCDate();
|
||||||
|
let year = nextDay.getUTCFullYear();
|
||||||
|
|
||||||
|
for (var key in fastsnipeObj) {
|
||||||
|
if (fastsnipeObj.hasOwnProperty(key)) {
|
||||||
|
let day_end = fastsnipeObj[key]['day_end'] - 1;
|
||||||
|
if (i <= day_end) {
|
||||||
|
var color = fastsnipeObj[key]['color'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pika_change_bg_color(day, month, year, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pika_change_bg_color(day, month, year, color, force = 0) {
|
||||||
|
console.log('day: ' + day + ' | month: ' + month + ' | year: ' + year + ' | color: ' + color);
|
||||||
|
month--;
|
||||||
|
let xpath = "//div[contains(@class, 'pika-single') and not(contains(@class, 'is-hidden'))]/div/table/tbody/tr/td//button[contains(@class, 'pika-button') and @data-pika-month='" + month + "' and @data-pika-day='" + day + "' and @data-pika-year='" + year + "']";
|
||||||
|
let el = getElementByXpath(xpath);
|
||||||
|
let className = jQuery(el)[0].parentElement.className;
|
||||||
|
if( force ) {
|
||||||
|
jQuery(el).css({"background": color, "opacity": "1"});
|
||||||
|
}
|
||||||
|
else if (className != 'is-disabled' && className != 'is-disabled is-today' && !force) {
|
||||||
|
jQuery(el).css('background', color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getElementByXpath(path) {
|
||||||
|
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fastsnipe_highest_end_day() {
|
||||||
|
let highestKey = Object.keys(fastsnipeObj).reduce(function(a, b){ return fastsnipeObj[a] > fastsnipeObj[b] ? a : b });
|
||||||
|
return fastsnipeObj[highestKey]['day_end'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function pikaday_maxDate() {
|
||||||
|
let add_days_end = fastsnipe_highest_end_day()-1;
|
||||||
|
let today = new Date();
|
||||||
|
let end_date = new Date();
|
||||||
|
end_date.setDate(today.getDate()+add_days_end);
|
||||||
|
return end_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
function wait_for_element(selector, fnName, dateObject) {
|
||||||
|
if (jQuery('#' + selector).length) {
|
||||||
|
console.log('ready');
|
||||||
|
window[fnName](selector, dateObject);
|
||||||
|
} else {
|
||||||
|
setTimeout(function() {
|
||||||
|
wait_for_element(selector, fnName, dateObject);
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeItRain() {
|
||||||
|
confetti.start(1200, 50, 150);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeA(array, item) {
|
||||||
|
var index = array.indexOf(item);
|
||||||
|
if (index !== -1) array.splice(index, 1);
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
function trim_string(string, length) {
|
||||||
|
if( string.length > length )
|
||||||
|
string = string.substring(0, length-3) + '...';
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
15
src/snippets/hide_wp_topbar_elements.php
Normal file
15
src/snippets/hide_wp_topbar_elements.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
add_action( 'wp_enqueue_scripts', "hook_javascript_admin_bar" );
|
||||||
|
function hook_javascript_admin_bar() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
jQuery('#wp-admin-bar-updates').hide();
|
||||||
|
jQuery('#wp-admin-bar-new-content').hide();
|
||||||
|
jQuery('#wp-admin-bar-edit').hide();
|
||||||
|
jQuery('#wp-admin-bar-new_draft').hide();
|
||||||
|
jQuery('#wp-admin-bar-wp-logo').hide();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
175
src/snippets/hook_my_ninja_forms_processing.php
Normal file
175
src/snippets/hook_my_ninja_forms_processing.php
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @tag my_ninja_forms_processing
|
||||||
|
* @callback my_ninja_forms_processing_callback
|
||||||
|
*/
|
||||||
|
add_action( 'my_ninja_forms_processing', 'my_ninja_forms_processing_callback' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $form_data array
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function my_ninja_forms_processing_callback( $form_data ) {
|
||||||
|
if ( !is_user_logged_in() ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'my_ninja_forms_processing_callback...', 'clear');
|
||||||
|
|
||||||
|
// FastSnipe Object
|
||||||
|
$fastsnipeObj = array(
|
||||||
|
1 => array(
|
||||||
|
'price' => 2250,
|
||||||
|
'day_end' => 7,
|
||||||
|
'color' => '#f8dd4d',
|
||||||
|
),
|
||||||
|
2 => array(
|
||||||
|
'price' => 1800,
|
||||||
|
'day_end' => 14,
|
||||||
|
'color' => 'hotpink',
|
||||||
|
),
|
||||||
|
3 => array(
|
||||||
|
'price' => 1100,
|
||||||
|
'day_end' => 21,
|
||||||
|
'color' => '#fd9f02',
|
||||||
|
),
|
||||||
|
4 => array(
|
||||||
|
'price' => 500,
|
||||||
|
'day_end' => 35,
|
||||||
|
'color' => '#87cefa',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$form_id = $form_data[ 'form_id' ];
|
||||||
|
$form_settings = $form_data[ 'settings' ];
|
||||||
|
$form_title = $form_data[ 'settings' ][ 'title' ];
|
||||||
|
$form_fields = $form_data[ 'fields' ];
|
||||||
|
|
||||||
|
foreach( $form_fields as $field ){
|
||||||
|
$field_id = $field[ 'id' ];
|
||||||
|
$field_key = $field[ 'key' ];
|
||||||
|
$field_value = $field[ 'value' ];
|
||||||
|
|
||||||
|
if( 'ich_brauche_einen_termin_1579378475182' == $field[ 'key' ] ) {
|
||||||
|
if( $field_value == 'sofort' ) {
|
||||||
|
$switch_termintype = 'sofort';
|
||||||
|
}
|
||||||
|
else if ( $field_value == 'zeitraum' ) {
|
||||||
|
$switch_termintype = 'zeitraum';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( 'wochentag_start_text' == $field[ 'key' ] ) {
|
||||||
|
$wochentag_start_text = $field_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'switch_termintype: ' . $switch_termintype);
|
||||||
|
|
||||||
|
if ( $switch_termintype == 'sofort' ) {
|
||||||
|
[$bool, $user_balance, $price, $is_premium] = subtract_fastcoins_by_start_date_local( $fastsnipeObj, 'sofort' );
|
||||||
|
}
|
||||||
|
else if ( $switch_termintype == 'zeitraum' ) {
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'wochentag_start_text: ' . $wochentag_start_text);
|
||||||
|
[$bool, $user_balance, $price, $is_premium] = subtract_fastcoins_by_start_date_local( $fastsnipeObj, 'zeitraum', $wochentag_start_text );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function subtract_fastcoins_by_start_date_local( $fastsnipeObj, $termintype_switch, $wochentag_start_text = null ) {
|
||||||
|
[$bool, $user_balance, $price, $is_premium] = check_premium_local( $fastsnipeObj, $termintype_switch, $wochentag_start_text );
|
||||||
|
|
||||||
|
if ( $bool ) {
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'transfer legit. subtracting amount...');
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
mycred_subtract( 'fastsnipe', $user_id, $price, 'Forms booking completed' );
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'subtracted ' . $price . ' from ' . $user_balance);
|
||||||
|
}
|
||||||
|
else if ( $bool === 0 ) {
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'not enough coins for transfer');
|
||||||
|
}
|
||||||
|
else if ( $bool === null ) {
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'no premium day');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rArr;
|
||||||
|
}
|
||||||
|
|
||||||
|
function DateDiffFromNow_local($d2) {
|
||||||
|
$d1 = new DateTime();
|
||||||
|
$d2 = new DateTime($d2);
|
||||||
|
$dDiff = $d1->diff($d2);
|
||||||
|
return $dDiff->format('%r%a');
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_premium_local( $fastsnipeObj, $fswitch, $wochentag_start_text ) {
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
$user_balance = mycred_get_users_balance( $user_id );
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'Balance: ' . $user_balance);
|
||||||
|
|
||||||
|
if ( $fswitch == 'zeitraum' ) {
|
||||||
|
$i = DateDiffFromNow_local($wochentag_start_text);
|
||||||
|
}
|
||||||
|
else if ( $fswitch == 'sofort' ) {
|
||||||
|
$i = 0;
|
||||||
|
}
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'i: ' . $i);
|
||||||
|
|
||||||
|
if( $price = get_premium_price_local($fastsnipeObj, $i) ) {
|
||||||
|
$is_premium = 1;
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'price: ' . $price);
|
||||||
|
if ( can_afford_local($user_balance, $price) ) {
|
||||||
|
$bool = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$bool = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$is_premium = 0;
|
||||||
|
$bool = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($bool, $user_balance, $price, $is_premium);
|
||||||
|
}
|
||||||
|
|
||||||
|
function can_afford_local($user_balance, $price) {
|
||||||
|
$can_afford = 0;
|
||||||
|
$diff = $user_balance-$price;
|
||||||
|
call_user_func('dump_to_file_local', '/var/www/lab/newfile.txt', 'price diff: ' . $diff);
|
||||||
|
if( $diff >= 0 ) {
|
||||||
|
$can_afford = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $can_afford;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_premium_price_local($fastsnipeObj, $i) {
|
||||||
|
$price = 0;
|
||||||
|
foreach ($fastsnipeObj as $key => $value) {
|
||||||
|
$day_end = $fastsnipeObj[$key]['day_end'] - 2;
|
||||||
|
if ($i <= $day_end) {
|
||||||
|
$price = $fastsnipeObj[$key]['price'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $price;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dump_to_file_local($file, $data, $method = '') {
|
||||||
|
if ($method == 'clear') {
|
||||||
|
$f = @fopen($file, "r+");
|
||||||
|
if ($f !== false) {
|
||||||
|
ftruncate($f, 0);
|
||||||
|
fclose($f);
|
||||||
|
}
|
||||||
|
|
||||||
|
$timestamp = "\n[" . date('m/d/Y h:i:sa', time()) . "]\n";
|
||||||
|
file_put_contents($file, $timestamp, FILE_APPEND | LOCK_EX);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($data) || is_object($data)) {
|
||||||
|
$data = print_r($data, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($file, $data.PHP_EOL , FILE_APPEND | LOCK_EX);
|
||||||
|
}
|
||||||
31
src/snippets/inactivity_refresh.php
Normal file
31
src/snippets/inactivity_refresh.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_inactivity_refresh' );
|
||||||
|
|
||||||
|
function my_inactivity_refresh() {
|
||||||
|
$requests = user_has_snipes_in_category('requests');
|
||||||
|
if (is_user_logged_in() && $requests > 0 ) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
|
||||||
|
var time = new Date().getTime();
|
||||||
|
jQuery(document.body).bind("mousemove keypress", function () {
|
||||||
|
//console.log('reset');
|
||||||
|
time = new Date().getTime();
|
||||||
|
});
|
||||||
|
|
||||||
|
let refresh = setInterval(function() {
|
||||||
|
if (new Date().getTime() - time >= 300000) {
|
||||||
|
clearTimeout(refresh);
|
||||||
|
window.location.reload(true);
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/snippets/login_redirect.php
Normal file
41
src/snippets/login_redirect.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_login_redirect' );
|
||||||
|
function my_login_redirect() {
|
||||||
|
if(page_id() === 832) {
|
||||||
|
|
||||||
|
$parts = parse_url(current_url());
|
||||||
|
if ($parts['query']) { // REDIRECT WITH ARGS
|
||||||
|
$url = 'http://zinomedia.de/terminsnipe/?login&' . $parts['query'];
|
||||||
|
}
|
||||||
|
parse_error($parts['query']);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parse_error($additional_args) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
jQuery('#page').hide();
|
||||||
|
let additional_args = "<?php echo $additional_args ?>"; // JS VAR = PHP VAR
|
||||||
|
let redirect_url = 'http://zinomedia.de/terminsnipe/?login';
|
||||||
|
let error;
|
||||||
|
|
||||||
|
if ( jQuery('.mepr_error').length ) {
|
||||||
|
error = jQuery('.mepr_error')[0].textContent.trim();
|
||||||
|
console.log(error);
|
||||||
|
redirect_url += '&error=' + encodeURIComponent(error);
|
||||||
|
}
|
||||||
|
if ( additional_args ) {
|
||||||
|
console.log('additional_args: ' + additional_args);
|
||||||
|
redirect_url += '&' + additional_args;
|
||||||
|
}
|
||||||
|
console.log('redirect_url: ' + redirect_url);
|
||||||
|
window.location.replace(redirect_url);
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
24
src/snippets/logout_thankyou_redirect.php
Normal file
24
src/snippets/logout_thankyou_redirect.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_thank_you_redirect' );
|
||||||
|
function my_thank_you_redirect() {
|
||||||
|
if(page_id() === 162) {
|
||||||
|
wp_logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action('wp_login', 'my_wp_login', 10, 2);
|
||||||
|
function my_wp_login( $user_login, $user ) {
|
||||||
|
$user_login_count = get_user_meta( $user->ID, 'user_login_count', true );
|
||||||
|
$user_login_count++;
|
||||||
|
update_user_meta( $user->ID, 'user_login_count', $user_login_count );
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action('clear_auth_cookie', 'my_wp_logout', 10);
|
||||||
|
function my_wp_logout() {
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
$user_login_count = get_user_meta( $user_id, 'user_login_count', true );
|
||||||
|
if ( $user_login_count == 1 ) {
|
||||||
|
redirect('http://zinomedia.de/terminsnipe/?ty=1');
|
||||||
|
}
|
||||||
|
}
|
||||||
99
src/snippets/menu_indicator_appointment_check.php
Normal file
99
src/snippets/menu_indicator_appointment_check.php
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'pre_menu_indicator' );
|
||||||
|
|
||||||
|
function pre_menu_indicator() {
|
||||||
|
if (is_menu_page()) {
|
||||||
|
$menu_mapping = array( 'requests' => 984,
|
||||||
|
'expired' => 983,
|
||||||
|
'appointment' => 1812,
|
||||||
|
);
|
||||||
|
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
$rows = db_count_snipes($user);
|
||||||
|
|
||||||
|
// APPOINTMENTS_OLD TO COMPARE
|
||||||
|
$appointments_old = get_user_meta( $user->ID, 'appointments_old', true );
|
||||||
|
php_console_log('appointments_old: ' . $appointments_old);
|
||||||
|
|
||||||
|
foreach ($menu_mapping as $category => $menu_id) {
|
||||||
|
$indicator = $rows[0][$category];
|
||||||
|
|
||||||
|
// NEW APPOINTMENT MODAL CHECK
|
||||||
|
if ($category === 'appointment') {
|
||||||
|
// NEW APPOINTMENT?
|
||||||
|
if ($indicator > $appointments_old) {
|
||||||
|
php_console_log('We have a new appointment');
|
||||||
|
|
||||||
|
// SAVE NUMBER OF APPOINTMENTS
|
||||||
|
update_user_meta( $user->ID, 'appointments_old', $indicator );
|
||||||
|
|
||||||
|
// NEW APPOINTMENT MODAL
|
||||||
|
redirect('http://zinomedia.de/terminsnipe/?fa=1');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
php_console_log('No new appointment');
|
||||||
|
|
||||||
|
// SAVE NUMBER OF APPOINTMENTS
|
||||||
|
update_user_meta( $user->ID, 'appointments_old', $indicator );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
append_indicator($menu_id, $indicator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function db_count_snipes($user) {
|
||||||
|
$wpdb = connect_to_server('zinomedia');
|
||||||
|
$rows = $wpdb->get_results( "
|
||||||
|
SELECT
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
COUNT(*)
|
||||||
|
FROM
|
||||||
|
reg_users
|
||||||
|
INNER JOIN request ON request.USER_ID = reg_users.ID
|
||||||
|
WHERE
|
||||||
|
reg_users.WP_ID = $user->ID AND
|
||||||
|
request.EXPIRED = 0
|
||||||
|
) AS requests,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
COUNT(*)
|
||||||
|
FROM
|
||||||
|
reg_users
|
||||||
|
INNER JOIN request ON request.USER_ID = reg_users.ID
|
||||||
|
WHERE
|
||||||
|
reg_users.WP_ID = $user->ID AND
|
||||||
|
request.EXPIRED = 1
|
||||||
|
) AS expired,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
COUNT(*)
|
||||||
|
FROM
|
||||||
|
reg_users
|
||||||
|
INNER JOIN appointments ON appointments.USER_ID = reg_users.ID
|
||||||
|
WHERE
|
||||||
|
reg_users.WP_ID = $user->ID
|
||||||
|
) AS appointment
|
||||||
|
", ARRAY_A );
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
function append_indicator($menu_id, $indicator) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
var a = '#menu-item-' + "<?php echo $menu_id ?>" + ' a';
|
||||||
|
if (typeof a !== "undefined") {
|
||||||
|
var icon = jQuery(a + ' span i')[0].outerHTML;
|
||||||
|
var text = jQuery(a).text();
|
||||||
|
jQuery(a + ' span')[0].innerHTML = icon + text + ' (' + "<?php echo $indicator ?>" + ')';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
59
src/snippets/menu_inject.php
Normal file
59
src/snippets/menu_inject.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter('wp_nav_menu_items', 'add_last_nav_item');
|
||||||
|
function add_last_nav_item($items) {
|
||||||
|
$login_logout .= '<li id="menu-logout-item">
|
||||||
|
[mepr-logout-link class="mp-login-logout"]
|
||||||
|
</li>';
|
||||||
|
|
||||||
|
if( strpos($items, '<li id="menu-item-2518"') === 0 ) { // menu_p
|
||||||
|
if( is_user_logged_in() ) {
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
$balance = mycred_return_users_balance();
|
||||||
|
$last_name = get_user_meta( $user->ID, 'last_name', true );
|
||||||
|
$first_name = get_user_meta( $user->ID, 'first_name', true );
|
||||||
|
$avatar = '<li>
|
||||||
|
<div id="menu-avatar">
|
||||||
|
<img src="http://zinomedia.de/terminsnipe/wp-content/uploads/sites/6/2020/03/021-superhero.svg" alt="user-avatar"><strong>' . $first_name . ' ' . $last_name . '</strong>
|
||||||
|
</div>
|
||||||
|
<div id="menu-user-info"><a href="http://zinomedia.de/terminsnipe/dash/kaufen/"><img src="http://zinomedia.de/terminsnipe/wp-content/uploads/sites/6/2020/03/630865.svg" alt="fastcoins"> ' . $balance . ' FastCoins</a></div>
|
||||||
|
</li>';
|
||||||
|
|
||||||
|
$items = $avatar . $items;$login_logout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( strpos($items, '<li id="menu-item-982"') === 0 ) { // dash menu
|
||||||
|
//$items .= $login_logout;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items .= $login_logout;
|
||||||
|
js_style_nav_login_logout();
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
function js_style_nav_login_logout() {
|
||||||
|
$is_user_logged_in = is_user_logged_in();
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
var is_user_logged_in = '<?php echo $is_user_logged_in ;?>';
|
||||||
|
|
||||||
|
if (is_user_logged_in) {
|
||||||
|
jQuery( ".mp-login-logout" ).each( function () {
|
||||||
|
var nav_entry = jQuery(this);
|
||||||
|
nav_entry[0].innerHTML = '<i class="fas fa-sign-out-alt"></i>Ausloggen';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (!is_user_logged_in) {
|
||||||
|
jQuery( ".mp-login-logout" ).each( function () {
|
||||||
|
var nav_entry = jQuery(this);
|
||||||
|
nav_entry[0].innerHTML = '<i class="fas fa-sign-in-alt"></i>Einloggen';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
53
src/snippets/mepr_event_member_added.php
Normal file
53
src/snippets/mepr_event_member_added.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_action('mepr-event-member-added','my_mepr_event_member_added');
|
||||||
|
function my_mepr_event_member_added($userObj) {
|
||||||
|
// GET USER DATA
|
||||||
|
$user = $userObj->get_data();
|
||||||
|
|
||||||
|
// CREATE META POST TO REGISTER NEW USER TAGS
|
||||||
|
$categoryObj = get_category_by_slug( 'metaposts' );
|
||||||
|
$post_title = 'META-POST-' . $user->user_nicename;
|
||||||
|
$filter_tag = get_user_filter_tags($user);
|
||||||
|
$new_post_id = wp_insert_post(array (
|
||||||
|
'post_type' => 'post',
|
||||||
|
'post_title' => $post_title,
|
||||||
|
'post_status' => 'private',
|
||||||
|
'comment_status' => 'closed',
|
||||||
|
'ping_status' => 'closed',
|
||||||
|
'tags_input' => array( $user->user_nicename, $filter_tag[requests], $filter_tag[expired], $filter_tag[appointment] ),
|
||||||
|
'post_category' => array( $categoryObj->term_id ),
|
||||||
|
));
|
||||||
|
if ( $new_post_id ) {
|
||||||
|
php_console_log('Post created with ID: ' . $new_post_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// CUSTOM USER METADATA
|
||||||
|
add_user_meta( $user->ID, 'appointments_old', 0, false );
|
||||||
|
add_user_meta( $user->ID, 'user_login_count', 0, false );
|
||||||
|
|
||||||
|
// GET NEWLY CREATED TAG ID
|
||||||
|
$tag = get_term_by('slug', $user->user_nicename, 'post_tag');
|
||||||
|
$tag_id = $tag->term_id;
|
||||||
|
|
||||||
|
// ADD RULE VIA RESTAPI
|
||||||
|
$post_title = 'Posts Tagged: ' . $user->user_nicename . ' (auto)';
|
||||||
|
$data_add = array(
|
||||||
|
'post_title' => $post_title,
|
||||||
|
'access_type' => 'member',
|
||||||
|
'access_operator' => 'is',
|
||||||
|
'access_condition' => $user->user_email,
|
||||||
|
'rule_type' => 'tag',
|
||||||
|
'unauth_excerpt_type' => 'more',
|
||||||
|
'rule_content' => $tag_id,
|
||||||
|
);
|
||||||
|
$response = mbpr_restapi_add_rule($data_add);
|
||||||
|
|
||||||
|
// LOGOUT
|
||||||
|
//wp_logout();
|
||||||
|
// get all sessions for user with ID $user_id
|
||||||
|
$sessions = WP_Session_Tokens::get_instance($user->ID);
|
||||||
|
|
||||||
|
// we have got the sessions, destroy them all!
|
||||||
|
$sessions->destroy_all();
|
||||||
|
}
|
||||||
67
src/snippets/mepr_event_member_deleted.php
Normal file
67
src/snippets/mepr_event_member_deleted.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_action('mepr-event-member-deleted','my_mepr_event_member_deleted');
|
||||||
|
function my_mepr_event_member_deleted($userObj) {
|
||||||
|
|
||||||
|
// GET USER DATA
|
||||||
|
$user = $userObj->get_data();
|
||||||
|
|
||||||
|
// DELETE USER TAGGED POSTS
|
||||||
|
$data_post_delete = array(
|
||||||
|
'tags' => array ( $user->user_nicename ),
|
||||||
|
);
|
||||||
|
delete_posts_by_tag($data_post_delete);
|
||||||
|
|
||||||
|
// DELETE USER TAGS
|
||||||
|
delete_tag_by_slug( $user->user_nicename );
|
||||||
|
$filter_tags = get_user_filter_tags($user);
|
||||||
|
foreach ($filter_tags as $tag) {
|
||||||
|
delete_tag_by_slug( $tag );
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE MEMBERPRESS USER ACCESS RULE VIA RESTAPI
|
||||||
|
$post_title = 'Posts Tagged: ' . $user->user_nicename . ' (auto)';
|
||||||
|
$data_delete = array(
|
||||||
|
'post_title' => $post_title,
|
||||||
|
'post_type' => 'memberpressrule',
|
||||||
|
);
|
||||||
|
$response = mbpr_restapi_delete_rule_by_title($data_delete);
|
||||||
|
|
||||||
|
// RENEW MEMBERPRESS logged_in RULE
|
||||||
|
renew_rule_logged_in();
|
||||||
|
|
||||||
|
// DELETE USER FROM THE NETWORK AND REMOVE FROM ALL SITES (ALLOWS RE-REGISTRATION)
|
||||||
|
require_once( ABSPATH . 'wp-admin/includes/ms.php' );
|
||||||
|
wpmu_delete_user( $user->ID );
|
||||||
|
}
|
||||||
|
|
||||||
|
function renew_rule_logged_in() {
|
||||||
|
$post_title = "All Content Tagged: logged_in (auto)";
|
||||||
|
|
||||||
|
// DELETE RULE VIA RESTAPI
|
||||||
|
$data_delete = array(
|
||||||
|
'post_title' => $post_title,
|
||||||
|
'post_type' => 'memberpressrule',
|
||||||
|
);
|
||||||
|
$response = mbpr_restapi_delete_rule_by_title($data_delete);
|
||||||
|
|
||||||
|
// ADD RULE VIA RESTAPI
|
||||||
|
$logged_in = get_term_by('slug', 'logged_in', 'post_tag');
|
||||||
|
$data_add = array(
|
||||||
|
'post_title' => $post_title,
|
||||||
|
'access_type' => 'membership',
|
||||||
|
'access_operator' => 'is',
|
||||||
|
'access_condition' => 172,
|
||||||
|
'rule_type' => 'all_tax_post_tag',
|
||||||
|
'unauth_excerpt_type' => 'more',
|
||||||
|
'rule_content' => $logged_in->term_id,
|
||||||
|
);
|
||||||
|
$response2 = mbpr_restapi_add_rule($data_add);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
add_action( 'delete_user', 'custom_remove_user', 10 );
|
||||||
|
function custom_remove_user( $user_id ) {
|
||||||
|
$user_meta = get_userdata( $user_id ); // IF you need additional user info before removal
|
||||||
|
}
|
||||||
|
*/
|
||||||
35
src/snippets/mpr_hide_activate_error.php
Normal file
35
src/snippets/mpr_hide_activate_error.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_action( 'admin_enqueue_scripts', 'my_hide_memberpressactivate' );
|
||||||
|
function my_hide_memberpressactivate() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
console.log('executing now');
|
||||||
|
//wait_for_class('error', 'hide_mbpr_error');
|
||||||
|
hide_mbpr_error();
|
||||||
|
});
|
||||||
|
|
||||||
|
function hide_mbpr_error() {
|
||||||
|
if( jQuery('.error').length ) {
|
||||||
|
if( jQuery('.error')[0].textContent == "MemberPress doesn't have a valid license key installed. Go to the MemberPress activation page to activate your license or go to memberpress.com to get one." ) {
|
||||||
|
jQuery('.error')[0].outerHTML = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function wait_for_class(selector, fnName) {
|
||||||
|
if (jQuery('.' + selector).length) {
|
||||||
|
console.log('ready');
|
||||||
|
window[fnName](selector);
|
||||||
|
} else {
|
||||||
|
setTimeout(function() {
|
||||||
|
wait_for_class(selector, fnName);
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
6
src/snippets/mycred_disable_autocomplete.php
Normal file
6
src/snippets/mycred_disable_autocomplete.php
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'mycred_transfer_render', 'mycredpro_disable_transfer_autocomplete' );
|
||||||
|
function mycredpro_disable_transfer_autocomplete( $transfer_shortcode ) {
|
||||||
|
return str_replace( 'mycred-autofill', '', $transfer_shortcode );
|
||||||
|
}
|
||||||
14
src/snippets/mycred_volume_pricing.php
Normal file
14
src/snippets/mycred_volume_pricing.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'mycred_buycred_get_cost', 'mycredpro_buyred_volume_pricing', 10, 2 );
|
||||||
|
function mycredpro_buyred_volume_pricing( $cost, $amount ) {
|
||||||
|
// If buying points
|
||||||
|
if ( $amount == 2500 )
|
||||||
|
return 19.99;
|
||||||
|
|
||||||
|
// If buying 14500 points
|
||||||
|
if ( $amount == 14500 )
|
||||||
|
return 99.99;
|
||||||
|
|
||||||
|
return $cost;
|
||||||
|
}
|
||||||
20
src/snippets/ninja_detect_logged_in_user_id.php
Normal file
20
src/snippets/ninja_detect_logged_in_user_id.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'ninja_forms_render_default_value', 'my_change_nf_default_value', 10, 3 );
|
||||||
|
function my_change_nf_default_value( $default_value, $field_type, $settings ) {
|
||||||
|
if( $settings['key'] == 'hidden_logged_in' && is_user_logged_in() ) {
|
||||||
|
$default_value = '1';
|
||||||
|
}
|
||||||
|
else if( $settings['key'] == 'hidden_logged_in' && !is_user_logged_in() ) {
|
||||||
|
$default_value = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( is_user_logged_in() && $settings['key'] == 'hidden_id' ) {
|
||||||
|
$default_value = get_current_user_id();
|
||||||
|
}
|
||||||
|
else if ( !is_user_logged_in() && $settings['key'] == 'hidden_id' ) {
|
||||||
|
$default_value = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $default_value;
|
||||||
|
}
|
||||||
28
src/snippets/ninja_memberpress_rest_api_trigger.php
Normal file
28
src/snippets/ninja_memberpress_rest_api_trigger.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter('ninja_forms_render_options','ninja_forms_pre_population_callback_rest_api', 10, 2);
|
||||||
|
function ninja_forms_pre_population_callback_rest_api($options, $settings) {
|
||||||
|
if( $settings['key'] == 'restapi-delete-user-select-email' ) {
|
||||||
|
global $wpdb;
|
||||||
|
$rows = $wpdb->get_results("
|
||||||
|
Select
|
||||||
|
wp_hq.wp_users.user_email,
|
||||||
|
wp_hq.wp_6_mepr_members.user_id
|
||||||
|
From
|
||||||
|
wp_hq.wp_users Inner Join
|
||||||
|
wp_hq.wp_6_mepr_members On wp_hq.wp_users.ID = wp_hq.wp_6_mepr_members.user_id
|
||||||
|
Order By
|
||||||
|
wp_hq.wp_users.user_email
|
||||||
|
", OBJECT );
|
||||||
|
|
||||||
|
foreach ($rows as $obj) :
|
||||||
|
if ($obj->user_id == 1) {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
array_push($options, array('label' => $obj->user_email, 'value' => $obj->user_id));
|
||||||
|
}
|
||||||
|
endforeach;
|
||||||
|
}
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
13
src/snippets/ninja_populate_services_from_db.php
Normal file
13
src/snippets/ninja_populate_services_from_db.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter('ninja_forms_render_options','ninja_forms_pre_population_callback', 10, 2);
|
||||||
|
function ninja_forms_pre_population_callback($options, $settings) {
|
||||||
|
if( $settings['key'] == 'listselect_services' ) {
|
||||||
|
$wpdb = connect_to_server('zinomedia');
|
||||||
|
$rows = $wpdb->get_results("SELECT ID, NAME FROM services ORDER BY NAME ASC");
|
||||||
|
foreach ($rows as $obj) :
|
||||||
|
array_push($options, array('label' => $obj->NAME, 'value' => $obj->ID));
|
||||||
|
endforeach;
|
||||||
|
}
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
163
src/snippets/ninja_populate_standorte.php
Normal file
163
src/snippets/ninja_populate_standorte.php
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'ninja_forms_enqueue_scripts', 'hook_javascript_40' );
|
||||||
|
function hook_javascript_40() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
var service_id;
|
||||||
|
var venueObj = new Array();
|
||||||
|
var myOpts;
|
||||||
|
var root_url = 'https://terminsnipe_p:9Hplg7MU214jFl7bkX1NF7@service.berlin.de.zinomedia.de/www/lib/terminsnipe_p/php-crud-api/api.php';
|
||||||
|
var venuesChecked = new Array();
|
||||||
|
|
||||||
|
jQuery(document).on('nfFormReady', function(e, layoutView) {
|
||||||
|
nfRadio.channel('nfMP').on('change:part', function() {
|
||||||
|
|
||||||
|
if (is_mp_page() == 3) { // DIENSTLEISTUNG WAEHLEN PAGE
|
||||||
|
jQuery('#nf-field-50').on('change', function() { // GET VENUES
|
||||||
|
venueObj = [];
|
||||||
|
service_id = this.value;
|
||||||
|
|
||||||
|
var url = root_url + '/records/mapping_services?include=VENUE_ID&filter=SERVICE_ID,eq,' + service_id;
|
||||||
|
|
||||||
|
jQuery.getJSON(url, null, function(data) {
|
||||||
|
jQuery.each(data.records, function(index, item) {
|
||||||
|
venue_ids += item.VENUE_ID + ',';
|
||||||
|
});
|
||||||
|
var venue_ids = venue_ids.substring(0, venue_ids.length - 1);
|
||||||
|
|
||||||
|
url = root_url + '/records/venues/' + venue_ids + '?include=NAME,ID';
|
||||||
|
jQuery.getJSON(url, null, function(data) {
|
||||||
|
jQuery.each(data, function(index, item) {
|
||||||
|
if (item != null) {
|
||||||
|
venueObj.push({
|
||||||
|
ID: item.ID,
|
||||||
|
NAME: item.NAME
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
venueObj.sort(function(a, b) {
|
||||||
|
return a.NAME.localeCompare(b.NAME);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
console.log(venueObj);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (is_mp_page() == 5) { // STANDORTE AUSWAEHLEN PAGE
|
||||||
|
//populate_select('#nf-field-96');
|
||||||
|
resetPart();
|
||||||
|
populate_table('table-standorte-auswaehlen');
|
||||||
|
jQuery("#modal-5e6603a34d72d .checkbox-venue").change(function() { venueChecked(this) });
|
||||||
|
jQuery("#button-stadorte-abschliessen").click(function() { jQuery('#modal-5e6603a34d72d .uabb-modal-close').click(); });
|
||||||
|
|
||||||
|
|
||||||
|
jQuery('#nf-field-186:not(.bound)').addClass('bound').on('click', openStandorteModal);
|
||||||
|
jQuery( "#nf-field-186" ).trigger( "click" );
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function allowNext(bool, selector) {
|
||||||
|
// DEFAULT
|
||||||
|
jQuery('#' + selector).removeClass('nf-fail nf-error nf-pass');
|
||||||
|
jQuery(".nf-next").css("pointer-events", "auto");
|
||||||
|
|
||||||
|
if (bool == 1) {
|
||||||
|
jQuery('#' + selector).addClass('nf-pass');
|
||||||
|
jQuery(".nf-next").css("pointer-events", "auto");
|
||||||
|
}
|
||||||
|
else if (bool == 0) {
|
||||||
|
jQuery('#' + selector).addClass('nf-fail nf-error');
|
||||||
|
jQuery(".nf-next").css("pointer-events", "none");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetPart() {
|
||||||
|
venuesChecked = [];
|
||||||
|
jQuery('#nf-field-186')[0].value = '';
|
||||||
|
jQuery("#table-standorte-auswaehlen").empty();
|
||||||
|
allowNext(0, 'nf-field-186-wrap');
|
||||||
|
}
|
||||||
|
|
||||||
|
function openStandorteModal() {
|
||||||
|
jQuery('#nf-field-186').blur();
|
||||||
|
jQuery('#standorte-auswaehlen-modal').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
function venueChecked(checkbox) {
|
||||||
|
if(checkbox.checked) {
|
||||||
|
console.log('checked');
|
||||||
|
venuesChecked.push(checkbox.value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('unchecked');
|
||||||
|
removeA(venuesChecked, checkbox.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof venuesChecked !== 'undefined' && venuesChecked.length > 0) {
|
||||||
|
jQuery('#nf-field-186')[0].value = venuesChecked.length + ' erfolgreich ausgewählt';
|
||||||
|
console.log('venueIDs: ' + venuesChecked.join(','));
|
||||||
|
jQuery('#nf-field-187')[0].defaultValue = venuesChecked.join(',');
|
||||||
|
allowNext(1, 'nf-field-186-wrap');
|
||||||
|
}
|
||||||
|
else if (typeof venuesChecked !== 'undefined' && venuesChecked.length == 0) {
|
||||||
|
jQuery('#nf-field-186')[0].value = '';
|
||||||
|
jQuery('#nf-field-187')[0].defaultValue = '';
|
||||||
|
allowNext(0, 'nf-field-186-wrap');
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery('#nf-field-187').trigger('change');
|
||||||
|
|
||||||
|
console.log(venuesChecked);
|
||||||
|
}
|
||||||
|
|
||||||
|
function populate_table(selector) {
|
||||||
|
venueObj.forEach(function(arrayItem) {
|
||||||
|
jQuery('#' + selector).append('<tr><td>' + arrayItem.NAME + '</td><td><input type="checkbox" name="venue-id" class="checkbox-venue" value="' + arrayItem.ID + '"></td></tr>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function populate_select_from_htmlcollection(id, populateSource, startIndex, endIndex) {
|
||||||
|
console.log('populating...');
|
||||||
|
jQuery(id + ' option').remove();
|
||||||
|
|
||||||
|
for (var i = startIndex; i < endIndex; i++) {
|
||||||
|
jQuery(id).append(
|
||||||
|
jQuery("<option></option>")
|
||||||
|
.text(populateSource[i].text)
|
||||||
|
.val(populateSource[i].value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function populate_select(id) {
|
||||||
|
console.log('populating...');
|
||||||
|
jQuery(id + ' option').remove();
|
||||||
|
venueObj.forEach(function(arrayItem) {
|
||||||
|
jQuery(id).append(
|
||||||
|
jQuery("<option></option>")
|
||||||
|
.text(arrayItem.NAME)
|
||||||
|
.val(arrayItem.ID)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_mp_page() {
|
||||||
|
var ids = ['nf-field-72', 'nf-field-73', 'nf-field-74', 'nf-field-88'];
|
||||||
|
for (i = 0; i < ids.length; i++) {
|
||||||
|
var element = document.getElementById(ids[i]);
|
||||||
|
if (typeof(element) != 'undefined' && element != null) {
|
||||||
|
return parseInt(element.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
209
src/snippets/postcreator.php
Normal file
209
src/snippets/postcreator.php
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'postcreator' );
|
||||||
|
function postcreator () {
|
||||||
|
if( is_user_logged_in() ) { // Needed for page 222
|
||||||
|
if(page_id() === 975 || page_id() === 222) {
|
||||||
|
$data = populate_section('requests');
|
||||||
|
}
|
||||||
|
else if(page_id() === 978) {
|
||||||
|
$data = populate_section('expired');
|
||||||
|
}
|
||||||
|
else if(page_id() === 965) {
|
||||||
|
$data = populate_section('appointment');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function populate_section($category) {
|
||||||
|
// CURRENT USER OBJECT
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
|
||||||
|
// CREATE TAG TO DISPLAY RIGHT CONTENT IN CONTENT GRID POSTS MODULE
|
||||||
|
$filter_tags = get_user_filter_tags($user);
|
||||||
|
|
||||||
|
// INIT DATA
|
||||||
|
$data = array(
|
||||||
|
'user' => $user,
|
||||||
|
'category' => $category,
|
||||||
|
'filter_tag' => $filter_tags[$category],
|
||||||
|
'existent_post_ids' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// GET DB DATA
|
||||||
|
$rows = get_snipes_from_db($category, $user);
|
||||||
|
if (!empty($rows)) {
|
||||||
|
php_console_log('We have data from db');
|
||||||
|
$data['rows'] = $rows;
|
||||||
|
//dump_to_file('/var/www/lab/newfile.txt', $rows, 'clear');
|
||||||
|
$data = create_and_publish_posts($data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
php_console_log('No data from db received.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// SYNC POSTS
|
||||||
|
sync_posts($data);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sync_posts($data) {
|
||||||
|
$data_exists = array(
|
||||||
|
'tags' => array ( $data[user]->user_nicename ),
|
||||||
|
'category' => $data[category],
|
||||||
|
);
|
||||||
|
$postslist = get_posts_by_tag_and_category($data_exists);
|
||||||
|
//php_console_log('count postslist: ' . count($postslist));
|
||||||
|
//php_console_log('count data[existent_post_ids]: ' . count($data[existent_post_ids]));
|
||||||
|
|
||||||
|
foreach ($postslist as $post) {
|
||||||
|
if (in_array($post->ID, $data[existent_post_ids])) {
|
||||||
|
//php_console_log('Post with ID ' . $post->ID . ' has a right to exist');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//php_console_log('Post with ID: ' . $post->ID . ' is not anymore in db, delete?');
|
||||||
|
wp_delete_post( $post->ID, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_and_publish_posts($data) {
|
||||||
|
|
||||||
|
if ($data[category] == 'appointment') {
|
||||||
|
foreach ($data[rows] as $appointment) {
|
||||||
|
$appointment[BUERGERAEMTER] = array($appointment[BUERGERAEMTER]);
|
||||||
|
$data[request] = $appointment;
|
||||||
|
$data = create_new_post($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// CREATE GROUPS TO DISTINGUISH REQUESTS
|
||||||
|
$rows_grouped = sort_aoa_by_value($data[rows], 'REQUEST_ID');
|
||||||
|
|
||||||
|
// CREATE POSTS CONTENT AND PUBLISH
|
||||||
|
foreach ($rows_grouped as $key=>$val) {
|
||||||
|
$request = array('BUERGERAEMTER' => array());
|
||||||
|
foreach($rows_grouped[$key] as $group) {
|
||||||
|
foreach(array_keys($group) as $k) {
|
||||||
|
if ($k == 'BUERGERAMT') {
|
||||||
|
array_push($request['BUERGERAEMTER'], $group[$k]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$request[$k] = $group[$k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data[request] = $request;
|
||||||
|
$data = create_new_post($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_new_post($data) {
|
||||||
|
$post_title = $data[category] . '_' . $data[request]['REQUEST_ID'];
|
||||||
|
|
||||||
|
// CHECK IF POST EXISTS: IF POST DOES NOT EXIST -> ADD
|
||||||
|
$data_exists = array(
|
||||||
|
'tags' => array ( $user->user_nicename, $data[request]['REQUEST_ID'] ),
|
||||||
|
'category' => $data[category],
|
||||||
|
);
|
||||||
|
$postslist = get_posts_by_tag_and_category($data_exists);
|
||||||
|
|
||||||
|
if (empty($postslist)) {
|
||||||
|
php_console_log('Post ' . $post_title . ' in category ' . $data[category] . ' does not yet exist. Creating post...');
|
||||||
|
|
||||||
|
// CREATE THE POST CONTENT
|
||||||
|
$post_content = create_post_content($data);
|
||||||
|
|
||||||
|
// INSERT NEW POST
|
||||||
|
$categoryObj = get_category_by_slug( $data[category] );
|
||||||
|
$new_post_id = wp_insert_post(array (
|
||||||
|
'post_type' => 'post',
|
||||||
|
'post_title' => $post_title,
|
||||||
|
'post_content' => $post_content,
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'comment_status' => 'closed',
|
||||||
|
'ping_status' => 'closed',
|
||||||
|
'tags_input' => array( $data[user]->user_nicename, $data[request][REQUEST_ID], $data[filter_tag] ),
|
||||||
|
'post_category' => array( $categoryObj->term_id ),
|
||||||
|
));
|
||||||
|
if ( $new_post_id ) {
|
||||||
|
php_console_log('Post created with ID: ' . $new_post_id);
|
||||||
|
array_push($data[existent_post_ids], $new_post_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK IF PREMIUM POST
|
||||||
|
$fastsnipeObj = get_fastsnipeObj();
|
||||||
|
[$bool, $user_balance, $price, $is_premium] = check_premium( $fastsnipeObj, 'zeitraum', $data['request']['DATETIME_FROM'] );
|
||||||
|
php_console_log('bool: ' . $bool . ' | user_balance: ' . $user_balance . ' | price: ' . $price . ' | is_premium: ' . $is_premium);
|
||||||
|
update_post_meta( $new_post_id, 'is_premium', $is_premium );
|
||||||
|
update_post_meta( $new_post_id, 'price', $price );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
array_push($data[existent_post_ids], $postslist[0]->ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_snipes_from_db($switch, $user) {
|
||||||
|
$wpdb = connect_to_server('zinomedia');
|
||||||
|
|
||||||
|
if ($switch == 'requests' || $switch == 'expired') {
|
||||||
|
if ($switch == 'requests') {
|
||||||
|
$expired = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$expired = 1;
|
||||||
|
}
|
||||||
|
$rows = $wpdb->get_results( "
|
||||||
|
Select
|
||||||
|
reg_users.WP_ID,
|
||||||
|
request.DATETIME_FROM,
|
||||||
|
request.DATETIME_TO,
|
||||||
|
request.SERVICE_ID,
|
||||||
|
request_dienstleister.VENUE_ID,
|
||||||
|
venues.NAME As BUERGERAMT,
|
||||||
|
services.NAME As DIENSTLEISTUNG,
|
||||||
|
request.EXPIRED,
|
||||||
|
request_dienstleister.REQUEST_ID
|
||||||
|
From
|
||||||
|
reg_users Inner Join
|
||||||
|
request On request.USER_ID = reg_users.ID Inner Join
|
||||||
|
request_dienstleister On request_dienstleister.REQUEST_ID = request.ID Inner Join
|
||||||
|
venues On venues.ID = request_dienstleister.VENUE_ID Inner Join
|
||||||
|
services On services.ID = request.SERVICE_ID
|
||||||
|
Where
|
||||||
|
reg_users.WP_ID = $user->ID And
|
||||||
|
request.EXPIRED = $expired
|
||||||
|
", ARRAY_A );
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
else if ($switch == 'appointment') {
|
||||||
|
$rows = $wpdb->get_results( "
|
||||||
|
Select
|
||||||
|
reg_users.WP_ID,
|
||||||
|
appointments.PROCESS_ID,
|
||||||
|
appointments.AUTH_KEY,
|
||||||
|
mapping.SERVICE_ID,
|
||||||
|
mapping.VENUE_ID,
|
||||||
|
appointments.ID As REQUEST_ID,
|
||||||
|
venues.NAME As BUERGERAEMTER,
|
||||||
|
services.NAME As DIENSTLEISTUNG,
|
||||||
|
datetime.DATETIME
|
||||||
|
From
|
||||||
|
reg_users Inner Join
|
||||||
|
appointments On appointments.USER_ID = reg_users.ID Inner Join
|
||||||
|
mapping On mapping.ID = appointments.MAPPING_ID Inner Join
|
||||||
|
services On services.ID = mapping.SERVICE_ID Inner Join
|
||||||
|
venues On venues.ID = mapping.VENUE_ID Inner Join
|
||||||
|
datetime On datetime.EPOCHTIME = mapping.DATETIME_ID
|
||||||
|
Where
|
||||||
|
reg_users.WP_ID = $user->ID
|
||||||
|
", ARRAY_A );
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/snippets/redirect_mobile.php
Normal file
11
src/snippets/redirect_mobile.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_redirect_mobile' );
|
||||||
|
function my_redirect_mobile() {
|
||||||
|
if(page_id() != 2540) {
|
||||||
|
if (wp_is_mobile()) {
|
||||||
|
if(!isset($_GET["no-mobile-redirect"]))
|
||||||
|
redirect('http://zinomedia.de/terminsnipe/get-app/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
167
src/snippets/redirect_trigger_modal.php
Normal file
167
src/snippets/redirect_trigger_modal.php
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_login_hook' );
|
||||||
|
function my_login_hook() {
|
||||||
|
if(page_id() === 222) {
|
||||||
|
$url = current_url();
|
||||||
|
if (basename($url) === 'login') {
|
||||||
|
redirect('http://zinomedia.de/terminsnipe/?login');
|
||||||
|
}
|
||||||
|
else if (basename($url) === 'register') {
|
||||||
|
redirect('http://zinomedia.de/terminsnipe/?register');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET["login"])) {
|
||||||
|
if ( is_user_logged_in() ) {
|
||||||
|
redirect('http://zinomedia.de/terminsnipe/dash/account/');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
my_login_modal($url);
|
||||||
|
clickModal('#login-modal');
|
||||||
|
remove_url_parameter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(isset($_GET["register"])) {
|
||||||
|
if (is_user_logged_in()) {
|
||||||
|
redirect('http://zinomedia.de/terminsnipe/dash/account/');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clickModal('#register-modal');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(isset($_GET["frlo"])) {
|
||||||
|
clickModal('#frlo-modal');
|
||||||
|
remove_url_parameter();
|
||||||
|
}
|
||||||
|
else if(isset($_GET["ca"])) {
|
||||||
|
clickModal('#created-appointment-modal');
|
||||||
|
remove_url_parameter();
|
||||||
|
}
|
||||||
|
else if(isset($_GET["snake"])) {
|
||||||
|
clickModal('#game-snake-modal');
|
||||||
|
remove_url_parameter();
|
||||||
|
}
|
||||||
|
else if(isset($_GET["fa"])) {
|
||||||
|
clickModal('#found-appointment-modal');
|
||||||
|
remove_url_parameter();
|
||||||
|
my_js_confetti();
|
||||||
|
}
|
||||||
|
else if(isset($_GET["ty"])) {
|
||||||
|
clickModal('#thank-you-modal');
|
||||||
|
remove_url_parameter();
|
||||||
|
}
|
||||||
|
else if(isset($_GET["im"])) {
|
||||||
|
clickModal('#impressum-modal');
|
||||||
|
remove_url_parameter();
|
||||||
|
}
|
||||||
|
else if(isset($_GET["uccr"])) {
|
||||||
|
my_uccr();
|
||||||
|
clickModal('#cancellation-refund-modal');
|
||||||
|
remove_url_parameter();
|
||||||
|
}
|
||||||
|
else if(isset($_GET["kontakt"])) {
|
||||||
|
clickModal('#kontakt-modal');
|
||||||
|
remove_url_parameter();
|
||||||
|
}
|
||||||
|
else if(isset($_GET["fcs"])) {
|
||||||
|
my_fcs_js_manipulate();
|
||||||
|
clickModal('#fcs-modal');
|
||||||
|
remove_url_parameter();
|
||||||
|
my_js_confetti();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function my_js_confetti() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
wait_for_element('confettijs', 'makeItRain', null);
|
||||||
|
}, false);
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function my_fcs_js_manipulate() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
jQuery( "#neue-terminsuche" ).click(function() {
|
||||||
|
jQuery('.uabb-modal-close').click();
|
||||||
|
});
|
||||||
|
}, false);
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function my_login_modal($url) {
|
||||||
|
$parts = parse_url($url);
|
||||||
|
parse_str($parts['query'], $query);
|
||||||
|
|
||||||
|
if( $query['error'] ) {
|
||||||
|
my_login_modal_js_manipulate($query['error']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function my_login_modal_js_manipulate($error) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
let error= "<?php echo $error ?>";
|
||||||
|
console.log('Error received: ' + error);
|
||||||
|
if( error == 'ERROR: Your username or password was incorrect' )
|
||||||
|
error = 'FEHLER: Deine E-Mail oder dein Passwort sind inkorrekt.';
|
||||||
|
|
||||||
|
jQuery('#login-modal-overlay .mp_login_form').prepend('<div class="mp_wrapper"><div class="mepr_error" id="mepr_jump">' + error + '</div></div>');
|
||||||
|
}, false);
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function my_uccr() {
|
||||||
|
if( isset($_GET['price']) && isset($_GET['bbr']) ) {
|
||||||
|
$balance = mycred_return_users_balance();
|
||||||
|
my_uccr_js_manipulate($_GET['price'], $balance, $_GET['bbr']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function my_uccr_js_manipulate($price, $balance, $balance_before) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
let price= "<?php echo $price ?>";
|
||||||
|
let balance = "<?php echo $balance ?>";
|
||||||
|
let balance_before = "<?php echo $balance_before ?>";
|
||||||
|
jQuery('#balance-before')[0].textContent = balance_before;
|
||||||
|
jQuery('#refund-amount')[0].textContent = price;
|
||||||
|
jQuery('#user-balance')[0].textContent = balance;
|
||||||
|
jQuery( "#neue-terminsuche-starten" ).click(function() {
|
||||||
|
jQuery('.uabb-modal-close').click();
|
||||||
|
});
|
||||||
|
}, false);
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function clickModal($modal) {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
jQuery("<?php echo $modal ?>").ready(function() {
|
||||||
|
jQuery("<?php echo $modal ?>").click()
|
||||||
|
});
|
||||||
|
}, false);
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
10
src/snippets/show_general_console_info.php
Normal file
10
src/snippets/show_general_console_info.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'php_console_log_page_id' );
|
||||||
|
function php_console_log_page_id() {
|
||||||
|
php_console_log('PAGE ID: ' . page_id());
|
||||||
|
php_console_log('IS_MENU_PAGE: ' . is_menu_page());
|
||||||
|
php_console_log('CURRENT URL: ' . current_url());
|
||||||
|
php_console_log('IS_USER_LOGGED_IN: ' . is_user_logged_in());
|
||||||
|
php_console_log(str_repeat("-",80));
|
||||||
|
}
|
||||||
18
src/snippets/show_ninja_forms_page_id.php
Normal file
18
src/snippets/show_ninja_forms_page_id.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
?>
|
||||||
|
<?php
|
||||||
|
add_filter( 'wp_enqueue_scripts', 'my_ninja_forms_page_id' );
|
||||||
|
function my_ninja_forms_page_id() {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
// START JAVASCRIPT
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
jQuery(document).on( 'nfFormReady', function( e, layoutView ) {
|
||||||
|
nfRadio.channel( 'nfMP' ).on('change:part', function() {
|
||||||
|
console.log('ninja-page-id: ' + jQuery('#ninja-page-id')[0].value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// END JAVASCRIPT
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
213
src/www/lib/confetti.js
Normal file
213
src/www/lib/confetti.js
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
var confetti = {
|
||||||
|
maxCount: 150, //set max confetti count
|
||||||
|
speed: 2, //set the particle animation speed
|
||||||
|
frameInterval: 15, //the confetti animation frame interval in milliseconds
|
||||||
|
alpha: 1.0, //the alpha opacity of the confetti (between 0 and 1, where 1 is opaque and 0 is invisible)
|
||||||
|
gradient: false, //whether to use gradients for the confetti particles
|
||||||
|
start: null, //call to start confetti animation (with optional timeout in milliseconds, and optional min and max random confetti count)
|
||||||
|
stop: null, //call to stop adding confetti
|
||||||
|
toggle: null, //call to start or stop the confetti animation depending on whether it's already running
|
||||||
|
pause: null, //call to freeze confetti animation
|
||||||
|
resume: null, //call to unfreeze confetti animation
|
||||||
|
togglePause: null, //call to toggle whether the confetti animation is paused
|
||||||
|
remove: null, //call to stop the confetti animation and remove all confetti immediately
|
||||||
|
isPaused: null, //call and returns true or false depending on whether the confetti animation is paused
|
||||||
|
isRunning: null //call and returns true or false depending on whether the animation is running
|
||||||
|
};
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
confetti.start = startConfetti;
|
||||||
|
confetti.stop = stopConfetti;
|
||||||
|
confetti.toggle = toggleConfetti;
|
||||||
|
confetti.pause = pauseConfetti;
|
||||||
|
confetti.resume = resumeConfetti;
|
||||||
|
confetti.togglePause = toggleConfettiPause;
|
||||||
|
confetti.isPaused = isConfettiPaused;
|
||||||
|
confetti.remove = removeConfetti;
|
||||||
|
confetti.isRunning = isConfettiRunning;
|
||||||
|
var supportsAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame;
|
||||||
|
var colors = ["rgba(30,144,255,", "rgba(107,142,35,", "rgba(255,215,0,", "rgba(255,192,203,", "rgba(106,90,205,", "rgba(173,216,230,", "rgba(238,130,238,", "rgba(152,251,152,", "rgba(70,130,180,", "rgba(244,164,96,", "rgba(210,105,30,", "rgba(220,20,60,"];
|
||||||
|
var streamingConfetti = false;
|
||||||
|
var animationTimer = null;
|
||||||
|
var pause = false;
|
||||||
|
var lastFrameTime = Date.now();
|
||||||
|
var particles = [];
|
||||||
|
var waveAngle = 0;
|
||||||
|
var context = null;
|
||||||
|
|
||||||
|
function resetParticle(particle, width, height) {
|
||||||
|
particle.color = colors[(Math.random() * colors.length) | 0] + (confetti.alpha + ")");
|
||||||
|
particle.color2 = colors[(Math.random() * colors.length) | 0] + (confetti.alpha + ")");
|
||||||
|
particle.x = Math.random() * width;
|
||||||
|
particle.y = Math.random() * height - height;
|
||||||
|
particle.diameter = Math.random() * 10 + 5;
|
||||||
|
particle.tilt = Math.random() * 10 - 10;
|
||||||
|
particle.tiltAngleIncrement = Math.random() * 0.07 + 0.05;
|
||||||
|
particle.tiltAngle = Math.random() * Math.PI;
|
||||||
|
return particle;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleConfettiPause() {
|
||||||
|
if (pause)
|
||||||
|
resumeConfetti();
|
||||||
|
else
|
||||||
|
pauseConfetti();
|
||||||
|
}
|
||||||
|
|
||||||
|
function isConfettiPaused() {
|
||||||
|
return pause;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pauseConfetti() {
|
||||||
|
pause = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resumeConfetti() {
|
||||||
|
pause = false;
|
||||||
|
runAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
function runAnimation() {
|
||||||
|
if (pause)
|
||||||
|
return;
|
||||||
|
else if (particles.length === 0) {
|
||||||
|
context.clearRect(0, 0, window.innerWidth, window.innerHeight);
|
||||||
|
animationTimer = null;
|
||||||
|
} else {
|
||||||
|
var now = Date.now();
|
||||||
|
var delta = now - lastFrameTime;
|
||||||
|
if (!supportsAnimationFrame || delta > confetti.frameInterval) {
|
||||||
|
context.clearRect(0, 0, window.innerWidth, window.innerHeight);
|
||||||
|
updateParticles();
|
||||||
|
drawParticles(context);
|
||||||
|
lastFrameTime = now - (delta % confetti.frameInterval);
|
||||||
|
}
|
||||||
|
animationTimer = requestAnimationFrame(runAnimation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startConfetti(timeout, min, max) {
|
||||||
|
var width = window.innerWidth;
|
||||||
|
var height = window.innerHeight;
|
||||||
|
window.requestAnimationFrame = (function() {
|
||||||
|
return window.requestAnimationFrame ||
|
||||||
|
window.webkitRequestAnimationFrame ||
|
||||||
|
window.mozRequestAnimationFrame ||
|
||||||
|
window.oRequestAnimationFrame ||
|
||||||
|
window.msRequestAnimationFrame ||
|
||||||
|
function (callback) {
|
||||||
|
return window.setTimeout(callback, confetti.frameInterval);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
var canvas = document.getElementById("confetti-canvas");
|
||||||
|
if (canvas === null) {
|
||||||
|
canvas = document.createElement("canvas");
|
||||||
|
canvas.setAttribute("id", "confetti-canvas");
|
||||||
|
canvas.setAttribute("style", "display:block;z-index:999999;pointer-events:none;position:fixed;top:0");
|
||||||
|
document.body.prepend(canvas);
|
||||||
|
canvas.width = width;
|
||||||
|
canvas.height = height;
|
||||||
|
window.addEventListener("resize", function() {
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
}, true);
|
||||||
|
context = canvas.getContext("2d");
|
||||||
|
} else if (context === null)
|
||||||
|
context = canvas.getContext("2d");
|
||||||
|
var count = confetti.maxCount;
|
||||||
|
if (min) {
|
||||||
|
if (max) {
|
||||||
|
if (min == max)
|
||||||
|
count = particles.length + max;
|
||||||
|
else {
|
||||||
|
if (min > max) {
|
||||||
|
var temp = min;
|
||||||
|
min = max;
|
||||||
|
max = temp;
|
||||||
|
}
|
||||||
|
count = particles.length + ((Math.random() * (max - min) + min) | 0);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
count = particles.length + min;
|
||||||
|
} else if (max)
|
||||||
|
count = particles.length + max;
|
||||||
|
while (particles.length < count)
|
||||||
|
particles.push(resetParticle({}, width, height));
|
||||||
|
streamingConfetti = true;
|
||||||
|
pause = false;
|
||||||
|
runAnimation();
|
||||||
|
if (timeout) {
|
||||||
|
window.setTimeout(stopConfetti, timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopConfetti() {
|
||||||
|
streamingConfetti = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeConfetti() {
|
||||||
|
stop();
|
||||||
|
pause = false;
|
||||||
|
particles = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleConfetti() {
|
||||||
|
if (streamingConfetti)
|
||||||
|
stopConfetti();
|
||||||
|
else
|
||||||
|
startConfetti();
|
||||||
|
}
|
||||||
|
|
||||||
|
function isConfettiRunning() {
|
||||||
|
return streamingConfetti;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawParticles(context) {
|
||||||
|
var particle;
|
||||||
|
var x, y, x2, y2;
|
||||||
|
for (var i = 0; i < particles.length; i++) {
|
||||||
|
particle = particles[i];
|
||||||
|
context.beginPath();
|
||||||
|
context.lineWidth = particle.diameter;
|
||||||
|
x2 = particle.x + particle.tilt;
|
||||||
|
x = x2 + particle.diameter / 2;
|
||||||
|
y2 = particle.y + particle.tilt + particle.diameter / 2;
|
||||||
|
if (confetti.gradient) {
|
||||||
|
var gradient = context.createLinearGradient(x, particle.y, x2, y2);
|
||||||
|
gradient.addColorStop("0", particle.color);
|
||||||
|
gradient.addColorStop("1.0", particle.color2);
|
||||||
|
context.strokeStyle = gradient;
|
||||||
|
} else
|
||||||
|
context.strokeStyle = particle.color;
|
||||||
|
context.moveTo(x, particle.y);
|
||||||
|
context.lineTo(x2, y2);
|
||||||
|
context.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateParticles() {
|
||||||
|
var width = window.innerWidth;
|
||||||
|
var height = window.innerHeight;
|
||||||
|
var particle;
|
||||||
|
waveAngle += 0.01;
|
||||||
|
for (var i = 0; i < particles.length; i++) {
|
||||||
|
particle = particles[i];
|
||||||
|
if (!streamingConfetti && particle.y < -15)
|
||||||
|
particle.y = height + 100;
|
||||||
|
else {
|
||||||
|
particle.tiltAngle += particle.tiltAngleIncrement;
|
||||||
|
particle.x += Math.sin(waveAngle) - 0.5;
|
||||||
|
particle.y += (Math.cos(waveAngle) + particle.diameter + confetti.speed) * 0.5;
|
||||||
|
particle.tilt = Math.sin(particle.tiltAngle) * 15;
|
||||||
|
}
|
||||||
|
if (particle.x > width + 20 || particle.x < -20 || particle.y > height) {
|
||||||
|
if (streamingConfetti && particles.length <= confetti.maxCount)
|
||||||
|
resetParticle(particle, width, height);
|
||||||
|
else {
|
||||||
|
particles.splice(i, 1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
230
src/www/lib/pikaday/pikaday.css
Normal file
230
src/www/lib/pikaday/pikaday.css
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
@charset "UTF-8";
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Pikaday
|
||||||
|
* Copyright © 2014 David Bushell | BSD & MIT license | https://dbushell.com/
|
||||||
|
*/
|
||||||
|
|
||||||
|
.pika-single {
|
||||||
|
z-index: 9999;
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
color: #333;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-bottom-color: #bbb;
|
||||||
|
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
clear child float (pika-lendar), using the famous micro clearfix hack
|
||||||
|
http://nicolasgallagher.com/micro-clearfix-hack/
|
||||||
|
*/
|
||||||
|
.pika-single:before,
|
||||||
|
.pika-single:after {
|
||||||
|
content: " ";
|
||||||
|
display: table;
|
||||||
|
}
|
||||||
|
.pika-single:after { clear: both }
|
||||||
|
|
||||||
|
.pika-single.is-hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-single.is-bound {
|
||||||
|
position: absolute;
|
||||||
|
box-shadow: 0 5px 15px -5px rgba(0,0,0,.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-lendar {
|
||||||
|
float: left;
|
||||||
|
width: 240px;
|
||||||
|
margin: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-title {
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-label {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
z-index: 9999;
|
||||||
|
overflow: hidden;
|
||||||
|
margin: 0;
|
||||||
|
padding: 5px 3px;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
.pika-title select {
|
||||||
|
cursor: pointer;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 9998;
|
||||||
|
margin: 0;
|
||||||
|
left: 0;
|
||||||
|
top: 5px;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-prev,
|
||||||
|
.pika-next {
|
||||||
|
display: block;
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
outline: none;
|
||||||
|
border: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 20px;
|
||||||
|
height: 30px;
|
||||||
|
/* hide text using text-indent trick, using width value (it's enough) */
|
||||||
|
text-indent: 20px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: transparent;
|
||||||
|
background-position: center center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 75% 75%;
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-prev:hover,
|
||||||
|
.pika-next:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-prev,
|
||||||
|
.is-rtl .pika-next {
|
||||||
|
float: left;
|
||||||
|
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAUklEQVR42u3VMQoAIBADQf8Pgj+OD9hG2CtONJB2ymQkKe0HbwAP0xucDiQWARITIDEBEnMgMQ8S8+AqBIl6kKgHiXqQqAeJepBo/z38J/U0uAHlaBkBl9I4GwAAAABJRU5ErkJggg==');
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-next,
|
||||||
|
.is-rtl .pika-prev {
|
||||||
|
float: right;
|
||||||
|
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAU0lEQVR42u3VOwoAMAgE0dwfAnNjU26bYkBCFGwfiL9VVWoO+BJ4Gf3gtsEKKoFBNTCoCAYVwaAiGNQGMUHMkjGbgjk2mIONuXo0nC8XnCf1JXgArVIZAQh5TKYAAAAASUVORK5CYII=');
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-prev.is-disabled,
|
||||||
|
.pika-next.is-disabled {
|
||||||
|
cursor: default;
|
||||||
|
opacity: .2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-select {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-table th,
|
||||||
|
.pika-table td {
|
||||||
|
width: 14.285714285714286%;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-table th {
|
||||||
|
color: #999;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 25px;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-button {
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
outline: none;
|
||||||
|
border: 0;
|
||||||
|
margin: 0;
|
||||||
|
width: 100%;
|
||||||
|
padding: 5px;
|
||||||
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 15px;
|
||||||
|
text-align: right;
|
||||||
|
background: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-week {
|
||||||
|
font-size: 11px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-today .pika-button {
|
||||||
|
color: #33aaff;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-selected .pika-button,
|
||||||
|
.has-event .pika-button {
|
||||||
|
color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
background: #33aaff;
|
||||||
|
box-shadow: inset 0 1px 3px #178fe5;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.has-event .pika-button {
|
||||||
|
background: #005da9;
|
||||||
|
box-shadow: inset 0 1px 3px #0076c9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-disabled .pika-button,
|
||||||
|
.is-inrange .pika-button {
|
||||||
|
background: #D5E9F7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-startrange .pika-button {
|
||||||
|
color: #fff;
|
||||||
|
background: #6CB31D;
|
||||||
|
box-shadow: none;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-endrange .pika-button {
|
||||||
|
color: #fff;
|
||||||
|
background: #33aaff;
|
||||||
|
box-shadow: none;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-disabled .pika-button {
|
||||||
|
pointer-events: none;
|
||||||
|
cursor: default;
|
||||||
|
color: #999;
|
||||||
|
opacity: .3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-outside-current-month .pika-button {
|
||||||
|
color: #999;
|
||||||
|
opacity: .3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-selection-disabled {
|
||||||
|
pointer-events: none;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pika-button:hover,
|
||||||
|
.pika-row.pick-whole-week:hover .pika-button {
|
||||||
|
color: #fff;
|
||||||
|
background: #ff8000;
|
||||||
|
box-shadow: none;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* styling for abbr */
|
||||||
|
.pika-table abbr {
|
||||||
|
border-bottom: none;
|
||||||
|
cursor: help;
|
||||||
|
}
|
||||||
56
src/www/lib/pikaday/pikaday.jquery.js
Normal file
56
src/www/lib/pikaday/pikaday.jquery.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*!
|
||||||
|
* Pikaday jQuery plugin.
|
||||||
|
*
|
||||||
|
* Copyright © 2013 David Bushell | BSD & MIT license | https://github.com/Pikaday/Pikaday
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function (root, factory)
|
||||||
|
{
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
if (typeof exports === 'object') {
|
||||||
|
// CommonJS module
|
||||||
|
factory(require('jquery'), require('pikaday'));
|
||||||
|
} else if (typeof define === 'function' && define.amd) {
|
||||||
|
// AMD. Register as an anonymous module.
|
||||||
|
define(['jquery', 'pikaday'], factory);
|
||||||
|
} else {
|
||||||
|
// Browser globals
|
||||||
|
factory(root.jQuery, root.Pikaday);
|
||||||
|
}
|
||||||
|
}(this, function (jQuery, Pikaday)
|
||||||
|
{
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
jQuery.fn.pikaday = function()
|
||||||
|
{
|
||||||
|
var args = arguments;
|
||||||
|
|
||||||
|
if (!args || !args.length) {
|
||||||
|
args = [{ }];
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.each(function()
|
||||||
|
{
|
||||||
|
var self = jQuery(this),
|
||||||
|
plugin = self.data('pikaday');
|
||||||
|
|
||||||
|
if (!(plugin instanceof Pikaday)) {
|
||||||
|
if (typeof args[0] === 'object') {
|
||||||
|
var options = jQuery.extend({}, args[0]);
|
||||||
|
options.field = self[0];
|
||||||
|
self.data('pikaday', new Pikaday(options));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (typeof args[0] === 'string' && typeof plugin[args[0]] === 'function') {
|
||||||
|
plugin[args[0]].apply(plugin, Array.prototype.slice.call(args,1));
|
||||||
|
|
||||||
|
if (args[0] === 'destroy') {
|
||||||
|
self.removeData('pikaday');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
}));
|
||||||
1257
src/www/lib/pikaday/pikaday.js
Normal file
1257
src/www/lib/pikaday/pikaday.js
Normal file
File diff suppressed because it is too large
Load Diff
2
src/www/lib/terminsnipe/.htpasswd
Normal file
2
src/www/lib/terminsnipe/.htpasswd
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
zino:$apr1$Rt3ZnnnB$XS0Vtz/9/eClTP/npV2wt/
|
||||||
|
terminsnipe:$apr1$yep6fNwH$y2kBPTBJwlutW3ZQBLu00/
|
||||||
467
src/www/lib/terminsnipe/log.txt
Normal file
467
src/www/lib/terminsnipe/log.txt
Normal file
@@ -0,0 +1,467 @@
|
|||||||
|
Access-control-allow-origin: *
|
||||||
|
Content-Type: application/json; charset=utf-8
|
||||||
|
|
||||||
|
RUN @ Tue Aug 18 15:43:13 2020
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::validate_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
Memberpress entered. We have data.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::decode_received_json
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::routes
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'UHRZEIT_END' => '18',
|
||||||
|
'WOCHENTAG_END' => '2020-09-15',
|
||||||
|
'WP_ID' => '223',
|
||||||
|
'event' => 'ninjaforms-terminerstellung',
|
||||||
|
'SWITCH_TERMINTYPE' => 'zeitraum',
|
||||||
|
'UHRZEIT_START' => '07',
|
||||||
|
'SERVICE_ID' => '120686',
|
||||||
|
'WOCHENTAG_START' => '2020-09-03',
|
||||||
|
'STANDORTE' => '',
|
||||||
|
'SWITCH_STANDORTE' => 'berlinweit'
|
||||||
|
};
|
||||||
|
ninjaforms-terminerstellung
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::event_ninjaforms_terminerstellung
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::lwp_get
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
GETTING https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/reg_users?filter=WP_ID,eq,223&include=ID...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'SERVICE_ID' => '120686',
|
||||||
|
'USER_ID' => 190,
|
||||||
|
'DATETIME_FROM' => '2020-09-03 07',
|
||||||
|
'DATETIME_TO' => '2020-09-15 18'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::lwp_get
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
GETTING https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/services/120686?include=HREF...
|
||||||
|
$VAR1 = [
|
||||||
|
'122210',
|
||||||
|
'122217',
|
||||||
|
'122219',
|
||||||
|
'122227',
|
||||||
|
'122231',
|
||||||
|
'122243',
|
||||||
|
'122252',
|
||||||
|
'122260',
|
||||||
|
'122262',
|
||||||
|
'122254',
|
||||||
|
'122271',
|
||||||
|
'122273',
|
||||||
|
'122277',
|
||||||
|
'122280',
|
||||||
|
'122282',
|
||||||
|
'122284',
|
||||||
|
'122291',
|
||||||
|
'122285',
|
||||||
|
'122286',
|
||||||
|
'122296',
|
||||||
|
'327262',
|
||||||
|
'325657',
|
||||||
|
'150230',
|
||||||
|
'122301',
|
||||||
|
'122297',
|
||||||
|
'122294',
|
||||||
|
'122312',
|
||||||
|
'122314',
|
||||||
|
'122304',
|
||||||
|
'122311',
|
||||||
|
'122309',
|
||||||
|
'122281',
|
||||||
|
'122279',
|
||||||
|
'122276',
|
||||||
|
'122274',
|
||||||
|
'122267',
|
||||||
|
'122246',
|
||||||
|
'122251',
|
||||||
|
'122257',
|
||||||
|
'122208',
|
||||||
|
'122226'
|
||||||
|
];
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122210'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122217',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122219'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122227',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122231',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122243',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122252'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122260',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122262'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122254',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122271',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122273'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122277',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122280',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122282'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122284'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122291'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122285'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122286',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122296'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '327262'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '325657'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '150230'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122301'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122297'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122294',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122312'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122314'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122304'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122311'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122309',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122281',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122279',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122276'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122274'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122267'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122246',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122251'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'REQUEST_ID' => '228',
|
||||||
|
'VENUE_ID' => '122257'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122208',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
> main::post_request
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
$VAR1 = {
|
||||||
|
'VENUE_ID' => '122226',
|
||||||
|
'REQUEST_ID' => '228'
|
||||||
|
};
|
||||||
|
Posting https://terminsnipe:y9aFwUO7htuyKMaaPQWu@zinomedia.de/scripts/terminsnipe/php-crud-api/api.php/records/request_dienstleister...
|
||||||
2
src/www/lib/terminsnipe_p/.htpasswd
Normal file
2
src/www/lib/terminsnipe_p/.htpasswd
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
zino:$apr1$Rt3ZnnnB$XS0Vtz/9/eClTP/npV2wt/
|
||||||
|
terminsnipe_p:$1$NTojvMnA$rVuLVSwOooVbKDSa3oVaY/
|
||||||
2
src/www/src/.htpasswd
Normal file
2
src/www/src/.htpasswd
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
zino:$apr1$Rt3ZnnnB$XS0Vtz/9/eClTP/npV2wt/
|
||||||
|
terminsnipe:$apr1$yep6fNwH$y2kBPTBJwlutW3ZQBLu00/
|
||||||
335
src/www/src/terminsnipe_controller.pl
Normal file
335
src/www/src/terminsnipe_controller.pl
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use CGI;
|
||||||
|
use CGI::Carp qw(fatalsToBrowser);
|
||||||
|
use feature qw(say);
|
||||||
|
use Data::Dumper;
|
||||||
|
use JSON qw( decode_json );
|
||||||
|
use LWP;
|
||||||
|
use DateTime;
|
||||||
|
use DateTime::Format::MySQL;
|
||||||
|
|
||||||
|
my $decoded_json;
|
||||||
|
my $cgi = CGI->new();
|
||||||
|
my $ua = LWP::UserAgent->new();
|
||||||
|
|
||||||
|
my %config = (
|
||||||
|
'HOST_WHITELIST' => [ '37.120.171.21' ],
|
||||||
|
'PHP_CRUD_API_URL' => 'https://terminsnipe:y9aFwUO7htuyKMaaPQWu@service.berlin.de.zinomedia.de/www/lib/terminsnipe/php-crud-api/api.php',
|
||||||
|
'MBPR_API_KEY' => 'sKjdz2pUHx',
|
||||||
|
);
|
||||||
|
|
||||||
|
print $cgi->header(-type => 'application/json', -access_control_allow_origin => '*', -charset => 'utf-8');
|
||||||
|
open (my $LOG, '>', 'log.txt'); # open filehandle log.txt
|
||||||
|
select $LOG; # select new filehandle
|
||||||
|
# say 'This should be logged.';
|
||||||
|
# select STDOUT; # restore STDOUT
|
||||||
|
|
||||||
|
|
||||||
|
# WORKFLOW
|
||||||
|
print $cgi->header(-type => 'application/json', -access_control_allow_origin => '*', -charset => 'utf-8');
|
||||||
|
#print $cgi->header();
|
||||||
|
# print Dumper $cgi->url_param();
|
||||||
|
|
||||||
|
|
||||||
|
# foreach my $key (sort(keys(%ENV))) {
|
||||||
|
# print "$key = $ENV{$key}<br>\n";
|
||||||
|
# }
|
||||||
|
my $timestamp = localtime(time);
|
||||||
|
say "RUN @ $timestamp";
|
||||||
|
|
||||||
|
&validate_request();
|
||||||
|
&routes();
|
||||||
|
|
||||||
|
|
||||||
|
# PRINT REVEIVED JSON TO FILE
|
||||||
|
#&dumpToFile("./POSTDATA_$timestamp", $decoded_json);
|
||||||
|
|
||||||
|
sub routes {
|
||||||
|
&Delimiter((caller(0))[3]);
|
||||||
|
|
||||||
|
print Dumper $decoded_json;
|
||||||
|
# if ($decoded_json->{'event'} eq 'member-added') {
|
||||||
|
# say 'member_added';
|
||||||
|
# &event_member_added();
|
||||||
|
# }
|
||||||
|
if ($decoded_json->{'event'} eq 'member-signup-completed') {
|
||||||
|
say 'member-signup-completed';
|
||||||
|
&event_member_signup_completed();
|
||||||
|
}
|
||||||
|
elsif ($decoded_json->{'event'} eq 'ninjaforms-terminerstellung') {
|
||||||
|
say 'ninjaforms-terminerstellung';
|
||||||
|
&event_ninjaforms_terminerstellung();
|
||||||
|
}
|
||||||
|
elsif ($decoded_json->{'event'} eq 'restapi-delete-user') {
|
||||||
|
say 'restapi-delete-user';
|
||||||
|
&event_restapi_delete_user();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
say $decoded_json->{'event'} . ' not handled yet';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sub event_restapi_delete_user {
|
||||||
|
&Delimiter((caller(0))[3]);
|
||||||
|
|
||||||
|
if( !$decoded_json->{'WP_ID'} ) {
|
||||||
|
say 'Missing args in event_restapi_delete_user';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# TRIGGER DELETE MBPR EVENT VIA API
|
||||||
|
say 'Triggering Memberpress REST-API to delete user with WP_ID: '. $decoded_json->{'WP_ID'};
|
||||||
|
my $url_delete_mbpr = 'https://zinomedia.de/wp_hq/terminsnipe/wp-json/mp/v1/members/' . $decoded_json->{'WP_ID'};
|
||||||
|
my $response = $ua->delete( $url_delete_mbpr, 'Authorization' => $config{'MBPR_API_KEY'});
|
||||||
|
#print Dumper $response;
|
||||||
|
|
||||||
|
# GET USER_ID FROM WP_ID
|
||||||
|
say 'Getting USER_ID from WP_ID...';
|
||||||
|
my $query = "records/reg_users?filter=WP_ID,eq,$decoded_json->{'WP_ID'}&include=ID";
|
||||||
|
my $url_get = "$config{'PHP_CRUD_API_URL'}/$query";
|
||||||
|
my $response2 = &lwp_get($url_get);
|
||||||
|
my $user_id = $response2->{'records'}[0]->{'ID'};
|
||||||
|
|
||||||
|
# DELETE USER FROM DB
|
||||||
|
my $query2 = 'records/reg_users/' . $user_id;
|
||||||
|
my $url_delete_db = "$config{'PHP_CRUD_API_URL'}/$query2";
|
||||||
|
my $response3 = $ua->delete( $url_delete_db );
|
||||||
|
#print Dumper $response3;
|
||||||
|
say 'Deleting user from db with ID: ' . $user_id . ' ... done';
|
||||||
|
}
|
||||||
|
sub event_ninjaforms_terminerstellung {
|
||||||
|
&Delimiter((caller(0))[3]);
|
||||||
|
|
||||||
|
# GET USER_ID FROM WP_ID
|
||||||
|
my $query = "records/reg_users?filter=WP_ID,eq,$decoded_json->{'WP_ID'}&include=ID";
|
||||||
|
my $url_get = "$config{'PHP_CRUD_API_URL'}/$query";
|
||||||
|
my $response = &lwp_get($url_get);
|
||||||
|
my $user_id = $response->{'records'}[0]->{'ID'};
|
||||||
|
|
||||||
|
# DATETIMES
|
||||||
|
my ($datetime_to, $datetime_from);
|
||||||
|
if ($decoded_json->{'SWITCH_TERMINTYPE'} eq 'sofort') {
|
||||||
|
my $dt = DateTime->now;
|
||||||
|
$dt->set_time_zone( 'Europe/Berlin' );
|
||||||
|
$datetime_from = DateTime::Format::MySQL->format_datetime($dt);
|
||||||
|
$datetime_to = "$decoded_json->{'WOCHENTAG_END'} $decoded_json->{'UHRZEIT_END'}";
|
||||||
|
}
|
||||||
|
elsif ($decoded_json->{'SWITCH_TERMINTYPE'} eq 'zeitraum') {
|
||||||
|
$datetime_from = "$decoded_json->{'WOCHENTAG_START'} $decoded_json->{'UHRZEIT_START'}";
|
||||||
|
$datetime_to = "$decoded_json->{'WOCHENTAG_END'} $decoded_json->{'UHRZEIT_END'}";
|
||||||
|
}
|
||||||
|
|
||||||
|
# INSERT INTO request
|
||||||
|
my %data = (
|
||||||
|
'USER_ID' => $user_id,
|
||||||
|
'SERVICE_ID' => $decoded_json->{'SERVICE_ID'},
|
||||||
|
'DATETIME_FROM' => $datetime_from,
|
||||||
|
'DATETIME_TO' => $datetime_to,
|
||||||
|
);
|
||||||
|
my $request_id = &post_request(\%data, "$config{'PHP_CRUD_API_URL'}/records/request");
|
||||||
|
|
||||||
|
# STANDORTE
|
||||||
|
my @standorte;
|
||||||
|
if ($decoded_json->{'SWITCH_STANDORTE'} eq 'berlinweit') {
|
||||||
|
my $query = "records/services/$decoded_json->{'SERVICE_ID'}?include=HREF";
|
||||||
|
my $url_get = "$config{'PHP_CRUD_API_URL'}/$query";
|
||||||
|
my $response = &lwp_get($url_get);
|
||||||
|
my $href = $response->{'HREF'};
|
||||||
|
$href =~ m/dienstleisterlist=(.*?)\&/;
|
||||||
|
@standorte= split(/,/, $1);
|
||||||
|
}
|
||||||
|
elsif ($decoded_json->{'SWITCH_STANDORTE'} eq 'standorte-auswaehlen') {
|
||||||
|
@standorte = split(/,/, $decoded_json->{'STANDORTE'});
|
||||||
|
}
|
||||||
|
print Dumper \@standorte;
|
||||||
|
|
||||||
|
# INSERT INTO request_dienstleister
|
||||||
|
for my $venue_id (@standorte) {
|
||||||
|
my %data_request_dienstleister = (
|
||||||
|
'REQUEST_ID' => $request_id,
|
||||||
|
'VENUE_ID' => $venue_id,
|
||||||
|
);
|
||||||
|
my $request_dienstleister_id = &post_request(\%data_request_dienstleister, "$config{'PHP_CRUD_API_URL'}/records/request_dienstleister");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sub lwp_get {
|
||||||
|
&Delimiter((caller(0))[3]);
|
||||||
|
my ($url) = @_;
|
||||||
|
|
||||||
|
say "GETTING $url...";
|
||||||
|
|
||||||
|
my $response = $ua->get($url);
|
||||||
|
if ($response->is_success) {
|
||||||
|
return decode_json($response->decoded_content);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
say "LWP not successful";
|
||||||
|
say $response->status_line;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sub post_request {
|
||||||
|
&Delimiter((caller(0))[3]);
|
||||||
|
my ($data_ref, $url) = @_;
|
||||||
|
|
||||||
|
print Dumper $data_ref;
|
||||||
|
say "Posting $url...";
|
||||||
|
|
||||||
|
my $response = $ua->post( $url, { %$data_ref } );
|
||||||
|
return $response->decoded_content();
|
||||||
|
}
|
||||||
|
sub event_member_signup_completed {
|
||||||
|
&Delimiter((caller(0))[3]);
|
||||||
|
|
||||||
|
my %data = (
|
||||||
|
'EMAIL' => $decoded_json->{'data'}->{'email'},
|
||||||
|
'WP_ID' => $decoded_json->{'data'}->{'id'},
|
||||||
|
'LAST_NAME' => $decoded_json->{'data'}->{'last_name'},
|
||||||
|
'FIRST_NAME' => $decoded_json->{'data'}->{'first_name'},
|
||||||
|
'PHONE' => $decoded_json->{'data'}->{'profile'}->{'mepr_telefon_mobil'},
|
||||||
|
);
|
||||||
|
print Dumper \%data;
|
||||||
|
|
||||||
|
# CHECK IF USER ALREADY EXISTS IN DB
|
||||||
|
my $url_get = "$config{'PHP_CRUD_API_URL'}/records/reg_users?filter=WP_ID,eq,$data{'WP_ID'}";
|
||||||
|
my $response = &lwp_get($url_get);
|
||||||
|
say 'Number of existing records ' . scalar @{$response->{'records'}};
|
||||||
|
print Dumper $response;
|
||||||
|
|
||||||
|
# INSERT NEW USER IF NOT ALREADY IN DB
|
||||||
|
if (scalar @{$response->{'records'}} == 0) {
|
||||||
|
say "Inserting new user...";
|
||||||
|
&post_request(\%data, "$config{'PHP_CRUD_API_URL'}/records/reg_users");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
say 'Already ' . @{$response->{'records'}} . ' datasets exist -> No db insert.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sub validate_request {
|
||||||
|
&Delimiter((caller(0))[3]);
|
||||||
|
|
||||||
|
if (!grep( /^$ENV{'REMOTE_ADDR'}$/, @{$config{'HOST_WHITELIST'}})) {
|
||||||
|
say "HOST $ENV{'REMOTE_ADDR'} not whitelisted.";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($cgi->param("POSTDATA")) { # MEMBERPRESS
|
||||||
|
say "Memberpress entered. We have data.";
|
||||||
|
&decode_received_json($cgi->param("POSTDATA"));
|
||||||
|
}
|
||||||
|
elsif (!$cgi->param("POSTDATA")) {
|
||||||
|
say "No data received.";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sub decode_received_json {
|
||||||
|
&Delimiter((caller(0))[3]);
|
||||||
|
my $data = @_;
|
||||||
|
|
||||||
|
$decoded_json = eval { decode_json($cgi->param("POSTDATA")) };
|
||||||
|
if ($@) {
|
||||||
|
say "decode_json failed, invalid json.";
|
||||||
|
say $@;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sub dumpToFile {
|
||||||
|
# &Delimiter((caller(0))[3]);
|
||||||
|
my ($filepath, $ref) = @_;
|
||||||
|
|
||||||
|
# DATA DUMPER UTF8 HACK
|
||||||
|
# no warnings 'redefine';
|
||||||
|
local *Data::Dumper::qquote = sub { qq["${\(shift)}"] };
|
||||||
|
local $Data::Dumper::Useperl = 1;
|
||||||
|
|
||||||
|
#open my $FILE, '>:encoding(UTF-8)', $filepath;
|
||||||
|
open( my $FILE, '>:encoding(UTF-8)', $filepath ) or die "Couldn't open: $!";
|
||||||
|
print $FILE Dumper $ref;
|
||||||
|
close $FILE;
|
||||||
|
}
|
||||||
|
sub Delimiter {
|
||||||
|
my $SubName = shift;
|
||||||
|
print "\n" . "-" x 80 . "\n";
|
||||||
|
print "> " . $SubName;
|
||||||
|
# print " | CHILD: $service_id_fork" if ($service_id_fork);
|
||||||
|
print "\n" . '-' x 80 . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# print <<'END';
|
||||||
|
# <!doctype html>
|
||||||
|
# <html> $local </html>
|
||||||
|
# END
|
||||||
|
|
||||||
|
# sub output_top($);
|
||||||
|
# sub output_end($);
|
||||||
|
# sub display_results($);
|
||||||
|
# sub output_form($);
|
||||||
|
|
||||||
|
# my $q = new CGI;
|
||||||
|
|
||||||
|
# print $q->header();
|
||||||
|
|
||||||
|
# # Output stylesheet, heading etc
|
||||||
|
# output_top($q);
|
||||||
|
|
||||||
|
# if ($q->param()) {
|
||||||
|
# # Parameters are defined, therefore the form has been submitted
|
||||||
|
# display_results($q);
|
||||||
|
# } else {
|
||||||
|
# # We're here for the first time, display the form
|
||||||
|
# output_form($q);
|
||||||
|
# }
|
||||||
|
|
||||||
|
# # Output footer and end html
|
||||||
|
# output_end($q);
|
||||||
|
|
||||||
|
# exit 0;
|
||||||
|
|
||||||
|
# # Outputs the start html tag, stylesheet and heading
|
||||||
|
# sub output_top($) {
|
||||||
|
# my ($q) = @_;
|
||||||
|
# print $q->start_html(
|
||||||
|
# -title => 'A Questionaire',
|
||||||
|
# -bgcolor => 'white');
|
||||||
|
# }
|
||||||
|
|
||||||
|
# # Outputs a footer line and end html tags
|
||||||
|
# sub output_end($) {
|
||||||
|
# my ($q) = @_;
|
||||||
|
# print $q->div("My Web Form");
|
||||||
|
# print $q->end_html;
|
||||||
|
# }
|
||||||
|
|
||||||
|
# # Displays the results of the form
|
||||||
|
# sub display_results($) {
|
||||||
|
# my ($q) = @_;
|
||||||
|
|
||||||
|
# my $username = $q->param('user_name');
|
||||||
|
# }
|
||||||
|
|
||||||
|
# # Outputs a web form
|
||||||
|
# sub output_form($) {
|
||||||
|
# my ($q) = @_;
|
||||||
|
# print $q->start_form(
|
||||||
|
# -name => 'main',
|
||||||
|
# -method => 'POST',
|
||||||
|
# );
|
||||||
|
|
||||||
|
# print $q->start_table;
|
||||||
|
# print $q->Tr(
|
||||||
|
# $q->td('Name:'),
|
||||||
|
# $q->td(
|
||||||
|
# $q->textfield(-name => "user_name", -size => 50)
|
||||||
|
# )
|
||||||
|
# );
|
||||||
|
|
||||||
|
# print $q->Tr(
|
||||||
|
# $q->td($q->submit(-value => 'Submit')),
|
||||||
|
# $q->td(' ')
|
||||||
|
# );
|
||||||
|
# print $q->end_table;
|
||||||
|
# print $q->end_form;
|
||||||
|
# }
|
||||||
Reference in New Issue
Block a user