Virtuemart E-commerce Report Status Enhancement | 2008-02-04

Technology Blog » Web Development

This week I helped http://www.kroeshaar.com to enhancement its virtuemart backend to have the report filter by the order status. Also I did a modification that will pop up a alert when the order status or notify customer by e-mail has been changed. Here is the code that I wrote......

 

Virtuemart Report Status Enhancement

Open the php file

/administrator/components/com_virtuemart/html/reportbasic.index.php

around lin22, under

$interval = mosGetParam( $_REQUEST, "interval", "byMonth" );

add this

$order_status = mosGetParam( $_REQUEST, "order_status", "orderAll" );//www.PCinvent.com Set initial

around line 174, under

$end_date = mktime(23,59,59,date("n")+1,0,date("Y")); $interval = "byMonth";

add this

$order_status = "orderAll"; //www.PCinvent.com Default value

around line203, under

$query_between_line = "WHERE cdate BETWEEN '" . $start_date . "' AND '" . $end_date . "' ";

add this

/*-----------------------------------------------------------------
The Following Code is written by Andy Ng <[email protected]>
Site: http://www.PCinvent.com
Please do not removed the above credits/copyrights
-----------------------------------------------------------------*/
/* start of www.PCinvent.com report status */
 switch ($order_status) {
    case 'orderAll':
     $query_date_line .= '';//do nothing
     break;
   case 'orderPending':
     $query_between_line .= "AND #__{vm}_orders.order_status='P' "; // Limit status
     break;
   case 'orderConfirmed':
     $query_between_line .= "AND #__{vm}_orders.order_status='C' "; // Limit status
     break;
   case 'orderCancelled':
     $query_between_line .= "AND #__{vm}_orders.order_status='X' "; // Limit status
     break;
   case 'orderRefunded':
     $query_between_line .= "AND #__{vm}_orders.order_status='R' "; // Limit status
     break;
   case 'orderShipped':
     $query_between_line .= "AND #__{vm}_orders.order_status='S' "; // Limit status
     break;
   default:
     $query_between_line .= '';
    break;
  }

/* end of www.PCinvent.com report status */

around line, under

<td><?php echo $VM_LANG->_PHPSHOP_RB_INTERVAL_TITLE; ?></td>

          <td><input type="radio" id="byMonth" name="interval" value="byMonth" <?php if($interval=="byMonth") echo "checked='checked'" ?> />
          <label for="byMonth"><?php echo $VM_LANG->_PHPSHOP_RB_INTERVAL_MONTHLY_TITLE ?></label>    
          <input type="radio" name="interval" id="byWeek" value="byWeek" <?php if($interval=="byWeek") echo "checked='checked'" ?> />
          <label for="byWeek"><?php echo $VM_LANG->_PHPSHOP_RB_INTERVAL_WEEKLY_TITLE; ?></label>    
          <input type="radio" name="interval" id="byDay" value="byDay" <?php if($interval=="byDay") echo "checked='checked'" ?> />
          <label for="byDay"><?php echo $VM_LANG->_PHPSHOP_RB_INTERVAL_DAILY_TITLE; ?></label></td>

add this table row

         <tr><?php //www.PCinvent.com Report status enhancement ?>
          <td>Status</td>
          <td><input type="radio" id="orderAll" name="order_status" value="orderAll" <?php if($order_status=="orderAll") echo "checked='checked'" ?> />
            <label for="orderAll">All</label>
            <input type="radio" id="orderPending" name="order_status" value="orderPending" <?php if($order_status=="orderPending") echo "checked='checked'" ?> />
            <label for="orderPending">Pending</label>
            <input type="radio" id="orderConfirmed" name="order_status" value="orderConfirmed" <?php if($order_status=="orderConfirmed") echo "checked='checked'" ?> />
<label for="orderConfirmed">Confirmed</label>
<input type="radio" id="orderCanceleld" name="order_status" value="orderCanceleld" <?php if($order_status=="orderCanceleld") echo "checked='checked'" ?> />
<label for="orderCancelled">Cancelled</label>
<input type="radio" id="orderRefunded" name="order_status" value="orderRefunded" <?php if($order_status=="orderRefunded") echo "checked='checked'" ?> />
<label for="orderRefunded">Refunded</label>
<input type="radio" id="orderShipped" name="order_status" value="orderShipped" <?php if($order_status=="orderShipped") echo "checked='checked'" ?> />
<label for="orderShipped">Shipped</label></td>
        </tr>

Now, you will see the exactly result shown in the screenshot below.