Plugin Directory

Changeset 3130304


Ignore:
Timestamp:
08/03/2024 09:13:28 AM (18 months ago)
Author:
susheelhbti
Message:

admin section

Location:
saksh-text-to-voice-system/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • saksh-text-to-voice-system/trunk/saksh_admin/saksh_admin_menu.php

    r3129836 r3130304  
    55define( 'PLUGIN_ROLE', 'manage_options' );
    66define( 'PLUGIN_DOMAIN', 'saksh' );
    7 
     7 
    88add_action( 'admin_menu', 'saksh_register_your_plugin_menu', 9 );
    99
     
    1414   
    1515    add_menu_page(
    16         __( 'Appointment Bookings',  'saksh' ),
    17         'Appointment Bookings',
     16        __( 'Appointment',  'saksh' ),
     17        'appointments',
    1818        'manage_options',
    1919        'saksh__booking',
     
    2929    add_submenu_page(
    3030        'saksh__booking',
    31         'Appointment Bookings',
    32         'Appointment Bookings',
     31        'Appointment',
     32        'Appointment',
    3333        'manage_options',
    3434        'saksh__booking',
  • saksh-text-to-voice-system/trunk/saksh_admin/saksh_time_slots_page.php

    r3129836 r3130304  
    11 
    2 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    3 <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    4 <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    5 </head>
    6 <body>
     2 
     3 
     4 <div class="susheelhbti" >
     5     
     6     
     7
    78<div id="app" class="container mt-5">
    89<table-component></table-component>
    910</div>
    10 
     11     
     12 </div>
    1113<script>
    1214
     
    1517var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
    1618
    17 
    18 Vue.component('table-component', {
    19 data: function() {
    20 return {
    21 days: [],
    22 times: {},
    23 ampm:"",id:"",
    24 newStartTime: '',
    25 newEndTime: '',
    26 selectedDay: ''
    27 }
    28 },
    29 created: async function() {
    30 await this.fetchDays();
    31 await this.fetchTimes();
    32 },
    33 methods: {
    34    
    35    
    36    
    37    
    38 async fetchDays() {
    39 try {
    40 const response = await axios.get( ajaxurl+'?action=saksh_time_slots_days');
    41 this.days = response.data;
    42 
    43 
    44 console.log(response.data);
    45 } catch (error) {
    46 console.error('Error fetching days:', error);
    47 }
    48 },
    49 
    50 
    51 
    52 
    53 async fetchTimes() {
    54 for (const day of this.days) {
    55 try {
    56 const response = await axios.post(ajaxurl+'?action=saksh_get_time_slots', { day: day });
    57 this.$set(this.times, day, response.data);
    58 } catch (error) {
    59 console.error(`Error fetching times for ${day}:`, error);
    60 }
    61 }
    62 },
    63 
    64 
    65 isWeekend: function(day) {
    66 return day === 'Saturday' || day === 'Sunday';
    67 },
    68 
    69 
    70 
    71 
    72 
    73 
    74 async addTimeSlot() {
    75 if (this.newStartTime && this.newEndTime && this.selectedDay) {
    76 try {
    77 const response = await axios.post(ajaxurl+'?action=saksh_create_new_time_slot', {
    78 day: this.selectedDay,
    79 startTime: this.newStartTime,
    80 endTime: this.newEndTime
    81 });
    82 if (response.data.success) {
    83 if (!this.times[this.selectedDay]) {
    84 this.$set(this.times, this.selectedDay, []);
    85 }
    86 this.times[this.selectedDay].push({
    87 startTime: this.newStartTime,
    88 endTime: this.newEndTime
    89 });
    90 this.newStartTime = '';
    91 this.newEndTime = '';
    92 this.selectedDay = '';
    93 }
    94 } catch (error) {
    95 console.error('Error adding time slot:', error);
    96 }
    97 }
    98 },
    99 
    100 
    101 
    102 
    103 
    104 
    105 async deleteTimeSlot(day, time) {
    106 try {
    107 const response = await axios.post(ajaxurl+'?action=saksh_delete_time_slot', {
    108  
    109 id: time.id,
    110  
    111 });
    112 
    113 
    114 if (response.data.success) {
    115    
    116    
    117 await this.fetchTimes();
    118 
    119 
    120 const index = this.times[day].indexOftime;
    121 if (index > -1) {
    122 this.times[day].splice(index, 1);
    123 }
    124 
    125 
    126 }
    127 } catch (error) {
    128 console.error('Error deleting time slot:', error);
    129 }
    130 }
    131 },
    132 template: `
    133 <div>
    134 <table class="table table-bordered">
    135 <thead class="thead-dark">
    136 <tr>
    137 <th v-for="day in days">{{ day }}</th>
    138 </tr>
    139 </thead>
    140 <tbody>
    141 <tr v-for="timeIndex in 16">
    142 <td v-for="day in days">
    143 <span v-if="times[day] && times[day][timeIndex]">
    144 {{ times[day][timeIndex].start_time }} - {{ times[day][timeIndex].end_time }} {{ times[day][timeIndex].ampm }} {{ times[day][timeIndex].id }}
    145 <button class="btn btn-danger btn-sm ml-2" @click="deleteTimeSlot(day, times[day][timeIndex])"> <span class="dashicons dashicons-trash"></span></button>
    146 </span>
    147 </td>
    148 </tr>
    149 </tbody>
    150 </table>
    151 <div class="mt-4">
    152 <h3>Add Time Slot</h3>
    153 <div class="form-group">
    154 <select class="form-control" v-model="selectedDay">
    155 <option v-for="day in days" :value="day">{{ day }}</option>
    156 </select>
    157 </div>
    158 <div class="form-group">
    159 <input type="time" class="form-control" v-model="newStartTime">
    160 </div>
    161 <div class="form-group">
    162 <input type="time" class="form-control" v-model="newEndTime">
    163 </div>
    164 
    165 
    166 <div class="form-group">
    167 <select class="form-control" v-model="ampm">
    168 <option value="am">am</option>
    169 <option value="pm">pm</option>
    170 </select>
    171 </div>
    172 
    173 
    174 <button class="btn btn-primary" @click="addTimeSlot">Add</button>
    175 </div>
    176 </div>
    177 `
    178 });
    179 
    180 new Vue({
    181 el: '#app'
    182 });
     19alert(ajaxurl);
    18320</script>
  • saksh-text-to-voice-system/trunk/saksh_appointment.php

    r3129836 r3130304  
    125125    }   
    126126   
    127    
    128  
     127
    129128function saksh_scripts(){
    130129     
     
    216215
    217216
    218 
    219 
    220 
     217function saksh_enqueue_vue_in_admin($hook) {
     218
     219 $pre="appointments_page_";
     220 
     221 
     222 
     223 
     224$allowed_hooks = array( );
     225 
     226 
     227 
     228
     229 $allowed_hooks[]= $pre. "saksh_booking_dashboard";
     230 
     231
     232 $allowed_hooks[]= $pre. "saksh_wb_print_report";
     233 
     234 $allowed_hooks[]= $pre. "saksh_todays_booking";
     235 
     236 $allowed_hooks[]= $pre. "saksh_holidays";
     237 
     238 $allowed_hooks[]= $pre. "saksh_time_slots_page";
     239 
     240 $allowed_hooks[]= $pre. "saksh_plugin_support";
     241 
     242 
     243 
     244if (!in_array($hook, $allowed_hooks)) {
     245return;
     246}
     247 
     248
     249wp_enqueue_script('vue-js', 'https://cdn.jsdelivr.net/npm/vue@2', array(), '', true);
     250
     251
     252wp_enqueue_script('vue-jsaxios', 'https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js', array(), '', true);
     253
     254
     255
     256wp_enqueue_script('saksh_admin', plugin_dir_url(__FILE__) . 'js/saksh_admin.js', array('vue-js','vue-jsaxios'), '1.0', true);
     257
     258
     259}
     260add_action('admin_enqueue_scripts', 'saksh_enqueue_vue_in_admin');
     261
     262   
     263 
    221264
    222265
     
    321364)  ;
    322365
    323 
     366 
    324367CREATE TABLE " . $wpdb->prefix ."time_slots   (
    325368  `id` int(11) NOT NULL AUTO_INCREMENT,
    326   `start` int(10) DEFAULT NULL,
    327   `end` int(10) DEFAULT NULL,
     369  `start_time` int(10) DEFAULT NULL,
     370  `end_time` int(10) DEFAULT NULL,
    328371  `ampm` varchar(4) DEFAULT NULL,
    329372  `slots` varchar(20) NOT NULL,
     
    338381
    339382 
    340 INSERT INTO  " . $wpdb->prefix ."time_slots (`id`, `start`, `end`, `ampm`, `slots`, `day`, `user_id`, `created_at`, `status`) VALUES
     383INSERT INTO  " . $wpdb->prefix ."time_slots (`id`, `start_time`, `end_time`, `ampm`, `slots`, `day`, `user_id`, `created_at`, `status`) VALUES
    341384(4, 12, 1, 'pm', '10', 'Monday', 1, '2023-11-20 20:16:39', 'Pending'),
    342385(5, 1, 2, 'pm', '10', 'Monday', 1, '2023-11-20 20:16:44', 'Pending'),
Note: See TracChangeset for help on using the changeset viewer.