<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Mail;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class MailController extends Controller {

   public function quotationsendmail(Request $request){
      
      $emaildata=[
         'mailbody'=>$request->mailbody,
         'mailquotation'=>$request->mailquotation,
         'quotationid'=>$request->quotation_ida,
      ];

      $data = $request->mailbody;
      $quotationid=$request->quotation_ida;
      $user=[
         'receiver'=>$request->receiverID,
         'mailsubject'=>$request->mailsubject,
      ];
      // $mailquotation=$request->quotation_ida;
      // $mailbody=$request->mailquotation;
      $receiver=$request->receiverID;
      $mailsubject=$request->mailsubject;
      
      Mail::send('mailformate/quotation_mail',$emaildata,function($message) use($user,$emaildata,$quotationid,$receiver){
         $message->from('admin@tannatechbiz.com', 'TANNA TECHBIZ LLP');
         $message->to($receiver)->subject($user['mailsubject']);
      });
      echo"HTML Email Sent. Check your inbox.";
   }   

   public function pisendmail(Request $request){
      
         $receiver_email=$request->receiverID;
         $mailsubject=$request->mailsubject;
         $mailpi=$request->mailpi;
           
         $emaildata=[
            'mailbody'=>$request->mailbody,
            'mailpi'=>$request->mailpi, 
         ];

         Mail::send('mailformate/pi_mail',$emaildata,function($message) use($receiver_email,$mailsubject){
            $message->from('admin@tannatechbiz.com', 'TANNA TECHBIZ LLP');
            $message->to($receiver_email)->subject($mailsubject);
         });
         echo"HTML Email Sent. Check your inbox.";
   }
   
    public function quotationsendmailforapp(Request $request){
      
      $emaildata=[
         'mailbody'=>$request->mailbody,
         'mailquotation'=>$request->mailquotation,
         'quotationid'=>$request->quotation_ida,
      ];

      $data = $request->mailbody;
      $quotationid=$request->quotation_ida;
      $user=[
         'receiver'=>$request->receiverID,
         'mailsubject'=>$request->mailsubject,
      ];
      // $mailquotation=$request->quotation_ida;
      // $mailbody=$request->mailquotation;
      $receiver=$request->receiverID;
      $mailsubject=$request->mailsubject;
      
      Mail::send('mailformate/quotation_mailapp',$emaildata,function($message) use($user,$emaildata,$quotationid,$receiver){
         $message->from('admin@tannatechbiz.com', 'TANNA TECHBIZ LLP');
         $message->to($receiver)->subject($user['mailsubject']);
      });
      echo"HTML Email Sent. Check your inbox.";
   }

   public function invoicesendmail(Request $request){
      
      $emaildata=[         
         'mailinvoice'=>$request->mailinvoice,
      ];      
      $quotationid=$request->quotation_ida;
      $user=[
         'receiver'=>$request->receiverID,
         'mailsubject'=>$request->mailsubject,
      ];
      $receiver=$request->receiverID;


      Mail::send('mailformate/invoice_mail',$emaildata,function($message) use($user,$emaildata,$quotationid,$receiver){
         $message->from('admin@tannatechbiz.com', 'TANNA TECHBIZ LLP');
         $message->to($receiver)->subject($user['mailsubject']);
      });
      echo"HTML Email Sent. Check your inbox.";
   }

   
}