function __construct()
 {
     // Get all the access values from Database
     $url = TauchTerminal_DB::getTTOption('soap_booking');
     $this->username = TauchTerminal_DB::getTTOption('soap_username');
     $this->password = TauchTerminal_DB::getTTOption('soap_password');
     $this->header_name = TauchTerminal_DB::getTTOption('header_name');
     $this->name_space = TauchTerminal_DB::getTTOption('soap_namespace');
     $this->soap = new SoapClient($url, array("trace" => false, "exceptions" => true));
 }
 public static function ca_handler()
 {
     $cacheName = 'ca_api_external.xml.cache';
     $cacheNameReview = 'ca_api_reviews.xml.cache';
     $ageInSeconds = 86400;
     // one day
     $globalStatistics = '';
     $portalStatistics = '';
     $errors = array();
     libxml_use_internal_errors(true);
     // generate the cache version if it doesn't exist or it's too old!
     clearstatcache();
     if (!file_exists($cacheName) || filemtime($cacheName) + $ageInSeconds < time()) {
         $ca_api_external = TauchTerminal_DB::getTTOption('ca_api_external');
         if (($response_xml_data = file_get_contents($ca_api_external)) !== false) {
             file_put_contents($cacheName, $response_xml_data);
         }
     }
     if (!file_exists($cacheNameReview) || filemtime($cacheNameReview) + $ageInSeconds < time()) {
         $ca_api_reviews = TauchTerminal_DB::getTTOption('ca_api_reviews');
         if (($response_xml_data = file_get_contents($ca_api_reviews)) !== false) {
             file_put_contents($cacheNameReview, $response_xml_data);
         }
     }
     $data = simplexml_load_file($cacheName);
     if (!$data) {
         $errors[] = "Error loading XML " . $cacheName;
         foreach (libxml_get_errors() as $error) {
             $errors[] = $error->message;
         }
         libxml_clear_errors();
     } else {
         $globalStatistics = $data->globalStatistics;
         $portalStatistics = $data->portalStatistics;
     }
     $data_review = simplexml_load_file($cacheNameReview);
     if (!$data_review) {
         $errors[] = "Error loading XML " . $cacheNameReview;
         foreach (libxml_get_errors() as $error) {
             $errors[] = $error->message;
         }
         libxml_clear_errors();
     } else {
         $data_review = $data_review->reviews->review;
     }
     if (!empty($errors)) {
         TauchTerminal::view('tulamben/rating_default', array('error' => $errors));
     } else {
         // pagination
         global $wp_query;
         $page = $wp_query->query_vars['page'] ? $wp_query->query_vars['page'] : 1;
         $pagination = new LimitPagination($page, $data_review->count(), 20);
         TauchTerminal::view('tulamben/rating', array('data_review' => $pagination->getLimitIterator($data_review), 'globalStatistics' => $globalStatistics, 'portalStatistics' => $portalStatistics, 'pagination' => $pagination));
     }
 }
function discount_when_room_winter_in_cart()
{
    global $woocommerce;
    $cart = $woocommerce->cart->get_cart();
    $_pf = new WC_Product_Factory();
    foreach ($cart as $item) {
        $_product = $_pf->get_product($item['product_id']);
        if (TauchTerminal_Tulamben::isRoomProduct($_product->get_sku())) {
            $winderDays = 0;
            $start = strtotime($item['start_date']);
            $end = strtotime($item['end_date']);
            $threemonths = strtotime("+3 months", strtotime(date('Y-m-d')));
            $wstart = strtotime(TauchTerminal_DB::getTTOption('winter_start'));
            $wend = strtotime(TauchTerminal_DB::getTTOption('winter_end'));
            if ($start >= $wstart && $end <= $wend) {
                $winderDays += floor(($end - $start) / (60 * 60 * 24));
                // var_dump('all days');
            } else {
                if ($start >= $wstart) {
                    $winderDays += floor(($wend - $start) / (60 * 60 * 24));
                    // var_dump('start in season');
                } else {
                    if ($end <= $wend) {
                        $winderDays += floor(($end - $wstart) / (60 * 60 * 24));
                        // var_dump('End in season');
                    }
                }
            }
            if ($winderDays != 0) {
                $title = 'Winter Season' . "\n" . $winderDays . ' Day';
                if ($winderDays > 1) {
                    $title .= 's';
                }
                $discount = floatval(TauchTerminal_DB::getTTOption('winter_discount')) * $winderDays * -1;
                $woocommerce->cart->add_fee($title, $discount, true, '');
                // Early bird
                if ($start >= $threemonths) {
                    $_product = new WC_Product_Variation($item['variation_id']);
                    $discountP = floatval(TauchTerminal_DB::getTTOption('earlybird'));
                    $price = floatval(preg_replace('#[^\\d.]#', '', $woocommerce->cart->get_product_price($_product)));
                    $discount = $price * $discountP / 100 * $winderDays * -1;
                    $title = 'Earlybird ' . $discountP . '%' . "\n" . 'for ' . $winderDays . ' Day';
                    if ($winderDays > 1) {
                        $title .= 's';
                    }
                    $woocommerce->cart->add_fee($title, $discount, true, '');
                }
            }
        }
    }
}
echo __('Winter season discount!', 'tauchterminal');
?>
</strong> <?php 
echo __('You are entitled to an winter season discount. Go to the cart to see how much discount you get.', 'tauchterminal');
?>
";
    var winterSeasonDiscountFewMsg = "<strong><?php 
