Пример #1
0
 /**
  * Добавление нового платежа
  */
 public function action_add(array $params = array())
 {
     $links = Resources::getInstance()->links;
     $request = $this->getRequest();
     if (empty($params)) {
         $this->flash('Не указан идентификатор заявки', $links->get('admin.applications', array('sort_field' => 'fio', 'sort_direction' => 'asc')));
     }
     $app_id = intval(array_shift($params));
     $opts = array('app_id' => $app_id);
     $action = $links->get('payments.add', $opts);
     $form = Form_Payment_Add::create($action);
     $this->set('form', $form);
     $method = $form->method();
     if (empty($request->{$method})) {
         $this->render();
     }
     if (!$form->validate($request)) {
         $this->render();
     }
     $payment = Model_Payment::create();
     $amount = $form->amount->value;
     if (!$payment->add($amount, $app_id)) {
         $msg = 'Не удалось добавить платёж';
     } else {
         $msg = 'Платёж успешно добавлен';
     }
     $this->flash($msg, $links->get('admin.applications', array('sort_field' => 'fio', 'sort_direction' => 'asc')));
 }
Пример #2
0
 /**
  * 获取支付方式
  */
 public function action_payments()
 {
     $address = \Model_Payment::query()->where(['status' => 'ENABLE', 'seller_id' => \Session::get('seller')->id])->get();
     $items = [];
     foreach ($address as $item) {
         array_push($items, $item->to_array());
     }
     die(json_encode(['status' => 'succ', 'msg' => '', 'errcode' => 0, 'data' => $items]));
 }
Пример #3
0
 public function action_delete($id = null)
 {
     is_null($id) and Response::redirect('payment');
     if ($payment = Model_Payment::find($id)) {
         $payment->delete();
         Session::set_flash('success', 'ลบรายการชำระเงิน #' . $id . " แล้ว");
     } else {
         Session::set_flash('error', 'ไม่สามารถลบรายการชำระเงิน #' . $id . " ได้");
     }
     Response::redirect('payment');
 }
Пример #4
0
 public function action_index()
 {
     $this->template->title = "Remittance Payment";
     $this->template->sub = "Follow the steps below to pay";
     if (isset($this->user)) {
         $data["student"] = Model_User::find("first", ["where" => [["deleted_at", 0], ["id", $this->user->id]]]);
     }
     if (Input::post('action') == 'submit') {
         if (Input::post("pay-method", null) != null && Input::post("refno", null) != null) {
             $checkExist = Model_Payment::find("first", ["where" => [["student_id", Input::post("studentId")], ["paid", Input::post("quarter")], ["status", 0]]]);
             if ($checkExist == NULL) {
                 // save
                 $payment = Model_Payment::forge();
                 $payment->student_id = Input::post("studentId");
                 $payment->pay_method = Input::post("paymethod");
                 $payment->paid_at = Input::post("date");
                 $payment->status = 0;
                 $payment->method = Input::post("pay-method");
                 $payment->ref_no = Input::post("refno");
                 if (Input::post("pay-method") == 1) {
                     $payment->paid = "1111";
                 } else {
                     $payment->paid = Input::post("quarter");
                 }
                 $payment->save();
                 $data["user"] = Model_User::find("first", ["where" => [["id", Input::post("studentId")]]]);
                 $pay = Model_Payment::query()->where('status', 0);
                 $lastID = $pay->max('id');
                 $data["pay"] = Model_Payment::find("first", ["where" => [["id", $lastID]]]);
                 //sending mail
                 $body = View::forge("email/payment", $data);
                 $sendmail = Email::forge("JIS");
                 $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
                 $sendmail->to("*****@*****.**");
                 //$sendmail->to("*****@*****.**");
                 $sendmail->subject("Payment / Game-bootcamp");
                 $sendmail->html_body("Dear Admin,<br><br>" . htmlspecialchars_decode($body));
                 $sendmail->send();
                 Response::redirect("/students/top/?success=2");
             } else {
                 Response::redirect("/coursefee/remit/?e=2&g=" . Input::post('paymethod', 0));
             }
         } else {
             Response::redirect("/coursefee/?e=4");
         }
     }
     if (isset($this->user)) {
         $view = View::forge("coursefee/remit", $data);
     } else {
         $view = View::forge("coursefee/remit");
     }
     $this->template->content = $view;
 }
Пример #5
0
 public function action_index()
 {
     $id = Input::get('id', 0);
     $data['payment'] = Model_Payment::find("all", ["where" => [["id", $id]]]);
     //save
     if (Input::post('action') == 'submit') {
         if (Input::post("payid", null) != null) {
             $payid = Input::post("payid", null);
             $payUp = Model_Payment::find("first", ["where" => [["id", $payid]]]);
             DB::update('payment')->value("status", "1")->where('id', '=', $payid)->execute();
             DB::update('users')->value("charge_html", $payUp->paid)->where('id', '=', $payUp->student_id)->execute();
             $data["user"] = Model_User::find("first", ["where" => [["id", $payUp->student_id]]]);
             $data["pay"] = Model_Payment::find("first", ["where" => [["student_id", $payUp->student_id], ["id", $payUp->id]]]);
             $user = $data["user"];
             //sending mail
             $body = View::forge("email/confirm", $data);
             $sendmail = Email::forge("JIS");
             $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
             $sendmail->to($user->email);
             $sendmail->subject("Payment Confirmation / Game-bootcamp");
             $sendmail->html_body("Dear " . $user->firstname . ",<br><br>" . htmlspecialchars_decode($body));
             $sendmail->send();
             Response::redirect("/admin/top/?pay=1");
         } else {
         }
     }
     if (Input::post("paymentID", 0) != 0) {
         $cancel = Model_Payment::find(Input::post("paymentID", 0));
         if ($cancel != null) {
             //save
             $cancel->reason = Input::post("explain", 0);
             $cancel->status = 2;
             $cancel->save();
             $data["cancel"] = Model_Payment::find("first", ["where" => [["id", Input::post("paymentID", 0)]]]);
             $student = $data["cancel"];
             $data["student"] = Model_User::find("first", ["where" => [["id", $student->student_id]]]);
             $stud = $data["student"];
             //sendingmail
             $body = View::forge("email/cancelpayment", $data);
             $sendmail = Email::forge("JIS");
             $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
             $sendmail->to($stud->email);
             $sendmail->subject("Denied Payment / Game-bootcamp");
             $sendmail->html_body("Dear " . $stud->firstname . ",<br><br>" . htmlspecialchars_decode($body));
             $sendmail->send();
             Response::redirect("/admin/top/?s=1");
         }
     }
     $view = View::forge("admin/payment/index", $data);
     $this->template->content = $view;
 }
Пример #6
0
 /**
  * Возвращает ответ на вопрос: "Оплачена ли заявка?" на основе суммирования оплат
  *
  * @param  int   $app_id Идентификатор заявки.
  * @return boolean
  */
 public function isAppPrepaid($app_id)
 {
     $app = Model_Application::create();
     $paym = Model_Payment::create();
     $a = $app->getAppInfo($app_id);
     //print_r($a); die();
     if ($a['type'] == 'program') {
         //товарищ учится по всему направлению
         $prog = $app->getProgram($a['object_id']);
         $paid_money = $paym->getTotal($a['app_id']);
         $rest = $prog['cost'] - $paid_money;
         // (program price - paid already)
     } elseif ($a['type'] == 'discipline') {
         //учится по дисциплине
         $disc = $app->getDiscipline($a['object_id']);
         $upper_prog = $app->getProgram($disc['program_id']);
         $paid_money = $paym->getTotal($a['app_id']);
         $rest = $upper_prog['cost'] * $disc['coef'] / 100 - $paid_money;
         // (program price - paid already)
     }
     return $rest <= 0;
 }
