Beispiel #1
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');
 }
Beispiel #2
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;
 }
Beispiel #3
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;
 }
Beispiel #4
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;
 }
Beispiel #5
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;
 }