'appointment', //singular name of the listed records 'plural' => 'appointments', //plural name of the listed records ) ); } function get_columns() { $columnNames = array( 'cb' => '', 'personName' => 'Patient Name', 'appointmentDate' => 'Appointment Date', 'slotTimeDesc' => 'Time Slot', 'serviceName' => 'Services', 'personEmailId' => 'Email Id', 'personMobileNo' => 'Contact Number', 'remarks' => 'Remarks', 'isDeleted' => 'Delete' ); return $columnNames; } function column_default( $item, $column_name ) { switch( $column_name ) { case 'personName': case 'appointmentDate': case 'slotTimeDesc': case 'serviceName': case 'personEmailId': case 'personMobileNo': case 'remarks': return $item[ $column_name ]; default: return print_r( $item, true ) ; } } function column_cb($item) { return sprintf( '',$item['appointmentId']); } function column_isDeleted($item) { $actions = array( 'delete' => sprintf('%s', $_REQUEST['page'], $item['appointmentId'], __('Delete')), ); return $this->row_actions($actions, true); } function get_bulk_actions() { $actions = array( 'delete' => 'Delete' ); return $actions; } function process_bulk_action() { global $wpdb; $abAppointmentMst = $wpdb->prefix . "abAppointmentMst"; if ('delete' === $this->current_action()) { $ids = isset($_REQUEST['appointmentId']) ? $_REQUEST['appointmentId'] : array(); if (is_array($ids)) $ids = implode(',', $ids); if (!empty($ids)) { $deleteResult = $wpdb->query("UPDATE ".$abAppointmentMst." SET isDeleted=1 WHERE appointmentId IN(".$ids.")"); $plugins_url = admin_url().'admin.php?page=view-booked-appointment-list'; if($deleteResult) { echo ""; } unset($deleteResult); } } } function get_sortable_columns() { $sortColumn = array( 'appointmentDate' => array('appointmentDate', true), 'personName' => array('personName', true) ); return $sortColumn; } function prepare_items() { global $wpdb; $perPage = 10; $currentPage = $this->get_pagenum(); $abAppointmentMst = $wpdb->prefix . "abAppointmentMst"; $abTimeSlotMst = $wpdb->prefix . "abTimeSlotMst"; $abSlotMappingDetails = $wpdb->prefix . "abSlotMappingDetails"; $abServiceMst = $wpdb->prefix . "abServiceMst"; $totalItems = $wpdb->get_var("SELECT COUNT(appointmentId) FROM ".$abAppointmentMst." WHERE isDeleted=0"); $columns = $this->get_columns(); $hidden = array(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array($columns, $hidden, $sortable); $this->process_bulk_action(); $orderby = (isset($_REQUEST['orderby']) && in_array($_REQUEST['orderby'], array_keys($sortable))) ? $_REQUEST['orderby'] : 'appointmentDate'; $order = (isset($_REQUEST['order']) && in_array($_REQUEST['order'], array('asc', 'desc'))) ? $_REQUEST['order'] : 'desc'; $appointmentDatas = $wpdb->get_results("SELECT ap.isDeleted, ap.appointmentId, ap.personName, DATE_FORMAT(ap.appointmentDate,'%d-%m-%Y') as appointmentDate, tr.serviceName, ts.slotName, concat(DATE_FORMAT(ts.slotStartTime, '%H:%i'), ' - ', DATE_FORMAT(ts.slotEndTime, '%H:%i')) as slotTimeDesc, ap.appointmentSlotMappingId, ap.personEmailId, ap.personMobileNo, ap.remarks FROM ".$abAppointmentMst." ap INNER JOIN ".$abServiceMst." tr ON ap.serviceId = tr.serviceId INNER JOIN ".$abSlotMappingDetails." smd ON ap.appointmentSlotMappingId = smd.slotMappingId INNER JOIN ".$abTimeSlotMst." ts ON smd.slotId = ts.slotId WHERE ap.isDeleted=0 ORDER BY ap.".$orderby." ".$order."", ARRAY_A); $appointmentDataValues = array_slice($appointmentDatas,(($currentPage-1)*$perPage),$perPage); $this->set_pagination_args(array( 'total_items' => $totalItems, // total items defined above 'per_page' => $perPage, // per page constant defined at top of method 'total_pages' => ceil($totalItems / $perPage) // calculate pages count )); $this->items = $appointmentDataValues; } } $myAppointmentTable = new Appointment_List_Table(); $myAppointmentTable->prepare_items(); ?>