Sådan benyttes komponenten ViewBasketInvoice klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/ViewBasketInvoice.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? ViewBasketInvoice::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new ViewBasketInvoice($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten ViewBasketInvoice klassen
Dato TODO
Levering efter aftale, normalt inden for 1-2 dage, men i højsæson kan der være en smule ventetid. Ring på tlf. (+45) 40 50 60 69 og hør nærmere.
Den fulde PHP kildekode for ViewBasketInvoice klassen
<?php/** * @package db-basket * @see HTML_DB_BASKET_VIEW_PATH.'/ViewBasketInvoice.php' * @copyright (c) http://Finn-Rasmussen.com * @license http://Finn-Rasmussen.com/license/ myPHP License conditions * @author http://Finn-Rasmussen.com * @version 1.11 * @since 27-nov-2009 *//** * The required files *///require_once(HTML_TABLE_COMPONENT_PATH.'/TableDataReader.php');require_once(HTML_TABLE_COMPONENT_PATH.'/TableHeader.php');require_once(HTML_TABLE_COMPONENT_PATH.'/Table.php');require_once(HTML_TABLE_COMPONENT_PATH.'/Tr.php');require_once(HTML_TABLE_COMPONENT_PATH.'/Th.php');require_once(HTML_TABLE_COMPONENT_PATH.'/Td.php');require_once(HTML_BASE_UTIL_PATH.'/Div.php');require_once(HTML_DTO_UTIL_PATH.'/DataReaderFactory.php');require_once(HTML_DB_BASKET_UTIL_PATH.'/DefaultHeaderBasket.php');require_once(HTML_DB_BASKET_UTIL_PATH.'/DefaultRowsBasket.php');require_once(HTML_DB_CUSTOMER_UTIL_PATH.'/DefaultRowsCustomer.php');require_once(HTML_DB_CUSTOMER_UTIL_PATH.'/DefaultRowsCompany.php');// Customer and Payment viewsrequire_once(HTML_DB_CUSTOMER_VIEW_PATH.'/ViewCustomerInfo.php');require_once(HTML_DB_CUSTOMER_VIEW_PATH.'/ViewCompanyInfo.php');require_once(HTML_DB_BASKET_VIEW_PATH.'/ViewPaymentInfo.php');require_once(HTML_DB_BASKET_VIEW_PATH.'/ViewBasketInfo.php');require_once(HTML_DB_BASKET_VIEW_PATH.'/ViewWarrantyInfo.php');require_once(HTML_DB_BASKET_VIEW_PATH.'/ViewDeliveryInfo.php');if (defined('HTML_DIBS_VIEW_PATH')) { require_once(HTML_DIBS_VIEW_PATH.'/DibsCreditCard.php');}/** * Generates the html for a View Basket Invoice * <code> * Usage: * $view = new ViewBasketInvoice($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); * print $view->getHtml(); * Or * ViewBasketInvoice::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); * * Generates a complete View Basket Invoice interface * +-------------------------------- * | Text header (HeaderIndo) * +-------------------------------- * | CustomerInfo | CompanyInfo * +-------------------------------- * | | PaymentInfo * +-------------------------------- * | Order lines (BasketInfo) * +-------------------------------- * | DeliveryInfo * | WarrantyInfo * +-------------------------------- * </code> * @package db-basket */class ViewBasketInvoice extends TableDataReader { /** * @var DataReader $basketInfo The DataReader object for this info */ protected $basketInfo = ''; /** * @var DataReader $customerInfo The DataReader object for this info */ protected $customerInfo = ''; /** * @var DataReader $companyInfo The DataReader object for this info */ protected $companyInfo = ''; /** * Constructor * @param DataReader / array $datareader The Data Reader object OR an array * @param String $text The text header for the table * @param String $width The Width for the table * @param String $class The Class * @param String $border The Border * @param String $cellpadding The CellSpacing * @param String $cellspacing The CellPadding * @param String $summary The Summary * @param String $caption The Caption * @param String $layout The layout to use */ function __construct($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $layout='') { // Global table characteristics $theWidth = $width != '' ? $width : BASKET_INVOICE_VIEW_WIDTH; $theClass = $class != '' ? $class : "NONE"; $theBorder = $border != '' ? $border : "0"; $theCellPadding = $cellpadding != '' ? $cellpadding : "0"; $theCellSpacing = $cellspacing != '' ? $cellspacing : "0"; $theLayout = $layout != '' ? $layout : BASKET_INVOICE_VIEW_LAYOUT; parent::__construct($datareader, $text, $theWidth, $theClass, $theBorder, $theCellPadding, $theCellSpacing, $summary, $caption, $theLayout); } /** * Get the CSS class Name for this component * You may override this function if you need another CSS class name * @abstract * @return String The CSS class name */ function getCssClass() { return CSS_BASKET_INVOICE_VIEW; } /** * Set the Basket Info * @param DataReader $basketInfo The DataReader object for the Basket Info */ function setBasketInfo($basketInfo) { $this->basketInfo = $basketInfo; } /** * Set the Company Info * @param DataReader $companyInfo The DataReader object for the Company Info */ function setCompanyInfo($companyInfo) { $this->companyInfo = $companyInfo; } /** * Set the Customer Info * @param DataReader The DataReader object for the Customer Info */ function setCustomerInfo($customerInfo) { $this->customerInfo = $customerInfo; } /** * Return the Header info as an object * @return Object The content as an object */ function newHeaderInfo() { $object = new Raw(); if ($this->text !== "") { $tr = new Tr(); $tr->add(new Td($class, $valign, $colspan, $this->text)); } return $object; } /** * Return the Dibs Credit Card info as an object * @return Object The content as an object */ function newDibsCreditCard() { $object = new Raw(); $creditCard = ""; if (defined('HTML_DIBS_VIEW_PATH')) { $creditCard = new DibsCreditCard(); } if ($creditCard !== "") { $tr = new Tr(); $class = ""; $valign = ""; $colspan = "2"; $tr->add(new Td('', '', 2, $creditCard)); $object->add($tr); } return $object; } /** * Return the Company info as an object * @return Object The Company info as an object */ function newCustomerCompanyInfo() { $tr = new Tr(); $tr->add($this->newCustomerInfo()); $tr->add($this->newCompanyInfo()); return $tr; } /** * Return the Customer info as an object * @return Object The Customer info as an object */ function newCustomerInfo() { if ($this->customerInfo === '') { $msg = 'customerInfo is not initialized'; Message::add($msg, __FILE__, __LINE__); $rows = DefaultRowsCustomer::get(); $header = ''; // The header meta data $default = ''; // The default meta data array $limit = ''; // The limit to use for the array $sort = true; $this->customerInfo = DataReaderFactory::newDataReader($rows, $header, $default, $limit, $sort); } $td = new Td(); $info = new ViewCustomerInfo($this->customerInfo,'','', $this->class); /** * DO NOT Trust this source, a hacker may hook into here */ $info->setStriptags(true); $info->setStriphttp(true); $td->add($info); return $td; } /** * Return the Company info as an object * @return Object The Company info as an object */ function newCompanyInfo() { if ($this->companyInfo === '') { $msg = 'companyInfo is not initialized'; Message::add($msg, __FILE__, __LINE__); $rows = DefaultRowsCompany::get(); $header = ''; // The header meta data $default = ''; // The default meta data array $limit = ''; // The limit to use for the array $sort = true; $this->companyInfo = DataReaderFactory::newDataReader($rows, $header, $default, $limit, $sort); } $td = new Td(); $info = new ViewCompanyInfo($this->companyInfo,'','', $this->class); /** * Trust this source, no hacker involved here */ $info->setStriptags(false); $info->setStriphttp(false); $div = new Div($info,CSS_ALIGN_RIGHT,''); $td->add($div); return $td; } /** * Return the Payment info as an object * @return Object The Payment as an object */ function newPaymentInfo() { $tr = new Tr(); $td = new Td('','','',' '); $tr->add($td); $td = new Td(); $td->add(new ViewPaymentInfo()); $tr->add($td); return $tr; } /** * Return the Basket info as an object * @return Object The Basket as an object */ function newBasketInfo() { if ($this->basketInfo === '') { $msg = 'basketInfo is not initialized'; Message::add($msg, __FILE__, __LINE__); $rows = DefaultRowsBasket::get(); $header = DefaultHeaderBasket::get(); $default = ''; // The default meta data array $limit = ''; // The limit to use for the array $sort = true; $this->basketInfo = DataReaderFactory::newDataReader($rows, $header, $default, $limit, $sort); } $tr = new Tr(); $class = ""; $valign = ""; $colspan = "2"; $td = new Td($class, $valign, $colspan); $info = new ViewBasketInfo($this->basketInfo, LINK_TEXT_PAYMENT_BASKET, $this->width); /** * DO NOT Trust this source, a hacker may hook into here */ $info->setStriptags(true); $info->setStriphttp(true); $td->add($info); $tr->add($td); return $tr; } /** * Return the Delivery info as an object * @return Object The content as an object */ function newDeliveryInfo() { $tr = new Tr(); $class = ""; $valign = ""; $colspan = "2"; $td = new Td($class, $valign, $colspan); $td->add(new ViewDeliveryInfo()); $tr->add($td); return $tr; } /** * Return the Warranty info as an object * @return Object The content as an object */ function newWarrantyInfo() { $tr = new Tr(); $class = ""; $valign = ""; $colspan = "2"; $td = new Td($class, $valign, $colspan); $td->add(new ViewWarrantyInfo()); $tr->add($td); return $tr; } /** * Return the content as an object * @return Object The content as an object */ function newColumnInfo() { $text = ""; $width = BASKET_INVOICE_VIEW_WIDTH; $class = BASKET_INVOICE_VIEW_CLASS; $border = BASKET_INVOICE_VIEW_BORDER; $cellpadding = BASKET_INVOICE_VIEW_CELLPADDING; $cellspacing = BASKET_INVOICE_VIEW_CELLSPACING; $datareader = null; $object = new Table($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing); $object->add($this->newHeaderInfo()); $object->add($this->newDibsCreditCard()); $object->add($this->newCustomerCompanyInfo()); $object->add($this->newPaymentInfo()); $object->add($this->newBasketInfo()); $object->add($this->newDeliveryInfo()); $object->add($this->newWarrantyInfo()); $imageName = IMAGE_CORNER_CONTENT_CENTER; // TODO does not work, $td = $this->newCorner($imageName); // C Border $td->add($object); return $td; } /** * Return the content as an object * @return Object The content as an object */ function newColumns() { $object = new Tr(); if ($this->layout & LINK_LAYOUT_CORNER) { if (!($this->layout & LINK_LAYOUT_TAB)) { $object->add($this->newCorner(IMAGE_CORNER_CONTENT_LEFT)); // L Border } } $object->add($this->newColumnInfo()); if ($this->layout & LINK_LAYOUT_CORNER) { if (!($this->layout & LINK_LAYOUT_TAB)) { $object->add($this->newCorner(IMAGE_CORNER_CONTENT_RIGHT)); // R Border } } return $object; } /** * Return the html for a basket invoice * @return String The html */ function getHtml() { $html = $this->html;// $this->add($this->newContent()); // Render it $html .= $this->getColumns();// if ($this->text != '') {// $html .= $this->getTableHeader();// }// $html .= $this->getStart();// $html .= $this->getEnd(); return $html; } /** * Display html * <code> * Usage: * ViewBasketInvoice::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); * </code> * @static * @param DataReader / array $datareader The Data Reader object OR an array * @param String $text The text header for the table * @param String $width The Width for the table * @param String $class The Class * @param String $border The Border * @param String $cellpadding The CellSpacing * @param String $cellspacing The CellPadding * @param String $summary The Summary * @param String $caption The Caption * @param String $layout The layout to use */ public static function display($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $layout='') { $html = new ViewBasketInvoice($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); $html->addHtml(); }}?>
Den fulde HTML kildekode for ViewBasketInvoice klassen
<? <!-- DEBUG: ViewBasketInvoice --> <table id="ViewBasketInvoiceId" width="650px" class="NONE" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" width="1px" title="ctl"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/ctl.gif" width="9" height="19" alt="ctl.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="ctc"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/ctc.gif" width="100%" height="19" alt="ctc.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="ctr"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/ctr.gif" width="9" height="19" alt="ctr.gif" class="baseFloatLeft" border="0" /> </td> </tr> <tr> <td class=" tableCornerView" valign="top" width="1px" title="ccl"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/ccl.gif" width="9" height="100%" alt="ccl.gif" class="baseFloatLeft" border="0" /> </td> <td class=" tableCornerView" valign="top" width="1px" title="ccc"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/ccc.gif" width="1" height="1" alt="ccc.gif" class="baseFloatLeft" border="0" /> <!-- DEBUG: Table --> <!-- DEBUG: TableHeader --> <!-- No text in TableHeader --> <table width="650px" class="tableBasketInvoiceView baseBorder" border="0" cellpadding="2" cellspacing="0"> <tr> <td valign="top"><!-- DEBUG: ViewCustomerInfo --> <table id="ViewCustomerInfoId" width="400" class="NONE" border="0" cellpadding="2" cellspacing="0"> <tr> <td valign="top">Company<br /> Contact Person<br /> Address<br /> Zip City<br /> Country<br /> Privat telefon: Private<br /> Mobil telefon: Mobile<br /> Firma telefon: Business<br /> Cvr nr.: cvr<br /> <!-- DEBUG: EmailLink --> <!-- email --><a class="baseLinkColor" href="mailto:email" title="email">email</a> <br /> <!-- DEBUG: Link --> <!-- www.hvepse.info --><a class="baseLinkColor" href="www.hvepse.info" title="www.hvepse.info">www.hvepse.info</a> <br /> EAN: ean<br /> </td> </tr> </table> </td> <td valign="top"><div class="baseAlignRight"><!-- DEBUG: ViewCompanyInfo --> <table id="ViewCompanyInfoId" width="400" class="NONE" border="0" cellpadding="2" cellspacing="0"> <tr> <td valign="top">HvepseEksperten.dk ApS<br /> Finn Rasmussen<br /> Kongens Vænge 79<br /> 3400 Hillerød<br /> Privat telefon: 48 24 60 37<br /> Mobil telefon: 40 50 60 69<br /> Firma telefon: 48 24 60 30<br /> Cvr nr.: 10142865 <br /> <!-- DEBUG: EmailLink --> <!-- http://hvepseeksperten.dk/FormMail/ --><a class="baseLinkColor" href="http://hvepseeksperten.dk/FormMail/" title="http://hvepseeksperten.dk/FormMail/">http://hvepseeksperten.dk/FormMail/</a> <br /> </td> </tr> </table> </div> </td> </tr> <tr> <td valign="top"> </td> <td valign="top"><!-- DEBUG: ViewPaymentInfo --> <h1>ViewPaymentInfo->getHtml() TODO</h1> <p>Dato TODO</p> </td> </tr> <tr> <td valign="top" colspan="2"><!-- DEBUG: ViewBasketInfo --> <!-- DEBUG: TableHeader --> <table width="650px" class="tableBasketView baseBorder" border="0" cellpadding="2" cellspacing="0"> <tr> <td class="baseArrowHeader" valign="middle"><!-- DEBUG: Link --> <a class="baseLinkColor" href="/source-code/db-basket/ViewBasketInvoice/index.php" title="Klik her for at Minimere ... TableHeader"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/arrow-headline.gif" width="4" height="7" alt="arrow-headline.gif" /> </a> </td> <th class="baseColorHeader" valign="top" align="left">Indkøbskurv (3) </th> </tr> </table> <table id="ViewBasketInfoId" width="650px" class="tableBasketView baseBorder" border="0" cellpadding="2" cellspacing="0"> <tr> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- text 100 string Basket --> <!-- DEBUG: Sortby --> <!-- Tekst --><a class="baseColorHeader" href="/source-code/db-basket/ViewBasketInvoice/index.php?mvcSORT_BY=asc&mvcORDER_BY=text" title="Mvcorder_by desc">Tekst</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- description 100 string Basket --> <!-- DEBUG: Sortby --> <!-- Beskrivelse --><a class="baseColorHeader" href="/source-code/db-basket/ViewBasketInvoice/index.php?mvcSORT_BY=asc&mvcORDER_BY=description" title="Mvcorder_by desc">Beskrivelse</a> </th> <th class="baseColorHeader baseNoWrap baseAlignRight" valign="top" align="right"> <!-- quantity 11 float Basket --> <!-- DEBUG: Sortby --> <!-- Antal --><a class="baseColorHeader" href="/source-code/db-basket/ViewBasketInvoice/index.php?mvcSORT_BY=asc&mvcORDER_BY=quantity" title="Mvcorder_by desc">Antal</a> </th> <th class="baseColorHeader baseNoWrap baseAlignRight" valign="top" align="right"> <!-- price 11 float Basket --> <!-- DEBUG: Sortby --> <!-- Pris --><a class="baseColorHeader" href="/source-code/db-basket/ViewBasketInvoice/index.php?mvcSORT_BY=asc&mvcORDER_BY=price" title="Mvcorder_by desc">Pris</a> </th> <th class="baseColorHeader baseNoWrap baseAlignRight" valign="top" align="right"> <!-- subtotal 11 float --> <!-- DEBUG: Sortby --> <!-- Beløb --><a class="baseColorHeader" href="/source-code/db-basket/ViewBasketInvoice/index.php?mvcSORT_BY=asc&mvcORDER_BY=subtotal" title="Mvcorder_by desc">Beløb</a> </th> </tr> <tr> <td class="baseColorDark" valign="top">some text1 </td> <td class="baseColorDark" valign="top">some description1 </td> <td class="baseColorDark baseAlignRight" valign="top">1,00 </td> <td class="baseColorDark baseAlignRight" valign="top">650,00 </td> <td class="baseColorDark baseAlignRight" valign="top">650,00 </td> </tr> <tr> <td class="baseColorLight" valign="top">some text2 </td> <td class="baseColorLight" valign="top">some description2 </td> <td class="baseColorLight baseAlignRight" valign="top">1,00 </td> <td class="baseColorLight baseAlignRight" valign="top">150,50 </td> <td class="baseColorLight baseAlignRight" valign="top">150,50 </td> </tr> <tr> <td class="baseColorDark" valign="top">some text3 </td> <td class="baseColorDark" valign="top">some description3 </td> <td class="baseColorDark baseAlignRight" valign="top">1,00 </td> <td class="baseColorDark baseAlignRight" valign="top">÷150,50 </td> <td class="baseColorDark baseAlignRight" valign="top">÷150,50 </td> </tr> <tr> <td class="tableBorderTop baseColorDark" valign="top">Beløb </td> <td class="tableBorderTop baseColorDark baseAlignRight" valign="top" colspan="5">650,00 </td> </tr> <tr> <td class="baseColorDark" valign="top">Moms </td> <td class="baseColorDark baseAlignRight" valign="top" colspan="5">162,50 </td> </tr> <tr> <td class="tableBorderTop baseColorLight" valign="top">Ialt </td> <td class="tableBorderTop baseColorLight baseAlignRight" valign="top" colspan="5"> DKK 812,50 </td> </tr> </table> </td> </tr> <tr> <td valign="top" colspan="2"><!-- DEBUG: ViewDeliveryInfo --> <h1>Leverings betingelser</h1> <p>Levering efter aftale, normalt inden for 1-2 dage, men i højsæson kan der være en smule ventetid.<br /> Ring på tlf. (+45) 40 50 60 69 og hør nærmere.</p> </td> </tr> <tr> <td valign="top" colspan="2"><!-- DEBUG: ViewWarrantyInfo --> <h1>ViewWarrantyInfo->getHtml() TODO</h1> </td> </tr> </table> </td> <td class=" tableCornerView" valign="top" width="1px" title="ccr"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/ccr.gif" width="9" height="100%" alt="ccr.gif" class="baseFloatLeft" border="0" /> </td> </tr> <tr> <td valign="top" width="1px" title="cbl"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/cbl.gif" width="9" height="19" alt="cbl.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="cbc"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/cbc.gif" width="100%" height="19" alt="cbc.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="cbr"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/cbr.gif" width="9" height="19" alt="cbr.gif" class="baseFloatLeft" border="0" /> </td> </tr> </table> ?>
Her er 'klasse metoderne' for ViewBasketInvoice klassen:
Her er 'objekt variable' for ViewBasketInvoice klassen: