Exemplo n.º 1
0
 /**
  * Функция оплаты акции.
  *  
  * @global object $DB база данных
  *
  * @param int $transaction_id ИД транзакции сделки
  * @param int $user_id        ИД пользователя
  *
  * @return int
  */
 public function setPayed($transaction_id, $user_id)
 {
     global $DB;
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/account.php';
     $account = new account();
     if (is_emp($_SESSION['role'])) {
         return 0;
     }
     $bill_id = 0;
     $error = $account->Buy($bill_id, $transaction_id, $this->getConst_OP_CODE(), $user_id, $this->title, $this->descr, $this->getConst_PAYED_SUM(), 0);
     if ($error !== 0) {
         return 0;
     }
     if ($bill_id) {
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/pay_place.php';
         $pay_place = new pay_place(1);
         $account->commit_transaction($transaction_id, $user_id, $bill_id);
         $this->setUserPro($user_id, $bill_id);
         $pay_place->addUserTop($user_id);
         return $bill_id;
     }
     return 0;
 }