Esempio n. 1
0
    public function metabox_orderID()
    {
        $orderID = intval($_POST['orderID']);
        $wpwsO = WPWS_Model::getDataOrderID($orderID);
        //Type
        $term_id_type = $wpwsO->term_id_type;
        $wpws_type = WPWS_Model::getTermByTermID($term_id_type);
        //Length
        $term_id_length = $wpwsO->term_id_length;
        $wpws_length = WPWS_Model::getTermByTermID($term_id_length);
        //Category
        $categoryO = get_term($wpwsO->term_id_category, 'category');
        $wpws_category = $categoryO->name;
        //Quantity
        $wpws_quantity = $wpwsO->quantity;
        //Notes
        $wpws_notes = stripslashes_deep(nl2br($wpwsO->notes));
        ?>
	
    <ul style="list-style-type:none; margin:0; padding:0;">
       <li><strong><em>Type: </em></strong><?php 
        echo $wpws_type;
        ?>
</li>
       <li> <strong><em>Length: </em></strong><?php 
        echo $wpws_length;
        ?>
 </li>
        <li><strong><em>Category: </em></strong><?php 
        echo $wpws_category;
        ?>
 </li>
        <li><strong><em>Quantity: </em></strong><?php 
        echo $wpws_quantity;
        ?>
</li>
        <li><strong><em>Notes: </em></strong><?php 
        echo $wpws_notes;
        ?>
</li>
     </ul>

	<?php 
        die;
    }
Esempio n. 2
0
    public function wpws_menu_client_clientOut()
    {
        ?>
<div class="wrap">
    
    
	  <h2>My Orders</h2>	
<p>Here is your current order and the status. 
</p>

<table cellspacing="0" class="wp-list-table widefat pages" style="margin: 5px;">
	<thead>
	<tr>
		<th width="67" class="manage-column column-orderid sortable desc" id="title" style="" scope="col"><a href="http://localhost/wordpress/wp-admin/admin.php?page=wpws-orders&amp;orderby=orderid&amp;order=asc"><span>Order ID</span><span class="sorting-indicator"></span></a></th>
        <th width="33" class="manage-column column-date sortable asc" id="date" style="" scope="col"><a href="http://localhost/wordpress/wp-admin/admin.php?page=wpws-orders&amp;orderby=date&amp;order=desc"><span>Date</span><span class="sorting-indicator"></span></a></th>
		<th width="73" class="manage-column column-categories" id="categories" style="" scope="col">Categories</th>
        <th width="34" class="manage-column column-type" id="type" style="" scope="col">Type</th>
        <th width="47" class="manage-column column-length" id="length" style="" scope="col">Length</th>
        <th width="58" class="manage-column column-quantity" id="quantity" style="" scope="col">Quantity</th>
        <th width="107" class="manage-column column-notes" id="notes" style="" scope="col">Notes</th>
        <th width="99" class="manage-column column-paid" id="paid" style="" scope="col">Paid</th>
        <th width="99" class="manage-column column-invoice" id="invoice" style="" scope="col">Invoice Sent?</th>
        <th width="99" class="manage-column column-status" id="status" style="" scope="col">Status</th>	
        
    </tr>
	</thead>

	<tbody id="the-list">
    
    <?php 
        //current logged user
        global $current_user;
        $orderA = WPWS_Model::getOrders($current_user->ID);
        //returns as an object
        foreach ($orderA as $order) {
            $orderID = $order->orderID;
            $userIDProject = WPWS_Model::getUserByOrderID($orderID);
            $orderDate = date('Y/m/d', strtotime($order->date));
            $userID = $order->userID;
            $userO = get_user_by('id', $userID);
            if ($userIDProject) {
                $userOProject = get_user_by('id', $userIDProject);
                $userProject = $userOProject->user_login;
            } else {
                $userProject = NULL;
            }
            $quantity = $order->quantity;
            $categoryO = get_term($order->term_id_category, 'category');
            //term_id, taxonomy; returns a category object
            //Type, Length, Status
            $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);
            //Display the status of an order ID
            $statusA = array('completed' => 'Completed', 'inprogress' => 'In-progress', 'cancelled' => 'Cancelled');
            //Paid?
            $wpws_paid = !empty($order->paid) ? 'Yes' : 'No';
            $wpws_sentInvoice = !empty($order->sentInvoice) ? 'Yes' : 'No';
            if (!empty($orderData->status)) {
                $wpws_order_status = $statusA[$orderData->status];
            } else {
                $wpws_order_status = NULL;
            }
            ?>
					<tr id="order-<?php 
            echo $orderID;
            ?>
" class="order-<?php 
            echo $orderID;
            ?>
 type-wpws_article alternate iedit author-self level-0" valign="top">
				<td class="post-title page-title column-orderid"><strong><?php 
            echo $orderID;
            ?>
</strong>
                <div class="locked-info"><span class="locked-avatar"></span> <span class="locked-text"></span></div>
                <div class="row-actions"></div>
                <div class="hidden" id="inline_<?php 
            echo $orderID;
            ?>
"></div>
				  </td>
					  <td class="date column-date"><abbr title="<?php 
            echo $orderDate;
            ?>
"><?php 
            echo $orderDate;
            ?>
</abbr></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="status column-notes">
                        <textarea cols="20" rows="1" readonly="readonly"><?php 
            echo stripslashes_deep($order->notes);
            ?>
</textarea>
                        
                        </td>
							<td class="due_date column-paid"><?php 
            echo $wpws_paid;
            ?>
</td>
						<td class="due_date column-invoice">&nbsp;<?php 
            echo $wpws_sentInvoice;
            ?>
</td>
						<td class="due_date column-status"><?php 
            echo $wpws_order_status;
            ?>
</td>
					</tr>
       <?php 
        }
        ?>
             
                    
		</tbody>
