fixed user dashboard for store owner (store settings, store reports)/ fixed login/register page/
This commit is contained in:
@@ -289,27 +289,37 @@ class UserController extends Controller {
|
||||
foreach ($product_array as $p => $pr_arr) {
|
||||
|
||||
$thumbnails_array = $newTeamStoreModel->getProductThumbnails($pr_arr->Id);
|
||||
foreach ($thumbnails_array as $t => $thumb) {
|
||||
|
||||
if(!empty($thumbnails_array)){
|
||||
foreach ($thumbnails_array as $t => $thumb) {
|
||||
|
||||
if($thumb->ImageClass == 'custom'){
|
||||
$displayThumbnails = $thumb->Image;
|
||||
break;
|
||||
if($thumb->ImageClass == 'custom'){
|
||||
$displayThumbnails = $thumb->Image;
|
||||
break;
|
||||
}
|
||||
|
||||
if($thumb->ImageClass == 'active'){
|
||||
$displayThumbnails = $thumb->Image;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$thumbnails[] = array(
|
||||
'folder' => $store_array[0]->ImageFolder,
|
||||
'product_id' => $pr_arr->Id,
|
||||
'thumb' => $displayThumbnails
|
||||
);
|
||||
|
||||
if($thumb->ImageClass == 'active'){
|
||||
$displayThumbnails = $thumb->Image;
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
$thumbnails[] = array(
|
||||
'folder' => $store_array[0]->ImageFolder,
|
||||
'product_id' => $pr_arr->Id,
|
||||
'thumb' => "product-image-placeholder.png"
|
||||
);
|
||||
}
|
||||
|
||||
$thumbnails[] = array(
|
||||
'folder' => $store_array[0]->ImageFolder,
|
||||
'product_id' => $pr_arr->Id,
|
||||
'thumb' => $displayThumbnails
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// var_dump($thumbnails);
|
||||
|
||||
return view('user-layouts.store_items')->with('store_array', $store_array)
|
||||
->with('product_array', $product_array)
|
||||
->with('thumbnails', $thumbnails);
|
||||
@@ -322,8 +332,10 @@ class UserController extends Controller {
|
||||
|
||||
$product_array = $newTeamStoreModel->selectTeamStoreProducts('ProductURL', $url);
|
||||
$thumbnails_array = $newTeamStoreModel->getThumbnails($product_array[0]->Id);
|
||||
$available_size = explode(",", $product_array[0]->AvailableSizes);
|
||||
// var_dump($product_array);
|
||||
return view('user-layouts.view-store-item')->with('product_array', $product_array)
|
||||
->with('available_size', $available_size)
|
||||
->with('thumbnails_array', $thumbnails_array);
|
||||
|
||||
|
||||
@@ -339,7 +351,9 @@ class UserController extends Controller {
|
||||
'ProductName' => $post['itemName'],
|
||||
'ProductPrice' => str_replace('$ ', '', $post['item_price']),
|
||||
'ProductDescription' => $post['itemDescription'],
|
||||
'PrivacyStatus' => $post['item_privacy']
|
||||
'PrivacyStatus' => $post['item_privacy'],
|
||||
'ProductForm' => $post['itemForm'],
|
||||
'AvailableSizes' => implode(",", $post['available_size'])
|
||||
);
|
||||
|
||||
$i = $newTeamStoreModel->updateStoreItem($data, $item_url);
|
||||
@@ -731,13 +745,75 @@ class UserController extends Controller {
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
function saveNewItemImage(Request $request){
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
$getYear = date('y');
|
||||
$id = $post['_id'];
|
||||
|
||||
$getActiveDisplay = $UserModel->selectDisplayItemThumbById($id);
|
||||
|
||||
for($i = 0; $i < count($post['upload_images']); $i++){
|
||||
$rawName = date('Ymd') . "-" . time().'-'.$request->file('upload_images')[$i]->getClientOriginalName();
|
||||
$imageExt = $request->file('upload_images')[$i]->getClientOriginalExtension();
|
||||
|
||||
$custom_file_name = str_replace(' ','-',strtolower($rawName));
|
||||
$custom_file_name = preg_replace("/\.[^.\s]{3,4}$/", "", $custom_file_name);
|
||||
$NewImageName = $custom_file_name.'.'.$imageExt;
|
||||
$thumbnail = $NewImageName;
|
||||
|
||||
if($i == 0 && empty($getActiveDisplay)){
|
||||
$imageClass = "active";
|
||||
}else{
|
||||
$imageClass = null;
|
||||
}
|
||||
|
||||
$thumbs = $data = array(
|
||||
'ProductId' => $id,
|
||||
'Image' => $thumbnail,
|
||||
'ImageClass' =>$imageClass
|
||||
);
|
||||
|
||||
$u = $UserModel->insertNewProductThumbnails($thumbs);
|
||||
// Storage::disk('sftp')->put($thumbnail, fopen($request->file('imgupload')[$i], 'r+')); live
|
||||
Storage::disk('localdir')->put($thumbnail, fopen($request->file('upload_images')[$i], 'r+'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'message' => 'success'
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
function deleteImageThumb(Request $request){
|
||||
$file = $request->thumb_filename;
|
||||
$id = $request->thumb_id;
|
||||
$UserModel = new UserModel;
|
||||
|
||||
$storagePath = Storage::disk('localdir')->getDriver()->getAdapter()->getPathPrefix();
|
||||
if(file_exists($storagePath.$file)) {
|
||||
unlink($storagePath.$file);
|
||||
}
|
||||
|
||||
$i = $UserModel->deleteImageThumb('Id', $id);
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'message' => 'success',
|
||||
'delete_row' => 'item-' . $id
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
function updateActiveThumbnail(Request $request){
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
$i = $UserModel->updateActiveThumb($post['id'], $post['product_id']);
|
||||
var_dump($i);
|
||||
// var_dump($i);
|
||||
|
||||
}
|
||||
|
||||
@@ -756,4 +832,152 @@ class UserController extends Controller {
|
||||
'message' => 'success'
|
||||
));
|
||||
}
|
||||
|
||||
function storeSettingUpdate(Request $request){
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
|
||||
$store_id = Auth::user()->store_id;
|
||||
$store_name = $post['store_name'];
|
||||
$store_url = $post['store_url'];
|
||||
$orig_store_url = $post['orig_store_url'];
|
||||
|
||||
|
||||
if($post['store_status'] == "Public"){
|
||||
$store_status = "true";
|
||||
}else{
|
||||
$store_status = "false";
|
||||
}
|
||||
|
||||
if(isset($post['set_store_password'])){
|
||||
$store_password = $post['store_password'];
|
||||
}else{
|
||||
$store_password = null;
|
||||
}
|
||||
|
||||
if($request->file('store_logo') != null){
|
||||
$store_logo_name = 'logo.'. $request->file('store_logo')->getClientOriginalExtension();
|
||||
}else{
|
||||
$store_logo_name = $post['orig_store_logo'];
|
||||
}
|
||||
|
||||
if($request->file('store_banner') != null){
|
||||
$store_banner_name = 'banner.'. $request->file('store_banner')->getClientOriginalExtension();
|
||||
}else{
|
||||
$store_banner_name = $post['orig_store_banner'];
|
||||
}
|
||||
|
||||
|
||||
if($orig_store_url != $store_url){
|
||||
|
||||
$check_store_url = array(
|
||||
'StoreUrl' => $store_url
|
||||
);
|
||||
|
||||
$validator = Validator::make($check_store_url, [
|
||||
'StoreUrl' => 'unique:teamstores'
|
||||
],
|
||||
[
|
||||
'StoreUrl.unique' => 'The Store URL has already been taken.',
|
||||
]);
|
||||
|
||||
|
||||
if ($validator->fails())
|
||||
{
|
||||
$errors = "";
|
||||
|
||||
foreach($validator->errors()->all() as $error){
|
||||
$errors .= "<li>".$error."</li>";
|
||||
}
|
||||
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'clearform' => false,
|
||||
'message' => $errors
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'StoreUrl' => $store_url,
|
||||
// 'ImageFolder' => $store_url,
|
||||
'Password' => $store_password,
|
||||
'HashId' => md5($store_url),
|
||||
'StoreName' => $store_name,
|
||||
'StoreLogo' => $store_logo_name,
|
||||
'StoreBanner' => $store_banner_name,
|
||||
'IsActive' => $store_status
|
||||
);
|
||||
|
||||
// var_dump($data);
|
||||
|
||||
|
||||
$res = $UserModel->updateTeamstore($store_id, $data);
|
||||
// var_dump($res);
|
||||
// if($res){
|
||||
if($request->file('store_logo') != null){
|
||||
Storage::disk('uploads')->put('/teamstore/'. $orig_store_url . '/' . $store_logo_name, fopen($request->file('store_logo'), 'r+'));
|
||||
}
|
||||
|
||||
if($request->file('store_banner') != null){
|
||||
Storage::disk('uploads')->put('/teamstore/'. $orig_store_url . '/' . $store_banner_name, fopen($request->file('store_banner'), 'r+'));
|
||||
}
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'clearform' => false,
|
||||
'message'=>'Store is successfully updated.'
|
||||
));
|
||||
|
||||
// }else{
|
||||
// return response()->json(array(
|
||||
// 'success' => false,
|
||||
// 'clearform' => true,
|
||||
// 'message' => 'Something went wrong. Please refresh the page and try again.'
|
||||
// ));
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
function storeOrders(){
|
||||
$UserModel = new UserModel;
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
$store_id = Auth::user()->store_id;
|
||||
|
||||
$array_store_orders = $UserModel->selectStoreOrders($store_id);
|
||||
$store_array = $newTeamStoreModel->selectTeamStore('Id', $store_id);
|
||||
|
||||
return view('user-layouts.store-orders')
|
||||
->with('store_array', $store_array)
|
||||
->with('array_store_orders', $array_store_orders);
|
||||
}
|
||||
|
||||
function showStoreOrderDetails(Request $request){
|
||||
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
$array_payment_details = $UserModel->selectPaymentDetails('CartKey', $post['ck']);
|
||||
$array_shipping_add = $UserModel->selectShippingAddress('PaymentDetail_Id', $array_payment_details[0]->Id);
|
||||
|
||||
$array_thumbnail_display = $UserModel->selectDisplayItemThumbById($post['pid']);
|
||||
$array_item = $UserModel->selectOrder('Id', $post['id']);
|
||||
|
||||
$handle_order_detail_body = view('user-layouts.order-details-body')
|
||||
->with('array_payment_details', $array_payment_details)
|
||||
->with('array_shipping_add', $array_shipping_add)
|
||||
->with('array_thumbnail_display', $array_thumbnail_display)
|
||||
->with('array_item', $array_item)
|
||||
->render();
|
||||
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'payment_details_response' => $handle_order_detail_body,
|
||||
'thumb' => $array_thumbnail_display,
|
||||
'item' => $array_item
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user