added order status list
This commit is contained in:
@@ -12,7 +12,8 @@ use Illuminate\Support\Facades\Validator;
|
||||
// use Validator;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Excel;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
// use Maatwebsite\Excel\Excel;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
@@ -1349,52 +1350,65 @@ class AdminController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function importExcel(Request $request){
|
||||
public function importExcel(Request $request)
|
||||
{
|
||||
//validate the xls file
|
||||
$this->validate($request, array(
|
||||
'file' => 'required'
|
||||
'file' => 'required'
|
||||
));
|
||||
|
||||
if($request->hasFile('file')){
|
||||
$extension = File::extension($request->file->getClientOriginalName());
|
||||
if ($extension == "xlsx" || $extension == "xls" || $extension == "csv") {
|
||||
if ($request->hasFile('file')) {
|
||||
$extension = File::extension($request->file->getClientOriginalName());
|
||||
if ($extension == "xlsx" || $extension == "xls" || $extension == "csv") {
|
||||
|
||||
$path = $request->file->getRealPath();
|
||||
$data = Excel::load($path, function($reader) {
|
||||
})->get();
|
||||
if(!empty($data) && $data->count()){
|
||||
$path = $request->file->getRealPath();
|
||||
$data = Excel::load($path, function ($reader) {
|
||||
})->get();
|
||||
if (!empty($data) && $data->count()) {
|
||||
|
||||
// var_dump($data);
|
||||
// var_dump($data);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$insert[] = [
|
||||
'TrackingNumber' => $value->tracking_number,
|
||||
'InvoiceNumber' => $value->invoice_number,
|
||||
'Carrier' => $value->carrier,
|
||||
'StepId' => 10,
|
||||
'ScannedBy' => 1,
|
||||
'created_at'=> Carbon::now()
|
||||
];
|
||||
}
|
||||
foreach ($data as $key => $value) {
|
||||
$insert[] = [
|
||||
'TrackingNumber' => $value->tracking_number,
|
||||
'InvoiceNumber' => $value->invoice_number,
|
||||
'Carrier' => $value->carrier,
|
||||
'StepId' => 10,
|
||||
'ScannedBy' => 1,
|
||||
'created_at' => Carbon::now()
|
||||
];
|
||||
}
|
||||
|
||||
if(!empty($insert)){
|
||||
if (!empty($insert)) {
|
||||
|
||||
$insertData = DB::table('tracking')->insert($insert);
|
||||
if ($insertData) {
|
||||
Session::flash('success', 'Your Data has successfully imported');
|
||||
}else {
|
||||
Session::flash('error', 'Error inserting the data..');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
$insertData = DB::table('tracking')->insert($insert);
|
||||
if ($insertData) {
|
||||
Session::flash('success', 'Your Data has successfully imported');
|
||||
} else {
|
||||
Session::flash('error', 'Error inserting the data..');
|
||||
return back();
|
||||
}
|
||||
|
||||
return back();
|
||||
|
||||
}else {
|
||||
Session::flash('error', 'File is a '.$extension.' file.!! Please upload a valid xls/csv file..!!');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
return back();
|
||||
} else {
|
||||
Session::flash('error', 'File is a ' . $extension . ' file.!! Please upload a valid xls/csv file..!!');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function homeCarousel()
|
||||
{
|
||||
$AdminModel = new AdminModel;
|
||||
$selectHomeCarousel = $AdminModel->selectHomeCarousel();
|
||||
return view('admin_pages.home_carousel')->with("carousels", $selectHomeCarousel);
|
||||
}
|
||||
|
||||
public function orderStatus() {
|
||||
$AdminModel = new AdminModel;
|
||||
$selectOrderStatus = $AdminModel->selectOrderStatus();
|
||||
return view('admin_pages.order_status')->with("order_status", $selectOrderStatus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,11 @@ Route::group(['middleware' => 'auth'], function () {
|
||||
|
||||
|
||||
|
||||
Route::get('duplicate-store/{id}/{newstore_id}', 'admin\AdminController@duplicateStore' );
|
||||
Route::get('duplicate-store/{id}/{newstore_id}', 'admin\AdminController@duplicateStore');
|
||||
|
||||
|
||||
Route::get('home-carousel', 'admin\AdminController@homeCarousel');
|
||||
Route::get('order-status', 'admin\AdminController@orderStatus');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -601,4 +601,28 @@ class AdminModel extends Model
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectHomeCarousel()
|
||||
{
|
||||
$i = DB::table('home_carousel')->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
function selectOrderStatus()
|
||||
{
|
||||
$i = DB::select("SELECT t.StoreName, pd.InvoiceNumber, o.ProductName, (
|
||||
SELECT ts.StepLabel
|
||||
FROM tracking AS tr
|
||||
LEFT JOIN tracking_steps AS ts ON tr.StepId = ts.Id
|
||||
WHERE tr.InvoiceNumber = pd.InvoiceNumber
|
||||
ORDER BY tr.StepId DESC
|
||||
LIMIT 1
|
||||
) AS OrderStatus, pd.DateCreated
|
||||
FROM orders AS o
|
||||
INNER JOIN teamstores AS t ON t.Id = o.StoreId
|
||||
INNER JOIN payment_details AS pd ON pd.CartKey = o.CartKey");
|
||||
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user