Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

extra field in invoice


pereztroff

Recommended Posts

Hello I add a extra field in table customers, all is ok, but I donk know how show this extra field in invoice.php the data are in table customers, but I think invoice.php use data of table orders

 

any idea how to do? thanks

Link to comment
Share on other sites

Hello I add a extra field in table customers, all is ok, but I donk know how show this extra field in invoice.php the data are in table customers, but I think invoice.php use data of table orders

 

any idea how to do? thanks

 

Hi Pereztrff,

 

If i understood you right, you have installed Customers Extra fields, then I can share what i have.

 

Here is the code from my invoce catalog/print_my_invocie.php:

 

<!-- PRINT EXTRA FIELDS CODE STARTS HERE //-->
<?php
    $orders_extrafields_query = tep_db_query("SELECT DISTINCT o.customers_id, cte.value, efi.fields_name, o.customers_name FROM "
.TABLE_EXTRA_FIELDS_INFO. " efi INNER JOIN " .TABLE_CUSTOMERS_TO_EXTRA_FIELDS. " cte ON (efi.fields_id = cte.fields_id) INNER JOIN "
.TABLE_ORDERS. " o ON (cte.customers_id = o.customers_id) WHERE (efi.languages_id = '".$languages_id."') AND (o.customers_id ='".$customer_info['customers_id']."') ORDER BY cte.fields_id ASC");
		    if (tep_db_num_rows($orders_extrafields_query)) {
				    $has_extrafields = false;			  
				    echo '  ';
				    echo '		  <tr>';
				    echo '				  <td class="smallTextBlue"><strong>' . TABLE_HEADING_EXTRAFIELDS . ':</strong><br><br></td>';
				    echo '		  </tr>';

				    while ($orders_extrafields = tep_db_fetch_array($orders_extrafields_query)) {
						    if (tep_not_null($orders_extrafields['value'])) {
								    $has_extrafields = true;// Not Null = Has Extra Fields
								    if (tep_not_null($orders_extrafields['value'])) {
										    $exInfo = new objectInfo($orders_extrafields);
										    echo '<tr>';
										    echo '  <td class="smallTextBlue">    ';
										    echo '		  <strong>' . nl2br(tep_db_output($orders_extrafields['fields_name']))
.':</strong><br /><span class="smallText">        ' . nl2br(tep_db_output($orders_extrafields['value'])) . '</span><br>';
										    echo '  </td>';
										    echo '</tr>';				  

								    }
						    }
				    }
					 if ($has_extrafields == false) {

							  echo '<tr>';
							  echo '</tr>';
					 }
							  echo '<tr>';
							  echo '</tr>';
							  echo '';
		    }
?>
<!-- PRINT EXTRA FIELDS CODE ENDS HERE //-->

 

 

Hope this helps.

Link to comment
Share on other sites

I check and this file dont exist in my oscommerce.

In folder admin I have the file invoice.php that show data, but the query is crate in file order.php (folder class). I check and all data is a query to table orders, then how I can get the field extra from the table customers?

 

I dont know how to do the query and add to show in the invoice.

 

thanks

Link to comment
Share on other sites

Ok.

 

I have made a quick invoice with extra fields inside, just replace yours admin/invoice.php with mine:

 

p.s. just clean up the code for better look of the invoice.

 

<?php
/*
 $Id: invoice.php,v 6.1 2005/06/05 00:37:30 PopTheTop Exp $
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2003 osCommerce
 Released under the GNU General Public License
*/
 require('includes/application_top.php');
 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();
 $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
//  $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
   $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . tep_db_input($oID) . "'");
 $customer_info_query = tep_db_query("select customers_id from " . TABLE_ORDERS . " where orders_id = '". (int)tep_db_input($oID) . "'");
 $customer_info = tep_db_fetch_array($customer_info_query);
 include(DIR_WS_CLASSES . 'order.php');
 $order = new order($oID);
 $date = date('M d, Y');
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<title><?php echo STORE_NAME; ?><?php echo INVOICE_TEXT_INVOICE; ?><?php echo INVOICE_TEXT_NUMBER_SIGN; ?><?php echo date("y"); ?><?php echo INVOICE_TEXT_DASH; ?><?php echo $oID; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script type="text/javascript" src='includes/admin_comments_popup.js'></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- body_text //-->
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
 <td align="left"><?php echo '<input type="image" src="../' . INVOICE_IMAGE . '" width="' . INVOICE_IMAGE_WIDTH . '" height="' . INVOICE_IMAGE_HEIGHT . '" " alt="' . INVOICE_IMAGE_ALT_TEXT . '" onclick="javascript:ShowHide(\'comments_open\',\'comments_close\');">'; ?></td>
 <TD ALIGN="right" VALIGN="top"><FONT FACE="Verdana" SIZE="2" COLOR="#006699"><strong><?php echo INVOICE_TEXT_INVOICE; ?> <?php echo INVOICE_TEXT_NUMBER_SIGN; ?> <?php echo date("y"); ?><?php echo INVOICE_TEXT_DASH; ?> <?php echo $oID; ?><BR>
   <?php echo $date; ?></strong></font></TD>
