css
1 year ago
img
1 year ago
js
1 year ago
partials
1 year ago
class-adv-order-filter.php
1 year ago
class-order-tip-promotion.php
1 year ago
class-pi-dtt-labels.php
1 year ago
class-pi-dtt-order-table.php
1 year ago
conflict-fixer.php
1 year ago
menu.php
1 year ago
options-addons.php
1 year ago
options-date.php
1 year ago
options-limit.php
1 year ago
options-pickup.php
1 year ago
options-time-slot.php
1 year ago
options-time.php
1 year ago
options.php
1 year ago
options-date.php
147 lines
| 1 | <?php |
| 2 | |
| 3 | class pisol_dtt_option_date{ |
| 4 | |
| 5 | private $settings = array(); |
| 6 | |
| 7 | private $active_tab; |
| 8 | |
| 9 | private $this_tab = 'date'; |
| 10 | |
| 11 | private $tab_name = "Date setting"; |
| 12 | |
| 13 | private $setting_key = 'pisol_dtt_date'; |
| 14 | |
| 15 | public $tab; |
| 16 | |
| 17 | function __construct(){ |
| 18 | |
| 19 | $this->tab = sanitize_text_field(filter_input( INPUT_GET, 'tab')); |
| 20 | $this->active_tab = $this->tab != "" ? $this->tab : 'default'; |
| 21 | |
| 22 | $this->settings = array( |
| 23 | array('field'=>'pi_delivery_days', 'label'=>__('We do delivery on this days','pisol-dtt'),'desc'=>__('If you deliver on all days then don\'t select any thing, if you do on specific days then select those days','pisol-dtt'), 'type'=>'multiselect', 'required'=>'required', 'multiple'=>'multiple', 'value'=>array('0'=>__('Sunday','pisol-dtt'), '1'=>__('Monday','pisol-dtt'), '2'=>__('Tuesday','pisol-dtt'), '3'=>__('Wednesday','pisol-dtt'), '4'=>__('Thursday','pisol-dtt'), '5'=>__('Friday','pisol-dtt'), '6'=>__('Saturday','pisol-dtt') )), |
| 24 | |
| 25 | array('field'=>'pi_pickup_days', 'label'=>__('We do pickup on this days','pisol-dtt'), 'desc'=>__('If you pickup on all days then dont select any thing, if you do on specific days then select those days','pisol-dtt'), 'type'=>'multiselect', 'required'=>'required', 'multiple'=>'multiple', 'value'=>array('0'=>__('Sunday','pisol-dtt'), '1'=>__('Monday','pisol-dtt'), '2'=>__('Tuesday','pisol-dtt'), '3'=>__('Wednesday','pisol-dtt'), '4'=>__('Thursday','pisol-dtt'), '5'=>__('Friday','pisol-dtt'), '6'=>__('Saturday','pisol-dtt') )), |
| 26 | |
| 27 | array('field'=>'pisol_dtt_pickup_dd', 'sanitize_callback' => 'sanitize_text_field'), |
| 28 | |
| 29 | array('field'=>'pisol_dtt_delivery_dd', 'sanitize_callback' => 'sanitize_text_field'), |
| 30 | |
| 31 | ); |
| 32 | delete_option('pi_dtt_remove_billing_when_pickup-pro'); delete_option('pi_dtt_remove_billing_when_delivery-pro'); |
| 33 | |
| 34 | if($this->this_tab == $this->active_tab){ |
| 35 | add_action('pisol_dtt_tab_content', array($this,'tab_content')); |
| 36 | } |
| 37 | |
| 38 | add_action('pisol_dtt_tab', array($this,'tab'),4); |
| 39 | |
| 40 | add_action('pickup_disabled_date', array($this, 'pickup_disabled_date')); |
| 41 | add_action('delivery_disabled_date', array($this, 'delivery_disabled_date')); |
| 42 | |
| 43 | $this->register_settings(); |
| 44 | |
| 45 | if(PISOL_DTT_FREE_RESET_SETTING){ |
| 46 | $this->delete_settings(); |
| 47 | } |
| 48 | |
| 49 | } |
| 50 | |
| 51 | function delete_settings(){ |
| 52 | foreach($this->settings as $setting){ |
| 53 | delete_option( $setting['field'] ); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | function register_settings(){ |
| 58 | |
| 59 | foreach($this->settings as $setting){ |
| 60 | pisol_class_form::register_setting( $this->setting_key, $setting); |
| 61 | } |
| 62 | |
| 63 | } |
| 64 | |
| 65 | function tab(){ |
| 66 | $page = sanitize_text_field(filter_input( INPUT_GET, 'page')); |
| 67 | $this->tab_name = __('Date setting', 'pisol-dtt'); |
| 68 | ?> |
| 69 | <a class=" pi-side-menu <?php echo ($this->active_tab == $this->this_tab ? 'bg-primary' : 'bg-secondary'); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page='.$page.'&tab='.$this->this_tab ) ); ?>"> |
| 70 | <span class="dashicons dashicons-calendar-alt"></span> <?php echo esc_html($this->tab_name); ?> |
| 71 | </a> |
| 72 | <?php |
| 73 | } |
| 74 | |
| 75 | function tab_content(){ |
| 76 | ?> |
| 77 | <form method="post" action="options.php" class="pisol-setting-form"> |
| 78 | <?php settings_fields( $this->setting_key ); ?> |
| 79 | <?php |
| 80 | foreach($this->settings as $setting){ |
| 81 | new pisol_class_form($setting, $this->setting_key); |
| 82 | } |
| 83 | ?> |
| 84 | <?php do_action('pickup_disabled_date'); ?> |
| 85 | <?php do_action('delivery_disabled_date'); ?> |
| 86 | <input type="submit" name="submit" id="submit" class="btn btn-primary btn-lg my-3" value="<?php esc_attr_e('Save Changes','pisol-dtt'); ?>"> |
| 87 | </form> |
| 88 | <div class="free-version"> |
| 89 | <img src="<?php echo esc_url( plugin_dir_url(__FILE__) ); ?>img/special-date.png" class="img-fluid"> |
| 90 | </div> |
| 91 | <?php |
| 92 | } |
| 93 | |
| 94 | function pickup_disabled_date(){ |
| 95 | $dates = get_option('pisol_dtt_pickup_dd'); |
| 96 | //print_r($dates); |
| 97 | ?> |
| 98 | <hr> |
| 99 | <h2><?php esc_html_e('Disable PICKUP on this dates','pisol-dtt'); ?></h2> |
| 100 | <div class='notice-info notice'> |
| 101 | <p> |
| 102 | <strong>BUY PRO</strong> version for <strong><?php echo esc_html( PISOL_DTT_PRICE ); ?></strong> and set holidays for complete year at once, as it allow unlimited date selection at once <a href="<?php echo esc_url( PISOL_DTT_BUY_URL ); ?>" target="_blank">BUY NOW</a> |
| 103 | </p> |
| 104 | </div> |
| 105 | <?php for($x= 0; $x <= 4; $x++){ ?> |
| 106 | <div class="pisol_grid"> |
| 107 | <div> |
| 108 | <label for="pi_delivery_days">Disable pickup on:</label><br> |
| 109 | </div> |
| 110 | <input type="text" name="pisol_dtt_pickup_dd[]" class="pisol-date-picker" readonly value="<?php echo esc_attr( (isset($dates[$x])? $dates[$x] : '') ); ?>"> |
| 111 | </div> |
| 112 | <?php } ?> |
| 113 | <p> |
| 114 | <a class="btn btn-secondary btn-sm" href="javascript:void(0);"><span class="dashicons dashicons-plus-alt pi-icon"></span> Add More Dates</a> (Only for PRO version <a href="<?php echo esc_url( PISOL_DTT_BUY_URL ); ?>" target="_blank">BUY NOW</a> ) |
| 115 | </p> |
| 116 | <?php |
| 117 | } |
| 118 | |
| 119 | function delivery_disabled_date(){ |
| 120 | $dates = get_option('pisol_dtt_delivery_dd'); |
| 121 | //print_r($dates); |
| 122 | ?> |
| 123 | <hr> |
| 124 | <h2><?php echo esc_html_e('Disable DELIVERY on this dates','pisol-dtt'); ?></h2> |
| 125 | <?php for($x= 0; $x <= 4; $x++){ ?> |
| 126 | <div class="pisol_grid"> |
| 127 | <div> |
| 128 | <label for="pi_delivery_days">Disable delivery on:</label><br> |
| 129 | </div> |
| 130 | <input type="text" name="pisol_dtt_delivery_dd[]" class="pisol-date-picker" readonly value="<?php echo esc_attr( (isset($dates[$x])? $dates[$x] : '') ); ?>"> |
| 131 | </div> |
| 132 | <?php } ?> |
| 133 | <p> |
| 134 | <a class="btn btn-secondary btn-sm" href="javascript:void(0);"><span class="dashicons dashicons-plus-alt pi-icon"></span> Add More Dates</a> (Only for PRO version <a href="<?php echo esc_url( PISOL_DTT_BUY_URL ); ?>" target="_blank">BUY NOW</a> ) |
| 135 | </p> |
| 136 | <?php |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | add_action('init', function(){ |
| 141 | /* if we have pro version setting for time tab then we can disable this */ |
| 142 | new pisol_dtt_option_date(); |
| 143 | }); |
| 144 | |
| 145 | |
| 146 | |
| 147 |