Ejemplo n.º 1
0
 function send()
 {
     $parser = $this->getParser();
     $request = $this->application->getRequest();
     $apiFieldNames = $parser->getApiFieldNames();
     $orderID = $request->get('orderID');
     $comment = $request->get('text');
     if (!isset($orderID)) {
         throw new Exception("Order ID is required");
     }
     if (!isset($comment)) {
         throw new Exception("User comment is required");
     }
     $order = CustomerOrder::getInstanceById($orderID, CustomerOrder::LOAD_DATA);
     $order->user->get()->load();
     $note = OrderNote::getNewInstance($order, $order->user->get());
     $note->isAdmin->set(false);
     $note->text->set($comment);
     $note->save();
     $note->load(true);
     /*if ($this->application->config->get('NOTIFY_NEW_NOTE'))
             {
                 $order->user->get()->load();
     
                 $email = new Email($this->application);
                 $email->setTo($this->application->config->get('NOTIFICATION_EMAIL'), $this->application->config->get('STORE_NAME'));
                 $email->setTemplate('notify.message');
                 $email->set('order', $order->toArray(array('payments' => true)));
                 $email->set('message', $note->toArray());
                 $email->set('user', $order->user->toArray());
                 $email->send();
             }*/
     $f = new ARSelectFilter();
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('OrderNote', 'ID'), $note->getID()));
     $orderNotes = ActiveRecordModel::getRecordSetArray('OrderNote', $f);
     $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>');
     while ($notes = array_shift($orderNotes)) {
         $xmlPage = $response->addChild('note');
         foreach ($notes as $k => $v) {
             if (in_array($k, $apiFieldNames)) {
                 $xmlPage->addChild($k, htmlentities($v));
             }
         }
     }
     return new SimpleXMLResponse($response);
 }
Ejemplo n.º 2
0
 public function add()
 {
     if ($this->buildOrderNoteValidator()->isValid()) {
         $order = CustomerOrder::getInstanceById($this->request->get('id'), CustomerOrder::LOAD_DATA);
         $note = OrderNote::getNewInstance($order, $this->user);
         $note->isAdmin->set(true);
         $note->text->set($this->request->get('comment'));
         $note->save();
         if ($this->config->get('EMAIL_ORDERNOTE')) {
             $order->user->get()->load();
             $email = new Email($this->application);
             $email->setUser($order->user->get());
             $email->setTemplate('order.message');
             $email->set('order', $order->toArray(array('payments' => true)));
             $email->set('message', $note->toArray());
             $email->send();
         }
         return new ActionRedirectResponse('backend.orderNote', 'view', array('id' => $note->getID()));
     } else {
         return new RawResponse('invalid');
     }
 }
Ejemplo n.º 3
0
 /**
  *	@role login
  */
 public function addNote()
 {
     ClassLoader::import('application.model.order.OrderNote');
     $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('CustomerOrder', 'ID'), $this->request->get('id')));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'userID'), $this->user->getID()));
     $set = ActiveRecordModel::getRecordSet('CustomerOrder', $f);
     if (!$set->size() || !$this->buildNoteValidator()->isValid()) {
         return new ActionRedirectResponse('user', 'index');
     }
     $order = $set->get(0);
     $note = OrderNote::getNewInstance($order, $this->user);
     $note->text->set($this->request->get('text'));
     $note->isAdmin->set(false);
     $note->save();
     if ($this->config->get('NOTIFY_NEW_NOTE')) {
         $order->user->get()->load();
         $email = new Email($this->application);
         $email->setTo($this->config->get('NOTIFICATION_EMAIL'), $this->config->get('STORE_NAME'));
         $email->setTemplate('notify.message');
         $email->set('order', $order->toArray(array('payments' => true)));
         $email->set('message', $note->toArray());
         $email->set('user', $this->user->toArray());
         $email->send();
     }
     return new ActionRedirectResponse('user', 'viewOrder', array('id' => $order->getID()));
 }