Files
bobsleighphotos.com/production/admin/sources/orders/orderBuilder.inc.php
2017-03-02 20:30:40 -06:00

776 lines
41 KiB
PHP

<?php
/*
+--------------------------------------------------------------------------
| CubeCart 4
| ========================================
| CubeCart is a registered trade mark of Devellion Limited
| Copyright Devellion Limited 2006. All rights reserved.
| Devellion Limited,
| 5 Bridge Street,
| Bishops Stortford,
| HERTFORDSHIRE.
| CM23 2JU
| UNITED KINGDOM
| http://www.devellion.com
| UK Private Limited Company No. 5323904
| ========================================
| Web: http://www.cubecart.com
| Email: info (at) cubecart (dot) com
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
| Licence Info: http://www.cubecart.com/site/faq/license.php
+--------------------------------------------------------------------------
| orderBuilder.inc.php
| ========================================
| Ability to add/edit orders
+--------------------------------------------------------------------------
*/
if (!defined('CC_INI_SET')) die("Access Denied");
$lang = getLang("admin".CC_DS."admin_orders.inc.php");
$lang = getLang("orders.inc.php");
require_once "classes".CC_DS."cart".CC_DS."order.php";
$order = new order();
require $glob['adminFolder'].CC_DS."includes".CC_DS."currencyVars.inc.php";
permission("orders", "write", true);
if (isset($_GET['reset']) && $_GET['reset']>0) {
$record['noDownloads'] = 0;
$record['expire'] = time()+$config['dnLoadExpire'];
$where = 'id = '.$_GET['reset'];
$update = $db->update($glob['dbprefix']."CubeCart_Downloads", $record, $where);
httpredir($glob['adminFile'].'?_g=orders/orderBuilder&edit='.$_GET['edit']);
}
if (isset($_POST['cart_order_id']) && !isset($_POST['prodRowsSubmit']) && $_POST['customer_id']>0) {
$cache = new cache();
$cache->clearCache();
// ORDER INVENTORY
if (count($_POST['prodName'])>0) {
for ($i=0;$i<=count($_POST['prodName']);$i++) {
if ((!empty($_POST['prodName'][$i]) && !empty($_POST['quantity'][$i]) && !empty($_POST['price'][$i])) || $_POST['delId'][$i] == 1) {
$newOrderInv['name'] = $db->mySQLSafe($_POST['prodName'][$i]);
$newOrderInv['productCode'] = $db->mySQLSafe($_POST['productCode'][$i]);
$newOrderInv['product_options'] = $db->mySQLSafe($_POST['product_options'][$i]);
$newOrderInv['quantity'] = $db->mySQLSafe($_POST['quantity'][$i]);
$newOrderInv['price'] = $db->mySQLSafe($_POST['price'][$i]);
$newOrderInv['cart_order_id'] = $db->mySQLSafe($_POST['cart_order_id']);
if ($_POST['delId'][$i] == 1) {
$where = "id = ".$db->mySQLSafe($_POST['id'][$i]);
$delete = $db->delete($glob['dbprefix']."CubeCart_order_inv", $where);
} else if ($_POST['id'][$i]>0) {
$where = "id = ".$db->mySQLSafe($_POST['id'][$i]);
$update = $db->update($glob['dbprefix']."CubeCart_order_inv", $newOrderInv, $where);
} else {
$insert = $db->insert($glob['dbprefix']."CubeCart_order_inv", $newOrderInv);
}
}
}
}
// ORDER SUMMARY
$newOrderSum['cart_order_id'] = $db->mySQLSafe($_POST['cart_order_id']);
$newOrderSum['customer_id'] = $db->mySQLSafe($_POST['customer_id']);
$newOrderSum['name'] = $db->mySQLSafe($_POST['name']);
$newOrderSum['add_1'] = $db->mySQLSafe($_POST['add_1']);
$newOrderSum['add_2'] = $db->mySQLSafe($_POST['add_2']);
$newOrderSum['town'] = $db->mySQLSafe($_POST['town']);
$newOrderSum['county'] = $db->mySQLSafe($_POST['county']);
$newOrderSum['postcode'] = $db->mySQLSafe($_POST['postcode']);
$newOrderSum['country'] = $db->mySQLSafe($_POST['country']);
$newOrderSum['name_d'] = $db->mySQLSafe($_POST['name_d']);
$newOrderSum['companyName'] = $db->mySQLSafe($_POST['companyName']);
$newOrderSum['companyName_d'] = $db->mySQLSafe($_POST['companyName_d']);
$newOrderSum['add_1_d'] = $db->mySQLSafe($_POST['add_1_d']);
$newOrderSum['add_2_d'] = $db->mySQLSafe($_POST['add_2_d']);
$newOrderSum['town_d'] = $db->mySQLSafe($_POST['town_d']);
$newOrderSum['county_d'] = $db->mySQLSafe($_POST['county_d']);
$newOrderSum['postcode_d'] = $db->mySQLSafe($_POST['postcode_d']);
$newOrderSum['country_d'] = $db->mySQLSafe($_POST['country_d']);
$newOrderSum['phone'] = $db->mySQLSafe($_POST['phone']);
$newOrderSum['mobile'] = $db->mySQLSafe($_POST['mobile']);
$newOrderSum['subtotal'] = $db->mySQLSafe($_POST['subtotal']);
$newOrderSum['discount'] = $db->mySQLSafe($_POST['discount']);
$newOrderSum['prod_total'] = $db->mySQLSafe($_POST['prod_total']);
$newOrderSum['total_tax'] = $db->mySQLSafe($_POST['total_tax']);
$newOrderSum['total_ship'] = $db->mySQLSafe($_POST['total_ship']);
// removed as this is done further down $newOrderSum['status'] = $db->mySQLSafe($_POST['status']);
$newOrderSum['email'] = $db->mySQLSafe($_POST['email']);
$newOrderSum['comments'] = $db->mySQLSafe($_POST['comments']);
$newOrderSum['customer_comments'] = $db->mySQLSafe($_POST['customer_comments']);
$newOrderSum['ship_date'] = $db->mySQLSafe($_POST['ship_date']);
$newOrderSum['shipMethod'] = $db->mySQLSafe($_POST['shipMethod']);
$newOrderSum['gateway'] = $db->mySQLSafe($_POST['gateway']);
$newOrderSum['courier_tracking'] = $db->mySQLsafe($_POST['courier_tracking']);
if (isset($_GET['edit'])) {
$where = "cart_order_id = ".$db->mySQLSafe($_GET['edit']);
$update = $db->update($glob['dbprefix']."CubeCart_order_sum", $newOrderSum, $where);
if (isset($_POST['card_number'])) {
$cardData = array(
'card_type' => $_POST['card_type'],
'card_number' => $_POST['card_number'],
'card_expire' => $_POST['card_expire'],
'card_valid' => $_POST['card_valid'],
'card_issue' => $_POST['card_issue'],
);
if (function_exists('mcrypt_module_open')) {
require "classes".CC_DS."cart".CC_DS."encrypt.inc.php";
$crypt = new encryption($keyArray);
$record['offline_capture'] = "'".base64_encode($crypt->encrypt(serialize($cardData)))."'";
}
$db->update($glob['dbprefix'].'CubeCart_order_sum', $record, array('customer_id' => $orderSum['customer_id'], 'cart_order_id' => $orderSum['cart_order_id']));
}
if ($update == true) {
$msg .= "<p class='infoText'>".sprintf($lang['admin']['orders_updated_successfully'],$_GET['edit'])."</p>";
}/* else {
$msg .= "<p class='warnText'>".sprintf($lang['admin']['orders_update_failed'], $_GET['edit'])."</p>";
} */
} else {
$newOrderSum['ip'] = $db->mySQLSafe(get_ip_address());
$newOrderSum['time'] = $db->mySQLSafe(time());
$insert = $db->insert($glob['dbprefix']."CubeCart_order_sum", $newOrderSum);
if ($_POST['customer_id']>0) {
$record['noOrders'] = "noOrders + 1";
$where = "customer_id = ".$_POST['customer_id'];
$update = $db->update($glob['dbprefix']."CubeCart_customer", $record, $where);
}
if ($insert == true) {
$msg .= "<p class='infoText'>".sprintf($lang['admin']['orders_add_success'],$_POST['cart_order_id'])."</p>";
// send email confirmation
$order->newOrderEmail($_POST['cart_order_id']);
} else {
$msg .= "<p class='warnText'>".sprintf($lang['admin']['orders_add_fail'],$_POST['cart_order_id'])."</p>";
}
}
// update order status email etc
$order->orderStatus($_POST['status'], $_POST['cart_order_id'], true);
if ($_POST['cart_order_id']!==$_GET['edit']) {
httpredir($glob['adminFile']."?_g=orders/orderBuilder&edit=".$_POST['cart_order_id']);
}
}
if (isset($_GET['edit'])) {
$orderSum = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_order_sum WHERE cart_order_id = ".$db->mySQLSafe($_GET['edit']));
$orderInv = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_order_inv WHERE cart_order_id = ".$db->mySQLSafe($_GET['edit']));
}
if (count($orderInv) < 1 && !empty($_GET['edit'])) {
$msg .= "<p class='warnText'>".sprintf($lang['admin']['orders_no_products'], $_GET['edit'])."</p>";
}
$customers = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_customer WHERE `type` > 0 ORDER BY lastName, firstName ASC");
$countries = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_iso_countries");
if ($countries == true) {
$countriesArray = array();
for($i=0;$i<=count($countries);$i++){
$countriesArray[$countries[$i]['id']] = $countries[$i]['printable_name'];
}
}
if(isset($_GET['PayPal-Pro']) && !empty($_GET['PayPal-Pro'])) {
// Get Module Config
$module = fetchDbConfig("PayPal_Pro");
$basePPPath = "modules".CC_DS."altCheckout".CC_DS."PayPal_Pro".CC_DS."wpp-".$module['mode'].CC_DS;
$order_id = $_GET['edit'];
$ppfunction = ereg_replace("[^A-Za-z]", "", $_GET['PayPal-Pro']);
switch($ppfunction) {
case "doCapture":
require($basePPPath."DoCaptureReceipt.php");
break;
case "doAuth":
case "doReAuth":
require($basePPPath."DoReauthorizationReceipt.php");
break;
case "doRefund":
require($basePPPath."RefundReceipt.php");
break;
case "doVoidAuth":
require($basePPPath."DoVoidReceipt.php");
break;
}
}
require($glob['adminFolder'].CC_DS."includes".CC_DS."header.inc.php");
?>
<p class="pageTitle">
<?php if(isset($_GET['edit'])) { echo $lang['admin_common']['edit']; } else { echo $lang['admin_common']['add']; } ?>
<?php echo $lang['admin']['orders_order'];?></p>
<?php if (isset($msg)) echo $msg; ?>
<p>
<input type="button" class="submit" onclick="openPopUp('<?php echo $glob['adminFile']; ?>?_g=orders/print&amp;cart_order_id=<?php echo $_GET['edit']; ?>', 'PrintSlip', 600, 550, '1,toolbar=1')" value="<?php echo $lang['admin']['orders_print_packing_slip'];?>" />
</p>
<?php if(getCountryFormat($config['siteCountry'],'id','iso')=="GB") { ?>
<div style="border:#666666 1px solid; background:#FFFFFF; padding: 5px; width: 400px; margin-bottom: 10px;"><strong><a href="http://labels.cubecart.com" target="_blank"><img src="images/admin/integratedPackSlip.jpg" align="left" alt="Integrated Packing Slip Icon" width="86" height="94" hspace="3" border="0" /></a>Single Integrated Label Sheets</strong><br />
Speed up the dispatch process with compatible single integrated label sheets. These can be used to peel off a delivery address which can be stuck straight on to the package. <br />
<span style="float: right;"><a href="http://labels.cubecart.com" target="_blank" class="txtLink">Purchase</a> | <a href="http://labels.cubecart.com" target="_blank" class="txtLink">Learn More &raquo;</a></span><br clear='all' />
</div>
<?php } ?>
<form action="<?php echo $glob['adminFile']; ?>?_g=orders/orderBuilder<?php if(isset($_GET['edit'])) { echo "&amp;edit=".$_GET['edit']; } ?>" method="post" enctype="multipart/form-data" name="orderBuilder" target="_self">
<table cellspacing="1" cellpadding="3" class="mainTable" width="100%">
<tr>
<td colspan="4" class="tdTitle"><?php echo $lang['admin']['orders_order_summary'];?></td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin_common']['other_order_no']; ?></strong></td>
<td class="tdText"><input name="cart_order_id" type="text" class="textbox" value="<?php if(isset($orderSum[0]['cart_order_id'])) { echo $orderSum[0]['cart_order_id'].'" readonly="readonly'; } else { echo $order->mkOrderNo(); } ?>" size="22" /></td>
<td class="tdText"><strong><?php echo $lang['admin_common']['other_customer']; ?></strong></td>
<td class="tdText"><select name="customer_id">
<?php if($orderSum == false) { ?>
<option value="0" <?php if(!$_POST['customer_id'] && $orderSum == false) { echo "selected='selected'"; } ?>>-- <?php echo $lang['admin_common']['na'];?> --</option>
<?php
}
if ($customers == true) {
for ($i=0; $i<count($customers); $i++) {
?>
<option value="<?php echo $customers[$i]['customer_id'];?>"
<?php if($customers[$i]['customer_id']==$_POST['customer_id'] || $customers[$i]['customer_id']==$orderSum[0]['customer_id']){ echo "selected='selected'"; } ?>
onmouseover="$('name').value = '<?php echo $customers[$i]['title'];?> <?php echo $customers[$i]['firstName'];?> <?php echo $customers[$i]['lastName'];?>';findObj('companyName').value = '<?php echo $customers[$i]['companyName'];?>';findObj('add_1').value = '<?php echo $customers[$i]['add_1'];?>';findObj('add_2').value = '<?php echo $customers[$i]['add_2'];?>';findObj('town').value = '<?php echo $customers[$i]['town'];?>';findObj('country').value='<?php echo $countriesArray[$customers[$i]['country']];?>';findObj('postcode').value='<?php echo $customers[$i]['postcode'];?>';findObj('county').value='<?php echo $customers[$i]['county'];?>';findObj('phone').value='<?php echo $customers[$i]['phone'];?>';findObj('mobile').value='<?php echo $customers[$i]['mobile'];?>';findObj('email').value='<?php echo $customers[$i]['email'];?>';"> <?php echo $customers[$i]['lastName'];?>, <?php echo $customers[$i]['firstName'];?> (<?php echo $customers[$i]['customer_id'];?>)</option>
<?php
}
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" class="tdTitle"><?php echo $lang['admin']['orders_billing_info']; ?></td>
<td colspan="2" class="tdTitle"><?php echo $lang['admin']['orders_shipping_info']; ?></td>
</tr>
<tr>
<td class="tdText">&nbsp;</td>
<td class="tdText"><input type="button" name="clear" value="<?php echo $lang['admin']['orders_reset_billing'];?>" onclick="findObj('name').value = '';findObj('companyName').value = '';findObj('add_1').value = '';findObj('add_2').value = '';findObj('town').value = '';findObj('country').value='';findObj('postcode').value='';findObj('county').value='';findObj('phone').value='';findObj('mobile').value='';findObj('email').value='';" class="submit" /></td>
<td class="tdText">&nbsp;</td>
<td class="tdText"><input type="button" name="shipCopy" value="<?php echo $lang['admin']['orders_copy_from_billing']; ?>" onclick="findObj('name_d').value = findObj('name').value;findObj('companyName_d').value = findObj('companyName').value;findObj('add_1_d').value = findObj('add_1').value;findObj('add_2_d').value = findObj('add_2').value;findObj('town_d').value = findObj('town').value;findObj('country_d').value = findObj('country').value;findObj('postcode_d').value = findObj('postcode').value;findObj('county_d').value = findObj('county').value;" class="submit"/></td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_name']; ?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="name" id="name" value="<?php echo $orderSum[0]['name']; ?>" /></td>
<td class="tdText"><strong><?php echo $lang['admin']['orders_name']; ?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="name_d" id="name_d" value="<?php echo $orderSum[0]['name_d']; ?>" /></td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_company_name']; ?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="companyName" id="companyName" value="<?php echo $orderSum[0]['companyName']; ?>" /></td>
<td class="tdText"><strong><?php echo $lang['admin']['orders_company_name']; ?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="companyName_d" id="companyName_d" value="<?php echo $orderSum[0]['companyName_d']; ?>" /></td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_address'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="add_1" id="add_1" value="<?php echo $orderSum[0]['add_1']; ?>" /></td>
<td class="tdText"><strong><?php echo $lang['admin']['orders_address'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="add_1_d" id="add_1_d" value="<?php echo $orderSum[0]['add_1_d']; ?>" /></td>
</tr>
<tr>
<td class="tdText">&nbsp;</td>
<td class="tdText"><input type="text" class="textbox" name="add_2" id="add_2" value="<?php echo $orderSum[0]['add_2']; ?>" /></td>
<td class="tdText">&nbsp;</td>
<td class="tdText"><input type="text" class="textbox" name="add_2_d" id="add_2_d" value="<?php echo $orderSum[0]['add_2_d']; ?>" /></td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_town'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="town" id="town" value="<?php echo $orderSum[0]['town']; ?>" /></td>
<td class="tdText"><strong><?php echo $lang['admin']['orders_town'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="town_d" id="town_d" value="<?php echo $orderSum[0]['town_d']; ?>" /></td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_state'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="county" id="county" value="<?php echo $orderSum[0]['county']; ?>" /></td>
<td class="tdText"><strong><?php echo $lang['admin']['orders_state'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="county_d" id="county_d" value="<?php echo $orderSum[0]['county_d']; ?>" /></td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_postcode'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="postcode" id="postcode" value="<?php echo $orderSum[0]['postcode']; ?>" /></td>
<td class="tdText"><strong><?php echo $lang['admin']['orders_postcode'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="postcode_d" id="postcode_d" value="<?php echo $orderSum[0]['postcode_d']; ?>" /></td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_country'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="country" id="country" value="<?php echo $orderSum[0]['country']; ?>" /></td>
<td class="tdText"><strong><?php echo $lang['admin']['orders_country'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="country_d" id="country_d" value="<?php echo $orderSum[0]['country_d']; ?>" /></td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_phone'];?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="phone" id="phone" value="<?php echo $orderSum[0]['phone']; ?>" /></td>
<td class="tdText">&nbsp;</td>
<td class="tdText">&nbsp;</td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_cell_phone']; ?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="mobile" id="mobile" value="<?php echo $orderSum[0]['mobile']; ?>" /></td>
<td class="tdText">&nbsp;</td>
<td class="tdText">&nbsp;</td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_email']; ?></strong></td>
<td class="tdText"><input type="text" class="textbox" name="email" id="email" value="<?php echo $orderSum[0]['email']; ?>" /></td>
<td class="tdText">&nbsp;</td>
<td class="tdText">&nbsp;</td>
</tr>
<tr>
<td class="tdText">&nbsp;</td>
<td class="tdText">&nbsp;</td>
<td class="tdText">&nbsp;</td>
<td class="tdText">&nbsp;</td>
</tr>
<tr>
<td valign="top" class="tdText"><strong><?php echo $lang['admin']['orders_status']; ?></strong></td>
<td valign="top" class="tdText"><select name="status" class="dropDown">
<?php
for ($i=1; $i<=6; $i++) {
?>
<option value="<?php echo $i; ?>" <?php if($orderSum[0]['status']==$i) { echo "selected='selected'"; } ?>><?php echo $lang['glob']['orderState_'.$i]; ?></option>
<?php
}
?>
</select> </td>
<td valign="top" class="tdText"><strong><?php echo $lang['admin']['orders_shipping_date']; ?></strong></td>
<td class="tdText"><input name="ship_date" type="text" value="<?php echo $orderSum['0']['ship_date']; ?>" class="textbox" id="ship_date" size="25" />
<br />
<?php echo $lang['admin']['orders_ship_today']; ?>
<input name="shipToday" type="checkbox" id="shipToday" value="checkbox" onclick="findObj('ship_date').value = '<?php echo strip_tags(date($config['dateFormat'])); ?>';" /></td>
</tr>
<tr>
<td valign="top" class="tdText"><strong><?php echo $lang['admin']['orders_staff_comments']; ?></strong></td>
<td class="tdText"><textarea name="comments" cols="30" rows="3" class="textbox"><?php echo $orderSum['0']['comments']; ?></textarea></td>
<td valign="top" class="tdText"><strong><?php echo $lang['admin']['orders_ship_method']; ?></strong> </td>
<td valign="top" class="tdText"><input type="text" name="shipMethod" class="textbox" value="<?php echo str_replace("_"," ",$orderSum['0']['shipMethod']); ?>" /></td>
</tr>
<tr>
<td valign="top" class="tdText"><strong><?php echo $lang['admin']['orders_customer_comments']; ?></strong></td>
<td class="tdText"><textarea name="customer_comments" cols="30" rows="3" class="textbox"><?php echo $orderSum['0']['customer_comments']; ?></textarea></td>
<td valign="top" class="tdText">&nbsp;</td>
<td valign="top" class="tdText">&nbsp;</td>
</tr>
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['orders_payment_method']; ?></strong></td>
<td class="tdText">
<?php if(ereg("PayPal Website Payments Pro", $orderSum['0']['gateway'])) { ?>
<input type="hidden" name="gateway" value="<?php echo str_replace("_"," ",$orderSum['0']['gateway']); ?>" />
<?php echo str_replace("_"," ",$orderSum['0']['gateway']); ?>
<?php } else { ?>
<input type="text" name="gateway" class="textbox" value="<?php echo str_replace("_"," ",$orderSum['0']['gateway']); ?>" />
<?php
}
?></td>
<td class="tdText">&nbsp;</td>
<td class="tdText">&nbsp;</td>
</tr>
<tr>
<td colspan="4" align="right" class="tdText"><span class="tdTitle">
<input type="submit" name="submit22" value="<?php if(isset($_GET['edit'])) { echo $lang['admin_common']['edit']; } else { echo $lang['admin_common']['add']; } ?> <?php echo $lang['admin']['orders_order'];?>" class="submit" />
</span></td>
</tr>
</table>
<br />
<table border="0" cellspacing="1" cellpadding="3" class="mainTable" width="100%">
<tr>
<td class="tdTitle"><?php echo $lang['admin']['orders_courier_tracking'];?></td>
</tr>
<tr>
<td valign="top" class="tdText"><strong><?php echo $lang['admin']['orders_courier_tracking_url'];?>:</strong> <br />
<textarea name="courier_tracking" rows="1" class="textbox" style="width: 99%;"><?php echo $orderSum[0]['courier_tracking']; ?></textarea></td>
</tr>
<tr>
<td align="right" class="tdText"><input type="submit" name="submit2" value="<?php if(isset($_GET['edit'])) { echo $lang['admin_common']['edit']; } else { echo $lang['admin_common']['add']; } ?> <?php echo $lang['admin']['orders_order'];?>" class="submit" /></td>
</tr>
</table>
<?php if (!empty($orderSum[0]['offline_capture']) || !isset($_GET['edit'])) { ?>
<br />
<table border="0" cellspacing="1" cellpadding="3" class="mainTable" width="100%">
<tr>
<td class="tdTitle" colspan="2"><?php echo $lang['admin']['orders_card_details'] ?></td>
</tr>
<?php
require("classes".CC_DS."cart".CC_DS."encrypt.inc.php");
//echo $orderSum[0]['offline_capture'];
$decrypt = new encryption(array($orderSum[0]['cart_order_id']));
$card = unserialize($decrypt->decrypt(base64_decode($orderSum[0]['offline_capture'])));
$card = (!empty($card)) ? $card : array('card_type' => '', 'card_number' => '', 'card_expire' => '', 'card_valid' => '', 'card_issue' => '');
foreach ($card as $field => $value) {
echo sprintf('<tr><td class="tdText">%1$s</td><td class="tdText"><input type="text" class="textbox" name="%1$s" value="%2$s" /></td></tr>', $lang['admin']['orders_'.$field], $value);
}
?>
</table>
<?php } ?>
<br />
<table border="0" cellspacing="1" cellpadding="3" class="mainTable" id="productList" width="100%">
<tr>
<td class="tdTitle">&nbsp;</td>
<td class="tdTitle"><?php echo $lang['admin']['orders_product'];?></td>
<td class="tdTitle"><?php echo $lang['admin']['orders_code'];?></td>
<td class="tdTitle"><?php echo $lang['admin']['orders_options'];?></td>
<td align="center" class="tdTitle"><?php echo $lang['admin']['orders_quantity'];?></td>
<td width="150" align="center" class="tdTitle"><?php echo $lang['admin']['orders_price'];?></td>
</tr>
<?php
$rows = (isset($_GET['edit'])) ? count($orderInv) : 1;
if (is_numeric($_POST['prodRowsAdd']) && isset($_POST['prodRowsSubmit'])) $rows=($_POST['prodRowsAdd']+$_POST['currentRowCount']);
for ($i=0; $i<$rows; $i++) {
$cellColor = "";
$cellColor = cellColor($i);
if (!isset($orderInv[$i])) {
$orderInv[$i] = array (
'name' => $_POST['prodName'][$i],
'productCode' => $_POST['productCode'][$i],
'product_options' => $_POST['product_options'][$i],
'quantity' => $_POST['quantity'][$i],
'price' => $_POST['price'][$i],
);
}
?>
<tr id="productItem_<?php echo $i ?>">
<td align="center" valign="top"><?php if ($orderInv[$i]['id']>0) { ?>
<a href="javascript:toggleProdStatus(<?php echo $i; ?>,'<?php echo sprintf($lang['admin']['orders_prod_will_be_removed'],$orderInv[$i]['name']);?>','<?php echo sprintf($lang['admin']['orders_prod_wont_be_removed'],$orderInv[$i]['name']);?>','<?php echo $glob['adminFolder']; ?>/images/del.gif','<?php echo $glob['adminFolder']; ?>/images/no_del.gif');"><img src="<?php echo $glob['adminFolder']; ?>/images/del.gif" id="del[<?php echo $i; ?>]" width="12" height="12" border="0" /></a>
<?php } else { ?>
&nbsp;
<?php } ?> </td>
<td valign="top"><input type="hidden" name="id[<?php echo $i; ?>]" value="<?php echo $orderInv[$i]['id']; ?>" />
<input type="hidden" name="delId[<?php echo $i; ?>]" value="0" />
<input type="text" name="prodName[<?php echo $i; ?>]" class="textbox" value="<?php echo htmlspecialchars($orderInv[$i]['name']); ?>" /></td>
<td valign="top"><input name="productCode[<?php echo $i; ?>]" type="text" class="textbox" value="<?php echo $orderInv[$i]['productCode']; ?>" size="15" /></td>
<td valign="top"><textarea name="product_options[<?php echo $i; ?>]" cols="30" rows="1" class="textbox"><?php echo stripslashes($orderInv[$i]['product_options']); ?></textarea></td>
<td align="center" valign="top"><input name="quantity[<?php echo $i; ?>]" type="text" class="textbox" style="text-align:center;" value="<?php echo $orderInv[$i]['quantity']; ?>" size="3" /></td>
<td width="150" align="center" valign="top"><input name="price[<?php echo $i; ?>]" type="text" class="textbox" style="text-align:right;" value="<?php echo $orderInv[$i]['price']; ?>" size="7" /></td>
</tr>
<tr id="productItem_<?php echo $i ?>">
<td align="center" valign="top">&nbsp;</td>
<td colspan="5" valign="top">
<?php if ($orderInv[$i]['digital'] && empty($orderInv[$i]['couponId'])) {
// get digital info
$query = "SELECT D.* FROM ".$glob['dbprefix']."CubeCart_Downloads AS D INNER JOIN ".$glob['dbprefix']."CubeCart_inventory AS I ON D.productId = I.productId WHERE D.cart_order_id = ".$db->mySQLSafe($_GET['edit'])." AND D.productId = ".$db->mySQLSafe($orderInv[$i]['productId']);
$download = $db->select($query);
?>
<hr />
<strong><?php echo $lang['admin']['orders_download_link']; ?></strong> [<a href="<?php echo $glob['adminFile']; ?>?_g=orders/orderBuilder&amp;edit=<?php echo $_GET['edit']; ?>&amp;reset=<?php echo $download[0]['id'];?>" class="txtLink" onclick="alert('<?php echo $lang['admin']['orders_warn_reset'];?>')"><?php echo $lang['admin']['orders_reset_link'];?></a>]
<br />
<?php
echo $glob['storeURL']."/index.php?_g=dl&pid=".$download[0]['productId']."&oid=".base64_encode($_GET['edit'])."&ak=".$download[0]['accessKey']
?>
<br />
<i><?php echo sprintf($lang['admin']['orders_download_stats'], $download[0]['noDownloads'], formatTime($download[0]['expire'])); ?></i>
<?php } ?>
</span> </td>
</tr>
<?php
}
?>
</table>
<input type="hidden" id="rowCount" value="<?php echo $rows ?>" />
<table border="0" cellspacing="1" cellpadding="3" class="mainTable" width="100%" style="border-top: none;">
<tr>
<td class="tdText"><input type="hidden" name="currentRowCount" value="<?php echo $rows; ?>" />
<?php echo $lang['admin_common']['add'];?>
<input type="text" name="prodRowsAdd" id="prodRowsAdd" value="1" size="2" style="text-align: center;" class="textbox" />
<input type="submit" name="prodRowsSubmit" value="Product Rows" class="submit" onclick="return addRows('productList', 'prodRowsAdd')" /></td>
<td align="right" class="tdText"><?php echo $lang['admin']['orders_subtotal']; ?></td>
<td width="150" align="center"><input name="subtotal" id="subtotal" type="text" class="textbox" style="text-align:right;" value="<?php echo $orderSum[0]['subtotal']; ?>" size="7" /></td>
</tr>
<tr>
<td rowspan="4">&nbsp;</td>
<td align="right" class="tdText"><?php echo $lang['admin']['orders_discount']; ?></td>
<td width="150" align="center"><input name="discount" id="discount" type="text" class="textbox" style="text-align:right;" value="<?php echo $orderSum[0]['discount']; ?>" size="7" /></td>
</tr>
<tr>
<td align="right" class="tdText"><?php echo $lang['admin']['orders_shipping']; ?></td>
<td width="150" align="center"><input name="total_ship" type="text" class="textbox" style="text-align:right;" value="<?php echo $orderSum[0]['total_ship']; ?>" size="7" /></td>
</tr>
<tr>
<td align="right" class="tdText"><?php echo $lang['admin']['orders_total_tax']; ?></td>
<td width="150" align="center"><input name="total_tax" id="total_tax" type="text" class="textbox" style="text-align:right;" value="<?php echo $orderSum[0]['total_tax']; ?>" size="7" /></td>
</tr>
<tr>
<td align="right" class="tdText"><?php echo $lang['admin']['orders_grand_total']; ?></td>
<td width="150" align="center"><input name="prod_total" id="prod_total" type="text" class="textbox" style="text-align:right;" value="<?php echo $orderSum[0]['prod_total']; ?>" size="7" /></td>
</tr>
<tr>
<td colspan="2" align="right">&nbsp;</td>
<td align="right"><input type="submit" name="submit" value="<?php if(isset($_GET['edit'])) { echo $lang['admin_common']['edit']; } else { echo $lang['admin_common']['add']; } ?> <?php echo $lang['admin']['orders_order'];?>" class="submit" /></td>
</tr>
</table>
</form>
<?php
// This is ONLY availble in English right now as this functionality was added after the language files wer being trasnlated.
// Yes... Al is an idiot. A big smelly idiot with no friends and a stupid haircut which makes him look like he has a disease.
if(ereg("PayPal Website Payments Pro", $orderSum['0']['gateway'])) {
$lang = getLang("admin".CC_DS."admin_order_transactions.inc.php");
$query = sprintf("SELECT * FROM %sCubeCart_transactions WHERE order_id = %s AND `status` = 'SUCCESS' ORDER BY time ASC", $glob['dbprefix'], $db->mySQLsafe($_GET['edit']));
$results = $db->select($query);
$thisPage = currentPage(array("PayPal-Pro"=>0, "form"=>0));
?><p class="pageTitle">PayPal Website Payments Pro Functionality</p>
<p>The functions below are specifically for orders purchased with PayPal Express Checkout without the need to login to your PayPal account.</p>
<?php
function doVoidForm ($authorizationID, $id, $TENDER) {
global $thisPage;
$htmlOut = "<form action='".$thisPage."&amp;PayPal-Pro=doVoidAuth".$id."#ppresult' id='doVoidForm".$id."' method='post' enctype='multipart/form-data'>
<strong>Void Authorization ID: `".$authorizationID."`</strong>
<p>
<strong>Message to customer:</strong><br />
<textarea name='note' cols='35' rows='3' class='textbox'>Please visit again soon.</textarea>
</p>
<input type='hidden' name='TENDER' value='".$TENDER."' />
<input type='hidden' name='authorization_id' value='".$authorizationID."' />
<input type='hidden' name='id' value='".$id."' />
<input type='submit' name='order_void' class='submit' value='Void Now' />
</form>";
return $htmlOut;
}
function doCaptureForm ($authorizationID, $exampleAmount, $id, $TENDER, $remainder) {
global $thisPage,$module;
$maxAmount = sprintf("%.2f",$exampleAmount - $remainder);
$htmlOut = "<form action='".$thisPage."&amp;PayPal-Pro=doCapture".$id."#ppresult' id='doCaptureForm".$id."' method='post' enctype='multipart/form-data'>
<p><strong>Capture all or part of Authorization ID `".$authorizationID."`</strong></p>
<strong>Final Capture:</strong><select name='CompleteCodeType' class='textbox'>
<option value='NotComplete'>No</option>
<option value='Complete'>Yes (If selected no further captures can be made)</option>
</select>
<p><strong>Capture Amount:</strong>
<input name='amount' type='text' class='textbox' id='amount' onclick='this.value=\"\"' value='e.g. &quot;".$maxAmount."&quot;' size='10' /></p>";
if($remainder>0) {
$htmlOut .= "(Max: ".$maxAmount.") ".sprintf("%.2f",$remainder)." has already been captured from this transaction.";
}
$htmlOut .= "<p><strong>Message to customer:</strong><br />
<textarea name='note' cols='35' rows='3' class='textbox'>Many thanks for your order.
</textarea></p>
<input type='submit' name='order_capture' class='submit' value='Capture Now' />
<input type='hidden' name='authorizationID' value='".$authorizationID."' />
<input type='hidden' name='TENDER' value='".$TENDER."' />
<input type='hidden' name='id' value='".$id."' />
</form>";
return $htmlOut;
}
function doReAuthForm ($originalAuthorizationID, $exampleAmount,$id, $TENDER) {
global $thisPage;
$htmlOut = "<form action='".$thisPage."&amp;PayPal-Pro=doReAuth".$id."#ppresult' id='doReAuthForm".$id."' method='post' enctype='multipart/form-data'>
<p><strong>Reauthorize ID `".$originalAuthorizationID."`</strong></p>
<strong>Reauthorization Amount:</strong> <input name='amount' type='text' class='textbox' id='amount' onclick='this.value=\"\"' value='e.g. &quot;".$exampleAmount."&quot;' size='10' />
<input type='hidden' name='authorizationID' value='".$originalAuthorizationID."' />
<input type='hidden' name='TENDER' value='".$TENDER."' />
<p><input type='submit' name='order_auth' class='submit' value='ReAuthorize Now' /></p>
</form>";
return $htmlOut;
}
function doAuthForm ($originalAuthorizationID, $exampleAmount,$id, $TENDER) {
global $thisPage;
$htmlOut = "<form action='".$thisPage."&amp;PayPal-Pro=doAuth".$id."#ppresult' id='doAuthForm".$id."' method='post' enctype='multipart/form-data'>
<p><strong>Authorize ID `".$originalAuthorizationID."`</strong></p>
<strong>Authorization Amount:</strong> <input name='amount' type='text' class='textbox' id='amount' onclick='this.value=\"\"' value='e.g. &quot;".$exampleAmount."&quot;' size='10' />
<input type='hidden' name='authorizationID' value='".$originalAuthorizationID."' />
<input type='hidden' name='TENDER' value='".$TENDER."' />
<p><input type='submit' name='order_auth' class='submit' value='Authorize Now' /></p>
</form>";
return $htmlOut;
}
function doRefundForm ($transactionId,$exampleAmount,$id, $TENDER) {
global $thisPage;
$htmlOut = "<form action='".$thisPage."&amp;PayPal-Pro=doRefund".$id."#ppresult' id='doRefundForm".$id."' method='post' enctype='multipart/form-data'>
<p><strong>Refund all or partial amount of transaction ID `".$transactionId."`</strong></p>
<strong>Refund Amount:</strong><br />
<input name='amount' type='text' class='textbox' id='amount' onclick='this.value=\"\"' value='e.g. &quot;".$exampleAmount."&quot;' size='10' />
<p><strong>Message to customer</strong>:<br />
<textarea name='note' cols='35' rows='3' class='textbox'>Payment for order number ".$_GET['edit']." has been refunded. </textarea></p>
<input type='hidden' name='transactionId' value='".$transactionId."' />
<input type='hidden' name='TENDER' value='".$TENDER."' />
<input type='hidden' name='id' value='".$id."' />
<input type='submit' name='order_refund' class='submit' value='Refund Now' />
</form>";
return $htmlOut;
}
?>
<?php if (isset($ppMsg)) echo $ppMsg; ?>
<table width="100%" cellspacing="1" cellpadding="3" class="mainTable">
<tr>
<td align="center" class="tdTitle" width="50%">Details</td>
<td align="center" class="tdTitle" width="50%">Action</td>
</tr>
<?php
if ($results==true) {
for ($i=0; $i<count($results); $i++) {
$cellColor = cellColor($i);
?>
<tr>
<td class="<?php echo $cellColor; ?> copyText" valign="top" width="50%">
<strong>Time:</strong> <?php echo formatTime($results[$i]['time']); ?><br />
<strong>Action:</strong> <?php echo $results[$i]['gateway']; ?><br />
<strong>Transaction Id:</strong> <?php echo $results[$i]['trans_id']; ?><br />
<?php if($results[$i]['amount']>0) { ?><strong>Amount:</strong> <?php echo priceFormat($results[$i]['amount'],true); ?><br /><?php } ?>
<strong>Notes:</strong> <?php echo $results[$i]['notes']; ?></td>
<td class="<?php echo $cellColor; ?> copyText" width="50%">
<?php
$action = false;
$links = "<div style='text-align: center;'>";
switch ($results[$i]['gateway']) {
case "PayPal Website Payments Pro (Authorization)":
case "PayPal Website Payments Pro (Order)":
if($results[$i]['amount'] > $results[$i]['remainder']) {
$links .= "<a href='".$thisPage."&amp;form=doCaptureForm".$results[$i]['id']."#doCaptureForm".$results[$i]['id']."' class='txtLink'>Capture</a> | ";
$action = true;
// reauth only possible if the initial auth is three days old or more
$threeDaysAgo = time()-259200;
if($results[$i]['time']<$threeDaysAgo) {
$links .= "<a href='".$thisPage."&amp;form=doReAuthForm".$results[$i]['id']."#doReAuthForm".$results[$i]['id']."' class='txtLink'>ReAuthorize</a> | ";
}
if($results[$i]['gateway']=="PayPal Website Payments Pro (Order)") {
$links .= "<a href='".$thisPage."&amp;form=doAuthForm".$results[$i]['id']."#doAuthForm".$results[$i]['id']."' class='txtLink'>Authorize</a> | ";
}
$links .= "<a href='".$thisPage."&amp;form=doVoidForm".$results[$i]['id']."#doVoidForm".$results[$i]['id']."' class='txtLink'>Void</a> | ";
echo substr($links,0,-2)."</div>";
if($_GET['form']=="doCaptureForm".$results[$i]['id'] && !isset($_POST['order_capture'])) {
echo "<hr size='1' />";
echo doCaptureForm($results[$i]['trans_id'],$results[$i]['amount'],$results[$i]['id'], $results[$i]['extra'], $results[$i]['remainder']);
} elseif($_GET['form']=="doVoidForm".$results[$i]['id'] && !isset($_POST['order_void'])) {
echo "<hr size='1' />";
echo doVoidForm ($results[$i]['trans_id'], $results[$i]['id'], $results[$i]['extra']);
} elseif($_GET['form']=="doReAuthForm".$results[$i]['id'] && !isset($_POST['order_auth'])) {
echo "<hr size='1'/>";
echo doReAuthForm($results[$i]['trans_id'],$results[$i]['amount'],$results[$i]['id'], $results[$i]['extra']);
} elseif($_GET['form']=="doAuthForm".$results[$i]['id'] && !isset($_POST['order_auth'])) {
echo "<hr size='1'/>";
echo doAuthForm($results[$i]['trans_id'],$results[$i]['amount'],$results[$i]['id'], $results[$i]['extra']);
}
}
break;
case "PayPal Website Payments Pro (Sale)":
case "PayPal Website Payments Pro (DoCapture)":
if($results[$i]['amount'] > $results[$i]['remainder']) {
echo " <div style='text-align: center;'><a href='".$thisPage."&amp;form=doRefundForm".$results[$i]['id']."#doRefundForm".$results[$i]['id']."' class='txtLink'>Refund</a></div> ";
if($_GET['form']=="doRefundForm".$results[$i]['id'] && !isset($_POST['order_refund'])) {
echo "<hr />";
echo doRefundForm($results[$i]['trans_id'],$results[$i]['amount'],$results[$i]['id'], $results[$i]['extra']);
}
$action = true;
}
break;
/*
case "PayPal Website Payments Pro (DoRefund)":
echo "&nbsp;";
break;
*/
case "PayPal Website Payments Pro (DoAuthorization)":
$action = true;
$links .= "<a href='".$thisPage."&amp;form=doCaptureForm".$results[$i]['id']."#doCaptureForm".$results[$i]['id']."' class='txtLink'>Capture</a> | ";
$links .= "<a href='".$thisPage."&amp;form=doReAuthForm".$results[$i]['id']."#doReAuthForm".$results[$i]['id']."' class='txtLink'>ReAuthorize</a> | ";
$links .= "<a href='".$thisPage."&amp;form=doVoidForm".$results[$i]['id']."#doVoidForm".$results[$i]['id']."' class='txtLink'>Void</a> | ";
echo substr($links,0,-2)."</div>";
if($_GET['form']=="doCaptureForm".$results[$i]['id'] && !isset($_POST['order_capture'])) {
echo "<hr size='1' />";
echo doCaptureForm($results[$i]['trans_id'],$results[$i]['amount'],$results[$i]['id'], $results[$i]['extra'], $results[$i]['remainder']);
} elseif($_GET['form']=="doVoidForm".$results[$i]['id'] && !isset($_POST['order_void'])) {
echo "<hr size='1' />";
echo doVoidForm ($results[$i]['trans_id'], $results[$i]['id'], $results[$i]['extra']);
} elseif($_GET['form']=="doReAuthForm".$results[$i]['id'] && !isset($_POST['order_auth'])) {
echo "<hr size='1'/>";
echo doReAuthForm($results[$i]['trans_id'],$results[$i]['amount'],$results[$i]['id'], $results[$i]['extra']);
}
break;
/*
case "PayPal Website Payments Pro (DoVoid)":
echo "&nbsp;";
break;
*/
}
if($action==false) echo "<div style='text-align: center;'>Complete</div>";
?> </td>
</tr>
<?php
}
}
?>
</table>
<?php
}
?>