</tr>
<tr>
 <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <TD ALIGN="right" COLSPAN="2"><span class="pageHeadingSM"><FONT FACE="Verdana" SIZE="1" COLOR="#006699"><strong><?php echo nl2br(STORE_NAME_ADDRESS); ?></strong></font></span></TD>
  </tr>
  <tr>
    <TD><table width="100%" border="0" cellspacing="0" cellpadding="2">
	    <tr>
		  <td colspan="4"><table width="100%" border="0" cellspacing="0" cellpadding="2">
			  <tr>
			    <td width="10%"><hr size="2"></td>
			    <td align="center" class="pageHeading"><em><b><?php echo INVOICE_TEXT_INVOICE; ?></b></em></td>
			    <td width="100%"><hr size="2"></td>
			  </tr>
		    </table></td>
<!-- START INVOICE -->
<table width=100% bgcolor="#C9C9C9" cellpadding="2">
 <tr class="dataTableHeadingRow">
   <td> <font face="Arial Black" size="3" color="#FFFFFF"><i><?php echo INVOICE_TEXT_INVOICE; ?></i></font></td>
 </tr>
</table>
<!-- END INVOICE -->
<table width="100%" border="3" cellpadding="5" bordercolor="#EEEEEE" bgcolor="#FFFFFF" style="border-collapse: collapse">
 <tr>
   <td width="30%" valign="top"><!-- START Billing Info -->
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="main">
    <tr>
	  <td class="smallTextBlue" align="left" valign="top"><b><?php echo ENTRY_SHIP_TO; ?></b></font></td>
    </tr>
    <tr>
	  <td> </td>
    </tr>
    <tr>
	  <td class="smallTextBlue" NOWRAP>    <?php echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br>    '); ?></font></td>
    </tr>
    <tr>
	  <td>    <img src="<?php echo $ei_image_dir; ?>pixel_trans.gif" width="1" height="10" alt=""></td>
    </tr>
    <tr>
	  <td>    </td>
    </tr>
    <tr>
	  <td>    </td>
    </tr>
    <tr>
	  <td><img src="<?php echo $ei_image_dir; ?>pixel_trans.gif" width="1" height="7" alt=""></td>
    </tr>
  </table>
  <!-- END Billing Info --></td>
   <td width="35%" valign="top"><!-- START Shipping Info -->
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">
    <tr>
	  <td class="smallTextBlue" align="left" valign="top"><b><?php echo ENTRY_SOLD_TO; ?></b></font></td>
    </tr>
    <tr>
	  <td> </td>
    </tr>
    <tr>
	  <td class="smallTextBlue" NOWRAP>    <?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>    '); ?></font></td>
    </tr>
    <tr>
	  <td>    <img src="<?php echo $ei_image_dir; ?>pixel_trans.gif" width="1" height="10" alt=""></td>
    </tr>
 <tr>
	  <td class="smallTextBlue" NOWRAP>    <?php echo $order->customer['telephone']; ?></font></td>
    </tr>
    <tr>
	  <td class="smallTextBlue" NOWRAP>    <?php echo $order->customer['email_address']; ?></font></td>
    </tr>
    <tr>
	  <td><img src="<?php echo $ei_image_dir; ?>pixel_trans.gif" width="1" height="7" alt=""></td>
    </tr>
  </table>
  <!-- END Shipping Info --></td>
  <!-- START JUR -->
  <td width="35%" valign="top">
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">
    <tr>
