示例#1
0
 /**
  * Выполняется после ошибки при занесении проекта в БД.
  * Откатывает покупку проекта (если таковая была) и возвращает данные создаваемого/редактируемого проекта
  * в предыдущее состояние (до попытки сохранить проект).
  *
  * @see tmp_project::_preDb()  
  * 
  * @param array   $pre        состояние проекта до попытки сохранения его в БД (состояние перед вызовом $this->_preDb())
  * @param integer $bill_id    account_operations.id -- номер операции при покупки проекта.
  * @param integer $buyer_id   users.uid -- ид. юзера-покупателя проекта.
  */
 private function _postDbFailed($pre, $bill_id, $buyer_id)
 {
     if ($bill_id && $buyer_id) {
         $account = new account();
         $account->Del($buyer_id, $bill_id);
     }
     $this->_project = $pre;
 }
示例#2
0
 /**
  * Отмена совершенной ранее выплаты. Если выплата в FM, то деньги снимаются со счета.
  *
  * @param integer $user_id   ид. юзера, которому предназначается выплата.
  * @return boolean   успешно?
  */
 function unpayout($user_id)
 {
     if (!$this->sbr->isAdmin()) {
         return;
     }
     if (!$this->getPayouts($user_id)) {
         return false;
     }
     $payout = $this->payouts[$user_id];
     if (!$payout['credit_id'] || !$payout['debit_id']) {
         return false;
     }
     $account = new account();
     if (!($err = $account->Del($user_id, $payout['credit_id'])) && !($err = $account->Del($this->sbr->emp_id, $payout['debit_id']))) {
         $sql = "\n              UPDATE sbr_stages_payouts\n                 SET completed = NULL\n               WHERE stage_id = ?i\n                 AND user_id = ?i\n            ";
         $sql = $this->db()->parse($sql, $this->id, $user_id);
         return !!pg_query(self::connect(), $sql);
     }
     return false;
 }
示例#3
0
 /**
  * Изменение логина юзера. Перед вызовом необходимо проинициализировать члены класса
  * old_login, new_login, save_old.
  * 
  * @param string $error	возвращает сообщение об ошибке	
  *
  * @return 0
  *
  * @see classes/db_access#Add($error, $return_id)
  */
 public function Add(&$error)
 {
     global $DB;
     require_once ABS_PATH . '/classes/users.php';
     $user = new users();
     $this->user_id = $user->GetUid($error, $this->old_login);
     if (!$this->user_id) {
         $error = 'Пользователь не найден!';
         return 0;
     }
     $new_user = $user->GetUid($error, $this->new_login);
     if ($new_user) {
         $error = 'Логин занят!';
         return 0;
     }
     if ($this->save_old) {
         require_once ABS_PATH . '/classes/users_old.php';
         require_once ABS_PATH . '/classes/account.php';
         $account = new account();
         $tr_id = $account->start_transaction($this->user_id);
         $id = 0;
         $error = $account->Buy($id, $tr_id, self::OP_CODE, $this->user_id, 'Изменеие логина', 'Изменение логина');
         if ($error) {
             return 0;
         }
         $this->operation_id = $id;
         $users_old = new users_old();
         $users_old->Add($this->old_login);
     }
     if (!$error) {
         $aData = array('user_id' => '', 'old_login' => '', 'new_login' => '', 'save_old' => '', 'operation_id' => '');
         foreach ($aData as $key => $val) {
             $aData[$key] = $this->{$key};
         }
         $CFile = new CFile();
         if (!$CFile->MoveDir($this->new_login, $this->old_login)) {
             $error = "Директория не создана! {$this->new_login}, {$this->old_login}";
             if ($this->operation_id) {
                 $account->Del($this->user_id, $this->operation_id);
             }
         } else {
             $DB->insert('login_change', $aData);
             $user->login = $this->new_login;
             $user->Update($this->user_id, $res);
         }
     }
     return 0;
 }
