print $result->faultString() . "<BR>"; } } ######################## ### Let 'er Rip! ### ######################## ### Here we build our posted contact data and collect the ID ### $conID = addCon(); if ($conID != "ERROR") { ### Assuming everything worked lets add the credit card and collect the ID ### $creditID = addCC($conID); if ($creditID != "ERROR") { ### Now if nothing errored, lets create a date object for today in the correct format ### $dateObj = date('Ymd\\TH:i:s'); ### Then build the order and collect the ID ### $order = buildOrder($conID, "Sample Order", $dateObj, 0, 0); if ($order != "ERROR") { ### If the order build was successful lets add our posted products. ### if (isset($_POST['hotDog'])) { addOrderItem($order, 41, 4, 2.0, 1, "HOT DOG!", "An All-Beef frank!"); } if (isset($_POST['Burger'])) { addOrderItem($order, 42, 4, 3.5, 1, "Hamburger!", "2 Buns and a patty!"); } if (isset($_POST['Fries'])) { addOrderItem($order, 43, 4, 1.75, 1, "French Fries!", "Potatoes Fried to perfection!"); } if (isset($_POST['Drink'])) { addOrderItem($order, 44, 4, 1.0, 1, "Cold Drink!", "Drink with NO free refills!"); } }
$found_where = strrpos($query1, "where"); $found_order = strrpos($query1, "order"); $target1 = buildTarget($query1); $from1 = buildFrom($found_where, $found_group, $found_order, $query1); $where1 = buildWhere($found_where, $found_group, $found_order, $query1); $group1 = buildGroup($found_group, $found_order, $query1); $order1 = buildOrder($found_order, $query1); //******************************************************EXTRACTION 2 $found_group = strrpos($query2, "group"); $found_where = strrpos($query2, "where"); $found_order = strrpos($query2, "order"); $target2 = buildTarget($query2); $from2 = buildFrom2($found_where, $found_group, $found_order, $query2); $where2 = buildWhere($found_where, $found_group, $found_order, $query2); $group2 = buildGroup($found_group, $found_order, $query2); $order2 = buildOrder($found_order, $query2); $query = buildQuery($cubetablenameB, $join_final, $target1, $target2, $from1, $from2, $where1, $where2, $group1, $group2, $order1, $order2); $result = exec_query($query); buildReport($result); //***************************************************************************************************************************************** function buildFrom($found_where, $found_group, $found_order, $query1) { //FROM if ($found_where == true) { $a = eregi("from (.+) where", $query1, $regs); } elseif ($found_group == true) { $a = eregi("from (.+) group", $query1, $regs); } elseif ($found_order == true) { $a = eregi("from (.+) order", $query1, $regs); } else { $a = eregi("from (.+)\$", $query1, $regs);
} else { print $result->faultCode() . "<BR>"; print $result->faultString() . "<BR>"; } } ############################################ ### Function to create a blank order ### ############################################ function buildOrder($cID, $desc, $oDate, $leadAff, $saleAff) { global $client, $key; ###Set up the call to add an order to a contact### $call = new xmlrpcmsg("InvoiceService.createBlankOrder", array(php_xmlrpc_encode($key), php_xmlrpc_encode($cID), php_xmlrpc_encode($desc), php_xmlrpc_encode($oDate, array('auto_dates')), php_xmlrpc_encode($leadAff), php_xmlrpc_encode($saleAff))); ###Send the call### $result = $client->send($call); if (!$result->faultCode()) { $ordID = $result->value(); print "Blank order built - ID: " . $ordID; print "<BR>"; return $ordID; } else { print $result->faultCode() . "<BR>"; print $result->faultString() . "<BR>"; } } ############################################# ### Build the order and add the items ### ############################################# $dateObj = date('Ymd\\TH:i:s'); $order = buildOrder(1300, "Sample Order", $dateObj, 0, 0); addOrderItem($order, 40, 4, 100.35, 2, "Sample Item", "Relax, its just an example!");