Exemple #1
0
    public function wpws_menu_tasks()
    {
        global $current_user;
        ?>

 <div class="wrap">
    
      <!-- Display confirmation message -->
		<?php 
        if (isset($_GET['updated']) && $_GET['updated']) {
            ?>
        
    		<div id="message" class="updated"> Settings saved!</div>
            
		<?php 
        } else {
            if (isset($_GET['errorMsg']) && $_GET['errorMsg']) {
                $msgID = intval($_GET['errorMsg']);
                ?>
 
				<div id="message" class="error"> <?php 
                echo WPWS_Menu::$errorMessages[$msgID];
                ?>
</div>
		<?php 
            }
        }
        ?>
    
	  <h2>My Tasks</h2>	
<p>Here is where you can see the current Orders you have claimed to work on.<br />
From an Order/Project level, you can set the overall status of it. That is, if you are required to write two articles and only one is required for completion, then you could mark
the overall project/Order ID as completed.
</p>


<form method="post" action="<?php 
        echo admin_url('admin-post.php');
        ?>
">

	<!-- to determine which action to process -->
    <input type="hidden" name="action" value="save_settings_tasks" />
	  
	  <!-- Adding security through hidden referrer field -->
	  <?php 
        wp_nonce_field('wpws_settings_tasks');
        ?>
      
      <span style="display:inline; width: 100px;  padding: 2px; border:1px solid #000;cursor:pointer;" onClick="document.location.href='admin.php?page=wpws-tasks&status=misc';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;
      <em><strong>Not Assigned/Misc</strong></em>&nbsp;&nbsp;&nbsp;<span style="display:inline; width: 100px;  padding: 2px; ;cursor:pointer;" class="inprogressStatus" onClick="document.location.href='admin.php?page=wpws-tasks&status=inprogress';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
           &nbsp;<em><strong>In Progress</strong></em>&nbsp;&nbsp;&nbsp;<span style="display:inline; width: 100px;  padding: 2px; cursor:pointer;" class="cancelledStatus" onClick="document.location.href='admin.php?page=wpws-tasks&status=cancelled';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;<em><strong>Cancelled</strong></em>&nbsp;&nbsp;<span style="display:inline; width: 100px;  padding: 2px; cursor:pointer;"  class="completedStatus" onClick="document.location.href='admin.php?page=wpws-tasks&status=completed';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;<em><strong>Completed</strong></em>
           &nbsp;&nbsp;&nbsp;<a href="admin.php?page=wpws-tasks">[View All Tasks]</a>
<table cellspacing="0" class="wp-list-table widefat  pages" style="margin: 5px;">
  <thead>
	<tr>
    	<th width="133" class="manage-column column-taskid sortable desc" id="title" style="" scope="col"><a href="wp-admin/admin.php?page=wpws-tasks&amp;orderby=taskid&amp;order=asc"><span>Task ID</span><span class="sorting-indicator"></span></a></th>
		<th width="133" class="manage-column column-orderid sortable desc" id="title" style="" scope="col"><a href="wp-admin/admin.php?page=wpws-tasks&amp;orderby=orderid&amp;order=asc"><span>Order ID</span><span class="sorting-indicator"></span></a></th>
        <th width="211" class="manage-column column-categories" id="categories" style="" scope="col">Categories</th>
        <th width="158" class="manage-column column-type" id="author" style="" scope="col">Type</th>
        <th width="137" class="manage-column column-length" id="orderID" style="" scope="col">Length</th>
        <th width="169" class="manage-column column-quantity" id="orderID" style="" scope="col">Quantity</th>
        <th width="117" class="manage-column column-client" id="length" style="" scope="col">Client</th>
        <th width="394" class="manage-column column-notes" id="status" style="" scope="col">Notes</th>
        <th width="289" class="manage-column column-status" id="due_date" style="" scope="col">Status</th>	
        
    </tr>
	</thead>

	<tbody id="the-list">
    
    <?php 
        //current logged user
        $userLogin = $current_user->user_login;
        $userID = $current_user->ID;
        $status = !empty($_GET['status']) ? $_GET['status'] : NULL;
        $taskA = WPWS_Model::getTasks($userID, $status);
        //returns as an object
        foreach ($taskA as $order) {
            //reset status style color
            $statusStyle = NULL;
            $taskID = $order->taskID;
            $orderID = $order->orderID;
            $clientID = $order->clientID;
            $clientO = get_user_by('id', $clientID);
            $status = $order->status;
            //Get color for status
            switch ($status) {
                case 'completed':
                    $statusStyle = 'completedStatus';
                    break;
                case 'inprogress':
                    $statusStyle = 'inprogressStatus';
                    break;
                case 'cancelled':
                    $statusStyle = 'cancelledStatus';
                    break;
            }
            $quantity = $order->quantity;
            $categoryO = get_term($order->term_id_category, 'category');
            //term_id, taxonomy; returns a category object
            //Type and Length
            $orderData = WPWS_Model::getDataOrderID($orderID);
            //returns an object
            $term_id_type = $orderData->term_id_type;
            $term_id_length = $orderData->term_id_length;
            $type = WPWS_Model::getTermByTermID($term_id_type);
            $length = WPWS_Model::getTermByTermID($term_id_length);
            $wpws_order_status = NULL;
            ?>
				<tr id="task-<?php 
            echo $taskID;
            ?>
" class="task-<?php 
            echo $taskID;
            ?>
 <?php 
            echo $statusStyle;
            ?>
" valign="top">
                <td class="post-title page-title column-taskid"><strong><?php 
            echo $taskID;
            ?>
</strong>
				<td class="post-title page-title column-orderid"><span style="font-weight:bold; text-decoration:underline;"><?php 
            echo $orderID;
            ?>
</span> <div class="hidden" id="inline_<?php 
            echo $taskID;
            ?>
"></div>
				  </td>
					  <td class="categories column-categories"><a href="edit.php?post_type=wpws_article&amp;category_name=<?php 
            echo $categoryO->slug;
            ?>
"><?php 
            echo $categoryO->name;
            ?>
</a></td>	
                      <td class="author column-author"><?php 
            echo $type;
            ?>
</td>
						<td class="orderID column-length"><?php 
            echo $length;
            ?>
</td>
                        <td class="orderID column-quantity"><?php 
            echo $quantity;
            ?>
</td>
						<td class="userID column-clientID"><?php 
            echo $clientO->user_login;
            ?>
</td>
						<td class="status column-notes">
                        <textarea cols="20" rows="1" readonly="readonly"><?php 
            echo stripslashes_deep($order->notes);
            ?>
</textarea>
                        
                        </td>
						<td class="due_date column-status">
						<select name="wpws_order_status" id="<?php 
            echo $taskID;
            ?>
" class="wpws_order_status">
                           <option value="">-----</option>
                           <option value="completed" <?php 
            selected($status, 'completed');
            ?>
>Completed</option>
                           <option value="inprogress" <?php 
            selected($status, 'inprogress');
            ?>
>In-progress</option>
                           <option value="cancelled" <?php 
            selected($status, 'cancelled');
            ?>
>Cancelled</option>
                     </select>
                                        
                        
                        </td>
					</tr>
                    
                    <tr>
                    
                    	<td colspan="10">
                        <div class="accordian">
                        	<h4 style="padding-left: 30px;">View Articles/Projects (<span style="font-style:italic; font-weight:bold;">Order ID: <?php 
            echo $orderID;
            ?>
</span>)</h4>
                            <div>
                            
                            	<?php 
            $postIDA = WPWS_Model::getPostIDByOrderID($orderID);
            //Loop through all postIDs
            if (count($postIDA)) {
                $count = 1;
                foreach ($postIDA as $postIDO) {
                    $post_id = $postIDO->post_id;
                    //Options
                    $wpws_duedate = get_post_meta($post_id, 'wpws_meta_duedate', true);
                    $wpws_status = get_post_meta($post_id, 'wpws_meta_status', true);
                    $postO = get_post($post_id);
                    $title = $postO->post_title;
                    //Title
                    echo "{$count}) <a href=" . admin_url() . "post.php?post={$post_id}&action=edit>" . $title . "<a/>";
                    echo " <strong><em>( Post ID: {$post_id}, Due Date: {$wpws_duedate}, Status: {$wpws_status} )</em></strong> <br />";
                    $count++;
                }
            } else {
                echo "<b>No Article yet - click 'Add New Article' for Order ID # {$orderID}</b><br /><br />\n";
            }
            ?>
                            
                            <p><a href="post-new.php?post_type=wpws_article">>> Add New Article </a></p>
                            
                            </div>

</div>
                        </td>
                    </tr>
                    
       <?php 
        }
        ?>
             
                    
		</tbody>
</table>
</form>
        
</div>    
        

        
    <?php 
    }