/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $validator = Validator::make($request->all(), ['name' => 'required|unique:papers', 'size' => 'required|unique:papers']);
     if ($validator->fails()) {
         if ($request->ajax()) {
             return response()->json($validator->messages());
             exit;
         } else {
             return \Redirect::back()->withErrors($validator)->withInput();
         }
     }
     array_forget($request, "_token");
     $all_request = $request->all();
     $paper = new Paper();
     foreach ($all_request as $key => $value) {
         $paper->{$key} = $value;
     }
     $paper->save();
     $papers = Paper::all();
     if ($request->ajax()) {
         if ($papers) {
             foreach ($papers as $paper) {
                 echo "\n                        <tr>\n                            <td>{$paper->id}</td>\n                            <td>{$paper->name}</td>\n                            <td>{$paper->description}</td>\n                            <td>{$paper->dimension}</td>\n                            <td>{$paper->unit}</td>\n\n                            <td><button class='edtPaperLink btn-primary' cid='{$paper->id}' cname='{$paper->name}' cdescription='{$paper->description}' cdimension='{$paper->dimension}' cunit='{$paper->unit}'><span  class='glyphicon glyphicon-pencil'></span></button></td>\n                            <td><button class='btn-danger'  data-target='#myModalPaperEdit' data-toggle='modal'><span  class='glyphicon glyphicon-trash'></span></button></td>\n                        </tr>\n                        ";
             }
         }
         exit;
     }
     return View("settings.paper", ["companies" => Company::all(), 'papers' => $papers, 'title' => 'Job Papers Setting']);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $dataView = array();
     $dataView['page_title'] = "Compañías";
     $dataView['companies'] = Company::all();
     return view('company.index', $dataView);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $companies = Company::all();
     $accountancies = Accountancy::all();
     return view('admin.accountancy.index')->with(['companies' => $companies, 'accountancies' => $accountancies]);
 }
 public function edit($id)
 {
     $userName = Auth::user()->name;
     $companies = Company::all();
     $campain = Campain::find($id);
     return view('campain.edit', ['userName' => $userName, 'companies' => $companies, 'campain' => $campain]);
 }
 public function showSettings()
 {
     $companies = \App\Company::all()->lists('name', 'id');
     $current_company = \App\Company::find(Auth::user()->current_company);
     //        dd($current_company);
     return view('settings.settings', compact('companies', 'current_company'));
 }
 public function index()
 {
     $data['is_showzhiye'] = Zhiye::where('z_show', '=', '1')->get();
     $data['allzhiye'] = Zhiye::all();
     $data['is_showcompany'] = Company::where('c_show', '=', '1')->get();
     $data['allcompany'] = Company::all();
     $data['alltime'] = Time::all();
     return view('contestRoom.index', $data);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::user()->hasRole('member')) {
         $companies = Company::where('comUserId', '=', Auth::user()->id)->get();
     } else {
         $companies = Company::all()->sortBy('comName');
     }
     return view('company.index', compact('companies'));
 }
 function index()
 {
     $user = Auth::user();
     $posts = Post::latest('id')->get();
     $companies = Company::all();
     $users = User::all();
     $testvar = "XYZABC";
     return view('users.test', compact('testvar'));
     return view('users.index', compact('user', 'posts', 'companies', 'users'));
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $query = Company::all('id', 'name')->toArray();
     // TODO: Rework this to be more efficient. Could probably be done in a
     // shorter way.
     $companies = [];
     foreach ($query as $row) {
         $companies[$row['id']] = $row['name'];
     }
     return view('expenses/create')->with('companies', $companies);
 }
 public function run()
 {
     $contacts = \App\Contact::all();
     $companies = \App\Company::all();
     for ($i = 0; $i < 20; $i++) {
         try {
             $contacts->random()->companies()->attach($companies->random());
         } catch (\Exception $e) {
         }
     }
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $products = Product::all();
     $weeknrs = getWeeknumbers();
     if (Auth::user()->hasRole('member')) {
         $companies = Company::where('comUserId', '=', Auth::user()->id)->get();
     } else {
         $companies = Company::all();
     }
     $providers = Provider::all();
     return view('allocatie.create', compact('products', 'companies', 'weeknrs', 'providers'));
 }