Пример #7
0
 public function action_index()
 {
     $year = date("Y");
     $month = date("m");
     $price = Model_Grade::find("first", ["where" => [["year", $year], ["month", $month]]]);
     if ($price == null) {
         $price = Model_Grade::forge();
         $price->year = $year;
         $price->month = $month;
         $price->grade_1 = Config::get("prices")[0];
         $price->grade_2 = Config::get("prices")[1];
         $price->grade_3 = Config::get("prices")[2];
         $price->grade_4 = Config::get("prices")[3];
         $price->grade_5 = Config::get("prices")[4];
         $price->save();
     }
     $data["ym"] = Input::get("ym", date("Y-m"));
     $data["contacts"] = Model_Contactforum::find("all", ["where" => [["deleted_at", 0]], "order_by" => [["id", "desc"]], "limit" => 5]);
     $data["payment"] = Model_Payment::find("all", ["where" => [["status", 0]], "order_by" => [["id", "desc"]], "limit" => 5]);
     $data["reservations"] = Model_Lessontime::find("all", ["where" => [["deleted_at", 0], ["freetime_at", ">=", strtotime($data["ym"] . "-01")], ["freetime_at", "<", strtotime($data["ym"] . "-01 +1 month")], ["status", ">", 0], ["status", "<>", 3]], "order_by" => [["freetime_at", "asc"]]]);
     $view = View::forge("admin/top", $data);
     $this->template->content = $view;
 }
Пример #8
0
 public function action_index()
 {
     $data['student'] = Model_User::find("all", ["where" => [["id", $this->user->id], ["deleted_at", 0]]]);
     if (Input::post('action') == 'submit') {
         // add
         if (Input::post("amount", null) != null) {
             if (is_uploaded_file($_FILES["photo"]["tmp_name"])) {
                 $filename = str_replace("/", "", $_FILES["photo"]["name"]);
                 $filepath = DOCROOT . "/contents/receipt/" . $filename;
                 if (move_uploaded_file($_FILES["photo"]["tmp_name"], $filepath)) {
                     chmod($filepath, 0644);
                     // save
                     $payment = Model_Payment::forge();
                     $payment->student_id = Input::post("studentId");
                     $payment->pay_method = Input::post("type");
                     $payment->amount = Input::post("amount");
                     $payment->paid_at = Input::post("date");
                     $payment->receipt = $filename;
                     $payment->status = 0;
                     $payment->method = Input::post("method");
                     $payment->paid = Input::post("quarter");
                     $payment->save();
                     Response::redirect("/students/top/?m=1");
                 } else {
                     Response::redirect("/students/payment/?e=1");
                 }
             } else {
                 Response::redirect("/students/payment/?e=2");
             }
         } else {
             Response::redirect("/students/payment/?e=3");
         }
     }
     $view = View::forge("students/payment/index", $data);
     $this->template->content = $view;
 }
Пример #9
0
 function api_b()
 {
     $operators = array("beeline" => 1, "mts" => 2, "megafon" => 3, "tele2" => 4);
     // http://mobi-flirt.ru/utilz/api_b?action=new&request_id=123&msisdn=123456&operator=mts&click_params={'click_id':111}
     // action - text наименование действия - new/quit/pay
     // request_id - int идентификатор уведомления
     // project_id - int внутренний идентификатор проекта
     // msisdn - int msisdn в формате 7xxx..
     // time - timestamp время события
     // operator - text наименование оператора - mts/beeline/megafon/tele2
     // click_params - json get параметры
     $action = isset($_GET['action']) ? $_GET['action'] : '';
     $request_id = intval(isset($_GET['request_id']) ? $_GET['request_id'] : 0);
     $project_id = intval(isset($_GET['project_id']) ? $_GET['project_id'] : 0);
     $msisdn = isset($_GET['msisdn']) ? $_GET['msisdn'] : '';
     $time = isset($_GET['time']) ? $_GET['time'] : '';
     $operator = isset($_GET['operator']) ? $_GET['operator'] : '';
     $click_params = isset($_GET['click_params']) ? $_GET['click_params'] : '';
     $click_id = 0;
     $click_array;
     if (!empty($click_params)) {
         $click_array = json_decode($click_params, true);
         if (isset($click_array)) {
             $click_id = intval(isset($click_array['click_id']) ? $click_array['click_id'] : 0);
         }
     }
     $op = isset($operators[$operator]) ? $operators[$operator] : 0;
     $response = 'fail';
     if ($action === 'new') {
         if ($click_id > 0) {
             $model = new Model_Profile();
             $model->activateProfile($click_id, $msisdn, $op);
         }
         $response = 'ok';
     } else {
         if ($action === 'quit') {
             $model = new Model_Profile();
             if (!empty($msisdn) && intval($msisdn) > 0) {
                 $model->removeProfile($msisdn);
                 $response = 'ok';
             } else {
                 if ($click_id > 0) {
                     $model->removeProfileByClickId($click_id);
                     $response = 'ok';
                 }
             }
         } else {
             if ($action === 'pay') {
                 $model = new Model_Payment();
                 $model->payHistory(0, $click_id, 0, $op, $msisdn);
                 $response = 'ok';
             }
         }
     }
     $this->stat->saveOperator($msisdn, $_SERVER["REQUEST_URI"], $response);
     echo $response;
 }
