View Single Post
  #2  
Old 11-17-2011, 05:10 PM
 
chiactivate chiactivate is offline
 

Senior Member
  
Join Date: Feb 2007
Location: Canada
Posts: 148
 

Wink Re: Show Order Details For (4.4.4) / Detail order management

It Works in 4.4.4 as Well!! Files are located in different directories, so I had to make some changes.

Here is the complete code for the first part:

your_xcart_dir/skin/common_files/main/order_info.tpl

After:

Quote:
{include file="main/subheader.tpl" title=$lng.lbl_products_info}

Add:
Quote:

{* genbilim *}
<script language=javascript src="../skin/common_files/js/copy_addr.js"></script>
{* genbilim-end *}


../skin/common_files/main/order_info.tpl

After:

Quote:
<td colspan="2"> <br /><i>{$lng.lbl_shipping_address}:</i></td>

Add:

Quote:
{* genbilim *}
{if $usertype eq "A"}

<a href="javascript :void(0)"
ship_to="{$order.s_title}{$order.s_firstname} {$order.s_lastname}"
ship_address="{$order.s_address}"
ship_city="{$order.s_city}"
ship_state="{$order.s_state}"
ship_country="{$order.s_country}"
ship_zipcode="{$order.s_zipcode}"
onclick="copyShipAddr(this, true);return false;">
<img src="{$ImagesDir}/copy.gif" border=0 align=absmiddle>Copy To Clipboard</a>
{/if}
</td>
</tr>

<tr valign="top">
<td width="31%">{if $customer.default_fields.s_firstname}&nbsp;&nbsp;{ $lng.lbl_first_name}{/if}</td>
<td width="13%">{if $customer.default_fields.s_firstname}{$customer.s_ firstname}{/if}</td>
<td width="55%" rowspan="10" align="center">
{* genbilim *}
{if $usertype eq "A"}

<a href="javascript:void(0)"
ship_to="{$order.s_title}{$order.s_firstname} {$order.s_lastname}"
ship_address="{$order.s_address}"
ship_city="{$order.s_city}"
ship_state="{$order.s_state}"
ship_country="{$order.s_country}"
ship_zipcode="{$order.s_zipcode}"
onclick="copyAddrToField(this);return false;">
<img src="{$ImagesDir}/copy.gif" border=0 align=absmiddle>Copy To Field</a>

<br>
<textarea cols=40 rows=6 id=ship_addr>
</textarea>
{/if}
{* genbilim-end *}

../skin/common_files/main/orders_list.tpl

After:

Quote:
{assign var="total_paid" value=0.00}

Add:
Quote:
{*
genbilim :
Javascript functions to copy the address to the clipboard
*}

<script language=javascript src="../skin/common_files/js/copy_addr.js"></script>
<div id="DIV_CopyInform" style="display:none;"></div>
{* genbilim-end *}

../skin/common_files/main/orders_list.tpl

Before:

Quote:
{section name=oid loop=$orders}
Add:
Quote:
{* genbilim
New column for admins to copy the address to the clipboard *}
{if $usertype eq 'A'}
<td align=center width=50>Copy&nbsp;Address</td>
{/if}
{* genbilim-end *}

../skin/common_files/main/orders_list.tpl

After:

Quote:
<a href="order.php?orderid={$orders[oid].orderid}">{currency value=$orders[oid].total}</a>
</td>
</tr>


Add:

Quote:
{* genbilim *}
{if $usertype eq 'A'}
<td align=center ><a href="javascript:void(0)"
ship_to="{$orders[oid].s_title}{$orders[oid].s_firstname} {$orders[oid].s_lastname}"
ship_address="{$orders[oid].s_address}"
ship_city="{$orders[oid].s_city}"
ship_state="{$orders[oid].s_state}"
ship_country="{$orders[oid].s_country}"
ship_zipcode="{$orders[oid].s_zipcode}"
onclick="copyShipAddr(this, false);return false;">
<img src="{$ImagesDir}/copy.gif" border=0 align=absmiddle></a></td>
{/if}
</TR>
<tr>
<td colspan=3></td>
<td colspan=4>
<table width=100% cellpadding=5 style="border-collapse:collapse" border=0>
<tr bgcolor=#DDDDCC>
<td>Ship To</td>
<td>Product</td>
<td>Code</td>
<td align=center>Amount</td>


{if $usertype eq 'A'}
<td align=center>Stock</td>
{/if}


</tr>
{foreach item=item from=$orders[oid].item_list}
<tr bgcolor=#CCCCDD>


