Beispiel #1
0
if (isset($_GET['department_delete'])) {
    ?>
        <div id="message" class="error notice is-dismissible below-h2">
            <p><?php 
    _e('Some department doesn\'t delete because some employees work under those department', 'wp-erp');
    ?>
</p>
            <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
        </div>
    <?php 
}
?>
    
    <div id="erp-dept-table-wrap">

        <div class="list-table-inner">

            <form method="get">
                <input type="hidden" name="page" value="erp-hr-depts">
                <?php 
$department_table = new \WeDevs\ERP\HRM\Department_List_Table();
$department_table->prepare_items();
$department_table->views();
$department_table->display();
?>
            </form>

        </div><!-- .list-table-inner -->
    </div><!-- .list-table-wrap -->

</div>
Beispiel #2
0
 /**
  * Department handle bulk action
  *
  * @since 0.1
  *
  * @return void [redirection]
  */
 public function department_bulk_action()
 {
     if (!$this->verify_current_page_screen('erp-hr-depts', 'bulk-departments')) {
         return;
     }
     $employee_table = new \WeDevs\ERP\HRM\Department_List_Table();
     $action = $employee_table->current_action();
     if ($action) {
         $redirect = remove_query_arg(array('_wp_http_referer', '_wpnonce', 'action', 'action2'), wp_unslash($_SERVER['REQUEST_URI']));
         $resp = [];
         switch ($action) {
             case 'delete_department':
                 if (isset($_GET['department_id']) && $_GET['department_id']) {
                     foreach ($_GET['department_id'] as $key => $dept_id) {
                         $resp[] = erp_hr_delete_department($dept_id);
                     }
                 }
                 if (in_array(false, $resp)) {
                     $redirect = add_query_arg(array('department_delete' => 'item_deleted'), $redirect);
                 }
                 wp_redirect($redirect);
                 exit;
         }
     }
 }