<!-- PRINT EXTRA FIELDS CODE STARTS HERE //-->
<?php
$orders_extrafields_query = tep_db_query("SELECT DISTINCT o.customers_id, cte.value, efi.fields_name, o.customers_name FROM "
.TABLE_EXTRA_FIELDS_INFO. " efi INNER JOIN " .TABLE_CUSTOMERS_TO_EXTRA_FIELDS. " cte ON (efi.fields_id = cte.fields_id) INNER JOIN "
.TABLE_ORDERS. " o ON (cte.customers_id = o.customers_id) WHERE (efi.languages_id = '".$languages_id."') AND (o.customers_id ='".$customer_info['customers_id']."') ORDER BY cte.fields_id ASC");
		    if (tep_db_num_rows($orders_extrafields_query)) {
				    $has_extrafields = false;			  
				    echo '  ';
				    echo '		  <tr>';
				    echo '				  <td class="smallTextBlue"><strong>' . TABLE_HEADING_EXTRAFIELDS . ':</strong><br><br></td>';
				    echo '		  </tr>';

				    while ($orders_extrafields = tep_db_fetch_array($orders_extrafields_query)) {
						    if (tep_not_null($orders_extrafields['value'])) {
								    $has_extrafields = true;// Not Null = Has Extra Fields
								    if (tep_not_null($orders_extrafields['value'])) {
										    $exInfo = new objectInfo($orders_extrafields);
										    echo '<tr>';
										    echo '  <td class="smallTextBlue">    ';
										    echo '		  <strong>' . nl2br(tep_db_output($orders_extrafields['fields_name']))
.':</strong><br /><span class="smallText">        ' . nl2br(tep_db_output($orders_extrafields['value'])) . '</span><br>';
										    echo '  </td>';
										    echo '</tr>';				  

								    }
						    }
				    }
					 if ($has_extrafields == false) { /*most of this stuff is row-to-row ending the section (with a FINAL row to end the table) */

							  echo '<tr>';
							  echo '</tr>';
					 }
							  echo '<tr>';
							  echo '</tr>';
							  echo '';
		    }
?>
<!-- PRINT EXTRA FIELDS CODE ENDS HERE //-->
    </tr>
  </table>
  </td><!-- END JUR -->
 </tr>
</table>
  </tr>
  <tr>
    <TD COLSPAN="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '15'); ?></td>
  </tr>
  <tr>
    <TD COLSPAN="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr>
    <TD COLSPAN="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
	    <tr class="dataTableHeadingRow">
		  <td class="dataTableHeadingContent" colspan="2"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
		  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
		  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TAX; ?></td>
		  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRICE_EXCLUDING_TAX; ?></td>
		  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRICE_INCLUDING_TAX; ?></td>
		  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_EXCLUDING_TAX; ?></td>
		  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_INCLUDING_TAX; ?></td>
	    </tr>
	    <?php
  for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
   echo '		  <tr class="dataTableRow">' . "\n" .
	 '		   <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
	 '		   <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];
  if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
    for ($j = 0; $j < $k; $j++) {
	  echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
	  if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';
	  echo '</i></small></nobr>';
    }
  }
  echo '		   </td>' . "\n" .
	   '		   <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n";
  echo '		   <td class="dataTableContent" align="right" valign="top">' . tep_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" .
	   '		   <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
	   '		   <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
	   '		   <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
	   '		   <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n";
  echo '		  </tr>' . "\n";
  }
?>
	    <tr>
		  <td align="right" colspan="8"><table border="0" cellspacing="0" cellpadding="2">
			  <?php
 for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
   echo '		 <tr>' . "\n" .
	 '		  <td align="right" class="smallText">' . $order->totals[$i]['title'] . '</td>' . "\n" .
	 '		  <td align="right" class="smallText">' . $order->totals[$i]['text'] . '</td>' . "\n" .
	 '		 </tr>' . "\n";
 }
?>
		    </table></td>
	    </tr>
	  </table></td>
  </tr>
   </table>
   <!-- ORDER COMMENTS CODE STARTS HERE //-->
   <div id="comments_open" style="position: relative;">
  <?php
