public function xlsProductFile()
 {
     $namefile = date('Y:h:i:s') . "_Products";
     Excel::create($namefile, function ($excel) {
         // Set the title
         $excel->setTitle('NMK Group Of Companies');
         // Chain the setters
         $excel->setCreator('NMK Application')->setCompany('NMK');
         // Call them separately
         $excel->setDescription('This files has all products');
         $excel->sheet('Products', function ($sheet) {
             if ($_GET['val'] == "all") {
                 $products = Product::where('product_type', 'Product')->get();
             } else {
                 if ($_GET['val'] == "custom") {
                     $products = Product::where('product_type', 'Custom Cable')->get();
                 } else {
                     if ($_GET['val'] == "7") {
                         $dt = Carbon::now();
                         $products = Product::where('created_at', '>=', $dt->subDays(7))->get();
                     } else {
                         if ($_GET['val'] == "30") {
                             $dt = Carbon::now();
                             $products = Product::where('created_at', '>=', $dt->subDays(30))->get();
                         } else {
                             $products = Product::where('company', '002')->get();
                         }
                     }
                 }
             }
             $sheet->setStyle(array('font' => array('name' => 'Calibri', 'size' => 13)));
             $sheet->row(1, array('Company', 'Person name', 'Item code', 'Alternative code', 'Description', 'Measurement unit', 'Retail price', 'Brand', 'Main supplier', 'Family', 'Group', 'Category', 'Sub category', 'Country', 'Inside box quantity', 'Master pack weight', 'L cm', 'W cm', 'H cm', 'HS code'));
             foreach ($products as $key => $value) {
                 $sheet->row(1, function ($row) {
                     // call cell manipulation methods
                     $row->setBackground('#888888');
                     $row->setFont(array('family' => 'Calibri', 'size' => '16', 'bold' => true));
                 });
                 $sheet->setColumnFormat(array('C' => '0', 'D' => '0'));
                 $sheet->rows(array(array($value->company, $value->person_name, $value->item_code, $value->alternative_code, $value->description, $value->measurement_unit, $value->retail_price, $value->brand, $value->main_supplier, $value->family, $value->group, $value->category, $value->sub_category, $value->country, $value->inside_box_quantity, $value->master_pack_weight, $value->l_cm, $value->w_cm, $value->h_cm, $value->hs_code)));
             }
             //$sheet->fromModel($roles);
             // $sheet->fromArray(array(
             //     array('Name', 'Phone','Email','Job Title','Company','Intrested Brand','Intrested Seminiar'),
             //     $leads
             // ));
             $sheet->setOrientation('landscape');
         });
         // Our second sheet
         if ($_GET['val'] == "custom" || $_GET['val'] == "7" || $_GET['val'] == "30") {
             $excel->sheet('Custom Cable Recipe', function ($sheet) {
                 if ($_GET['val'] == "custom") {
                     $cable_products = Cable::all();
                 } else {
                     if ($_GET['val'] == "7") {
                         $dt = Carbon::now();
                         $cable_products = Cable::where('created_at', '>=', $dt->subDays(7))->get();
                     } else {
                         if ($_GET['val'] == "30") {
                             $dt = Carbon::now();
                             $cable_products = Cable::where('created_at', '>=', $dt->subDays(30))->get();
                         }
                     }
                 }
                 $sheet->setStyle(array('font' => array('name' => 'Calibri', 'size' => 13)));
                 $sheet->row(1, array('Item Code', 'Components', 'Description', 'Qty', 'Measurement Unit'));
                 foreach ($cable_products as $key => $value) {
                     $sheet->row(1, function ($row) {
                         // call cell manipulation methods
                         $row->setBackground('#888888');
                         $row->setFont(array('family' => 'Calibri', 'size' => '16', 'bold' => true));
                     });
                     $sheet->setColumnFormat(array('A' => '0'));
                     $sheet->rows(array(array($value->product_name, $value->recipe_components, $value->recipe_desc, $value->recipe_qty, $value->recipe_mu)));
                 }
                 $sheet->setOrientation('landscape');
             });
         }
     })->export('xls');
 }
Exemple #2
0
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
header('Access-Control-Allow-Origin: http://localhost');
header('Access-Control-Allow-Credentials: true');
Route::get('/', function () {
    return view('admin/roadshows_nmk');
});
/* API Calls to Application */
Route::get('products/api/{id}', function ($id) {
    $product = DB::table('products')->find($id);
    if ($product->product_type == "Custom Cable") {
        $cables = Cable::where('product_name', $product->item_code)->get();
        return Response::json(array($product, $cables));
    } else {
        return Response::json(array($product));
    }
});
Route::get('/main-page', function () {
    return view('admin/nmk-main');
});
Route::get('/add-product', function () {
    return view('admin/products');
});
Route::get('/nmk-customer', function () {
    return view('admin/nmk-customer');
});
Route::get('/roadshow-nmk', function () {