<?php

class Ays_Sccp_Data {
    /*
    ==========================================
        Sale Banner | Start
    ==========================================
    */

    public static function ays_sccp_sale_baner(){
        /*if(isset($_POST['ays_sccp_sale_btn_spring'])){
            update_option('ays_sccp_sale_notification_spring', 1); 
            update_option('ays_sccp_sale_date', current_time( 'mysql' ));
        }*/

        if(isset($_POST['ays_sccp_sale_btn'])){
            update_option('ays_sccp_sale_btn', 1);
            update_option('ays_sccp_sale_date', current_time( 'mysql' ));
        }

       /* if(isset($_POST['ays_sccp_sale_btn_spring_for_two_months'])){
            update_option('ays_sccp_sale_dismiss_for_two_month_spring', 1);
            update_option('ays_sccp_sale_date', current_time( 'mysql' ));
        }*/

        if(isset($_POST['ays_sccp_sale_btn_for_two_months'])){
            update_option('ays_sccp_sale_btn_for_two_months', 1);
            update_option('ays_sccp_sale_date', current_time( 'mysql' ));
        }


        $ays_sccp_sale_date = get_option('ays_sccp_sale_date');
        // $ays_sccp_sale_two_months = get_option('ays_sccp_sale_dismiss_for_two_month_spring');
        $ays_sccp_sale_two_months = get_option('ays_sccp_sale_btn_for_two_months');

        $val = 60*60*24*5;
        if($ays_sccp_sale_two_months == 1){
            $val = 60*60*24*61;
        }

        $current_date = current_time( 'mysql' );
        $date_diff = strtotime($current_date) -  intval(strtotime($ays_sccp_sale_date)) ;
        // $val = 60*60*24*5;
        $days_diff = $date_diff / $val;

        if(intval($days_diff) > 0 ){
            // update_option('ays_sccp_sale_notification_spring', 0); 
            // update_option('ays_sccp_sale_dismiss_for_two_month_spring', 0);
            update_option('ays_sccp_sale_btn', 0);
            update_option('ays_sccp_sale_btn_for_two_months', 0);
        }

        // $ays_sccp_ishmar = intval(get_option('ays_sccp_sale_notification_spring'));
        // $ays_sccp_ishmar += intval(get_option('ays_sccp_sale_dismiss_for_two_month_spring'));
        $ays_sccp_ishmar = intval(get_option('ays_sccp_sale_btn'));
        $ays_sccp_ishmar += intval(get_option('ays_sccp_sale_btn_for_two_months'));
        if($ays_sccp_ishmar == 0 ){
            if (isset($_GET['page']) && strpos($_GET['page'], SCCP_NAME) !== false) {
                // self::ays_sccp_spring_bundle_message($ays_sccp_ishmar);
                // self::ays_sccp_helloween_message($ays_sccp_ishmar);
                self::ays_sccp_black_friday_message($ays_sccp_ishmar);
            }
        }
    }    

    public static function ays_sccp_spring_bundle_message($ishmar){
        if($ishmar == 0 ){
            $content = array();         

            $content[] = '<div id="ays-sccp-dicount-month-main" class="notice notice-success is-dismissible ays_sccp_dicount_info">';
                $content[] = '<div id="ays-sccp-dicount-month" class="ays_sccp_dicount_month">';
                    $content[] = '<a href="https://ays-pro.com/spring-bundle" target="_blank" class="ays-sccp-sale-banner-link"><img src="' . SCCP_ADMIN_URL . '/images/spring_bundle_logo_box.png"></a>';

                    $content[] = '<div class="ays-sccp-dicount-wrap-box">';
                        $content[] = '<p>';
                            $content[] = '<strong>';
                                $content[] = __( "Spring is here! <span class='ays-sccp-dicount-wrap-color'>50%</span> SALE on <span><a href='https://ays-pro.com/spring-bundle' target='_blank' class='ays-sccp-dicount-wrap-color ays-sccp-dicount-wrap-text-decoration'>Spring Bundle</a></span><span style='display: block;'>Quiz + Popup + Copy</span>", SCCP_NAME );
                            $content[] = '</strong>';
                        $content[] = '</p>';
                    $content[] = '</div>';

                    $content[] = '<div class="ays-sccp-dicount-wrap-box">';

                        $content[] = '<div id="ays-sccp-countdown-main-container">';

                            $content[] = '<form action="" method="POST" class="ays-sccp-btn-form">';
                                $content[] = '<button class="btn btn-link ays-button" name="ays_sccp_sale_spring_btn" style="height: 32px; margin-left: 0;padding-left: 0">Dismiss ad</button>';
                                $content[] = '<button class="btn btn-link ays-button" name="ays_sccp_sale_spring_btn_for_two_months" style="height: 32px; padding-left: 0">Dismiss ad for 2 months</button>';
                            $content[] = '</form>';

                        $content[] = '</div>';
                            
                    $content[] = '</div>';

                    $content[] = '<a href="https://ays-pro.com/spring-bundle" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank">' . __( 'Buy Now !', SCCP_NAME ) . '</a>';
                $content[] = '</div>';
            $content[] = '</div>';

            $content = implode( '', $content );
            echo $content;
        }
    }

