upload to Notifications
Signed-off-by: Jeff <jeff@gotenzing.com>
Showing
2 changed files
with
43 additions
and
1 deletions
| ... | @@ -523,6 +523,9 @@ function create_notification() | ... | @@ -523,6 +523,9 @@ function create_notification() |
| 523 | update_post_meta($id, 'style', $style); | 523 | update_post_meta($id, 'style', $style); |
| 524 | update_post_meta($id, 'system', $systemMessageData); | 524 | update_post_meta($id, 'system', $systemMessageData); |
| 525 | update_post_meta($id, 'push', $pushMessageData); | 525 | update_post_meta($id, 'push', $pushMessageData); |
| 526 | if(!empty($_POST['report_ids'])){ | ||
| 527 | update_post_meta($id, 'report_ids', $_POST['report_ids']); | ||
| 528 | } | ||
| 526 | 529 | ||
| 527 | $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; | 530 | $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; |
| 528 | require_once __DIR__ . '/views/create.php'; | 531 | require_once __DIR__ . '/views/create.php'; | ... | ... |
| ... | @@ -121,7 +121,7 @@ $event_newsletterFr = get_post($event_newsletterFrId); | ... | @@ -121,7 +121,7 @@ $event_newsletterFr = get_post($event_newsletterFrId); |
| 121 | <tr class="scheduled_sendto"> | 121 | <tr class="scheduled_sendto"> |
| 122 | <td>Sent To:</td> | 122 | <td>Sent To:</td> |
| 123 | <td> | 123 | <td> |
| 124 | <select name="sendto" class="wide-input-field"> | 124 | <select id="sendto" name="sendto" class="wide-input-field"> |
| 125 | <option value="nousers" <?php echo ($validation->set_value('sendto') == "nousers") | 125 | <option value="nousers" <?php echo ($validation->set_value('sendto') == "nousers") |
| 126 | ? 'selected="selected"' : ""; ?>>No Users | 126 | ? 'selected="selected"' : ""; ?>>No Users |
| 127 | </option> | 127 | </option> |
| ... | @@ -137,9 +137,17 @@ $event_newsletterFr = get_post($event_newsletterFrId); | ... | @@ -137,9 +137,17 @@ $event_newsletterFr = get_post($event_newsletterFrId); |
| 137 | ) == $group->getID()) ? 'selected="selected"' | 137 | ) == $group->getID()) ? 'selected="selected"' |
| 138 | : ""; ?>><?php echo $group->getName(); ?></option> | 138 | : ""; ?>><?php echo $group->getName(); ?></option> |
| 139 | <?php };?> | 139 | <?php };?> |
| 140 | <option value="uploadlist" <?php echo ($validation->set_value('sendto') == "uploadlist") | ||
| 141 | ? 'selected="selected"' : ""; ?>>Upload List by CSV | ||
| 142 | </option> | ||
| 140 | </optgroup> | 143 | </optgroup> |
| 141 | </select> | 144 | </select> |
| 142 | <?php echo $validation->form_error('sendto'); ?> | 145 | <?php echo $validation->form_error('sendto'); ?> |
| 146 | <div id="uploadcsv" style="display:none;"> | ||
| 147 | <input type="file" name="uploadCSVlist" id="uploadCSVlist" /> | ||
| 148 | <div id="users_count" style="display:none;"> | ||
| 149 | </div> | ||
| 150 | </div> | ||
| 143 | </td> | 151 | </td> |
| 144 | </tr> | 152 | </tr> |
| 145 | 153 | ||
| ... | @@ -341,6 +349,37 @@ endforeach; | ... | @@ -341,6 +349,37 @@ endforeach; |
| 341 | <script> | 349 | <script> |
| 342 | jQuery(document).ready(function($) { | 350 | jQuery(document).ready(function($) { |
| 343 | 351 | ||
| 352 | |||
| 353 | $(document).on('change', '#sendto', function() { | ||
| 354 | if ($(this).val() == 'uploadlist') { | ||
| 355 | $(this).hide(); | ||
| 356 | $('#uploadcsv').show(); | ||
| 357 | } | ||
| 358 | }); | ||
| 359 | |||
| 360 | $('#uploadCSVlist').on("change", function(){ | ||
| 361 | var file = this.files[0]; | ||
| 362 | var formdata = new FormData(); | ||
| 363 | formdata.append("uploadCSVlist", file); | ||
| 364 | formdata.append("action", "upload_users_by_csv"); | ||
| 365 | $.ajax({ | ||
| 366 | url: '/wp-admin/admin-ajax.php', | ||
| 367 | type: 'POST', | ||
| 368 | data: formdata, | ||
| 369 | contentType: false, | ||
| 370 | processData: false, | ||
| 371 | success: function(data) { | ||
| 372 | const obj = JSON.parse(data); | ||
| 373 | console.log(obj.users); | ||
| 374 | $('#users_count').html(''+obj.users.length+' Users Added').css('color','green').show(); | ||
| 375 | $('#users_count').append('<input type="hidden" name="report_ids" value="' + obj.users.join(',') + '">'); | ||
| 376 | $('#users_count').append('<input type="hidden" name="sendto" value="report"'); | ||
| 377 | } | ||
| 378 | }); | ||
| 379 | }); | ||
| 380 | |||
| 381 | |||
| 382 | |||
| 344 | var codeCleaned = false; | 383 | var codeCleaned = false; |
| 345 | 384 | ||
| 346 | $('#submit').on('click', function() { | 385 | $('#submit').on('click', function() { | ... | ... |
-
Please register or sign in to post a comment