View Single Post
  #2  
Old 06-04-2007, 08:58 PM
 
Berto Berto is offline
 

Member
  
Join Date: Mar 2007
Posts: 19
 

Default Re: PO Numbers on Invoices, Searchable in Orders.

Step 2: Add this to the bottom of xcart_root_folder/include/func/func.db.php: --(See reply #6 for a fix.)

Code:
function getPONum($o_details) { if (strpos($o_details, "PO Number") > -1) { $po_number_arr = explode(' ',$o_details); for ($int=0; $int<count($po_number_arr); $int++) { if ((strpos($po_number_arr[$int], "PO") > -1)&&(strpos($po_number_arr[$int + 1], "Number") > -1)) { $po_num = $po_number_arr[$int + 2]; break; } } return $po_num; } else { return ""; } }


Step 3: The above will not work if there are spaces in the PO Number, so modify xcart_root_folder/skin1/customer/main/payment_po.tpl:
Add this script after the "required fields" script (just before the table tag):
Code:
{literal} <script type="text/javascript"> <!-- function ckFld() { var fld = document.checkout_form.PO_Number; if (fld.value.indexOf(' ') > -1) { alert('There can be no spaces in this field.'); fld.value = fld.value.replace(' ',''); fld.focus(); } } --> </script> {/literal}
and change this line:
Code:
<input type="text" size="32" id="PO_Number" name="PO_Number" />
to this:
Code:
<input type="text" size="32" id="PO_Number" name="PO_Number" onChange="ckFld();" />


Step 4: Find the array in xcart_root_folder/include/func/func_order.php that begins:
Code:
$insert_data = array (
and insert "po_number" at the end of it (around line 579) by replacing this:
Code:
'extra' => addslashes(serialize($_extra)));
with the following, so that the last two lines in the array read:
Code:
'extra' => addslashes(serialize($_extra)), 'po_number' => addslashes(getPONum($order_details)));


Step 5: Modify xcart_root_folder/include/orders.php:

Find the array:
Code:
$advanced_options = array("orderid1", "orderid2", "total_max", "payment_method", "shipping_method", "status", "provider", "features", "product_substring", "productcode", "productid", "price_max", "customer", "address_type", "phone", "email");
and replace it with this to add "po_number" so that it reads:
Code:
$advanced_options = array("orderid1", "orderid2", "total_max", "payment_method", "po_number", "shipping_method", "status", "provider", "features", "product_substring", "productcode", "productid", "price_max", "customer", "address_type", "phone", "email");