    public static function ays_sccp_sale_message($ishmar){
        if($ishmar == 0 ){
            $content = array();

            $content[] = '<div id="ays-sccp-dicount-month-main" class="notice notice-success is-dismissible ays_sccp_dicount_info">';
                $content[] = '<div id="ays-sccp-dicount-month" class="ays_sccp_dicount_month">';                    
                    $content[] = '<a href="https://ays-pro.com/wordpress/secure-copy-content-protection" target="_blank" class="ays-sccp-sale-banner-link"><img src="' . SCCP_ADMIN_URL . '/images/sccp.png"></a>';
                    $content[] = '<div class="ays-sccp-dicount-wrap-box">';

                        $content[] = '<strong style="font-weight: bold;">';
                            $content[] = __( "Limited Time <span class='ays-sccp-dicount-wrap-color'>20%</span> SALE on <br><span><a href='https://ays-pro.com/wordpress/secure-copy-content-protection' target='_blank' class='ays-sccp-dicount-wrap-color ays-sccp-dicount-wrap-text-decoration' style='display:block;'>Secure Copy Content Protection Premium Versions</a></span>", SCCP_NAME );
                        $content[] = '</strong>';

                        $content[] = '<strong>';
                                $content[] = __( "Hurry up! <a href='https://ays-pro.com/wordpress/secure-copy-content-protection' target='_blank'>Check it out!</a>", SCCP_NAME );
                        $content[] = '</strong>';
                            
                    $content[] = '</div>';

                    $content[] = '<div class="ays-sccp-dicount-wrap-box">';

                        $content[] = '<div id="ays-sccp-countdown-main-container">';
                            $content[] = '<div class="ays-sccp-countdown-container">';

                                $content[] = '<div id="ays-sccp-countdown">';
                                    $content[] = '<ul>';
                                        $content[] = '<li><span id="ays-sccp-countdown-days"></span>days</li>';
                                        $content[] = '<li><span id="ays-sccp-countdown-hours"></span>Hours</li>';
                                        $content[] = '<li><span id="ays-sccp-countdown-minutes"></span>Minutes</li>';
                                        $content[] = '<li><span id="ays-sccp-countdown-seconds"></span>Seconds</li>';
                                    $content[] = '</ul>';
                                $content[] = '</div>';

                                $content[] = '<div id="ays-sccp-countdown-content" class="emoji">';
                                    $content[] = '<span>🚀</span>';
                                    $content[] = '<span>⌛</span>';
                                    $content[] = '<span>🔥</span>';
                                    $content[] = '<span>💣</span>';
                                $content[] = '</div>';

                            $content[] = '</div>';                           

                        $content[] = '</div>';
                            
                    $content[] = '</div>';

                    $content[] = '<div class="ays-sccp-dicount-wrap-box ays-buy-now-button-box">';
                        $content[] = '<a href="https://ays-pro.com/wordpress/secure-copy-content-protection" class="button button-primary ays-buy-now-button" id="ays-button-top-buy-now" target="_blank" style="" >' . __( 'Buy Now !', SCCP_NAME ) . '</a>';
                    $content[] = '</div>';              

                $content[] = '</div>';

                $content[] = '<div style="position: absolute;right: 0;bottom: 1px;" class="ays-sccp-dismiss-buttons-container-for-form">';
                    $content[] = '<form action="" method="POST">';
                        $content[] = '<div id="ays-sccp-dismiss-buttons-content">';                         
                            $content[] = '<button class="btn btn-link ays-button" name="ays_sccp_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0; color: #979797;">Dismiss ad</button>';
                        $content[] = '</div>';
                    $content[] = '</form>';
                $content[] = '</div>';

            $content[] = '</div>';

            $content = implode( '', $content );
            echo $content;
        }
    }

