energine
[ class tree: energine ] [ index: energine ] [ all elements ]

Source for file OrderHistory.class.php

Documentation is available at OrderHistory.class.php

  1. <?php
  2. /**
  3.  * Содержит класс OrderHistory
  4.  *
  5.  * @package energine
  6.  * @subpackage shop
  7.  * @author dr.Pavka
  8.  * @copyright ColoCall 2006
  9.  * @version $Id$
  10.  */
  11.  
  12. //require_once('core/modules/share/components/Grid.class.php');
  13.  
  14. /**
  15.  * История заказов
  16.  *
  17.  * @package energine
  18.  * @subpackage shop
  19.  * @author dr.Pavka
  20.  */
  21. class OrderHistory extends Grid {
  22.     /**
  23.       * Детали заказа(список продуктов)
  24.       *
  25.       * @var OrderDetails 
  26.       * @access private
  27.       */
  28.     private $details;
  29.     /**
  30.      * Конструктор класса
  31.      *
  32.      * @param string $name 
  33.      * @param string $module 
  34.      * @param Document $document 
  35.      * @param array $params 
  36.      * @access public
  37.      */
  38.     public function __construct($name$moduleDocument $document,  array $params null{
  39.         parent::__construct($name$module$document,  $params);
  40.         $this->setTableName('shop_orders');
  41.         $this->setOrder(array('order_created'=>QAL::DESC));
  42.     }
  43.  
  44.     /**
  45.      * Формат даты создания заказа
  46.      *
  47.      * @return DataDescription 
  48.      * @access protected
  49.      */
  50.  
  51.      protected function createDataDescription({
  52.          $result parent::createDataDescription();
  53.          if ($this->getAction(== 'getRawData'{
  54.              $result->getFieldDescriptionByName('order_created')->setProperty('outputFormat''%d/%m/%Y %H:%M');
  55.          }
  56.          return $result;
  57.      }
  58.     /**
  59.      * Выводит детали заказа
  60.      *
  61.      * @return void 
  62.      * @access protected
  63.      */
  64.  
  65.     protected function showDetails({
  66.         $orderID $this->getActionParams();
  67.         $orderID $orderID[0];
  68.         $this->request->setPathOffset($this->request->getPathOffset(2);
  69.         $this->details $this->document->componentManager->createComponent('orderDetails''shop''OrderDetails'array('orderID'=>$orderID)false);
  70.         $this->details->getAction();
  71.         $this->details->run();
  72.     }
  73.  
  74.     /**
  75.      * Для метода вывода информации о заказе доавбляем инфу о данных заказа
  76.      *
  77.      * @return void 
  78.      * @access protected
  79.      */
  80.  
  81.      protected function edit({
  82.         parent::edit();
  83.  
  84.         $data $this->dbh->select($this->getTableName()array('user_detail''order_detail')$this->getFilter());
  85.         if (is_array($data)) {
  86.             list($data$data;
  87.             $userData unserialize($data['user_detail']);
  88.             $orderData unserialize($data['order_detail']);
  89.             unset($userData['u_id']);
  90.             foreach ($userData as $fieldName => $value{
  91.                 $field new FieldDescription($fieldName);
  92.                 $field->setType(FieldDescription::FIELD_TYPE_STRING);
  93.                 $field->setProperty('customField'true);
  94.                 $field->setMode(FieldDescription::FIELD_MODE_READ);
  95.                 $this->getDataDescription()->addFieldDescription($field);
  96.  
  97.                 $field new Field($fieldName);
  98.                 $field->setData($value);
  99.                 $this->getData()->addField($field);
  100.             }
  101.         }
  102.  
  103.      }
  104.  
  105.     /**
  106.       * Выводим детали заказа
  107.       *
  108.       * @return DOMNode 
  109.       * @access public
  110.       */
  111.  
  112.     public function build({
  113.         if ($this->getAction(== 'showDetails'{
  114.             $result $this->details->build();
  115.         }
  116.         else {
  117.             $result parent::build();
  118.         }
  119.         return $result;
  120.     }
  121. }
В создании документации нам помог: phpDocumentor