コード例 #1
0
    /**
     * [reqSaveAction description]
     * @return [type] [description]
     */
    public function reqSaveAction()
    {
        $data = Input::all();
        // var_dump($data);exit;
        $req = new RequestData();
        $qry_data = new QueryData();
        $dataid = $data['dataid'];
        $conid = $data['condid'];
        $agencycode = $data['agencyid'];
        $req_type = $data['req_type'];
        $rs_check = $qry_data->checkNumData($agencycode, $dataid);
        if ($rs_check > 0) {
            $numReq = $req->numReqData($dataid, $conid, $agencycode, $req_type);
            //Count reqest data
            //var_dump($rs['data']);
            // var_dump($numReq);
            // exit;
            if ($numReq == 0) {
                $req->data_id = $data['dataid'];
                $req->cond_id = $data['condid'];
                $req->agency_code = $data['agencyid'];
                $req->req_status = FALSE;
                $req->send_userid = Auth::getUser()->id;
                $req->send_agencyid = Auth::getUser()->agency_id;
                $req->downloaded = FALSE;
                $req->req_type = $data['req_type'];
                $req->save();
                return '<div class="alert alert-success alert-block">
						<button type="button" class="close" data-dismiss="alert">&times;</button>
				        <strong>เสร็จสิ้น</strong> คำร้องขอของท่านได้รับการบันทึกเรียบร้อยแล้ว.
				      </div>';
            } else {
                return '<div class="alert alert-danger alert-block">
						<button type="button" class="close" data-dismiss="alert">&times;</button>
				        <strong>ผิดพลาด</strong> ไม่พบข้อมูลที่ท่านร้องขอในฐานข้อมูล หรือท่านได้ทำการร้องขอข้อมูลนี้ไปแล้ว.
				      </div>';
            }
        } else {
            return '<div class="alert alert-danger alert-block">
						<button type="button" class="close" data-dismiss="alert">&times;</button>
				        <strong>ผิดพลาด</strong> ไม่พบข้อมูลที่ท่านร้องขอในฐานข้อมูล.
				      </div>';
        }
    }