Пример #10
0
 /**
  * Shows the payment form
  */
 public function action_home()
 {
     // To store any form errors
     $errors = array();
     // Check for a valid AD session form
     $session = Session::instance();
     $temp_ad = $session->get('temp_ad');
     // Redirects user to the create form if temp ad was not found
     if (!$temp_ad) {
         $this->request->redirect('/ads/create');
     }
     $amount = $this->config['ad']['price_base'];
     if (1 == $temp_ad['highlight']) {
         $amount += $this->config['ad']['price_highlight'];
     }
     // Make sure this is a POST request
     if ($this->request->method() == 'POST') {
         // Get required parameters from the web form for the request
         $fields['paymentType'] = urlencode('Sale');
         $fields['amount'] = $this->config['ad']['price_base'];
         $fields['amount'] += $amount;
         $fields['currencyCode'] = 'USD';
         $fields['firstName'] = urlencode(arr::get($_POST, 'firstName'));
         $fields['lastName'] = urlencode(arr::get($_POST, 'lastName'));
         $fields['creditCardType'] = urlencode(arr::get($_POST, 'creditCardType'));
         $fields['creditCardNumber'] = urlencode(arr::get($_POST, 'creditCardNumber'));
         $fields['expDateMonth'] = urlencode(arr::get($_POST, 'expDateMonth'));
         $fields['expDateYear'] = urlencode(arr::get($_POST, 'expDateYear'));
         $fields['cvv2Number'] = urlencode(arr::get($_POST, 'cvv2Number'));
         $fields['address1'] = urlencode(arr::get($_POST, 'address1'));
         $fields['city'] = urlencode(arr::get($_POST, 'city'));
         $fields['state'] = urlencode(arr::get($_POST, 'state'));
         $fields['zip'] = urlencode(arr::get($_POST, 'zip'));
         $fields['country'] = urlencode(arr::get($_POST, 'country'));
         // validates fields
         $validation = Validation::factory($fields);
         $payment = new Model_Payment();
         $rules = $payment->rules();
         $validation->rules('paymentType', $rules['paymentType'])->rules('amount', $rules['amount'])->rules('currencyCode', $rules['currencyCode'])->rules('firstName', $rules['firstName'])->rules('lastName', $rules['lastName'])->rules('creditCardType', $rules['creditCardType'])->rules('creditCardNumber', $rules['creditCardNumber'])->rules('expDateMonth', $rules['expDateMonth'])->rules('expDateYear', $rules['expDateYear'])->rules('cvv2Number', $rules['cvv2Number'])->rules('address1', $rules['address1'])->rules('city', $rules['city'])->rules('state', $rules['state'])->rules('zip', $rules['zip'])->rules('country', $rules['country']);
         if ($validation->check()) {
             // Data seems good, try to send ti to paypal
             $result = $payment->transaction($fields);
             if ($result) {
                 // Adds AD to DB
                 $ad = ORM::factory('ad');
                 $ad->set_fields($temp_ad);
                 $ad->active = 1;
                 // Ugly ugly hack !
                 $ad->_valid = TRUE;
                 $ad->save();
                 // Deleted session
                 $session->delete('temp_ad');
                 // Create temp session value
                 $session->set('ad_created_id', $ad->id);
                 // Send email to client
                 $this->request->redirect('/payment/complete');
             } else {
                 $errors['paypal'] = $payment->resArray['L_LONGMESSAGE0'];
             }
         } else {
             // If form did not pass, get errors
             $e = new ORM_Validation_Exception('payment', $validation);
             $errors = $e->errors('models');
         }
     }
     // Fixed arrays
     $creditCardTypes = array('Visa' => 'Visa', 'MasterCard' => 'MasterCard', 'Discover' => 'Discover', 'Amex' => 'Amex');
     // Months
     $expDateMonths = array('01' => '01', '02' => '02', '03' => '03', '04' => '04', '05' => '05', '06' => '06', '07' => '07', '08' => '08', '09' => '09', '10' => '10', '11' => '11', '12' => '12');
     // Years
     $expDateYears = array();
     for ($i = date('Y'); $i <= (int) date('Y') + 10; $i++) {
         $expDateYears[$i] = $i;
     }
     $this->template->scripts = array('media/js/payment.js');
     // Show view
     $this->template->title = __('Purchase and complete (Final step)');
     $this->template->content = View::factory('payment/purchase', array('creditCardTypes' => $creditCardTypes, 'expDateMonths' => $expDateMonths, 'expDateYears' => $expDateYears, 'countries' => $this->country_list(), 'errors' => $errors, 'temp_payment' => $_POST, 'amount' => $amount));
 }