$orders_status_history_query = tep_db_query("select * from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . tep_db_input($oID) . "' order by date_added");
if (tep_db_num_rows($orders_status_history_query)) {
   $has_comments = false;
 echo '	  <br><br>';
 echo '	  <table width="100%" border="0" cellpadding="0" cellspacing="0">';
 echo '	   <tr>';
 echo '	    <td width="9"> </td>';
 echo '	    <td>';
 echo '	    <table width="100%" border="0" cellpadding="0" cellspacing="0">';
 echo '		 <tr>';
 echo '		  <td width="11"><img src="../images/borders/maingrey_01.gif" width="11" height="16" alt=""></td>';
 echo '		  <td background="../images/borders/maingrey_02.gif"><img src="../images/borders/maingrey_02.gif" width="100%" height="16" alt="" ></td>';
 echo '		  <td width="19"><img src="../images/borders/maingrey_03.gif" width="19" height="16" alt=""></td>';
 echo '		 </tr>';
 echo '		 <tr>';
 echo '		  <td background="../images/borders/maingrey_04.gif"><img src="../images/borders/maingrey_04.gif" width="100%" height="100%" alt=""></td>';
 echo '		  <td align="center" bgcolor="#F2F2F2">';
 echo '		  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">';
 echo '		   <tr>';
 echo '		    <td width="95%"> <b>' . TABLE_HEADING_COMMENTS . '</b><br><br></td>';
 echo '		   </tr>';
 while ($orders_comments = tep_db_fetch_array($orders_status_history_query)) {
   if (tep_not_null($orders_comments['comments'])) {
   $has_comments = true; // Not Null = Has Comments
   if (tep_not_null($orders_comments['comments'])) {
	   $sInfo = new objectInfo($orders_comments);
	   echo '		   <tr>';
	   echo '		    <td align="center" width="95%">';
	   echo '		    <table width="95%" border="0" cellpadding="0" cellspacing="0">';
	   echo '			 <tr>';
	   echo '			  <td width="95%" class="smallText">';
	   echo '			  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">';
	   echo '			   <tr>';
	   echo '			    <td width="150" align="left" valign="top" class="smallText"><strong><u>' . TABLE_HEADING_DATE_ADDED . '</u></strong></td>';
	   echo '			    <td align="left" valign="top" class="smallText"><strong><u>' . TABLE_HEADING_COMMENT_LEFT . '</u></strong></td>';
	   echo '			   </tr>';
	   echo '			  </table>';
	   echo '			  </td>';
	   echo '			 </tr>';
	   echo '		    </table>';
	   echo '		    </td>';
	   echo '		   </tr>';
	   echo '		   <tr>';
	   echo '		    <td align="center" width="95%">';
	   echo '		    <table width="95%" border="0" cellpadding="0" cellspacing="0">';
	   echo '			 <tr>';
	   echo '			  <td width="95%" class="smallText">';
	   echo '			  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">';
	   echo '			   <tr>';
	   echo '			    <td width="150" align="left" valign="top" class="smallText">' . tep_date_short($sInfo->date_added) . '</td>';
	   echo '			    <td align="left" valign="top" class="smallText">' . nl2br(tep_db_output($orders_comments['comments'])) . '<br><br></td>';
 echo '			   </tr>';
 echo '			  </table>';
	   echo '			  </td>';
 echo '			 </tr>';
	   echo '		    </table>';
	   echo '		    </td>';
	   echo '		   </tr>';
   }
   }
 }
 if ($has_comments == false) {
  echo '		   <tr>';
  echo '		    <td align="center" width="95%">';
  echo '		    <table width="95%" border="0" cellpadding="0" cellspacing="0">';
  echo '			 <tr>';
  echo '			  <td width="95%" class="smallText">';
  echo '			  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">';
  echo '			   <tr>';
  echo '			    <td width="100%" align="left" valign="top" class="smallText">' . INVOICE_TEXT_NO_COMMENT . '</td>';
  echo '			   </tr>';
  echo '			  </table>';
  echo '			  </td>';
  echo '			 </tr>';
  echo '		    </table>';
  echo '		    </td>';
  echo '		   </tr>';
 }
  echo '		   <tr>';
  echo '		    <td>' . tep_draw_separator('pixel_trans.gif', '1', '7') . '</td>';
  echo '		   </tr>';
  echo '		  </table>';
  echo '		  </td>';
  echo '		  <td background="../images/borders/maingrey_06.gif"><img src="../images/borders/maingrey_06.gif" width="100%" height="100%" alt=""></td>';
  echo '		 </tr>';
  echo '		 <tr>';
  echo '		  <td><img src="../images/borders/maingrey_07.gif" width="11" height="18" alt=""></td>';
  echo '		  <td background="../images/borders/maingrey_08.gif"><img src="../images/borders/maingrey_08.gif" width="100%" height="18" alt=""></td>';
  echo '		  <td><img src="../images/borders/maingrey_09.gif" width="19" height="18" alt=""></td>';
  echo '		 </tr>';
  echo '	    </table>';
  echo '	    </td>';
  echo '	   </tr>';
  echo '	  </table>';
}
?>
  <!-- ORDER COMMENTS CODE ENDS HERE //-->
   </div>
   <br>
   <CENTER>
  <span class="smallText"><FONT FACE="Verdana" COLOR="#006699"><strong><?php echo INVOICE_TEXT_THANK_YOU; ?><BR>
  <?php echo STORE_NAME; ?><BR>
  <?php echo STORE_URL_ADDRESS; ?></strong></font></span>
   </CENTER>
   <!-- body_text_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Boriss

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...