<?php
/**
* СодеÑÐ¶Ð¸Ñ ÐºÐ»Ð°ÑÑ OrderHistory
*
* @package energine
* @subpackage shop
* @author dr.Pavka
* @copyright ColoCall 2006
* @version $Id: OrderHistory.class.php,v 1.6 2007/12/17 14:24:30 pavka Exp $
*/
//require_once('core/modules/share/components/Grid.class.php');
/**
* ÐÑÑоÑÐ¸Ñ Ð·Ð°ÐºÐ°Ð·Ð¾Ð²
*
* @package energine
* @subpackage shop
*/
class OrderHistory extends Grid {
/**
* ÐеÑали заказа(ÑпиÑок пÑодÑкÑов)
*
* @var OrderDetails
* @access private
*/
private $details;
/**
* ÐонÑÑÑÑкÑÐ¾Ñ ÐºÐ»Ð°ÑÑа
*
* @param string $name
* @param string $module
* @param Document $document
* @param array $params
* @access public
*/
public function __construct($name, $module, Document $document, array $params = null) {
parent::__construct($name, $module, $document, $params);
$this->setTableName('shop_orders');
$this->setOrder(array('order_created'=>QAL::DESC));
}
/**
* ФоÑÐ¼Ð°Ñ Ð´Ð°ÑÑ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ð·Ð°ÐºÐ°Ð·Ð°
*
* @return DataDescription
* @access protected
*/
protected function createDataDescription() {
$result = parent::createDataDescription();
if ($this->getAction() == 'getRawData') {
$result->getFieldDescriptionByName('order_created')->addProperty('outputFormat', '%d/%m/%Y %H:%M');
}
return $result;
}
/**
* ÐÑÐ²Ð¾Ð´Ð¸Ñ Ð´ÐµÑали заказа
*
* @return void
* @access protected
*/
protected function showDetails() {
$orderID = $this->getActionParams();
$orderID = $orderID[0];
$this->request->setPathOffset($this->request->getPathOffset() + 2);
$this->details = $this->document->componentManager->createComponent('orderDetails', 'shop', 'OrderDetails', array('orderID'=>$orderID), false);
$this->details->getAction();
$this->details->run();
}
/**
* ÐÐ»Ñ Ð¼ÐµÑода вÑвода инÑоÑмаÑии о заказе доавблÑем инÑÑ Ð¾ даннÑÑ
заказа
*
* @return void
* @access protected
*/
protected function edit() {
parent::edit();
$data = $this->dbh->select($this->getTableName(), array('user_detail', 'order_detail'), $this->getFilter());
if (is_array($data)) {
list($data) = $data;
$userData = unserialize($data['user_detail']);
$orderData = unserialize($data['order_detail']);
unset($userData['u_id']);
foreach ($userData as $fieldName => $value) {
$field = new FieldDescription($fieldName);
$field->setType(FieldDescription::FIELD_TYPE_STRING);
$field->addProperty('customField', true);
$field->setMode(FieldDescription::FIELD_MODE_READ);
$this->getDataDescription()->addFieldDescription($field);
$field = new Field($fieldName);
$field->setData($value);
$this->getData()->addField($field);
}
}
}
/**
* ÐÑводим деÑали заказа
*
* @return DOMNode
* @access public
*/
public function build() {
if ($this->getAction() == 'showDetails') {
$result = $this->details->build();
}
else {
$result = parent::build();
}
return $result;
}
}