Exemple #12
0
 public function companies()
 {
     $userName = Auth::user()->name;
     $companies = Company::all();
     $results = [];
     foreach ($companies as $company) {
         $company_id = $company->id;
         $campains = DB::table('campains')->where('company_id', '=', $company_id)->get();
         $totalGain = 0;
         $totalInvestment = 1;
         foreach ($campains as $campain) {
             $totalGain = $totalGain + $campain->gain;
             $totalInvestment = $totalInvestment + $campain->cost;
         }
         $roi = ($totalGain - $totalInvestment) / $totalInvestment;
         $roi = number_format($roi, 2);
         $results[] = ["name" => $company->name, "roi" => $roi];
     }
     return view('report.companies', ['userName' => $userName, 'results' => $results]);
 }
 public function months($months)
 {
     Excel::create('通讯报销汇总_' . $months, function ($excel) use($months) {
         $companies = Company::all();
         foreach ($companies as $company) {
             $excel->sheet('new Sheet', function ($sheet) use($company, $months) {
                 $sheet->setAllBorders('thin');
                 // Set border for cells
                 $sheet->setBorder('A1', 'thin');
                 // Font family
                 $sheet->setFontFamily('Comic Sans MS');
                 // Set font with ->setStyle()`
                 $sheet->setStyle(array('font' => array('name' => 'Calibri', 'size' => 11, 'bold' => false)));
                 $sum = \App\MobileFees::where('company_id', $company->id)->where('months', $months)->with('company', 'employee')->sum('fee');
                 $mobilefees = \App\MobileFees::where('company_id', $company->id)->where('months', $months)->with('company', 'employee')->get();
                 $sheet->loadView('report.index')->with('mobilefees', $mobilefees)->with('sum', $sum)->with('company_name', $company->name);
             });
         }
     })->download('xls');
 }
 /**
  * create exhibitor by admin
  * 
  * @return Response
  */
 public function createexhibitorbyadmin()
 {
     $countries = Country::all();
     $companies = Company::all();
     return view('AdminCP.exhibitors.create', compact('countries', 'companies'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     //
     return View("administrators.edituser", ["companies" => Company::all(), "myuser" => User::find($id), "myrole" => \DB::table("role_user")->where("user_id", $id)->get(), "roles" => \DB::table("roles")->get(), "title" => "Edit User"]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return Company::all();
 }
 public function getPrice(Request $request, $compid)
 {
     //
     $mcompany = Company::find($compid);
     $jobprices = \DB::table("prices")->where("company_id", $compid)->get();
     return View("settings.price", ["companies" => Company::all(), "mcompany" => $mcompany, 'prices' => $jobprices, "companyname" => $mcompany->name, 'papers' => Paper::all(), 'jobs' => Job::all(), 'title' => 'Job Price Setting']);
 }
 public function Index()
 {
     return View("dashboard", ["companies" => Company::all()]);
 }
 /**
  * Show the profile for the given user. Yay
  *
  * @param  int  $id
  * @return Response
  */
 public function index()
 {
     $companies = Company::all();
     $types = Category::all();
     return view('pages.home', ['companies' => $companies, 'types' => $types]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $company = Company::all();
     return $company;
 }
Exemple #21
0
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
// 注册路由...
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', 'Auth\\AuthController@postRegister');
Route::resource('upload', 'UploadController');
Route::resource('employee', 'EmployeeController');
Route::get('report/{month?}', 'ReportController@index')->where('month', '(\\d)(\\d)(\\d)(\\d)-[0-1]?[1-9]-[0-3]?[1-9]');
//Route::get('report/{month?}','ReportController@index');
Route::resource('report', 'ReportController');
Route::get('export', function () {
    Excel::create('Filename', function ($excel) {
        // Call writer methods here
        $excel->setTitle('Our new awesome title');
        // Chain the setters
        $excel->setCreator('Maatwebsite')->setCompany('Maatwebsite');
        // Call them separately
        $excel->setDescription('A demonstration to change the file properties');
        $companys = Company::all();
        foreach ($companys as $company) {
            $this->company_name = $company->name;
            $this->company_id = $company->id;
            $excel->sheet($this->company_name, function ($sheet) {
                $employees = \App\Reportview::where('公司', $this->company_name)->get()->toArray();
                $sum = \App\Reportview::sum('费用');
                dd($sum);
                $sheet->with($employees);
            });
        }
    })->export('xlsx');
});
 public function getCompanies()
 {
     return view('admin.companies', ['companies' => Company::all()]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $companies = Company::all();
     return view('company.index', array('title' => 'Video game companies', 'page_h1' => 'Video game companies', 'companies' => $companies));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     return View("privileges.index", ["companies" => Company::all(), 'roles' => Role::all(), 'permissions' => Permission::all(), 'title' => 'Roles and Privileges']);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $companies = Company::all();
     return view('companies/index')->with('companies', $companies);
 }
 public static function getCompanyDetails()
 {
     return Company::all()->first();
 }
 public function generateInvoice(Request $request, $id = "")
 {
     $input = $request->all();
     $company = !empty($id) ? Company::find($id) : Company::find($input['company_id']);
     $ArrMain = [];
     //  print_r($input);
     if (count($input) > 0) {
         //allow room for invoice to be processed for recent uploaded and date range
         $stacks = Invoicingstack::where("company_id", "=", $company->id)->where("status", "=", 0)->get();
         // var_dump("ok ok");
     } else {
         $stacks = Invoicingstack::where("company_id", "=", $company->id)->where("status", "=", 0)->get();
     }
     //$input['id']=$id;
     $total = 0;
     $bill = new Bill();
     $invoiceno = "";
     if (count($stacks) > 0) {
         $bill_no = $bill->genInvoiceNo($company->id) > 0 ? $bill->genInvoiceNo($company->id) : "01";
         $invoiceno = !empty($input['inv_no']) && $input['inv_no'] != "" ? "RJLEX/" . strtoupper(substr($company->name, 0, 3)) . "/" . $input['inv_no'] : "RJLEX/" . strtoupper(substr($company->name, 0, 3)) . "/" . str_pad($bill_no, 3, "0", STR_PAD_LEFT);
         $bill->invoice_no = $invoiceno;
         $bill->created_at = date("Y-m-d H:i:s");
         $bill->updated_at = date("Y-m-d H:i:s");
         $bill->company_id = $company->id;
         $bill->invoice_date = date("Y-m-d H:i:s");
         $check = Bill::where("invoice_no", "=", $invoiceno)->pluck("invoice_no");
         if (!empty($check)) {
             echo "Invoice number already existing in database";
             exit;
         }
         $bill->save();
         //$invoiceno = "RJLEX/".strtoupper(substr($company->name,0,3))."/".$bill->genInvoiceNo();
     }
     $dateFrom = "2000-01-01";
     $dateTo = "2000-01-01";
     $objPHPExcel = new \PHPExcel();
     $m = 0;
     $s = 0;
     foreach ($stacks as $stack) {
         // Create a new worksheet called “My Data”
         $s++;
         $sheetName = "RJLEX_" . strtoupper(substr($company->name, 0, 3)) . "_" . $bill_no;
         $siteName = Branch::where("id", "=", $stack->site_id)->pluck("name");
         $myWorkSheet = new \PHPExcel_Worksheet($objPHPExcel, $siteName);
         $objPHPExcel->addSheet($myWorkSheet, $m);
         /**/
         $objPHPExcel->setActiveSheetIndex($m);
         $m++;
         $site = "";
         $siteName = "";
         $description = "";
         $printNo = 0;
         $copyNo = 0;
         /**
          * For each loop of the invoicing table,
          * compute the cost of each print job and populate/create
          * the invoice detail table
          */
         $a3Arr = [];
         $a4Arr = [];
         $sumNoPagesA3Color = 0;
         //+= $minvoice->number_of_pages;
         $sumAmountA3Color = 0;
         //$amount;
         $sumNoPagesA4Color = 0;
         // $minvoice->number_of_pages;
         $sumAmountA4Color = 0;
         //$amount;
         $sumNoPagesA3Mono = 0;
         // $minvoice->number_of_pages;
         $sumAmountA3Mono = 0;
         $sumNoPagesA4Mono = 0;
         //0 $minvoice->number_of_pages;
         $sumAmountA4Mono = 0;
         //$amount;
         $sumTotal = 0;
         $unitCostA3Mono = 0;
         $unitCostA4Mono = 0;
         $unitCostA3Color = 0;
         $unitCostA4Color = 0;
         $x = 1;
         $p = 1;
         if (count($input) > 0) {
             $invoicing = DB::table("invoicing")->where("stack_id", "=", $stack->id)->get();
             //->where("final_date",">=",$input['date_from'])->where("final_date","<=","date_to")
         } else {
             $invoicing = DB::table("invoicing")->where("stack_id", "=", $stack->id)->get();
         }
         //$dateFrom  = DB::table("invoicing")->where("stack_id","=",$stack->id)->max('final_date');  //DB::table("invoicing")->where()
         //$dateTo    = DB::table("invoicing")->where("stack_id","=",$stack->id)->min('final_date');
         foreach ($invoicing as $minvoice) {
             //One Location in loop
             $froDate = new \DateTime("2000-01-01");
             $toDate = new \DateTime("2000-01-01");
             if ($x == 1) {
                 //$dateFrom = new \DateTime($minvoice->final_date);
                 //$dateTo = new \DateTime($minvoice->final_date);
                 $objPHPExcel->getActiveSheet()->setCellValue('A' . $x, "SITE");
                 $objPHPExcel->getActiveSheet()->setCellValue('B' . $x, "User ID");
                 $objPHPExcel->getActiveSheet()->setCellValue('C' . $x, "Submit IP");
                 $objPHPExcel->getActiveSheet()->setCellValue('D' . $x, "Print Job Name");
                 $objPHPExcel->getActiveSheet()->setCellValue('E' . $x, "Submit Date");
                 $objPHPExcel->getActiveSheet()->setCellValue('F' . $x, "Final Date");
                 $objPHPExcel->getActiveSheet()->setCellValue('G' . $x, "Final Action");
                 $objPHPExcel->getActiveSheet()->setCellValue('H' . $x, "Final Site");
                 $objPHPExcel->getActiveSheet()->setCellValue('I' . $x, "Number of Pages");
                 $objPHPExcel->getActiveSheet()->setCellValue('J' . $x, "Cost Per Page");
                 $objPHPExcel->getActiveSheet()->setCellValue('K' . $x, "Total Cost");
                 $objPHPExcel->getActiveSheet()->setCellValue('L' . $x, "Release IP");
                 $objPHPExcel->getActiveSheet()->setCellValue('M' . $x, "Release User");
                 $objPHPExcel->getActiveSheet()->setCellValue('N' . $x, "Release Method");
                 $objPHPExcel->getActiveSheet()->setCellValue('O' . $x, "Print Job Color");
                 $objPHPExcel->getActiveSheet()->setCellValue('P' . $x, "Print Job Duplex");
                 $objPHPExcel->getActiveSheet()->setCellValue('Q' . $x, "Print Job Paper Size");
                 $objPHPExcel->getActiveSheet()->setCellValue('R' . $x, "Release Model");
                 $objPHPExcel->getActiveSheet()->setCellValue('S' . $x, "Release Model Type");
                 $objPHPExcel->getActiveSheet()->setCellValue('T' . $x, "Rrelease Host Name");
             }
             //$date = date_create_from_format("Y-m-d H:i:s",$minvoice->final_date);
             if (isset($input['date_from'])) {
                 $dateFrom = $input['date_from'];
             } else {
                 /*$froDate = $dateFrom;
                   if( (int)$date->getTimestamp() <= (int)$froDate->getTimestamp() ){
                       $dateFrom = new \DateTime($minvoice->final_date);
                   }*/
             }
             if (isset($input['date_to'])) {
                 $dateTo = $input['date_to'];
             } else {
                 /*$toDate = $dateTo;
                                     if( (int)$date->getTimestamp() >= (int)$toDate->getTimestamp() ){
                                         $dateTo = new \DateTime($minvoice->final_date);
                 
                                     }*/
             }
             $site = Branch::where("id", "=", $minvoice->site)->pluck("name");
             $a3Arr[] = "";
             $a4Arr[] = "";
             // if($minvoice->job_paper_size == "A3"){}
             $paperid = DB::table("papers")->where("name", $minvoice->job_paper_size)->pluck("id");
             if (strtolower($minvoice->final_action) == "p" || strtolower($minvoice->final_action) == "c") {
                 //check if action type is print
                 /**
                  * check if colored or mono
                  */
                 $p++;
                 if (strtolower($minvoice->device_type) == "c") {
                     if (strtolower($minvoice->job_color) == "y") {
                         if ($minvoice->job_paper_size == "A3" || ($minvoice->job_paper_size == "Tabloid" || $minvoice->job_paper_size == "Ledger")) {
                             if (strtolower($minvoice->device_name) == 'lexmark x925' || strtolower($minvoice->device_name) == 'lexmark x950' || strtolower($minvoice->device_name) == 'lexmark x950de' || strtolower($minvoice->device_name) == 'lexmark x792de' || strtolower($minvoice->device_name) == 'lexmark cx510de') {
                                 $cost = Price::where("job_id", 1)->where("job_type", "color")->where("paper_id", $paperid)->pluck("price");
                                 $amount = $cost * $minvoice->number_of_pages;
                                 $sumNoPagesA3Color += $minvoice->number_of_pages;
                                 $sumAmountA3Color += $amount;
                                 //not longer neccessory because cumulated pages could be multiplied by the unit cost
                                 $unitCostA3Color = $cost;
                                 $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                                 $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                                 $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                                 $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                                 $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                                 $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                                 $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "Y");
                                 //
                                 $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                                 //duplex
                                 $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, $minvoice->job_paper_size);
                                 $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                                 $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                                 $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                             } elseif (strtolower($minvoice->device_name) == 'lexmark x860') {
                                 # else if Lexmark X860 (a mono A3 printer) //|| strtolower($minvoice->device_name) == 'lexmark x860de'
                                 $cost = Price::where("job_id", 1)->where("job_type", "mono")->where("paper_id", $paperid)->pluck("price");
                                 $amount = $cost * $minvoice->number_of_pages;
                                 $sumNoPagesA3Mono += $minvoice->number_of_pages;
                                 $sumAmountA3Mono += $amount;
                                 //not longer neccessory because cumulated pages could be multiplied by the unit cost
                                 $unitCostA3Mono = $cost;
                                 $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                                 $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                                 $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                                 $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                                 $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                                 $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                                 $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "N");
                                 //
                                 $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                                 //duplex
                                 $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, $minvoice->job_paper_size);
                                 $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                                 $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                                 $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                             } else {
                                 # otherwise its an A4 job for color not A3 as may be indicated in datafile but A4
                                 $cost = Price::where("job_id", 1)->where("job_type", "color")->where("paper_id", $paperid)->pluck("price");
                                 $amount = $cost * $minvoice->number_of_pages;
                                 $sumNoPagesA4Color += $minvoice->number_of_pages;
                                 $sumAmountA4Color += $amount;
                                 //not longer neccessory because cumulated pages could be multiplied by the unit cost
                                 $unitCostA4Color = $cost;
                                 $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                                 $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                                 $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                                 $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                                 $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                                 $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                                 $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "Y");
                                 //
                                 $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                                 //duplex
                                 $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, $minvoice->job_paper_size);
                                 $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                                 $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                                 $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                             }
                         } else {
                             $cost = Price::where("job_id", 1)->where("job_type", "color")->where("paper_id", $paperid)->pluck("price");
                             $amount = $cost * $minvoice->number_of_pages;
                             $sumNoPagesA4Color += $minvoice->number_of_pages;
                             $sumAmountA4Color += $amount;
                             //not longer neccessory because cumulated pages could be multiplied by the unit cost
                             $unitCostA4Color = $cost;
                             $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                             $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                             $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                             $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                             $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                             $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                             $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                             $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                             $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                             $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                             $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                             $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                             $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                             $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                             $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "Y");
                             //
                             $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                             //duplex
                             $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, $minvoice->job_paper_size);
                             $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                             $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                             $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                         }
                     } elseif (strtolower($minvoice->job_color) == "n") {
                         if ($minvoice->job_paper_size == "A3" || ($minvoice->job_paper_size == "Tabloid" || $minvoice->job_paper_size == "Ledger")) {
                             //&&
                             if (strtolower($minvoice->device_name) == 'lexmark mx860') {
                                 //de
                                 $cost = Price::where("job_id", 1)->where("job_type", "mono")->where("paper_id", $paperid)->pluck("price");
                                 $amount = $cost * $minvoice->number_of_pages;
                                 $sumNoPagesA3Mono += $minvoice->number_of_pages;
                                 $sumAmountA3Mono += $amount;
                                 //not longer neccessory because cumulated pages could be multiplied by the unit cost
                                 $unitCostA3Mono = $cost;
                                 $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                                 $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                                 $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                                 $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                                 $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                                 $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                                 $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "N");
                                 //
                                 $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                                 //duplex
                                 $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, $minvoice->job_paper_size);
                                 $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                                 $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                                 $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                             } elseif (strtolower($minvoice->device_name) == 'lexmark x925' || strtolower($minvoice->device_name) == 'lexmark x950' || strtolower($minvoice->device_name) == 'lexmark x950de' || strtolower($minvoice->device_name) == 'lexmark x792de' || strtolower($minvoice->device_name) == 'lexmark cx510de') {
                                 $cost = Price::where("job_id", 1)->where("job_type", "mono")->where("paper_id", $paperid)->pluck("price");
                                 $amount = $cost * $minvoice->number_of_pages;
                                 $sumNoPagesA3Mono += $minvoice->number_of_pages;
                                 $sumAmountA3Mono += $amount;
                                 //not longer neccessory because cumulated pages could be multiplied by the unit cost
                                 $unitCostA3Mono = $cost;
                                 $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                                 $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                                 $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                                 $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                                 $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                                 $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                                 $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "N");
                                 //
                                 $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                                 //duplex
                                 $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, $minvoice->job_paper_size);
                                 $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                                 $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                                 $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                             } else {
                                 # otherwise its an A4 job for mono not A3 as may be indicated in datafile
                                 /** Print is a mono device*/
                                 $cost = Price::where("job_id", 1)->where("job_type", "mono")->where("paper_id", $paperid)->pluck("price");
                                 $amount = $cost * $minvoice->number_of_pages;
                                 $sumNoPagesA4Mono += $minvoice->number_of_pages;
                                 $sumAmountA4Mono += $amount;
                                 //not longer neccessory because cumulated pages could be multiplied by the unit cost
                                 $unitCostA4Mono = $cost;
                                 $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                                 $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                                 $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                                 $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                                 $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                                 $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                                 $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                                 $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                                 $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                                 $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                                 $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "N");
                                 //
                                 $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                                 //duplex
                                 $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, $minvoice->job_paper_size);
                                 $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                                 $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                                 $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                             }
                         } else {
                             $cost = Price::where("job_id", 1)->where("job_type", "mono")->where("paper_id", $paperid)->pluck("price");
                             $amount = $cost * $minvoice->number_of_pages;
                             $sumNoPagesA4Mono += $minvoice->number_of_pages;
                             $sumAmountA4Mono += $amount;
                             //not longer neccessory because cumulated pages could be multiplied by the unit cost
                             $unitCostA4Mono = $cost;
                             $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                             $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                             $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                             $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                             $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                             $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                             $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                             $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                             $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                             $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                             $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                             $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                             $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                             $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                             $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "N");
                             //
                             $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                             //duplex
                             $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, $minvoice->job_paper_size);
                             $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                             $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                             $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                         }
                     }
                 } elseif (strtolower($minvoice->device_type) == "m") {
                     if ($minvoice->job_paper_size == "A3" || ($minvoice->job_paper_size == "Tabloid" || $minvoice->job_paper_size == "Ledger")) {
                         #if device type is a mono and paper is A3
                         if (strtolower($minvoice->device_name) == 'lexmark mx860') {
                             #de we need to be sure its an lexmark mx860de device
                             $cost = Price::where("job_id", 1)->where("job_type", "mono")->where("paper_id", $paperid)->pluck("price");
                             $amount = $cost * $minvoice->number_of_pages;
                             $sumNoPagesA3Mono += $minvoice->number_of_pages;
                             $sumAmountA3Mono += $amount;
                             //not longer neccessory because cumulated pages could be multiplied by the unit cost
                             $unitCostA3Mono = $cost;
                             $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                             $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                             $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                             $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                             $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                             $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                             $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                             $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                             $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                             $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                             $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                             $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                             $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                             $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                             $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "N");
                             //
                             $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                             //duplex
                             $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, $minvoice->job_paper_size);
                             $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                             $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                             $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                         } elseif (strtolower($minvoice->device_name) == 'lexmark x654de' || strtolower($minvoice->device_name) == 'lexmark x654' || (strtolower($minvoice->device_name) == 'lexmark t656' || strtolower($minvoice->device_name) == 'lexmark t656de')) {
                             # otherwise its an A4 job for mono not A3 as may be indicated in script
                             $paperid = DB::table("papers")->where("name", "A4")->pluck("id");
                             $cost = Price::where("job_id", 1)->where("job_type", "mono")->where("paper_id", $paperid)->pluck("price");
                             $amount = $cost * $minvoice->number_of_pages;
                             $sumNoPagesA4Mono += $minvoice->number_of_pages;
                             $sumAmountA4Mono += $amount;
                             //not longer neccessory because cumulated pages could be multiplied by the unit cost
                             $unitCostA4Mono = $cost;
                             $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                             $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                             $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                             $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                             $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                             $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                             $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                             $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                             $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                             $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                             $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                             $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                             $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                             $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                             $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "N");
                             //
                             $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                             //duplex
                             $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, "A4");
                             $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                             $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                             $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                         }
                     } else {
                         $cost = Price::where("job_id", 1)->where("job_type", "mono")->where("paper_id", $paperid)->pluck("price");
                         $amount = $cost * $minvoice->number_of_pages;
                         $sumNoPagesA4Mono += $minvoice->number_of_pages;
                         $sumAmountA4Mono += $amount;
                         //not longer neccessory because cumulated pages could be multiplied by the unit cost
                         $unitCostA4Mono = $cost;
                         $objPHPExcel->getActiveSheet()->setCellValue('A' . $p, $site);
                         $objPHPExcel->getActiveSheet()->setCellValue('B' . $p, $minvoice->user);
                         $objPHPExcel->getActiveSheet()->setCellValue('C' . $p, $minvoice->ip);
                         $objPHPExcel->getActiveSheet()->setCellValue('D' . $p, $minvoice->job_title);
                         $objPHPExcel->getActiveSheet()->setCellValue('E' . $p, $minvoice->submit_date);
                         $objPHPExcel->getActiveSheet()->setCellValue('F' . $p, $minvoice->final_date);
                         $objPHPExcel->getActiveSheet()->setCellValue('G' . $p, $minvoice->final_action);
                         $objPHPExcel->getActiveSheet()->setCellValue('H' . $p, $minvoice->final_site);
                         $objPHPExcel->getActiveSheet()->setCellValue('I' . $p, $minvoice->number_of_pages);
                         $objPHPExcel->getActiveSheet()->setCellValue('J' . $p, $cost);
                         $objPHPExcel->getActiveSheet()->setCellValue('K' . $p, $amount);
                         $objPHPExcel->getActiveSheet()->setCellValue('L' . $p, $minvoice->release_ip);
                         $objPHPExcel->getActiveSheet()->setCellValue('M' . $p, $minvoice->release_user);
                         $objPHPExcel->getActiveSheet()->setCellValue('N' . $p, $minvoice->release_method);
                         $objPHPExcel->getActiveSheet()->setCellValue('O' . $p, "N");
                         //
                         $objPHPExcel->getActiveSheet()->setCellValue('P' . $p, $minvoice->print_job_duplex);
                         //duplex
                         $objPHPExcel->getActiveSheet()->setCellValue('Q' . $p, $minvoice->job_paper_size);
                         $objPHPExcel->getActiveSheet()->setCellValue('R' . $p, $minvoice->device_name);
                         $objPHPExcel->getActiveSheet()->setCellValue('S' . $p, $minvoice->device_type);
                         $objPHPExcel->getActiveSheet()->setCellValue('T' . $p, $minvoice->device_host);
                     }
                 }
                 $printNo++;
             }
             $x++;
         }
         //End of invoicing loop
         $b = $p + 5;
         $sumAmountA3Color = $sumNoPagesA3Color * $unitCostA3Color;
         $sumAmountA3Mono = $sumNoPagesA3Mono * $unitCostA3Mono;
         $sumAmountA4Color = $sumNoPagesA4Color * $unitCostA4Color;
         $sumAmountA4Mono = $sumNoPagesA4Mono * $unitCostA4Mono;
         /**
          * Sum total of all net
          * amounts
          */
         $sumTotal += $sumAmountA4Mono;
         $sumTotal += $sumAmountA3Mono;
         $sumTotal += $sumAmountA4Color;
         $sumTotal += $sumAmountA3Color;
         $a3Arr = ["a3mono" => ["nopages" => $sumNoPagesA3Mono, "unitcost" => $unitCostA3Mono, "netamount" => $sumAmountA3Mono], "a3color" => ["nopages" => $sumNoPagesA3Color, "unitcost" => $unitCostA3Color, "netamount" => $sumAmountA3Color]];
         if ($sumNoPagesA3Mono > 0) {
             DB::table("invoice_detail")->insert(['invoice_id' => $bill->id, 'branch_id' => $minvoice->site, 'location' => $site, 'un_identity' => 'A3 Mono', 'description' => "Print / Copy Mono A3", 'no_of_pages' => $sumNoPagesA3Mono, 'cost_per_page' => $unitCostA3Mono, 'paper_size' => "A3", 'amount' => $sumAmountA3Mono, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")]);
         }
         if ($sumNoPagesA3Color > 0) {
             DB::table("invoice_detail")->insert(['invoice_id' => $bill->id, 'branch_id' => $minvoice->site, 'location' => $site, 'un_identity' => 'A3 Color', 'description' => "Print / Copy Color A3", 'no_of_pages' => $sumNoPagesA3Color, 'cost_per_page' => $unitCostA3Color, 'paper_size' => "A3", 'amount' => $sumAmountA3Color, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")]);
         }
         if ($sumNoPagesA4Mono > 0) {
             DB::table("invoice_detail")->insert(['invoice_id' => $bill->id, 'branch_id' => $minvoice->site, 'location' => $site, 'un_identity' => 'A4 Mono', 'description' => "Print / Copy Mono A4", 'no_of_pages' => $sumNoPagesA4Mono, 'cost_per_page' => $unitCostA4Mono, 'paper_size' => "A4", 'amount' => $sumAmountA4Mono, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")]);
         }
         if ($sumNoPagesA4Color > 0) {
             DB::table("invoice_detail")->insert(['invoice_id' => $bill->id, 'branch_id' => $minvoice->site, 'location' => $site, 'un_identity' => 'A4 Color', 'description' => "Print / Copy Color A4", 'no_of_pages' => $sumNoPagesA4Color, 'cost_per_page' => $unitCostA4Color, 'paper_size' => "A4", 'amount' => $sumAmountA4Color, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")]);
         }
         $a4Arr = ["a4mono" => ["nopages" => $sumNoPagesA4Mono, "unitcost" => $unitCostA4Mono, "netamount" => $sumAmountA4Mono], "a4color" => ["nopages" => $sumNoPagesA4Color, "unitcost" => $unitCostA4Color, "netamount" => $sumAmountA4Color]];
         array_push($ArrMain, ["site" => $site, "a4" => $a4Arr, "a3" => $a3Arr, "sumTotal" => $sumTotal]);
         $total += $sumTotal;
         $stack->status = 1;
         $stack->update();
     }
     // End of stack loop
     if (isset($input['date_from']) && isset($input['date_to'])) {
         $duration = date_format(date_create($input['date_from']), "d M. Y") . " - " . date_format(date_create($input['date_to']), "d M. Y");
     } else {
         // $duration = date_format($dateFrom ,"d M. Y") ." - ". date_format($dateTo,"d M. Y");
     }
     define('BUDGETS_DIR', public_path() . "/invoicexlxs/");
     // I define this in a constants.php file
     $pdfPath = "";
     if (!is_dir(BUDGETS_DIR)) {
         mkdir(BUDGETS_DIR, 0755, true);
     }
     $fileurl = "RJLEX_" . strtoupper(substr($company->name, 0, 3)) . "_" . date("Y-M-d") . "_" . time();
     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007");
     $objWriter->save(BUDGETS_DIR . $fileurl . ".xlsx");
     $outputName = $fileurl . ".pdf";
     // str_random is a [Laravel helper](http://laravel.com/docs/helpers#strings)
     $pdfPath = BUDGETS_DIR . $outputName;
     $bill->pdf_url = $outputName;
     // File::put($pdfPath, PDF::loadView($pdf, 'A4', 'portrait')->output());
     $bill->subtotal = $total;
     $bill->tax = 5 / 100 * $total;
     $bill->total = $total + $bill->tax;
     $bill->invoice_date = date("Y-m-d H:i:s");
     $bill->duration = $duration;
     $bill->file_url = $fileurl . ".xlsx";
     $bill->update();
     $input["invoice"] = $bill;
     $invoiceItems = DB::table("invoice_detail")->where("invoice_id", $bill->id)->groupBy("location")->get();
     $input["invoiceItems"] = $invoiceItems;
     //$pdf = new PDF($dompdf, $config, $app['files'], $app['view']);
     $pdf = App::make('dompdf.wrapper');
     //$pdf->set_base_path(public_path()."/bootstrap");->download($outputName)
     $pdf->loadView('invoicing.invoicepdf', $input)->setPaper('a4')->setOrientation('landscape')->save($pdfPath);
     //return $pdf->download($outputName);
     return View("invoicing.invoice", ["companies" => Company::all(), 'invoice' => $bill, "total" => $total, "company" => $company, "branches" => Branch::where("company_id", $company->id)->get(), "invoiceDatum" => $ArrMain, "title" => "Invoice"]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $companies = Company::all();
     return view('estabelecimentos.index', compact('companies'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $companies = Company::all();
     return view('companies.index', compact('companies'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $companies = Company::all();
     return view('admin.company.index')->with(['companies' => $companies]);
 }