public function getCreateinvoice($dealid)
 {
     $id = $dealid;
     $invoicedata = Deal::where('Id', $id)->get();
     // dd($invoicedata);
     foreach ($invoicedata as $dat) {
         # code...
         $evname = $dat['Eventname'];
     }
     $invoicemails = invoiceemails::where('deal_id', $id)->where('invoicemark', '=', 'Y')->get();
     $invemail = $invoicemails->toArray();
     $categories = Event::where('event', $evname)->get();
     foreach ($categories as $category) {
         $EventDate = $category['date'];
     }
     $employee = Employee::all();
     $invoice = Invoice::all();
     return View('executor/createinvoice')->with(array('categories' => $categories, 'employee' => $employee, 'invoice' => $invoice, 'invoicedata' => $invoicedata, 'EventDate' => $EventDate, 'invoicemails' => $invoicemails));
 }
 public function postDelegatedealupload(Request $request)
 {
     $data = Input::get();
     $eventcode = Input::get('eventname');
     $result = explode('|', $eventcode, 2);
     $eventcode = trim($result[0]);
     $eventname = trim($result[1]);
     //emp id and name
     $eid = Input::get('emp_id');
     $result = explode('|', $eid, 2);
     $emid = trim($result[0]);
     $ename = trim($result[1]);
     $leadid = Input::get('leadid');
     $empdept = Input::get('empdept');
     $billingaddress = $data['billingadd'];
     $billiong = preg_replace("/\r|\n/", "", $billingaddress);
     $dealstatus = '1';
     $dealtype = 'single';
     $c = new Deal();
     $ydate = date('Y-m-d', strtotime("-1 days"));
     // dd($ydate);
     if ($data['deal_curr'] != 'INR') {
         $exchnagerate = $this->getExchangex($data['deal_value'], $data['deal_curr'], $ydate);
     } else {
         $exchnagerate = $data['deal_value'];
     }
     if ($data['kindofsub'] == 'paid') {
         $dealvalue = $data['deal_value'];
         $dealcurr = $data['deal_curr'];
     }
     if ($data['kindofsub'] == 'free') {
         $dealvalue = '0';
         $dealcurr = '0';
     }
     $c->Companyname = $data['company'];
     $c->billingadd = $billiong;
     $c->Eventcode = $eventcode;
     $c->Eventname = $eventname;
     $c->Dealdate = $data['dealdate'];
     $c->Dealvalue = $dealvalue;
     $c->kindofsub = $data['kindofsub'];
     $c->Dealcurr = $dealcurr;
     $c->Rcvalue = $exchnagerate;
     $c->Empid = $emid;
     $c->Empname = $ename;
     $c->leadcode = $data['leadcode'];
     $c->Status = $dealstatus;
     $c->Dealtype = $dealtype;
     $c->save();
     $lastinsertid = $c->Id;
     $updatedeal = new delegatedealinfo();
     $updatedeal->deal_id = $lastinsertid;
     $updatedeal->leadcode = $data['leadcode'];
     $updatedeal->boq = '1';
     $updatedeal->vip = 'NULL';
     $updatedeal->hotel = 'NULL';
     $updatedeal->logo = 'NULL';
     $updatedeal->save();
     $benefit = new benefits();
     $benefit->deal_id = $lastinsertid;
     $benefit->leadcode = $data['leadcode'];
     $benefit->hotelaccommodation = $data['hotelacc'];
     $benefit->specification = $data['specification'];
     $benefit->flightticket = $data['flight'];
     $benefit->airportpickupdrop = $data['airport'];
     $benefit->visa = $data['visa'];
     $benefit->save();
     for ($i = 0; $i < count($data['name']); $i++) {
         // dd(count($data['name']));
         $invemail = new invoiceemails();
         $invemail->name = $data['name'][$i];
         $invemail->email = $data['email'][$i];
         $invemail->mobile = $data['mobile'][$i];
         $invemail->desg = $data['desg'][$i];
         $invemail->dept = $data['dept'][$i];
         $invemail->invoicemark = $data['preferred'][$i];
         $invemail->deal_id = $lastinsertid;
         $invemail->leadcode = $data['leadcode'];
         $invemail->save();
     }
     return redirect('initiator/pendingactivity/');
 }