# buttonizer-multifunctional-button/1.0.2/classes/admin/CompanyOpened.php

Buttonizer – Floating Menus, Sticky Buttons, &amp; Popup Builder, version 1.0.2. 116 lines.

- Page: https://pluginprobe.com/plugins/buttonizer-multifunctional-button/1.0.2/code/classes/admin/CompanyOpened.php
- Raw: https://pluginprobe.com/plugins/buttonizer-multifunctional-button/1.0.2/raw/classes/admin/CompanyOpened.php
- Modified: 2017-08-31T08:15:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/buttonizer-multifunctional-button/1.0.2/code/classes/admin/CompanyOpened.php#L10-L20`.

```php
<?php

/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Copyright 2017 Buttonizer
*/
namespace Buttonizer\Admin;

# No script kiddies
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
class CompanyOpened
{
    private  $aSavedData = array() ;
    public function __construct()
    {
        $this->loadData();
        $this->createTable();
    }
    
    private function loadData()
    {
        $this->aSavedData = (array) get_option( 'buttonizer_opening_settings' );
    }
    
    public function createTable()
    {
        echo  '<table class="opening_hours">' ;
        echo  '<thead><td></td><td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>Thursday</td><td>Friday</td><td>Saturday</td><td>Sunday</td></thead>' ;
        echo  '<tbody>' ;
        // Opened
        echo  '<tr>
    				<td><b>Opened from ' . (( ButtonizerLicense()->is__premium_only() ? ( !ButtonizerLicense()->is_plan( 'premium' ) ? '<span class="buttonizer-pro-feature">PRO</span>' : '' ) : '<span class="buttonizer-pro-feature">PRO</span>' )) . '</b></td>
    				<td>' . $this->fieldOpeningTimeSelector( 'monday', false ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'tuesday', false ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'wednesday', false ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'thursday', false ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'friday', false ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'saturday', false ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'sunday', false ) . '</td>
    			</tr>' ;
        // Opened
        echo  '<tr>
    				<td><b>Closing at ' . (( ButtonizerLicense()->is__premium_only() ? ( !ButtonizerLicense()->is_plan( 'premium' ) ? '<span class="buttonizer-pro-feature">PRO</span>' : '' ) : '<span class="buttonizer-pro-feature">PRO</span>' )) . '</b></td>
    				<td>' . $this->fieldOpeningTimeSelector( 'monday', true ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'tuesday', true ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'wednesday', true ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'thursday', true ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'friday', true ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'saturday', true ) . '</td>
    				<td>' . $this->fieldOpeningTimeSelector( 'sunday', true ) . '</td>
    			</tr>' ;
        // Closed today
        echo  '<tr>
    				<td><b>Is it closed today? ' . (( ButtonizerLicense()->is__premium_only() ? ( !ButtonizerLicense()->is_plan( 'premium' ) ? '<span class="buttonizer-pro-feature">PRO</span>' : '' ) : '<span class="buttonizer-pro-feature">PRO</span>' )) . '</b></td>
    				<td>' . $this->fieldClosedToday( 'monday' ) . '</td>
    				<td>' . $this->fieldClosedToday( 'tuesday' ) . '</td>
    				<td>' . $this->fieldClosedToday( 'wednesday' ) . '</td>
    				<td>' . $this->fieldClosedToday( 'thursday' ) . '</td>
    				<td>' . $this->fieldClosedToday( 'friday' ) . '</td>
    				<td>' . $this->fieldClosedToday( 'saturday' ) . '</td>
    				<td>' . $this->fieldClosedToday( 'sunday' ) . '</td>
    			</tr>' ;
        echo  '</tbody>' ;
        echo  '</table>' ;
        echo  '<div class="buttonizer-pro-text"><i class="fa fa-lock"></i> You are missing the fun! When upgrading to <a href="admin.php?page=Buttonizer-pricing">Buttonizer Pro</a> you will unlock opening hours.</div>' ;
    }
    
    public function fieldOpeningTimeManager( $value )
    {
        $sSelectBuilder = '';
        // Get all 24-hours from a day
        for ( $i = 0 ;  $i < 24 ;  $i++ ) {
            // Set a zero before the hours less than 10 hours. (00, 01, 02 ...)
            if ( $i < 10 ) {
                $i = '0' . $i;
            }
            // Get all minutes in this hour
            for ( $j = 0 ;  $j < 60 ;  $j++ ) {
                // Set a zero before the minutes less than 10 minutes. (00, 01, 02 ...)
                if ( $j < 10 ) {
                    $j = '0' . $j;
                }
                // Make a readable string. 00:00, 12:43, 16:16, ...
                $sTime = $i . ':' . $j;
                // Make a query
                $sSelectBuilder .= '<option value=\'' . $sTime . '\'' . (( $value == $sTime ? 'selected="selected"' : '' )) . '>' . $sTime . '</option>';
            }
        }
        return $sSelectBuilder;
    }
    
    public function fieldOpeningTimeSelector( $sDay, $bIsClosedSelector = false )
    {
        $sName = 'buttonizer_' . $sDay . '_' . (( $bIsClosedSelector == false ? 'opened_from' : 'closing_on' ));
        return '<select class="buttonizer-click-to-pro" readonly><option disabled selected>' . (( $bIsClosedSelector == false ? '10:00' : '17:00' )) . '</option></select>';
    }
    
    public function fieldClosedToday( $sDay = 'monday' )
    {
        return '<input type="checkbox" class="buttonizer-click-to-pro" readonly />';
    }

}
```