</table>
        
</div>    
     <?php 
    }
Esempio n. 3
0
    public function wpws_submit_form_display()
    {
        $payemail = get_option('wpws_settings_payemail');
        $wpws_settings_pages = get_option('wpws_settings_pages');
        $productPage = $wpws_settings_pages['wpws_product_page'];
        $payURL = get_page_link($productPage);
        //retrieve product ID, if exists
        if (isset($_GET['productID'])) {
            $productID = intval($_GET['productID']);
            //Retrieve term IDs based on product ID
            $terms = $this->wpws_model->getTermsByProductID($productID);
            $_POST['term_id_type'] = $terms['term_id_type'];
            $_POST['term_id_length'] = $terms['term_id_length'];
        } else {
            //if no product ID is set, then use the one set in the Settings menu
            $productID = get_option('wpws_default_product');
            //Retrieve term IDs based on product ID
            $terms = $this->wpws_model->getTermsByProductID($productID);
            $_POST['term_id_type'] = $terms['term_id_type'];
            $_POST['term_id_length'] = $terms['term_id_length'];
        }
        $term_id_type = !empty($_POST['term_id_type']) ? intval($_POST['term_id_type']) : 0;
        $term_id_length = !empty($_POST['term_id_length']) ? intval($_POST['term_id_length']) : 0;
        $term_id_category = !empty($_POST['term_id_category']) ? intval($_POST['term_id_category']) : 0;
        //from actual wp_terms table
        $wpws_quantity = !empty($_POST['wpws_quantity']) ? intval($_POST['wpws_quantity']) : 0;
        $wpws_notes = !empty($_POST['wpws_notes']) ? $_POST['wpws_notes'] : NULL;
        //Login
        $user_login = !empty($_POST['user_login']) ? $_POST['user_login'] : NULL;
        ?>
    		<!-- Display confirmation message to users who submit a book review -->
		<?php 
        if (isset($_GET['orderID']) && isset($_SERVER['HTTP_REFERER'])) {
            $orderID = intval($_GET['orderID']);
            //Get object data of Order ID
            $orderData = WPWS_Model::getDataOrderID($orderID);
            //retrieve the product Type/Length name
            $item_type = WPWS_Model::getTermByTermID($orderData->term_id_type);
            $item_type = !empty($item_type) ? $item_type : NULL;
            $item_length = WPWS_Model::getTermByTermID($orderData->term_id_length);
            $item_length = !empty($item_length) ? $item_length : NULL;
            $item_name = $item_type && $item_length ? $item_type . '/' . $item_length : $item_type;
            ?>
		<div style="background:#0C6;">
			Thank you for your request - please complete payment to continue. 
            
                <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
                    <input type="hidden" name="cmd" value="_xclick">
                    <input type="hidden" name="business" value="<?php 
            echo $payemail;
            ?>
">
                    <input type="hidden" name="item_name" value="<?php 
            echo $item_name;
            ?>
">
                    <input type="hidden" name="item_number" value="<?php 
            echo $orderData->productID;
            ?>
">
                    <input type="hidden" name="quantity" value="<?php 
            echo $orderData->quantity;
            ?>
">
                    <input type="hidden" name="currency_code" value="USD">
                    <input type="hidden" name="amount" value="<?php 
            echo number_format($orderData->price, 2);
            ?>
">
                    <input type="hidden" name="return" value="<?php 
            echo $payURL;
            ?>
">
                    <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
            </form>

		</div>
		<?php 
            exit;
        }
        ?>
        

	<form method="post" id="submit-article" action="">
    
		<!-- Nonce fields to verify form submission -->
		<?php 
        wp_nonce_field('articlesubmit_form', 'wpws_submit_form');
        ?>


	    <!-- Post variable to indicate user submitted  -->
		<input type="hidden" name="wpws_article_submit" value="1" />
        
        <!-- Hidden variable for ProductID -->
        <input type="hidden" name="productID" value="<?php 
        echo $productID;
        ?>
" />
        

		<table>

			<tr>
				<td>Type</td>
				<td>
					<?php 
        // Retrieve array of all types in system
        //$types = get_terms( 'wpws_article_type', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
        $taxonomy_id = $this->wpws_model->getTaxonomyID('Type');
        $types = $this->wpws_model->getTerms($taxonomy_id);
        // Check if types were found
        if (!is_wp_error($types) && !empty($types)) {
            echo '<select name="term_id_type">';
            echo '<option value="">---</option>';
            // Display all types
            foreach ($types as $type) {
                ?>
							<option value="<?php 
                echo $type->term_id;
                ?>
" <?php 
                echo selected($term_id_type, $type->term_id);
                ?>
><?php 
                echo $type->term;
                ?>
</option>
						
                        <?php 
            }
            echo '</select>';
        }
        ?>
				</td>
			</tr>
            <tr>
				<td>Length</td>
				<td>
					<?php 
        // Retrieve array of all book types in system
        //$lengths = get_terms( 'wpws_article_length', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
        $taxonomy_id = $this->wpws_model->getTaxonomyID('Length');
        $lengths = $this->wpws_model->getTerms($taxonomy_id);
        // Check if types were found
        if (!is_wp_error($lengths) && !empty($lengths)) {
            echo '<select name="term_id_length">';
            echo '<option value="">---</option>';
            // Display all types
            foreach ($lengths as $length) {
                ?>
							<option value="<?php 
                echo $length->term_id;
                ?>
" <?php 
                echo selected($term_id_length, $length->term_id);
                ?>
><?php 
                echo $length->term;
                ?>
</option>
						
                        <?php 
            }
            echo '</select>';
        }
        ?>
				</td>
			</tr>
             <tr>
				<td>Category</td>
				<td>
					<?php 
        $mycategories = get_option('wpws_categories');
        if (!empty($mycategories)) {
            $mycategories = implode(",", $mycategories);
        } else {
            $mycategories = '';
        }
        $args = array('type' => 'post', 'child_of' => 0, 'parent' => '', 'orderby' => 'id', 'order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'exclude' => '', 'include' => $mycategories, 'number' => '', 'taxonomy' => 'category', 'pad_counts' => false);
        $categories = get_categories($args);
        // Check if types were found
        if (!is_wp_error($categories) && !empty($categories)) {
            echo '<select name="term_id_category">';
            echo '<option value="">- Select -</option>';
            // Display all types
            foreach ($categories as $category) {
                ?>
							<option value="<?php 
                echo $category->term_id;
                ?>
" <?php 
                echo selected($term_id_category, $category->term_id);
                ?>
><?php 
                echo $category->name;
                ?>
</option>
						
                        <?php 
            }
            echo '</select>';
        }
        ?>
				</td>
			</tr>
            <tr>
				<td>Quantity</td>
				<td>
					<input type="text" name="wpws_quantity" size="3" value="<?php 
        echo $wpws_quantity;
        ?>
" />
				</td>
			</tr>
            
            <tr>
				<td>Notes</td>
				<td><textarea name="wpws_notes"><?php 
        echo $wpws_notes;
        ?>
</textarea></td>
			</tr>
            
            <?php 
        if (!$this->is_login) {
            ?>
            <tr>
            	<td colspan="3">Please Login/Register.</td>
               
            </tr>
            </tr>
            <tr>
				<td>Email:</td>
				<td>
					<input type="text" name="user_login" size="25" value="<?php 
            echo $user_login;
            ?>
" />
				</td>
			</tr>
            </tr>
            <tr>
				<td>Password:</td>
				<td>
					<input type="password" name="user_password" size="25" value="" />
				</td>
			</tr>
           <?php 
        }
        ?>
		</table>
        
        

		<input type="submit" name="submit" value="Submit" />
	</form>
    
<?php 
    }