Пример #11
0
 public function action_index()
 {
     $this->template->title = "Cash Payment";
     $this->template->sub = "Follow the steps below to pay";
     if (isset($this->user)) {
         $data["student"] = Model_User::find("first", ["where" => [["deleted_at", 0], ["id", $this->user->id]]]);
     }
     if (Input::post('action') == 'submit') {
         // add
         if (Input::post("studentId", null) != null) {
             if (is_uploaded_file($_FILES["photo"]["tmp_name"])) {
                 $filename = str_replace("/", "", $_FILES["photo"]["name"]);
                 $filepath = DOCROOT . "/contents/receipt/" . $filename;
                 $checkExist = Model_Payment::find("first", ["where" => [["student_id", Input::post("studentId")], ["paid", Input::post("quarter")], ["status", 0]]]);
                 if ($checkExist == NULL) {
                     if (move_uploaded_file($_FILES["photo"]["tmp_name"], $filepath)) {
                         chmod($filepath, 0644);
                         // save
                         $payment = Model_Payment::forge();
                         $payment->student_id = Input::post("studentId");
                         $payment->pay_method = Input::post("paymethod");
                         $payment->paid_at = Input::post("date");
                         $payment->receipt = $filename;
                         $payment->status = 0;
                         $payment->method = Input::post("method");
                         if (Input::post("method") == 1) {
                             $payment->paid = "1111";
                         } else {
                             $payment->paid = Input::post("quarter");
                         }
                         $payment->save();
                         $data["user"] = Model_User::find("first", ["where" => [["id", Input::post("studentId")]]]);
                         $pay = Model_Payment::query()->where('status', 0);
                         $lastID = $pay->max('id');
                         $data["pay"] = Model_Payment::find("first", ["where" => [["id", $lastID]]]);
                         //sending mail
                         $body = View::forge("email/payment", $data);
                         $sendmail = Email::forge("JIS");
                         $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
                         //$sendmail->to("*****@*****.**");
                         $sendmail->to("*****@*****.**");
                         $sendmail->subject("Payment / Game-bootcamp");
                         $sendmail->html_body("Dear Admin,<br><br>" . htmlspecialchars_decode($body));
                         $rec = $data["pay"];
                         $receipt = Model_Payment::query()->where('id', $rec->id)->limit(1)->get_one();
                         $query = Model_Payment::find($receipt->id);
                         $sendmail->attach(DOCROOT . '/contents/receipt/' . $query->receipt);
                         $sendmail->send();
                         Response::redirect("/students/top/?success=1");
                     } else {
                         Response::redirect("/coursefee/?e=1");
                     }
                 } else {
                     Response::redirect("/coursefee/cash/?e=2&g=" . Input::post('g', 0));
                 }
             } else {
                 Response::redirect("/coursefee/?e=3");
             }
         } else {
             Response::redirect("/coursefee/?e=4");
         }
     }
     if (isset($this->user)) {
         $view = View::forge("coursefee/cash", $data);
     } else {
         $view = View::forge("coursefee/cash");
     }
     $this->template->content = $view;
 }