<td width="30%" nowrap="nowrap">{$orders[oid].s_firstname} {$orders[oid].s_lastname}</td>
<td width="40%" nowrap="nowrap">{$item.product}</td>
<td width="10%" nowrap="nowrap">{$item.productcode}</td>
<td width="10%" nowrap="nowrap" align=center>{$item.amount}</td>
{if $usertype eq 'A'}
<td width="10%" nowrap="nowrap" align=center>{$item.avail}</td>
{/if}


</tr>
{/foreach}
</table>
</td>
</tr>
<TR>
<TD style="padding-top:3px;border-bottom:1px solid black" colspan=12>&nbsp;</TD>
</TR>
<TR>
<TD style="padding-top:3px;" colspan=12>&nbsp;</TD>
{* genbilim-end *}


in your xcart directory:
../skin/common_files/js

Create copy_addr.js file

Add:

Quote:
var attributes = ['to', 'address', 'city', 'state', 'country', 'zipcode'];
var addrFormat =
"{to}\r\n" +
"{address}\r\n" +
"{city} {state}, {zipcode}";
function findPos(obj)
{
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
function removeInformation()
{
var div = document.getElementById('DIV_CopyInform');
if (! div)
return;
div.style.display = 'none';
div.innerHTML = '';
}

function getAddr(aObj)
{
var str = addrFormat;
for(var i=0; i<attributes.length; i++)
{
var na = 'ship_' + attributes[i];
var val= aObj.getAttribute(na);
if (typeof val != "undefined")
str = str.replace('{' + attributes[i] + '}', aObj.getAttribute(na));
}

return str;
}

function copyAddrToField(aObj)
{
document.getElementById('ship_addr').value = getAddr(aObj);
document.getElementById('ship_addr').focus();
document.getElementById('ship_addr').select();
}

function copyShipAddr(aObj, quickCopy)
{

var str = getAddr(aObj);

if (str.length > 0 )
{
if (! document.getElementById('DIV_CopyInform') )
document.getElementsByTagName('DIV')[0].innerHTML += '<div id="DIV_CopyInform" style="display:none;"></div>';
var div = document.getElementById('DIV_CopyInform');
div.style.position = 'absolute';
div.innerHTML = '';
div.style.left = (findPos(aObj)[0] + aObj.offsetWidth) + 'px';
div.style.top = findPos(aObj)[1] + 'px';
try
{
if (! quickCopy)
// make it throw an exception
genbilim.style = 'dummy';
window.clipboardData.setData("Text", str);

// Inform the user
div.style.width = '75px';

div.style.backgroundColor = 'pink';
div.style.padding = '3px';
div.style.color = 'black';
div.style.border= '1px solid black';
div.innerHTML = 'Copied';
div.style.display = 'inline';

setTimeout('removeInformation()', 1000);
}
catch(e)
{
div.style.left = (findPos(aObj)[0] + aObj.offsetWidth - 300 - 10 ) + 'px';
div.style.top = (findPos(aObj)[1] + aObj.offsetHeight) + 'px';
div.style.backgroundColor = '#DDDDCC';
div.style.padding = '5px';
div.style.color = 'black';
div.style.border= '1px solid black';
div.style.display = 'inline';
div.innerHTML =
'<table width=300 >' +
'<tr><td align=right><a href="javascript :void(0)" onclick="removeInformation()">Close</a></td></tr>' +
'<tr><td>You can copy (Ctrl+C) the adress manually</td></tr> '+
'<tr><td><textarea id=addr_ta rows=6 cols=50 >' + str + '</textarea></td></tr>';
document.getElementById('addr_ta').focus();
document.getElementById('addr_ta').select();
}
}
}
Open this file: …/include/orders.php

After:


Quote:
$orders = func_query("SELECT $sql_tbl[orders].* $search_condition ORDER BY $sort_string LIMIT $first_page, $objects_per_page");


Add:

Quote:
# genbilim
#
# Get the details of each order
#
require_once($xcart_dir . "/include/orders_genbilim.php");
#
# genbilim-end

In this directory: …/include/

create
orders_genbilim.php file

Add:

Quote:
<?php
for($i=0; $i<count($orders); $i++)
{
$items = func_query("SELECT od.productid, od.amount, od.productcode,p.product, p.avail
FROM xcart_order_details od
LEFT OUTER JOIN xcart_products p ON p.productid = od.productid
WHERE od.orderid = " . $orders[$i]['orderid']);
$orders[$i]['item_list'] = $items;
}
?>

That's All for part one. The color part to be continued....
__________________
www.ChiMassager.com
X-cart Version 4.44

www.SEOMarketing30days.com
--> Download FREE SEO marketing Ebook (valued $50)
Attract more visitors and sales with top 5 most powerful SEO marketing strategies. Converting visitors into buyers, not just traffic!
Reply With Quote