function sendTradeRegisteredNotification($tradeObj)
 {
     if ($tradeObj) {
         try {
             //Get target emails
             $userDao = DaoFactory::getFactory()->getUserDao();
             $buyerData = $userDao->getUserByUid($tradeObj->getBuyerUid());
             $sellerData = $userDao->getUserByUid($tradeObj->getSellerUid());
             $enteredByData = $userDao->getUserByUid($tradeObj->getEnteredByUid());
             $object = new stdClass();
             $object->description = $tradeObj->getDescription();
             $object->amount = $tradeObj->getAmount();
             $object->buyerFullLabel = $buyerData['firstname'] . " " . $buyerData['surname'] . " [" . $tradeObj->getBuyerUid() . "]";
             $object->sellerFullLabel = $sellerData['firstname'] . " " . $sellerData['surname'] . " [" . $tradeObj->getSellerUid() . "]";
             $object->enteredByFullLabel = $enteredByData['firstname'] . " " . $enteredByData['surname'] . " [" . $tradeObj->getEnteredByUid() . "]";
             //die(var_dump($object));
             $message = $this->buildHtmlTradeNotification($object);
             //echo "<br>message-->".$message;
             $title = "Intercambio registrado";
             if ($buyerData['email']) {
                 $this->sendEmail($buyerData['email'], $title, $message);
             }
             if ($sellerData['email']) {
                 $this->sendEmail($sellerData['email'], $title, $message);
             }
             $this->sendEmail("*****@*****.**", $title, $message);
         } catch (Exception $e) {
             throw new Exception("Email notification problem occured" . $e->getMessage());
         }
     }
 }
Esempio n. 2
0
 function deleteTradeById($tradeId)
 {
     $tradeDao = DaoFactory::getFactory()->getTradeDao();
     try {
         $tradeObj = $tradeDao->getTradeById($tradeId);
         $tradeDao->deleteTradeSQL($tradeId);
         //Update seller / buyer credits
         $userDao = DaoFactory::getFactory()->getUserDao();
         $userDao->updateUserCredit($tradeObj['seller']);
         $userDao->updateUserCredit($tradeObj['buyer']);
         return json_encode((object) array(code => 'OK', message => 'Trade successfully removed'));
     } catch (Exception $e) {
         return json_encode((object) array(code => 'KO', message => $e->getMessage()));
     }
 }