    public static function ays_sccp_helloween_message($ishmar){
        if($ishmar == 0 ){
            $content = array();

            $content[] = '<div id="ays-sccp-dicount-month-main-helloween" class="notice notice-success is-dismissible ays_sccp_dicount_info">';
                $content[] = '<div id="ays-sccp-dicount-month-helloween" class="ays_sccp_dicount_month_helloween">';
                    $content[] = '<div class="ays-sccp-dicount-wrap-box-helloween-limited">';

                        $content[] = '<p>';
                            $content[] = __( "Limited Time 
                            <span class='ays-sccp-dicount-wrap-color-helloween' style='color:#b2ff00;'>50%</span> 
                            <span>
                                SALE on
                            </span> 
                            <br>
                            <span style='' class='ays-sccp-helloween-bundle'>
                                <a href='https://ays-pro.com/halloween-bundle?src=41' target='_blank' class='ays-sccp-dicount-wrap-color-helloween ays-sccp-dicount-wrap-text-decoration-helloween' style='display:block; color:#b2ff00;margin-right:6px;'>
                                    Helloween Bundle
                                </a>
                                (Copy + Poll + Survey + Popup)!
                            </span>", SCCP_NAME );
                        $content[] = '</p>';
                        $content[] = '<p>';
                                $content[] = __( "Hurry up! 
                                                <a href='https://ays-pro.com/halloween-bundle?src=42' target='_blank' style='color:#ffc700;'>
                                                    Check it out!
                                                </a>", SCCP_NAME );
                        $content[] = '</p>';
                            
                    $content[] = '</div>';

                    
                    $content[] = '<div class="ays-sccp-helloween-bundle-buy-now-timer">';
                        $content[] = '<div class="ays-sccp-dicount-wrap-box-helloween-timer">';
                            $content[] = '<div id="ays-sccp-countdown-main-container" class="ays-sccp-countdown-main-container-helloween">';
                                $content[] = '<div class="ays-sccp-countdown-container-helloween">';
                                    $content[] = '<div id="ays-sccp-countdown">';
                                        $content[] = '<ul>';
                                            $content[] = '<li><p><span id="ays-sccp-countdown-days"></span><span>days</span></p></li>';
                                            $content[] = '<li><p><span id="ays-sccp-countdown-hours"></span><span>Hours</span></p></li>';
                                            $content[] = '<li><p><span id="ays-sccp-countdown-minutes"></span><span>Mins</span></p></li>';
                                            $content[] = '<li><p><span id="ays-sccp-countdown-seconds"></span><span>Secs</span></p></li>';
                                        $content[] = '</ul>';
                                    $content[] = '</div>';

                                    $content[] = '<div id="ays-sccp-countdown-content" class="emoji">';
                                        $content[] = '<span>🚀</span>';
                                        $content[] = '<span>⌛</span>';
                                        $content[] = '<span>🔥</span>';
                                        $content[] = '<span>💣</span>';
                                    $content[] = '</div>';

                                $content[] = '</div>';

                            $content[] = '</div>';
                                
                        $content[] = '</div>';
                        $content[] = '<div class="ays-sccp-dicount-wrap-box ays-buy-now-button-box-helloween">';
                            $content[] = '<a href="https://ays-pro.com/halloween-bundle?src=43" class="button button-primary ays-buy-now-button-helloween" id="ays-button-top-buy-now-helloween" target="_blank" style="" >' . __( 'Buy Now !', SCCP_NAME ) . '</a>';
                        $content[] = '</div>';
                    $content[] = '</div>';

                $content[] = '</div>';

                $content[] = '<div style="position: absolute;right: 0;bottom: 1px;"  class="ays-sccp-dismiss-buttons-container-for-form-helloween">';
                    $content[] = '<form action="" method="POST">';
                        $content[] = '<div id="ays-sccp-dismiss-buttons-content-helloween">';
                            $content[] = '<button class="btn btn-link ays-button-helloween" name="ays_sccp_sale_btn" style="">Dismiss ad</button>';
                        $content[] = '</div>';
                    $content[] = '</form>';
                $content[] = '</div>';
                // $content[] = '<button type="button" class="notice-dismiss">';
                // $content[] = '</button>';
            $content[] = '</div>';

            $content = implode( '', $content );

            echo $content;
        }
    }

    // Black Friday
    public static function ays_sccp_black_friday_message($ishmar){
        if($ishmar == 0 ){
            $content = array();

            $content[] = '<div id="ays-sccp-dicount-black-friday-month-main" class="notice notice-success is-dismissible ays_sccp_dicount_info">';
                $content[] = '<div id="ays-sccp-dicount-black-friday-month" class="ays_sccp_dicount_month">';
                    $content[] = '<div class="ays-sccp-dicount-black-friday-box">';
                        $content[] = '<div class="ays-sccp-dicount-black-friday-wrap-box ays-sccp-dicount-black-friday-wrap-box-80" style="width: 70%;">';
                            $content[] = '<div class="ays-sccp-dicount-black-friday-title-row">' . __( 'Limited Time', SCCP_NAME ) .' '. '<a href="https://ays-pro.com/wordpress/secure-copy-content-protection" class="ays-sccp-dicount-black-friday-button-sale" target="_blank">' . __( 'Sale', SCCP_NAME ) . '</a>' . '</div>';
                            $content[] = '<div class="ays-sccp-dicount-black-friday-title-row">' . __( 'Secure Copy Content Protection plugin', SCCP_NAME ) . '</div>';
                        $content[] = '</div>';

                        $content[] = '<div class="ays-sccp-dicount-black-friday-wrap-box ays-sccp-dicount-black-friday-wrap-text-box">';
                            $content[] = '<div class="ays-sccp-dicount-black-friday-text-row">' . __( '20% off', SCCP_NAME ) . '</div>';
                        $content[] = '</div>';

                        $content[] = '<div class="ays-sccp-dicount-black-friday-wrap-box" style="width: 25%;">';
                            $content[] = '<div id="ays-sccp-countdown-main-container">';
                                $content[] = '<div class="ays-sccp-countdown-container">';
                                    $content[] = '<div id="ays-sccp-countdown" style="display: block;">';
                                        $content[] = '<ul>';
                                            $content[] = '<li><span id="ays-sccp-countdown-days">0</span>' . __( 'Days', SCCP_NAME ) . '</li>';
                                            $content[] = '<li><span id="ays-sccp-countdown-hours">0</span>' . __( 'Hours', SCCP_NAME ) . '</li>';
                                            $content[] = '<li><span id="ays-sccp-countdown-minutes">0</span>' . __( 'Minutes', SCCP_NAME ) . '</li>';
                                            $content[] = '<li><span id="ays-sccp-countdown-seconds">0</span>' . __( 'Seconds', SCCP_NAME ) . '</li>';
                                        $content[] = '</ul>';
                                    $content[] = '</div>';
                                    $content[] = '<div id="ays-sccp-countdown-content" class="emoji" style="display: none;">';
                                        $content[] = '<span>🚀</span>';
                                        $content[] = '<span>⌛</span>';
                                        $content[] = '<span>🔥</span>';
                                        $content[] = '<span>💣</span>';
                                    $content[] = '</div>';
                                $content[] = '</div>';
                            $content[] = '</div>';
                        $content[] = '</div>';

                        $content[] = '<div class="ays-sccp-dicount-black-friday-wrap-box" style="width: 25%;">';
                            $content[] = '<a href="https://ays-pro.com/wordpress/secure-copy-content-protection" class="ays-sccp-dicount-black-friday-button-buy-now" target="_blank">' . __( 'Get Your Deal', SCCP_NAME ) . '</a>';
                        $content[] = '</div>';
                    $content[] = '</div>';
                $content[] = '</div>';

                $content[] = '<div style="position: absolute;right: 0;bottom: 1px;"  class="ays-sccp-dismiss-buttons-container-for-form-black-friday">';
                    $content[] = '<form action="" method="POST">';
                        $content[] = '<div id="ays-sccp-dismiss-buttons-content-black-friday">';
                            $content[] = '<button class="btn btn-link ays-button-black-friday" name="ays_sccp_sale_btn" style="">' . __( 'Dismiss ad', SCCP_NAME ) . '</button>';
                        $content[] = '</div>';
                    $content[] = '</form>';
                $content[] = '</div>'; 
            $content[] = '</div>';

            $content = implode( '', $content );

            echo $content;
        }
    }

    /*
    ==========================================
        Sale Banner | End
    ==========================================
    */
}
