Exemple #1
0
function ord_getItemDescription($itemid, $orderid)
{
    //Test with ordernumber:  IA4f310f1212c9b
    $order = db_getOrderById($orderid);
    //jh candidate for removal since this info was already obtained in calling section:  reloadOrderItems.  maybe is better to pass these individual values as arguments???
    //printr($order);
    $order_userid = "";
    foreach ($order as $o) {
        $order_userid = $o['userid'];
    }
    $item = db_getItem($itemid);
    //jh again candidate for removal, this was already obtained in calling section. maybe is better to pass these individual values as arguments???
    $itemtype = "";
    foreach ($item as $i) {
        $itemtype = $i['type'];
    }
    //	echo '<script type="text/javascript">alert("In orders.php ord_getItemDescription  after db_getItem itemid= '.$itemid .' orderid= ' . $orderid .'")</script>';
    $timeZoneId = 'GMT-05:00 US/Eastern';
    //jh original was(need input from the Professor): db_getUserTimeZone($order_userid)->data;
    $description = "";
    if ($itemtype == "PACKAGE") {
        //	echo '<script type="text/javascript">alert("In orders.php ord_getItemDescription in if package section")</script>';
        $items = array();
        $packageItems = db_getPackageItems($itemid);
        foreach ($packageItems as $packageItem) {
            //jh here the logic is getting the items
            $item = db_getItem($packageItem['itemid']);
            //$item->quantity = $packageItem->quantity; //replaced by foreach loop below.  I cannot use object->field because getting back  a mixed mysqli array
            foreach ($item as $i) {
                $i['quantity'] = $packageItem['quantity'];
            }
            array_push($items, $item);
            //			echo '<script type="text/javascript">alert("in orders.php $packageItems foreach loop i->quantity='. $packageItem['quantity'].'")</script>'; //jh remove this
        }
        //	echo '<script type="text/javascript">alert("in orders.php after $packageItems foreach loop")</script>';
        //	echo "items array with item array elements";
        //	var_dump($items);
        $description .= "<ul>";
        foreach ($items as $item) {
            //jh we also need to do a foreach loop for each $item
            $itemname = "";
            $itemquantity = "";
            $item_referenceid = "";
            //check array size first.
            //		echo '<script type="text/javascript">alert("in orders.php after $packageItems foreach loop first items foreach loop item size is:'.sizeof($item). '")</script>';
            foreach ($item as $i) {
                //echo "items sub loop, size of item is: " . sizeof($i);
                $itemname = $i['name'];
                $itemquantity = $i['quantity'];
                $item_referenceid = ['referenceid'];
            }
            //		echo '<script type="text/javascript">alert("in orders.php after $packageItems after foreach items, item before soap call")</script>';
            //echo "Right before ws_getCreditTypeById() call";
            $creditType = ws_getCreditTypeById($item_referenceid);
            //jh here another getCreditTypeById. Replace with Ajax call
            //jh CAREFUL!!!! NEED TO TEST IF creditType returned is null else it will look ugly
            //echo '<script type="text/javascript">alert("in orders.php after $packageItems about to dump creditType")</script>';
            //echo "credit type var_dump ";
            //var_dump($creditType);
            $course = db_getCourseById($creditType->courseId);
            //jh needs to be put back once credittype ajax call is available
            $course_name = "";
            foreach ($course as $c) {
                $course_name = $c['name'];
            }
            $description .= "<li>";
            $description .= "<strong>" . $itemname . "(" . $itemquantity . "):</strong> ";
            $description .= "This item allows students enrolled in the course " . $course_name . " to use the resource " . $creditType->resource . " for ";
            $description .= ord_getPolicyDescription($creditType->policyId, $timeZoneId);
            $description .= "</li>";
        }
        $description .= "</ul>";
    } else {
        $item_referenceid = "";
        foreach ($item as $i) {
            $item_referenceid = $i['referenceid'];
        }
        $creditType = ws_getCreditTypeById($item_referenceid);
        //echo "creditType vardump: ";
        //var_dump($creditType);
        $course = db_getCourseById($creditType->courseId);
        $course_name = "";
        foreach ($course as $c) {
            $course_name = $c['name'];
        }
        //	$description .=  "This item allows students enrolled in the course ".$course->shortname."  to use the resource ".$creditType->resource." for ";	//jh original code needs retrofitting, efront course table does not have a shortname field
        $description .= "This item allows students enrolled in the course " . $course_name . "  to use the resource " . $creditType->resource . " for ";
        //echo "description data: " . $description;
        $description .= ord_getPolicyDescription($creditType->policyId, $timeZoneId);
    }
    //		$description .=  "Else section Needs a lot of Work (orders.php ord_getItemDescription) ";	//jh remove
    //		$description .= "You have 1 millisecond left of Quota";  //jh remove
    return $description;
}
function ord_getItemDescription($itemid, $orderid)
{
    $order = db_getOrderById($orderid);
    $item = db_getItem($itemid);
    $timeZoneId = db_getUserTimeZone($order->userid)->data;
    $description = "";
    if ($item->type == "PACKAGE") {
        $items = array();
        $packageItems = db_getPackageItems($item->id);
        foreach ($packageItems as $packageItem) {
            $item = db_getItem($packageItem->itemid);
            $item->quantity = $packageItem->quantity;
            array_push($items, $item);
        }
        $description .= "<ul>";
        foreach ($items as $item) {
            $creditType = ws_getCreditTypeById($item->referenceid);
            $course = db_getCourseById($creditType->courseId);
            $description .= "<li>";
            $description .= "<strong>" . $item->name . "(" . $item->quantity . "):</strong> ";
            $description .= "This item allows students enrolled in the course " . $course->shortname . " to use the resource " . $creditType->resource . " for ";
            $description .= ord_getPolicyDescription($creditType->policyId, $timeZoneId);
            $description .= "</li>";
        }
        $description .= "</ul>";
    } else {
        $creditType = ws_getCreditTypeById($item->referenceid);
        $course = db_getCourseById($creditType->courseId);
        $description .= "This item allows students enrolled in the course " . $course->shortname . "  to use the resource " . $creditType->resource . " for ";
        $description .= ord_getPolicyDescription($creditType->policyId, $timeZoneId);
    }
    return $description;
}