Пример #12
0
 /**
  * Открыта ли дисциплина для студента
  *
  * @param int $disciplineId
  * @param int $studentId
  * @param array $statuses Статусы заявок студента
  * @return bool
  */
 public function isDisciplineOpenForStudent($disciplineId, $studentId, $statuses = false)
 {
     $result = false;
     $modelApps = Model_Application::create();
     if (!$statuses) {
         $statuses = $modelApps->getAppsStatus($disciplineId, $studentId);
     }
     if (array_key_exists(Model_Application::STATUS_PREPAID, $statuses) || array_key_exists(Model_Application::STATUS_FINISHED, $statuses)) {
         $result = true;
     } elseif ($k = array_search(Model_Application::STATUS_SIGNED, $statuses) !== false) {
         foreach ($statuses[$k] as $appId) {
             $appInfo = $modelApps->getAppInfo($appId);
             $modelEducationPrograms = Model_Education_Programs::create();
             if ($appInfo['type'] == 'discipline') {
                 $programId = $modelEducationPrograms->getProgramIdByDiscipline($appInfo['object_id']);
             } elseif ($appInfo['type'] == 'program') {
                 $programId = $appInfo['object_id'];
             }
             $programInfo = $modelEducationPrograms->getProgramInfo($programId);
             if ($programInfo['paid_type'] == Model_Education_Programs::PAID_TYPE_FREE) {
                 $result = true;
                 break;
             } else {
                 $modelPayment = Model_Payment::create();
                 $total_payment = $modelPayment->getTotal($appId);
                 $cost_total = $program_data['cost'];
                 $ar = $this->_getAllowed(array($disciplineId), $payment_total, $cost_total);
                 if (!empty($ar)) {
                     $result = true;
                     break;
                 }
             }
         }
     }
     return $result;
 }
Пример #13
0
 /**
  * Добавление записи в кортеж о состояние оплаты завки: поля rest (остаток в рублях), rest_rate (остаток в длолях)
  *
  * @param array Кортеж описания  заявки: должен обязательно содержать поля 
  *     app_id, object_id, program_title/discipline_title
  *
  * @return array
  */
 public function addInfoIntoKortegAboutPaidState($a)
 {
     $paym = Model_Payment::create();
     if ($a['program_title']) {
         //товарищ учится по всему направлению
         $prog = $this->getProgram($a['object_id']);
         if ($prog['paid_type'] == 'paid') {
             $paid_money = $paym->getTotal($a['app_id']);
             $rest = $prog['cost'] - $paid_money;
             // (program price - paid already)
             $rest_rate = $rest / $prog['cost'];
             // how many cost's parts to pay
             $app = array_merge($a, array('rest' => $rest, 'rest_rate' => $rest_rate));
         } else {
             $app = array_merge($a, array('rest' => 'free', 'rest_rate' => 'free'));
         }
     } elseif ($a['discipline_title']) {
         //учится по дисциплине
         $disc = $this->getDiscipline($a['object_id']);
         $upper_prog = $this->getProgram($disc['program_id']);
         if ($upper_prog['paid_type'] == 'paid') {
             $paid_money = $paym->getTotal($a['app_id']);
             $rest = $upper_prog['cost'] * $disc['coef'] / 100 - $paid_money;
             // (program price - paid already)
             $rest_rate = $rest / ($upper_prog['cost'] * $disc['coef'] / 100);
             // how many cost's parts to pay
             $app = array_merge($a, array('rest' => $rest, 'rest_rate' => $rest_rate));
         } else {
             $app = array_merge($a, array('rest' => 'free', 'rest_rate' => 'free'));
         }
     }
     return $app;
 }