In the same file, find:
Code:
if (!empty($sort) && in_array($sort, array("orderid","status","customer","date","provider", "total"))) {
and change it to include "po_number" as well, to read:
Code:
if (!empty($sort) && in_array($sort, array("orderid","status","customer","date","po_number","provider", "total"))) {

Then, find this "if" clause (around line 182):
Code:
# Search by payment method if (!empty($data["payment_method"])) $search_condition .= " AND $sql_tbl[orders].payment_method LIKE '".$data["payment_method"]."%'";
keep it there and add another search clause below it, (before "# Search by shipping method"):
Code:
# Search by po number if (!empty($data["po_number"])) $search_condition .= " AND $sql_tbl[orders].po_number LIKE '%".$data["po_number"]."%'";

The last mod on this file is to find this case (around line 420):
Code:
case "date": $sort_string = "$sql_tbl[orders].date $direction"; break;
keep it there and add this case below it:
Code:
case "po_number": // added for po number $sort_string = "($sql_tbl[orders].po_number + 0) $direction"; break;


Step 6: In the file xcart_root_folder/admin/order.php, find this line (around line 190):
Code:
$query_data['details'] = func_crypt_order_details($details);
and add this line directly under it:
Code:
$query_data['po_number'] = getPOnum($details);


Step 7: Edit the file xcart_root_folder/skin1/mail/html/order_invoice.tpl:

Find this line:
Code:
<b>{$lng.lbl_payment_method}:</b><br />{$order.payment_method}<br /><b>{$lng.lbl_delivery}:</b><br />{$order.shipping|trademark|default:$lng.txt_not_available}
and change it to:
Code:
<b>{$lng.lbl_payment_method}:</b><br />{$order.payment_method}<br /><b>{$lng.lbl_po_number}:</b> {$order.po_number}<br /><b>{$lng.lbl_delivery}:</b><br />{$order.shipping|trademark|default:$lng.txt_not_available}


Step 8: Edit the file xcart_root_folder/skin1/main/order_info.tpl:

After the table row:
Code:
<tr> <td valign="top">{$lng.lbl_payment_method}</td> <td valign="top">{$order.payment_method}</td> </tr>
add this new table row:
Code:
<tr> <td valign="top">{$lng.lbl_po_number}</td> <td valign="top">{$order.po_number}</td> </tr>


Step 9: Edit the file xcart_root_folder/skin1/main/order_list.tpl:

Find the section:
Code:
<tr class="TableHead"> <td width="5">&nbsp;</td> <td width="5%" nowrap="nowrap">{if $search_prefilled.sort_field eq "orderid"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=orderid">#</a></td> <td nowrap="nowrap">{if $search_prefilled.sort_field eq "status"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=status">{$lng.lbl_status}</a></td> <td width="30%" nowrap="nowrap">{if $search_prefilled.sort_field eq "customer"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=customer">{$lng.lbl_customer}</a></td> {if $usertype eq "A" and $single_mode eq ""} {assign var="colspan" value=7} <td width="20%" nowrap="nowrap">{if $search_prefilled.sort_field eq "provider"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=provider">{$lng.lbl_provider}</a></td> {/if} <td width="20%" nowrap="nowrap">{if $search_prefilled.sort_field eq "date"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=date">{$lng.lbl_date}</a></td> <td width="20%" align="right" nowrap="nowrap">{if $search_prefilled.sort_field eq "total"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=total">{$lng.lbl_total}</a></td> </tr>
and replace it with this:
Code:
<tr class="TableHead"> <td width="5">&nbsp;</td> <td width="5%" nowrap="nowrap">{if $search_prefilled.sort_field eq "orderid"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=orderid">#</a></td> <td nowrap="nowrap">{if $search_prefilled.sort_field eq "status"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=status">{$lng.lbl_status}</a></td> <td width="35%" nowrap="nowrap">{if $search_prefilled.sort_field eq "customer"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=customer">{$lng.lbl_customer}</a></td> {if $usertype eq "A" and $single_mode eq ""} {assign var="colspan" value=7} <td width="20%" nowrap="nowrap">{if $search_prefilled.sort_field eq "provider"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=provider">{$lng.lbl_provider}</a></td> {/if} <td width="20%" nowrap="nowrap">{if $search_prefilled.sort_field eq "date"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=date">{$lng.lbl_date}</a></td> <td width="15%" nowrap="nowrap">{if $search_prefilled.sort_field eq "po_number"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=po_number">{$lng.lbl_po_number}</a></td> <td width="10%" align="right" nowrap="nowrap">{if $search_prefilled.sort_field eq "total"}{include file="buttons/sort_pointer.tpl" dir=$search_prefilled.sort_direction}&nbsp;{/if}<a href="orders.php?mode=search&amp;sort=total">{$lng.lbl_total}</a></td> </tr>

Find this line:
Code:
<td nowrap="nowrap"><a href="order.php?orderid={$orders[oid].orderid}">{$orders[oid].date|date_format:$config.Appearance.datetime_format}</a></td>
and add this line directly under it:
Code:
<td nowrap="nowrap"><a href="order.php?orderid={$orders[oid].orderid}">{$orders[oid].po_number}</a></td>


Step 10: Edit the file xcart_root_folder/skin1/main/orders.tpl:

Find the line:
Code:
var searchform_def = [
and at the end of that entire array insert:
Code:
['posted_data[po_number]', '']
after the 'posted_data[status]' line.

Now find the table row:
Code:
<tr> <td class="FormButton" nowrap="nowrap">{$lng.lbl_payment_method}:</td> <td width="10">&nbsp;</td> <td> <select name="posted_data[payment_method]" style="width:70%"> <option value=""></option> {section name=pm loop=$payment_methods} <option value="{$payment_methods[pm].payment_method}"{if $search_prefilled.payment_method eq $payment_methods[pm].payment_method} selected="selected"{/if}>{$payment_methods[pm].payment_method}</option> {/section} </select> </td> </tr>
and add this row after it:
Code:
<tr> <td class="FormButton" nowrap="nowrap">{$lng.lbl_po_number}:</td> <td width="10">&nbsp;</td> <td> <input type="text" name="posted_data[po_number]" size="30" value="{$search_prefilled.po_number}" style="width:70%" /> </td> </tr>


That's it.
__________________
Russell
X-cart Version 4.1.9 [linux]

Last edited by Berto : 06-09-2007 at 02:05 PM. Reason: New function created for step 2
Reply With Quote