echo __('Winter season discount! But only REPLACE_COUNT left!', 'tauchterminal');
?>
</strong> <?php 
echo __('You are entitled to an winter season discount. Go to the cart to see how much discount you get.', 'tauchterminal');
?>
 <?php 
echo __('Book now, there are not many rooms left.', 'tauchterminal');
?>
";

    var wstart = '<?php 
echo strtotime(TauchTerminal_DB::getTTOption("winter_start"));
?>
'
    var wend = '<?php 
echo strtotime(TauchTerminal_DB::getTTOption("winter_end"));
?>
'
</script>
<script src="<?php 
echo get_template_directory_uri();
?>
/js/room.js" type="text/javascript"></script>
 private static function getPrefix()
 {
     global $wpdb;
     $prefix = $wpdb->prefix;
     $url = TauchTerminal_DB::getTTOption('default_prefix');
     if (get_current_blog_id() != 1 && $url) {
         $prefix = $url;
     }
     return $prefix;
 }
Beispiel #6
0
                          onReady: function(e) {
                            e.target.mute();
                          }
                        }
                      });
                     }

                     // Written by @labnol
                    </script>
                </div>
            <?php 
    } elseif ($post && $post->post_name == 'contact' && TauchTerminal_DB::getTTOption('contacts_map')) {
        ?>
                <div class="carousel-header">
                    <iframe src="<?php 
        echo TauchTerminal_DB::getTTOption('contacts_map');
        ?>
" width="100%" height="100%" frameborder="0" style="border:0; display: inherit;" allowfullscreen></iframe>
                </div>
            <?php 
    } elseif (is_plugin_active('slick-carousel/slick-carousel.php')) {
        ?>
                <div class="carousel-header">
                    <?php 
        $langcode = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : 'de';
        ?>
                    <?php 
        echo do_shortcode('[slick-carousel category="header-' . $langcode . '"]');
        ?>
                </div>
            <?php 
function tt_update_db_check()
{
    if (version_compare(get_site_option('tt_version'), TAUCHTERMINAL_VERSION, '<')) {
        TauchTerminal_DB::migrations(TAUCHTERMINAL_VERSION);
    }
}
Beispiel #8
0
                        <th scope="row"><?php 
echo __('Contacts Map');
?>
</th>
                        <td><input class="form-control" type="text" name="settings['contacts_map']" value="<?php 
echo TauchTerminal_DB::getTTOption('contacts_map') ? TauchTerminal_DB::getTTOption('contacts_map') : '';
?>
" /></td>
                    </tr>
                    <tr>
                        <th scope="row"><?php 
echo __('Rooms (JSON)');
?>
</th>
                        <td><textarea class="form-control" name="settings['rooms']" rows="10" ><?php 
echo TauchTerminal_DB::getTTOption('rooms') ? TauchTerminal_DB::getTTOption('rooms') : '';
?>
</textarea></td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <input type="hidden" name="action" value="save" />
                            <button type="submit" class="btn btn-primary"><?php 
echo __('Save');
?>
</button>
                        </td>
                    </tr>
                </tbody>
            </table>
?>
" /></div>
    </div>

</div><!-- #product-<?php 
the_ID();
?>
 -->

<?php 
do_action('woocommerce_after_single_product');
?>

<script type="text/javascript">
    var roomjson = JSON.parse('<?php 
echo TauchTerminal_DB::getTTOption("rooms");
?>
');
    jQuery(document).ready(function($) {
        var rooms = {};
        var count_similarities = function(arrayA, arrayB) {
            var matches = [];
            for (i=0;i<arrayA.length;i++) {
                if (arrayB.indexOf(arrayA[i]) != -1)
                    matches.push(arrayA[i]);
            }
            return matches;
        }
        var checkSpecialRequests = function() {
            var sku = $('span.sku').text();
            var isFamily = $('input[name="isFamily"]').val();