| 1 |
<?php |
| 2 |
if (!defined( 'ABSPATH' ) )exit('No Such File'); |
| 3 |
wpsp_header(); |
| 4 |
if( is_user_logged_in() ) { |
| 5 |
global $current_user, $wpdb,$wpsp_settings_data; |
| 6 |
$notify_table = $wpdb->prefix . "wpsp_notification"; |
| 7 |
$status = $ins = 0; |
| 8 |
$notify_type_name='SMS'; |
| 9 |
$current_user_role=$current_user->roles[0]; |
| 10 |
if($current_user_role=='teacher') { |
| 11 |
$receiverTypeList = array( 'all' => __( 'All Users', 'wpschoolpress' ), |
| 12 |
'allt' => __( 'All Teachers', 'wpschoolpress' ), |
| 13 |
'alls' => __( 'All Students', 'wpschoolpress'), |
| 14 |
'allp' => __( 'All Parents', 'wpschoolpress') |
| 15 |
); |
| 16 |
} else { |
| 17 |
$receiverTypeList = array( 'all' => __( 'All Users', 'wpschoolpress' ), |
| 18 |
'alls' => __( 'All Students', 'wpschoolpress'), |
| 19 |
'allp' => __( 'All Parents', 'wpschoolpress'), |
| 20 |
'allt' => __( 'All Teachers', 'wpschoolpress' ) ); |
| 21 |
} |
| 22 |
$notifyTypeList = array( 0 => __( 'All', 'wpschoolpress') , |
| 23 |
1 => __( 'Email', 'wpschoolpress'), |
| 24 |
// 2 => __( 'SMS', 'wpschoolpress'), |
| 25 |
2 => (apply_filters("notify_type_name", $notify_type_name)), |
| 26 |
3 => __( 'Web Notification', 'wpschoolpress'), |
| 27 |
4 => __( 'Push Notification (Android & IOS)', 'wpschoolpress') ); |
| 28 |
//to send notifications |
| 29 |
$student_table = $wpdb->prefix.'wpsp_student'; |
| 30 |
$teacher_table = $wpdb->prefix.'wpsp_teacher'; |
| 31 |
$users_table = $wpdb->prefix.'users '; |
| 32 |
$whereQuery1 = 'where ut.ID = st.parent_wp_usr_id AND ut.user_email!=""'; |
| 33 |
$whereQuery = 'where ut.ID = st.wp_usr_id AND ut.user_email!=""'; |
| 34 |
$student_ids1 = $wpdb->get_results( "select * from $student_table st, $users_table ut $whereQuery",ARRAY_A ); |
| 35 |
$teacher_ids1 = $wpdb->get_results( "select * from $teacher_table st, $users_table ut $whereQuery", ARRAY_A ); |
| 36 |
$parent_ids1 = $wpdb->get_results( "select * from $student_table st, $users_table ut $whereQuery1", ARRAY_A ); |
| 37 |
$usersList1 = array_merge( $student_ids1,$teacher_ids1); |
| 38 |
$current_user_role=$current_user->roles[0]; |
| 39 |
wpsp_topbar(); |
| 40 |
wpsp_sidebar(); |
| 41 |
wpsp_body_start(); |
| 42 |
$addUrl = add_query_arg( 'ac', 'add', get_permalink()); |
| 43 |
if($current_user_role=='administrator' || $current_user_role=='teacher') { ?> |
| 44 |
<?php |
| 45 |
if($ins) { ?> |
| 46 |
<div class="wpsp-popupMain wpsp-popVisible" id="SuccessModal" style="display:block;"> |
| 47 |
<div class="wpsp-overlayer"></div> |
| 48 |
<div class="wpsp-popBody wpsp-alert-body"> |
| 49 |
<div class="wpsp-popInner"> |
| 50 |
<a href="javascript:;" class="wpsp-closePopup"></a> |
| 51 |
<div class="wpsp-popup-cont wpsp-alertbox wpsp-alert-success"> |
| 52 |
<div class="wpsp-alert-icon-box"> |
| 53 |
<i class="icon dashicons dashicons-yes"></i> |
| 54 |
</div> |
| 55 |
<div class="wpsp-alert-data"> |
| 56 |
<input type="hidden" name="teacherid" id="teacherid"> |
| 57 |
<h4><?php esc_html_e( 'Success', 'wpschoolpress' );?></h4> |
| 58 |
<p><?php esc_html_e( 'Notification Successfully Send!', 'wpschoolpress' );?></p> |
| 59 |
</div> |
| 60 |
</div> |
| 61 |
</div> |
| 62 |
</div> |
| 63 |
</div> |
| 64 |
<?php } ?> |
| 65 |
<?php if( isset($_GET['ac']) && sanitize_text_field($_GET['ac'])=='add' ) { ?> |
| 66 |
<div class="wpsp-card"> |
| 67 |
<div class="wpsp-card-head"> |
| 68 |
<h3 class="wpsp-card-title"><?php echo esc_html(apply_filters('wpsp_add_notify_heading_item',"Notification :"),"wpschoolpress"); ?> </h3> |
| 69 |
</div> |
| 70 |
<div class="wpsp-card-body"> |
| 71 |
<form method="post" class="form-horizontal" id="NotifyEntryForm" enctype="multipart/form-data"> |
| 72 |
<?php wp_nonce_field( 'WPSAddNotifica', 'wps_addnoti_nonce', '', true ); ?> |
| 73 |
<input type="hidden" id="wpsp_locationginal" value="<?php echo esc_url(admin_url());?>"/> |
| 74 |
<div class="wpsp-row"> |
| 75 |
<?php do_action('wpsp_before_notification'); |
| 76 |
$item = apply_filters('wpsp_add_event_popup_title_item',array()); |
| 77 |
?> |
| 78 |
<div class="wpsp-col-md-4"> |
| 79 |
<div class="wpsp-form-group"> |
| 80 |
<label class="wpsp-label"><?php esc_html_e("Name","wpschoolpress"); |
| 81 |
?><span class="wpsp-required"> *</span></label> |
| 82 |
<input type="text" name="subject" class="wpsp-form-control"> |
| 83 |
</div> |
| 84 |
</div> |
| 85 |
<div class="wpsp-col-md-4"> |
| 86 |
<div class="wpsp-form-group"> |
| 87 |
<label class="wpsp-label"><?php esc_html_e("Receiver","wpschoolpress"); ?><span class="wpsp-required"> *</span></label> |
| 88 |
<select class="selectpicker wpsp-form-control" data-icon-base="fa" data-tick-icon="fa-check" id="" name="receiver[]" multiple data-live-search="true"> |
| 89 |
<option value="all"><?php esc_html_e( 'All Users', 'wpschoolpress' );?></option> |
| 90 |
<option value="alls"><?php esc_html_e( 'All Students', 'wpschoolpress' );?></option> |
| 91 |
<option value="<?php echo 'allp'?>"><?php esc_html_e( 'All Parents', 'wpschoolpress' );?></option> |
| 92 |
<option value="<?php echo 'allt'?>"><?php esc_html_e( 'All Teachers', 'wpschoolpress' );?></option> |
| 93 |
<?php foreach($usersList1 as $usersList1details){?> |
| 94 |
<option value="<?php echo esc_attr($usersList1details['wp_usr_id']);?>"><?php if(!empty($usersList1details['s_fname']) && !empty($usersList1details['s_lname'])){echo esc_html($usersList1details['s_fname']." ".$usersList1details['s_lname']);} if(!empty($usersList1details['first_name']) && !empty($usersList1details['last_name'])){ |
| 95 |
echo esc_html($usersList1details['first_name']." ".$usersList1details['last_name']);}?></option> |
| 96 |
<?php } if(!empty($parent_ids1)){ |
| 97 |
foreach($parent_ids1 as $parent_idsdata){ |
| 98 |
?> |
| 99 |
<option value="<?php echo esc_attr($parent_idsdata['parent_wp_usr_id']);?>"><?php echo esc_html($parent_idsdata['p_fname']." ".$parent_idsdata['p_lname']); |
| 100 |
?></option> |
| 101 |
<?php } } ?> |
| 102 |
</select> |
| 103 |
<!-- <select name="receiver" class="wpsp-form-control"> |
| 104 |
<option value=""><?php esc_html_e( 'Whom to notify?', 'wpschoolpress'); ?></option> |
| 105 |
<?php |
| 106 |
foreach( $receiverTypeList as $key => $value ) { |
| 107 |
echo '<option value="'.esc_attr($key).'">'.esc_html($value).'</option>'; |
| 108 |
} |
| 109 |
?> |
| 110 |
</select> --> |
| 111 |
</div> |
| 112 |
</div> |
| 113 |
<div class="wpsp-col-md-4"> |
| 114 |
<div class="wpsp-form-group"> |
| 115 |
<label class="wpsp-label"><?php esc_html_e("Notify Type","wpschoolpress"); ?><span class="wpsp-required"> *</span></label> |
| 116 |
<?php $proversion = wpsp_check_pro_version('wpsp_sms_version'); |
| 117 |
$proclass = !$proversion['status'] && isset( $proversion['class'] )? $proversion['class'] : ''; |
| 118 |
$protitle = !$proversion['status'] && isset( $proversion['message'] )? $proversion['message'] : ''; |
| 119 |
$prodisable = !$proversion['status'] ? 'disabled="disabled"' : ''; |
| 120 |
?> |
| 121 |
<select name="type" class="wpsp-form-control"> |
| 122 |
<option value=""><?php esc_html_e( 'How to notify?', 'wpschoolpress'); ?></option> |
| 123 |
<option value="1"><?php esc_html_e( 'Email', 'wpschoolpress'); ?></option> |
| 124 |
<option value="2" title="<?php echo esc_attr($protitle); ?>" class="<?php echo esc_attr($proclass); ?>" |
| 125 |
<?php $notify_type_name = "SMS"; if( !empty( $prodisable ) ) {?> disabled <?php } ?>> |
| 126 |
<?php echo esc_html(apply_filters("notify_type_name", $notify_type_name)); ?> |
| 127 |
</option> |
| 128 |
<option value="0"><?php esc_html_e( 'All', 'wpschoolpress'); ?></option> |
| 129 |
</select> |
| 130 |
<?php |
| 131 |
if( !isset( $wpsp_settings_data['notification_sms_alert'] ) || ( isset( $wpsp_settings_data['notification_sms_alert'] ) && $wpsp_settings_data['notification_sms_alert'] != 1 ) ) { |
| 132 |
echo '<p style="margin-top:6px;"> |
| 133 |
<img src="'.esc_url(plugins_url( '/img/svg/info-icon.svg', dirname(__FILE__) )).'" width="12" height="12" /> Enable SMS Notification Option from setting page to send SMS</p>'; |
| 134 |
} |
| 135 |
?> |
| 136 |
</div> |
| 137 |
</div> |
| 138 |
</div> |
| 139 |
<div class="wpsp-row"> |
| 140 |
<div class="wpsp-col-md-12"> |
| 141 |
<div class="wpsp-form-group"> |
| 142 |
<label class="wpsp-label"><?php esc_html_e("Description","wpschoolpress"); ?><span class="wpsp-required"> *</span></label> |
| 143 |
<textarea class="wpsp-form-control" name="description" required></textarea> |
| 144 |
</div> |
| 145 |
</div> |
| 146 |
</div> |
| 147 |
<?php do_action('wpsp_after_notification'); ?> |
| 148 |
<div class="wpsp-form-group"> |
| 149 |
<div class="wpsp-row"> |
| 150 |
<div class="wpsp-col-md-12"> |
| 151 |
<!-- <input type="submit" class="wpsp-btn wpsp-btn-success" name="notifySubmit" value="Notify" id="notifySubmit"> --> |
| 152 |
<button type="submit" class="wpsp-btn wpsp-btn-success" name="" value="Notify" id="notifySubmit">Submit</button> |
| 153 |
<a href="<?php echo esc_url(wpsp_admin_url().'sch-notify');?>" class="wpsp-btn wpsp-dark-btn"><?php esc_html_e( 'Back', 'wpschoolpress' ); ?></a> |
| 154 |
</div> |
| 155 |
</div> |
| 156 |
</div> |
| 157 |
</form> |
| 158 |
</div> |
| 159 |
</div> |
| 160 |
<?php } else { ?> |
| 161 |
<div class="wpsp-card"> |
| 162 |
<div class="wpsp-card-body"> |
| 163 |
<table id="notify_table" class="wpsp-table" cellspacing="0" width="100%" style="width:100%"> |
| 164 |
<thead> |
| 165 |
<tr> |
| 166 |
<th class="nosort">#</th> |
| 167 |
<th><?php esc_html_e( 'Name', 'wpschoolpress' ); ?></th> |
| 168 |
<th><?php esc_html_e( 'Description', 'wpschoolpress' );?></th> |
| 169 |
<!-- <th><?php esc_html_e( 'Receiver', 'wpschoolpress' ); ?></th> --> |
| 170 |
<th><?php esc_html_e( 'Type', 'wpschoolpress' ); ?></th> |
| 171 |
<th><?php esc_html_e( 'Date', 'wpschoolpress'); ?></th> |
| 172 |
<th class="nosort" align="center"><?php esc_html_e( 'Action', 'wpschoolpress'); ?></th> |
| 173 |
</tr> |
| 174 |
</thead> |
| 175 |
<tbody> |
| 176 |
<?php |
| 177 |
//Last added will me shown first |
| 178 |
$notifyInfo = $wpdb->get_results("Select * from $notify_table order by nid desc"); |
| 179 |
foreach( $notifyInfo as $key=>$value ) { |
| 180 |
$receiver = isset( $receiverTypeList[$value->receiver] ) ? $receiverTypeList[$value->receiver] : $value->receiver; |
| 181 |
$type = isset( $notifyTypeList[$value->type] ) ? $notifyTypeList[$value->type] : $value->type; |
| 182 |
echo '<tr> |
| 183 |
<td>'.esc_html($key+1).'</td> |
| 184 |
<td>'.esc_html($value->name).'</td> |
| 185 |
<td>'.esc_html(substr( $value->description, 0, 20)).'</td> |
| 186 |
<td>'.esc_html($type).'</td> |
| 187 |
<td>'.esc_html(wpsp_ViewDate( $value->date) ).'</td> |
| 188 |
<td align="center"> |
| 189 |
<div class="wpsp-action-col"> |
| 190 |
<a href="javascript:;" class="wpsp-popclick notify-view" data-id="'.esc_attr(intval($value->nid)).'" data-pop="ViewModal"><i class="icon wpsp-view wpsp-view-icon"></i></a> |
| 191 |
<a href="javascript:;" class="wpsp-popclick notify-Delete" data-id="'.esc_attr(intval($value->nid)).'" > |
| 192 |
<i class="icon wpsp-trash wpsp-delete-icon notify-Delete" ></i> |
| 193 |
</a> |
| 194 |
</div> |
| 195 |
</td> |
| 196 |
</tr>'; |
| 197 |
} |
| 198 |
?> |
| 199 |
</tbody> |
| 200 |
<tfoot> |
| 201 |
<tr> |
| 202 |
<th class="nosort">#</th> |
| 203 |
<th><?php esc_html_e( 'Name', 'wpschoolpress' ); ?></th> |
| 204 |
<th><?php esc_html_e( 'Description', 'wpschoolpress' );?></th> |
| 205 |
<!-- <th><?php esc_html_e( 'Receiver', 'wpschoolpress' ); ?></th> --> |
| 206 |
<th><?php esc_html_e( 'Type', 'wpschoolpress' ); ?></th> |
| 207 |
<th><?php esc_html_e( 'Date', 'wpschoolpress'); ?></th> |
| 208 |
<th class="nosort"><?php esc_html_e( 'Action', 'wpschoolpress'); ?></th> |
| 209 |
</tr> |
| 210 |
</tfoot> |
| 211 |
</table> |
| 212 |
</div> |
| 213 |
</div> |
| 214 |
<div class="wpsp-popupMain" id="ViewModal"> |
| 215 |
<div class="wpsp-overlayer"></div> |
| 216 |
<div class="wpsp-popBody"> |
| 217 |
<div class="wpsp-popInner"> |
| 218 |
<a href="javascript:;" class="wpsp-closePopup"></a> |
| 219 |
<div id="ViewModalContent" class="wpsp-text-left"></div> |
| 220 |
</div> |
| 221 |
</div> |
| 222 |
</div> |
| 223 |
<?php } |
| 224 |
} |
| 225 |
else if($current_user_role=='parent' || $current_user_role='student') |
| 226 |
{ |
| 227 |
} |
| 228 |
wpsp_body_end(); |
| 229 |
wpsp_footer(); |
| 230 |
} |
| 231 |
else{ |
| 232 |
include_once( WPSP_PLUGIN_PATH.'/includes/wpsp-login.php'); |
| 233 |
} |
| 234 |
?> |
| 235 |
|