<?php
	namespace App\Http\Controllers;
	use Illuminate\Foundation\Bus\DispatchesJobs;
	use Illuminate\Routing\Controller as BaseController;
	use Illuminate\Foundation\Validation\ValidatesRequests;
	use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
	use Illuminate\Foundation\Auth\Access\AuthorizesResources;
	use Illuminate\Http\Request;
	use DB;
	use App\Http\Model\QuotationModel;
	use App\Http\Model\PurchaseModel;
	use Validator;
	
	class QuotationRequest extends Controller
	{
		public function __construct()
		{
			$this->Quotation= new QuotationModel;
			$this->purshase= new PurchaseModel;
		}
		
		public function AddQuotation()
		{		    
			$data['Quotatn']=$this->Quotation->Quotation_no();
			$data['company']=$this->purshase->PurchaseCompany();
			$data['itemCompany']=$this->purshase->itemCompany();
			return view('quotationrequest',compact('data'));
		}
		
		public function QutationRequest(Request $request)
		{
			$sub['num']=$request->input('num');
			for($i=1;$i<=$sub['num'];$i++)
			{
				$sub['Schoolname'.$i]=$request->input('Schoolname'.$i);
				$sub['Major'.$i]=$request->input('Major'.$i);
				$sub['Degree'.$i]=$request->input('Degree'.$i);
			}
			$sub['description']=$request->input('description');
			$sub['itemcategory1']=$request->input('itemcategory1');
			$sub['itemcode']=$request->input('itemcode');
			$sub['saleorderdate']=$request->input('saleorderdate');
			$sub['itemcategory']=$request->input('itemcategory');
			$sub['status']=$request->input('status');
			return $purchaseSub=$this->Quotation->QutationRequestItem($sub);
		}
		
		public function ViewQuotation()
		{
		    $data['url']='QuotationRequestview';
		    $Mid=$this->Quotation->QPermission($data);
			$data['delete']= $Mid->Delete;
			$data['edit']= $Mid->Edit;
			$data['create']= $Mid->create;
			$data['ViewQuotation']=$this->Quotation->ViewQutationOrder();
			return view('quotationrequestview',compact('data'));
		}
		
		public function printBillqutat(Request $request)
		{
			$data['Billno']=$request->input('Billno');
			$data['ViewPurchase']=$this->Quotation->printCustomerDetails($data);
			$data['ViewPurchaseItem']=$this->Quotation->printBillItem($data);
			$data['CompanyData']=$this->purshase->CompanyData();
			return view('qutationPrint',compact('data'));			
		}
		
		public function printBillNoCheck(Request $request)
		{
		    $data['Billno']=$request->input('Billno');
			$data['ViewPurchase']=$this->Quotation->MaxprintCustomerDetails();
			$data['ViewPurchaseItem']=$this->Quotation->MaxprintBillItem();
			$data['CompanyData']=$this->purshase->CompanyData();
			return view('purchaseOder',compact('data'));
		}
	}
