Beispiel #1
0
 public static function Update_DB()
 {
     $method = Request::input('method');
     if ($method == "add") {
         $office_salary = new office_salary();
         $pay_status = 0;
         $redirct_link = "add_officepayment";
     } else {
         if ($method == "edit") {
             $id = Request::input('id');
             $office_salary = office_salary::where('id', '=', $id)->first();
             $redirct_link = "edit_officepayment/" . $id;
             if (count($office_salary) > 0) {
                 $pay_status = $office_salary->pay_status;
             } else {
                 $office_salary = new office_salary();
                 $pay_status = 0;
             }
         }
     }
     $pay_name = Request::input('pay_name');
     $pay_amt = Request::input('pay_amt');
     $note = Request::input('note');
     $splite_user_id = explode(" ", Request::input('user_id'));
     $user_id = str_replace("]", "", str_replace("[", "", $splite_user_id[0]));
     if (!is_numeric($user_id)) {
         return redirect::to($redirct_link)->withInput(Request::all())->withErrors("กรุณาเลือกชื่อผู้จ่ายเงินจากรายการที่แสดง");
     }
     $office_salary->pay_name = $pay_name;
     $office_salary->pay_amt = $pay_amt;
     $office_salary->pay_status = $pay_status;
     $office_salary->note = $note;
     $office_salary->user_id = $user_id;
     if ($office_salary->save()) {
         return redirect::to('officepayment_report/null')->with('status', "บันทึกสำเร็จ");
     } else {
         return redirect::to($redirct_link)->with('status', "เกิดข้อผิดพลาดไม่สามารถบันทึกได้");
     }
 }