/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex($dealid)
 {
     $id = $dealid;
     $invoicedata = Deal::where('Id', $id)->get();
     // dd($invoicedata);
     foreach ($invoicedata as $dat) {
         # code...
         $evname = $dat['Eventname'];
     }
     $categories = Event::where('event', $evname)->get();
     foreach ($categories as $category) {
         $EventDate = $category['date'];
     }
     $employee = Employee::all();
     $invoice = Invoice::all();
     return View('createinvoice')->with(array('categories' => $categories, 'employee' => $employee, 'invoice' => $invoice, 'invoicedata' => $invoicedata, 'EventDate' => $EventDate));
 }
<?php

use App\vipbooking;
use App\Deal;
use App\Event;
use App\hotelform;
$lastId = hotelform::get()->last();
$lastinvoice = hotelform::where('id', $lastId->id)->get();
foreach ($lastinvoice as $inv) {
    $leadcode = $inv->leadcode;
    $token = $inv['token'];
    $token1 = str_random(30);
}
$details = Deal::where('leadcode', $leadcode)->get();
foreach ($details as $lead) {
    $eventc = $lead->Eventcode;
}
$event = Event::where('eventcode', $eventc)->get();
foreach ($event as $eve) {
}
?>
	<p><b>Dear {{$inv->clientname}}	</b></p>								
										
	<p>We thank  <b>{{$lead->Companyname}} </b>for giving us an opportunity to serve you at our initiative <b>{{$lead->Eventname}}</b>  to be held on <b>{{$eve->date}}</b> at <b>{{$eve->city}},{{$eve->country}}</b>								
	As part of the confirmation process you need to fill up a Service booking  form.	</p>								
										
	<p>Please follow the link to register for the initiative:</p>	


	<p>Service  Booking Form Link : {{url('form/serviceform/'.$token."===".$token1)}} </p>									
										
 public function postDealcancel(Request $request)
 {
     $dealid = Input::get('dealid');
     $post = Input::get();
     $i = Deal::where('Id', $dealid)->update(array('Status' => 'Request Cancel'));
     if ($i > 0) {
         $request->session()->flash('alert-success', 'Updated Success!');
         return redirect('executor/dealsclosed');
     }
 }
 public function getServiceform($token1)
 {
     $status = 0;
     $token = explode('===', $token1);
     $lead_id = hotelform::where('token', $token[0])->get();
     // dd($lead_id);
     foreach ($lead_id as $lead) {
         $leadcode = $lead->leadcode;
         if ($lead->token == $token[0]) {
             $status = 1;
         }
     }
     //dd($dealtype);
     if ($status == 1) {
         $dealtype = Deal::where('leadcode', $leadcode)->get();
         foreach ($dealtype as $dealt) {
             $evcode = $dealt->Eventcode;
             # code...
         }
         $vip = vipbooking::where('leadcode', $leadcode)->max('id');
         $event = Event::where('eventcode', $evcode)->get();
         $leadsheet = leadsheet::where('leadcode', $leadcode)->get();
         $benefits = benefits::where('leadcode', $leadcode)->get();
         return View('form/serviceform')->with(array('lead_id' => $lead_id, 'dealtype' => $dealtype, 'event' => $event, 'leadsheet' => $leadsheet, 'benefits' => $benefits, 'vip' => $vip));
     } else {
         echo 'token expired';
     }
 }
 public function postVariancecard()
 {
     $empid = Auth::user()->empid;
     $eventName = Input::get('event');
     $targets = Targetassign::where('Employeeid', $empid)->where('Eventname', $eventName)->get();
     $variancedata = $targets;
     $deals = Deal::where('Eventname', $eventName)->where('Empid', $empid)->get();
     $eventDate = Event::where('event', $eventName)->select('date')->get();
     $userData = array();
     $key = 0;
     foreach ($eventDate as $val) {
         $eventdate = $val['date'];
     }
     foreach ($targets as $target) {
         $achieved = 0;
         $userData[$key]['event'] = $target->Eventname;
         $userData[$key]['eventcode'] = $target->Eventcode;
         $userData[$key]['targetVal'] = $target->Targetvalue;
         foreach ($deals as $key1 => $deal) {
             if ($target->Eventname == $deal->Eventname) {
                 $achieved = $achieved + $deal->Dealvalue;
                 $dealx[$key1]['dealdate'] = $deal->Dealdate;
                 $dealx[$key1]['cost'] = (double) $deal->Dealvalue;
             }
         }
         $userData[$key]['achieved'] = $achieved;
         $userData[$key]['variance'] = $achieved - $target->Targetvalue;
         $userData[$key]['cur'] = $target->Currency;
         $date2 = strtotime(date('d-m-Y'));
         $date1 = $target->Targetdate;
         $date5 = $target->Targetassigned;
         // dd($date5);
         $date3 = strtotime($target->Targetdate);
         $diff = $date3 - $date2;
         $days = floor($diff / (60 * 60 * 24));
         // dd($days);
         $userData[$key]['dayleft'] = $days;
         $key++;
     }
     $dealjson = json_encode($dealx);
     // dd($dealjson);
     return View('targetmodule/variancecard')->with(array('target' => $targets, 'userdata' => $userData, 'variancedata' => $variancedata, 'eventdate' => $date1, 'targetdate' => $date5, 'dealjson' => $dealjson));
 }
 public function postInvoice(Request $request)
 {
     $dealid = Input::get('dealid');
     $variable = Input::get('purpose');
     $inv = 'IDE';
     $nameofinvoice = 'PROFORMA INVOICE';
     $dateValue = date('d-m-Y');
     $time = strtotime($dateValue);
     $year = date("Y", $time);
     $count = Invoice::all()->count();
     $counti = $count + 01;
     $invoicecode = $inv . $year . $counti;
     $varr = 'Null';
     $st = 'Invoice Created';
     $dealstatus = '0';
     if ($variable == 'annual') {
         $c = new Invoice();
         $c->Particulars = Input::get('purpose');
         $c->CientAddress = Input::get('client_address');
         $c->ClientName = Input::get('client_name');
         $c->Companyname = Input::get('companyname');
         $c->ClientEmail = Input::get('client_email');
         $c->RepresentativeNo = Input::get('rep_id');
         $c->InvoiceDate = Input::get('invoice_date');
         $c->DueDate = Input::get('due_date');
         $c->AnnualSerialNo = Input::get('s_no_anuual1');
         $c->AnnualText = Input::get('anuual_text');
         $c->AnnualCurrencyType = Input::get('annual_currency1');
         $c->AnnualAmount = Input::get('annual_amount1');
         $c->SerialNo = Input::get('s_no');
         $c->Eventcode = Input::get('eventcode');
         $c->EventName = Input::get('event_name');
         $c->CurrencyType = Input::get('currency_type');
         $c->Amount = Input::get('amount');
         $c->GrandTotal = Input::get('grand_total');
         $c->Subtotal = Input::get('sub_total');
         $c->AmountInWords = Input::get('amount_in_words');
         $c->PaymentTerms = Input::get('payment_interms');
         $c->ServiceTax = Input::get('service_tax');
         $c->ServiceTaxAmount = Input::get('service_tax_amount');
         $c->Status = $varr;
         $c->InvoiceCode = $invoicecode;
         $c->Nameofinvoice = $nameofinvoice;
         $c->dealid = $dealid;
         $c->save();
         // you had skipped the parenthesis in your code.
         $insertedId = $c->id;
         $invoicedata = Invoice::where('Id', $insertedId)->get();
         foreach ($invoicedata as $in) {
             $inv = $in->InvoiceCode;
             # code...
         }
         $html22 = View('pdfgenerate')->with(array('invoicedata' => $invoicedata))->render();
         $html1 = "<h1>adsfadsfasdf</h1>";
         require_once app_path() . '/libs/html2pdf/html2pdf.class.php';
         $html2pdf = new \HTML2PDF('P', 'A4', 'en', true, 'UTF-8', array(0, 0, 0, 0));
         // $html2pdf->pdf->SetDisplayMode('fullpage');
         $html2pdf->WriteHTML($html22);
         $htmltosend = $html2pdf->Output('', 'S');
         $i = 'Invoice_';
         $b = $inv;
         $h = '_Generated';
         $subject = $i . $b . $h;
         Mail::send('emails.test', ['Invoice' => 'hgff'], function ($message) use($subject, $htmltosend) {
             // note: if you don't set this, it will use the defaults from config/mail.php
             $message->from('*****@*****.**', 'Jeevan');
             $message->to('*****@*****.**', 'Harshitha')->subject($subject)->attachData($htmltosend, 'invoice.pdf', array('mime' => 'application/pdf', 'Content-Disposition' => 'attachment'));
         });
         $request->session()->flash('alert-success', 'Invoice was successful added!');
         return redirect('dealsclosed');
     }
     if ($variable == 'single') {
         $c = new Invoice();
         $c->Particulars = Input::get('purpose');
         $c->CientAddress = Input::get('client_address');
         $c->ClientName = Input::get('client_name');
         $c->Companyname = Input::get('companyname');
         $c->ClientEmail = Input::get('client_email');
         $c->RepresentativeNo = Input::get('rep_id');
         $c->InvoiceDate = Input::get('invoice_date');
         $c->DueDate = Input::get('due_date');
         $c->SerialNo = Input::get('s_no');
         $c->Eventcode = Input::get('eventcode');
         $c->EventName = Input::get('event_name');
         $c->CurrencyType = Input::get('currency_type');
         $c->Amount = Input::get('amount');
         $c->ServiceTax = Input::get('service_tax');
         $c->ServiceTaxAmount = Input::get('service_tax_amount');
         $c->GrandTotal = Input::get('grand_total');
         $c->Subtotal = Input::get('sub_total');
         $c->AmountInWords = Input::get('amount_in_words');
         $c->PaymentTerms = Input::get('payment_interms');
         $c->InvoiceCode = $invoicecode;
         $c->Nameofinvoice = $nameofinvoice;
         $c->dealid = $dealid;
         $c->Status = $varr;
         $c->save();
         // you had skipped the parenthesis in your code.
         $insertedId = $c->id;
         $invoicedata = Invoice::where('Id', $insertedId)->get();
         foreach ($invoicedata as $in) {
             $inv = $in->InvoiceCode;
             # code...
         }
         $i = Deal::where('Id', $dealid)->update(array('Status' => $dealstatus));
         $html22 = View('pdfgenerate')->with(array('invoicedata' => $invoicedata))->render();
         $html1 = "<h1>adsfadsfasdf</h1>";
         require_once app_path() . '/libs/html2pdf/html2pdf.class.php';
         $html2pdf = new \HTML2PDF('P', 'A4', 'en', true, 'UTF-8', array(0, 0, 0, 0));
         // $html2pdf->pdf->SetDisplayMode('fullpage');
         $html2pdf->WriteHTML($html22);
         $htmltosend = $html2pdf->Output('', 'S');
         $i = 'Invoice_';
         $b = $inv;
         $h = '_Generated';
         $subject = $i . $b . $h;
         Mail::send('emails.test', ['Invoice' => 'hgff'], function ($message) use($subject, $htmltosend) {
             // note: if you don't set this, it will use the defaults from config/mail.php
             $message->from('*****@*****.**', 'Jeevan');
             $message->to('*****@*****.**', 'Harshitha')->subject($subject)->attachData($htmltosend, 'invoice.pdf', array('mime' => 'application/pdf', 'Content-Disposition' => 'attachment'));
         });
         $request->session()->flash('alert-success', 'Invoice was successful added!');
         //return redirect()->route('/home');
         return redirect('dealsclosed');
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getIndex()
 {
     $categories = Deal::where('Status', '=', 1)->get();
     $in = Invoice::all();
     return View('dealsclosed')->with(array('categories' => $categories, 'in' => $in));
 }
 public function getVipbooking($token)
 {
     $status = 0;
     $lead_id = vipbooking::where('confirmation_code', $token)->get();
     foreach ($lead_id as $lead) {
         $leadocde = $lead->leadcode;
         if ($lead->confirmation_code == $token) {
             $status = 1;
         }
     }
     $dealtype = Deal::where('leadcode', $leadocde)->get();
     //dd($dealtype);
     if ($status == 1) {
         return View('initiator/vipbooking')->with(array('lead_id' => $lead_id, 'dealtype' => $dealtype));
     }
     /**$lead_id=Deal::where('leadcode',$dealid)->get();
        return View('initiator/vipbooking')->with(array('lead_id'=>$lead_id));**/
     /**$status=0;
      	
     	$lead_id=vipbooking::where('confirmation_code',$token)->get();
     	
     	foreach($lead_id as $lead){
     		if($lead->confirmation_code==$token)
     		{
     			$status =1;
     		}
     	}
     	
     	if($status==1)
     	{
           		 return View('initiator/editdeal')->with(array('lead_id'=>$lead_id));
           		 return View('initiator/home');
           
           }else
           	dd('ssss');**/
 }
 public function getViewdetails($dealid)
 {
     $leadsheet = leadsheet::where('leadcode', $dealid)->get();
     // dd($leadsheet);
     $varr = Auth::user()->empid;
     $evarr = User::where('empid', $varr)->get();
     $emp = Employee::where('emp_ide_id', $varr)->get();
     foreach ($emp as $empp) {
         $fromemail = $empp->email;
     }
     // dd($fromemail);
     $lead_id = Deal::where('leadcode', $dealid)->get();
     foreach ($lead_id as $editlead) {
         $dealid = $editlead->Id;
         $leadcode = $editlead->leadcode;
     }
     // dd($dealid);
     $editlead = vipbooking::where('leadcode', $leadcode)->where('deal_id', $dealid)->where('id', DB::raw("(select max(`id`) from vipbooking)"))->get();
     $delegateinfo = delegatedealinfo::where('leadcode', $leadcode)->where('deal_id', $dealid)->get();
     //dd(count($editlead));
     return View('initiator/viewdetails')->with(array('lead_id' => $lead_id, 'editlead' => $editlead, 'emp' => $emp, 'delegateinfo' => $delegateinfo, 'leadsheet' => $leadsheet));
 }
 public function postHotelform(Request $request)
 {
     // dd('dhkajhd');
     $post = Input::get();
     $leadcode = Input::get('leadid');
     $pemail = Input::get('pemail');
     $dealid = Input::get('dealid');
     $pname = Input::get('pname');
     $confirmation_code = str_random(30);
     // $fromemail=Input::get('fromemail');
     // $empid=Input::get('empid');
     // dd($fromemail);
     $c = new hotelform();
     $c->pemail = $pemail;
     $c->pname = $pname;
     $c->dealid = $dealid;
     $c->leadcode = $leadcode;
     $c->token = $confirmation_code;
     $c->save();
     //update delegate deal info
     $deal = Deal::where('leadcode', $leadcode)->get();
     foreach ($deal as $key) {
         $event = $key->Eventname;
         $company = $key->Companyname;
     }
     // dd($confirmation_code);
     $subject = $event . "_" . "Service" . " Booking" . "Form" . "_" . $company;
     // dd($subject);
     Mail::send('emails.hotelbooking', ['Hotelbooking' => 'sdsad'], function ($message) use($subject, $pemail) {
         // note: if you don't set this, it will use the defaults from config/mail.php
         $message->from('*****@*****.**', 'IDE Consulting Services Pvt  Ltd');
         $message->to($pemail)->subject($subject);
     });
     $request->session()->flash('alert-success', 'Service Booking  Form has been sent to client');
     return redirect('reviewer/pendingactivity');
 }