示例#4
0
 /**
  * Покупка дополнительной специализации.
  *
  * @param $uid integer   ид. пользователя-покупателя.
  * @param $ammount integer   количество специализаций.
  * @param $tr_id integer   ид. транзакции. Если нет, то создается новая.
  * @param integer $commit             Завершать ли транзакцию после этой операции.
  * @return mixed   0 -- все ок, иначе текст ошибки.
  */
 function buySpec($uid, $ammount, $tr_id = 0, $period = '1 mon', $commit = 1)
 {
     global $DB;
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/account.php";
     if ($ammount <= 0) {
         return 0;
     }
     $account = new account();
     $transaction_id = $account->start_transaction($uid, $tr_id);
     $error = $account->Buy($billing_id, $transaction_id, self::OP_PAID_SPEC, $uid, "{$ammount} шт.", "{$ammount} шт.", $ammount, $commit);
     if ($error) {
         return $error;
     }
     do {
         $sql = "INSERT INTO spec_paid_choise (user_id, paid_to) VALUES ({$uid}, now() + '{$period}'::interval) RETURNING id,paid_from,paid_to";
         $res = $DB->query($sql);
         $paid_id = pg_fetch_result($res, 0, 0);
         $paid_from = pg_fetch_result($res, 0, 1);
         $paid_to = pg_fetch_result($res, 0, 2);
         $sql = "INSERT INTO spec_paid_acc_operations (billing_id, paid_from, paid_to)\n                    VALUES ({$billing_id}, '{$paid_from}'::timestamp, '{$paid_to}'::timestamp)";
         $rs = $DB->query($sql);
     } while ($res && --$ammount > 0);
     if (!$res) {
         $account->Del($uid, $billing_id);
         return 'Неизвестная ошибка';
     }
     return 0;
 }
示例#5
0
        }
    } else {
        $sError = 'Пользователь не найден';
    }
} elseif ($action == 'del') {
    if ($_SESSION["rand"] != $_POST["u_token_key"]) {
        header("Location: /404.php");
        exit;
    }
    $sId = intval($_GET['id']);
    $sUid = intval($_GET['uid']);
    $bForce = isset($_GET['force']);
    if ($sId && $sUid) {
        $aInfo = account::getOperationInfo($sId);
        if ($account->GetInfo($sUid) && ($bForce || $account->sum >= $aInfo['ammount'])) {
            $account->Del($sUid, $sId);
            // уведомление о том, что ошибочно зачисленное списано
            require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/smail.php';
            $sm = new smail();
            $sm->alphaBankMistakeSorry($sUid, $aInfo['op_date']);
            $_SESSION['success'] = 'ok';
            header('Location: /siteadmin/alpha/?ds=' . $_GET['ds'] . '&de=' . $_GET['de']);
            exit;
        } else {
            $bAskForce = true;
        }
    } else {
        $sError = 'Данные указаны не верно';
    }
}
if ($_GET['ds']) {
示例#6
0
 case "unblocked":
     $opid = intval($_GET['opid']);
     if ($ok = $account->unBlocked($_SESSION['uid'], $opid)) {
         header('Location: /siteadmin/bill/?login='******'opid']);
     $op_code = intval($_GET['op_code']);
     $pro_opid = array(1, 2, 3, 4, 5, 6, 15, 48, 49, 50, 51, 76, 90, 91, 92, 93);
     if (in_array($op_code, $pro_opid)) {
         $sql = "UPDATE users SET is_pro_auto_prolong = FALSE WHERE login = ?";
         $DB->query($sql, $login);
     }
     print $account->Del($uid, $opid);
     header('Location: /siteadmin/bill/?login='******'login'], $GLOBALS['balanceCanChangeAdmins'])) {
         $ucomment = trim($_POST['ucomment']);
         $scomment = trim($_POST['scomment']);
         $trs_sum = floatval($_POST['val']);
         $sum = floatval($_POST['val']);
         $op_type = floatval($_POST['op_type']);
         $for = floatval($_POST['for']);
         $fort = floatval($_POST['fort']);
         $nrid = floatval($_POST['nrid']);
         $op_date = date('c', strtotime($_POST['date']));
         switch ($op_type) {