示例#1
0
 /**
  * details der bestellung anzeigen
  */
 public function detailAction()
 {
     // init
     $order = Object_OnlineShopOrder::getById($this->getParam('id'));
     /* @var OnlineShop_Framework_AbstractOrder $order */
     $orderAgent = $this->view->orderAgent = $this->orderManager->createOrderAgent($order);
     /**
      * @param array $address
      *
      * @return string
      */
     $geoPoint = function (array $address) {
         # https://developers.google.com/maps/documentation/geocoding/index?hl=de#JSON
         $url = sprintf('http://maps.googleapis.com/maps/api/geocode/json?address=%1$s&sensor=false', urlencode($address[0] . ' ' . $address[1] . ' ' . $address[2] . ' ' . $address[3]));
         $json = json_decode(file_get_contents($url));
         return $json->results[0]->geometry->location;
     };
     // get geo point
     $this->view->geoAddressInvoice = $geoPoint([$order->getCustomerStreet(), $order->getCustomerZip(), $order->getCustomerCity(), $order->getCustomerCountry()]);
     if ($order->getDeliveryStreet() && $order->getDeliveryZip()) {
         $this->view->geoAddressDelivery = $geoPoint([$order->getDeliveryStreet(), $order->getDeliveryZip(), $order->getDeliveryCity(), $order->getDeliveryCountry()]);
     }
     // get customer info
     if ($order->getCustomer()) {
         // init
         $arrCustomerAccount = [];
         $customer = $order->getCustomer();
         // register
         $register = new Zend_Date($order->getCreationDate());
         $arrCustomerAccount['created'] = $register->get(Zend_Date::DATE_MEDIUM);
         // mail
         if (method_exists($customer, 'getEMail')) {
             $arrCustomerAccount['email'] = $customer->getEMail();
         }
         // order count
         $addOrderCount = function () use($customer, $arrCustomerAccount) {
             $order = new Object_OnlineShopOrder();
             $field = $order->getClass()->getFieldDefinition('customer');
             if ($field instanceof \Pimcore\Model\Object\ClassDefinition\Data\Href) {
                 if (count($field->getClasses()) == 1) {
                     $class = 'Pimcore\\Model\\Object\\' . reset($field->getClasses())['classes'];
                     /* @var \Pimcore\Model\Object\Concrete $class */
                     $orderList = $this->orderManager->createOrderList();
                     $orderList->joinCustomer($class::classId());
                     $orderList->getQuery()->where('customer.o_id = ?', $customer->getId());
                     $arrCustomerAccount['orderCount'] = $orderList->count();
                 }
             }
         };
         $addOrderCount();
         $this->view->arrCustomerAccount = $arrCustomerAccount;
     }
     // create timeline
     $arrIcons = ['itemChangeAmount' => 'glyphicon glyphicon-pencil', 'itemCancel' => 'glyphicon glyphicon-remove', 'itemComplaint' => 'glyphicon glyphicon-alert'];
     $arrContext = ['itemChangeAmount' => 'default', 'itemCancel' => 'danger', 'itemComplaint' => 'warning'];
     $arrTimeline = [];
     $date = new Zend_Date();
     foreach ($orderAgent->getFullChangeLog() as $note) {
         /* @var \Pimcore\Model\Element\Note $note */
         // get avatar
         $user = Pimcore_Model_User::getById($note->getUser());
         /* @var \Pimcore\Model\User $user */
         $avatar = sprintf('/admin/user/get-image?id=%d', $user->getId());
         // group events
         $group = $date->setTimestamp($note->getDate())->get(Zend_Date::DATE_MEDIUM);
         // load reference
         $reference = Pimcore\Model\Object\Concrete::getById($note->getCid());
         $title = $reference instanceof OnlineShop_Framework_AbstractOrderItem ? $reference->getProduct()->getOSName() : null;
         // add
         $arrTimeline[$group][] = ['icon' => $arrIcons[$note->getTitle()], 'context' => $arrContext[$note->getTitle()] ?: 'default', 'type' => $note->getTitle(), 'date' => $date->setTimestamp($note->getDate())->get(Zend_Date::DATETIME_MEDIUM), 'avatar' => $avatar, 'user' => $user->getName(), 'message' => $note->getData()['message']['data'], 'title' => $title ?: $note->getTitle()];
     }
     $this->view->timeLine = $arrTimeline;
 }
 /**
  * @param \Pimcore\Model\Object\Concrete $object
  * @param string $method
  * @return bool
  */
 private function isUsingI18n(Pimcore\Model\Object\Concrete $object, $method)
 {
     $modelId = $object->getClassId();
     // Stolen from Object_Class_Resource - it's protected there.
     $file = PIMCORE_CLASS_DIRECTORY . "/definition_" . $modelId . ".psf";
     if (!is_file($file)) {
         return false;
     }
     $tree = unserialize(file_get_contents($file));
     $definition = $this->parse_tree($tree, array());
     return $definition[$method];
 }