diff --git a/app/Http/Controllers/paypal/PaypalController.php b/app/Http/Controllers/paypal/PaypalController.php
index 49ec306..b322702 100755
--- a/app/Http/Controllers/paypal/PaypalController.php
+++ b/app/Http/Controllers/paypal/PaypalController.php
@@ -611,6 +611,7 @@ class PaypalController extends Controller
//throw $th;
// echo $e->getCode();
echo $e->getData();
+ // var_dump($e->getData());
Session::put('cartkeyError', 'Invalid payment.');
return Redirect::route('cart');
}
diff --git a/app/Http/Controllers/user/UserController.php b/app/Http/Controllers/user/UserController.php
index f84f252..1e2713e 100755
--- a/app/Http/Controllers/user/UserController.php
+++ b/app/Http/Controllers/user/UserController.php
@@ -1,4 +1,6 @@
-role;
- if($userRole == "store_owner"){
+ if ($userRole == "store_owner") {
$storeId = Auth::user()->store_id;
$countStoreOrder = $m->countStoreOrder($storeId);
@@ -34,8 +38,8 @@ class UserController extends Controller {
'store_income' => $storeIncome[0]->store_income,
'store_product_count' => $countStoreProduct[0]->store_product_count,
'store_published_product' => $countStorePublishedProduct[0]->store_published_product
- );
- }else{
+ );
+ } else {
$post_data = array(
'isStoreOwner' => false,
'store_order' => "",
@@ -47,32 +51,32 @@ class UserController extends Controller {
// $post_data = json_encode($post_data, JSON_FORCE_OBJECT);
return view('user-layouts.index')->with('data', $post_data);
-
}
- public function addressBook(){
+ public function addressBook()
+ {
$m = new UserModel;
$userId = Auth::user()->id;
-
+
$array_address_book = $m->selectAddresBook('UserId', $userId);
return view('user-layouts.address_book')
- ->with('array_address_book', $array_address_book);
-
+ ->with('array_address_book', $array_address_book);
}
- public function createAddressBook(){
+ public function createAddressBook()
+ {
return view('user-layouts.create_address_book');
-
}
- public function saveAddressBook(Request $request){
+ public function saveAddressBook(Request $request)
+ {
$post = $request->all();
$m = new UserModel;
$userId = Auth::user()->id;
-
+
$data = array(
'UserId' => $userId,
'Fullname' => $post['fullname'],
@@ -86,27 +90,27 @@ class UserController extends Controller {
'CountryCode' => $post['countryCode'],
'Country' => $post['country']
);
-
- echo $i = $m->insertAddressBook($data);
+ echo $i = $m->insertAddressBook($data);
}
- public function editAddressBook($id){
+ public function editAddressBook($id)
+ {
$m = new UserModel;
$userId = Auth::user()->id;
-
+
$array_address_book = $m->selectAddresBook('Id', $id);
-
- if($array_address_book[0]->UserId != $userId){
+
+ if ($array_address_book[0]->UserId != $userId) {
return redirect('user/address-book');
}
-
+
return view('user-layouts.edit_address_book')
- ->with('array_address_book', $array_address_book);
-
+ ->with('array_address_book', $array_address_book);
}
- public function updateAddressBook(Request $request){
+ public function updateAddressBook(Request $request)
+ {
$post = $request->all();
$m = new UserModel;
@@ -126,90 +130,94 @@ class UserController extends Controller {
'CountryCode' => $post['countryCode'],
'Country' => $post['country']
);
-
- echo $i = $m->saveUpdateAddressBook($data, $id);
+ echo $i = $m->saveUpdateAddressBook($data, $id);
}
- public function profile(){
+ public function profile()
+ {
$m = new UserModel;
$userId = Auth::user()->id;
$array_profile_info = $m->selectProfileInfo($userId);
return view('user-layouts.profile')
- ->with('array_profile_info', $array_profile_info);
+ ->with('array_profile_info', $array_profile_info);
}
- public function editProfile(){
+ public function editProfile()
+ {
$m = new UserModel;
$userId = Auth::user()->id;
$array_profile_info = $m->selectProfileInfo($userId);
return view('user-layouts.edit_profile')
- ->with('array_profile_info', $array_profile_info);
-
+ ->with('array_profile_info', $array_profile_info);
}
-
- public function updateProfile(Request $request){
+
+ public function updateProfile(Request $request)
+ {
$post = $request->all();
$m = new UserModel;
$userId = Auth::user()->id;
$user_logins_data = array(
- 'name' => $post['fullname'],
- 'email' => $post['email'],
- 'other_email' => $post['other_email'],
- );
+ 'name' => $post['fullname'],
+ 'email' => $post['email'],
+ 'other_email' => $post['other_email'],
+ );
$user_info_data = array(
- 'UserId' => $userId,
- 'ContactNumber' => $post['contactnumber'],
- 'Gender' => $post['gender'],
- 'Birthday' => date('Y-m-d', strtotime($post['birthday']))
- );
-
+ 'UserId' => $userId,
+ 'ContactNumber' => $post['contactnumber'],
+ 'Gender' => $post['gender'],
+ 'Birthday' => date('Y-m-d', strtotime($post['birthday']))
+ );
+
$i = $m->saveUpdateUserLogins($user_logins_data, $userId);
$i1 = $m->saveUpdateUserInfo($user_info_data, $userId);
-
+
return $i;
}
- public function changePassword(){
+ public function changePassword()
+ {
return view('user-layouts.change_password');
}
- public function updatePassword(Request $request){
+ public function updatePassword(Request $request)
+ {
$post = $request->all();
$m = new UserModel;
$c_password = Auth::user()->password;
$userId = Auth::user()->id;
- if(!(Hash::check($post['current_password'], $c_password))){
+ if (!(Hash::check($post['current_password'], $c_password))) {
$message = "Your current password does not matches with the password you provided. Please try again.";
- return $message;
+ return $message;
}
- if(strcmp($post['current_password'], $post['new_password']) == 0){
- //Current password and new password are same
+ if (strcmp($post['current_password'], $post['new_password']) == 0) {
+ //Current password and new password are same
$message = "New Password cannot be same as your current password. Please choose a different password.";
- return $message;
- }
+ return $message;
+ }
if ($post['new_password'] != $post['con_new_password']) {
// The passwords matches
$message = "Password confirmation and New Password must match. Please try again.";
- return $message;
+ return $message;
}
- $i = $m->saveUpdatePassword(bcrypt($post['new_password']) , $userId);
-
+ $i = $m->saveUpdatePassword(bcrypt($post['new_password']), $userId);
+
return $i;
}
-
- public function orders(){
+
+ public function orders()
+ {
$m = new UserModel;
$userId = Auth::user()->id;
$array_payment_details = $m->selectPaymentDetails('UserId', $userId);
@@ -221,23 +229,25 @@ class UserController extends Controller {
}
- public function myDesigns(){
+ public function myDesigns()
+ {
$m = new UserModel;
$userId = Auth::user()->id;
-
+
$array_client_designs = $m->selectClientDesigns($userId);
// var_dump($array_client_designs);
return view('user-layouts.my-design')->with('array_client_designs', $array_client_designs);
}
-
- public function viewDesign($designCode){
+
+ public function viewDesign($designCode)
+ {
$m = new UserModel;
$newMainModel = new MainModel;
$userId = Auth::user()->id;
$array_client_designs = $m->selectClientDesignsbyCode($designCode);
-
+
// check if its your design
- if($userId != $array_client_designs[0]->ClientId){
+ if ($userId != $array_client_designs[0]->ClientId) {
return redirect()->back();
}
@@ -245,12 +255,13 @@ class UserController extends Controller {
$array_cat_name = $newMainModel->selectCategoryName($array_client_designs[0]->TemplateCode);
return view('user-layouts.view-design')
- ->with('array_client_designs', $array_client_designs)
- ->with('array_template_paths', $array_template_paths)
- ->with('array_cat_name', $array_cat_name);
+ ->with('array_client_designs', $array_client_designs)
+ ->with('array_template_paths', $array_template_paths)
+ ->with('array_cat_name', $array_cat_name);
}
- public function updateDesignDetails(Request $request){
+ public function updateDesignDetails(Request $request)
+ {
$post = $request->all();
$m = new UserModel;
@@ -264,27 +275,25 @@ class UserController extends Controller {
$i = $m->updateClientDesign($client_design_data, $design_code);
return $i;
-
}
- public function store(){
+ public function store()
+ {
$m = new UserModel;
$userRole = Auth::user()->role;
$array_store_info = array();
- if($userRole == "store_owner"){
+ if ($userRole == "store_owner") {
$storeId = Auth::user()->store_id;
-
+
$array_store_info = $m->selectStoreInfo($storeId);
- return redirect('store/'. $array_store_info[0]->StoreUrl);
-
-
+ return redirect('store/' . $array_store_info[0]->StoreUrl);
}
-
}
- public function storeItems(){
+ public function storeItems()
+ {
$thumbnails = array();
$newUserModel = new UserModel;
$newTeamStoreModel = new TeamStoreModel;
@@ -299,42 +308,41 @@ class UserController extends Controller {
$thumbnails_array = $newTeamStoreModel->getProductThumbnails($pr_arr->Id);
- if(!empty($thumbnails_array)){
+ if (!empty($thumbnails_array)) {
foreach ($thumbnails_array as $t => $thumb) {
-
- if($thumb->ImageClass == 'custom'){
+
+ if ($thumb->ImageClass == 'custom') {
$displayThumbnails = $thumb->Image;
break;
}
-
- if($thumb->ImageClass == 'active'){
+
+ if ($thumb->ImageClass == 'active') {
$displayThumbnails = $thumb->Image;
break;
- }
+ }
}
-
- $thumbnails[] = array(
- 'folder' => $store_array[0]->ImageFolder,
- 'product_id' => $pr_arr->Id,
- 'thumb' => $displayThumbnails
- );
- }else{
$thumbnails[] = array(
- 'folder' => $store_array[0]->ImageFolder,
- 'product_id' => $pr_arr->Id,
- 'thumb' => "product-image-placeholder.png"
+ 'folder' => $store_array[0]->ImageFolder,
+ 'product_id' => $pr_arr->Id,
+ 'thumb' => $displayThumbnails
+ );
+ } else {
+ $thumbnails[] = array(
+ 'folder' => $store_array[0]->ImageFolder,
+ 'product_id' => $pr_arr->Id,
+ 'thumb' => "product-image-placeholder.png"
);
}
-
}
-
+
return view('user-layouts.store_items')->with('store_array', $store_array)
- ->with('product_array', $product_array)
- ->with('thumbnails', $thumbnails);
+ ->with('product_array', $product_array)
+ ->with('thumbnails', $thumbnails);
}
- public function viewStoreItem($url){
+ public function viewStoreItem($url)
+ {
$product_array = array();
$newUserModel = new UserModel;
$newTeamStoreModel = new TeamStoreModel;
@@ -345,21 +353,20 @@ class UserController extends Controller {
$shipping_cost = $newUserModel->selectShippingCost();
return view('user-layouts.view-store-item')->with('product_array', $product_array)
- ->with('available_size', $available_size)
- ->with('thumbnails_array', $thumbnails_array)
- ->with('shipping_cost', $shipping_cost);
-
-
+ ->with('available_size', $available_size)
+ ->with('thumbnails_array', $thumbnails_array)
+ ->with('shipping_cost', $shipping_cost);
}
- public function storeItemUpdate(Request $request){
+ public function storeItemUpdate(Request $request)
+ {
$post = $request->all();
$newTeamStoreModel = new TeamStoreModel;
- if($post['shipping_cost'] == 0){
+ if ($post['shipping_cost'] == 0) {
$shipping_cost_id = null;
- }else{
+ } else {
$shipping_cost_id = $post['shipping_cost'];
}
@@ -378,7 +385,7 @@ class UserController extends Controller {
);
$i = $newTeamStoreModel->updateStoreItem($data, $item_url);
-
+
return $i;
}
@@ -389,7 +396,7 @@ class UserController extends Controller {
$store_array = $TeamStoreModel->selectTeamStore('Id', $store_id);
return view('user-layouts.store_setting')
- ->with('store_array', $store_array);
+ ->with('store_array', $store_array);
}
public function emailVerify()
@@ -398,53 +405,52 @@ class UserController extends Controller {
$userId = Auth::user()->id;
$email_is_verified = Auth::user()->email_is_verified;
- if($email_is_verified == 0){
+ if ($email_is_verified == 0) {
$array_profile_info = $m->selectProfileInfo($userId);
return view('user-layouts.email_verify')
- ->with('array_profile_info', $array_profile_info);
+ ->with('array_profile_info', $array_profile_info);
}
return redirect('user/profile');
-
}
- public function resendVericationCode(Request $request){
+ public function resendVericationCode(Request $request)
+ {
$post = $request->all();
$random_hash = rand(1000, 9999);
$newUserModel = new UserModel;
-
+
$emailDetails = [
- 'receiver' => $post['email'],
+ 'receiver' => $post['email'],
'subject' => 'CREW Sportswear Email Verification Code',
'verification_code' => $random_hash
];
-
- Mail::send('emails.resend_code', $emailDetails, function($message) use ($emailDetails) {
-
+
+ Mail::send('emails.resend_code', $emailDetails, function ($message) use ($emailDetails) {
+
$message->from('no-reply@crewsportswear.com', 'CREW Sportswear');
$message->to($emailDetails['receiver'])->subject('CREW Sportswear Email Verification Code');
-
});
- if( count(Mail::failures()) > 0 ) {
-
+ if (count(Mail::failures()) > 0) {
+
echo '0';
-
- }else{
+ } else {
$data = array(
'EmailAddress' => $post['email'],
'VerCode' => $random_hash
);
-
+
$i = $newUserModel->saveResendCode($data);
echo $i;
}
}
-
- public function verifyCode(Request $request){
+
+ public function verifyCode(Request $request)
+ {
$post = $request->all();
$verification_code = $post['verification_code'];
@@ -452,7 +458,7 @@ class UserController extends Controller {
$newUserModel = new UserModel;
$userId = Auth::user()->id;
-
+
$data = array(
'EmailAddress' => $userEmail,
'Code' => $verification_code
@@ -461,41 +467,42 @@ class UserController extends Controller {
$i = $newUserModel->validateCode($data);
// var_dump($i);
- if($i){
+ if ($i) {
$user_logins_data = array(
'email_is_verified' => 1
);
-
+
$newUserModel->saveUpdateUserLogins($user_logins_data, $userId);
-
+
return response()->json(array(
- 'success' => true,
- 'message'=>'Your email is successfully verified.'
+ 'success' => true,
+ 'message' => 'Your email is successfully verified.'
));
-
- }else{
+ } else {
return response()->json(array(
- 'success' => false,
- 'message'=>'Invalid verification code.'
+ 'success' => false,
+ 'message' => 'Invalid verification code.'
));
}
}
- public function orderDetails($ck){
+ public function orderDetails($ck)
+ {
$newUserModel = new UserModel;
$order_item_array = $newUserModel->selectOrderItem($ck);
$item_goup_array = $newUserModel->itemGroup($ck);
$item_thumbs = $newUserModel->selectDisplayItemThumb();
$array_payment_details = $newUserModel->selectPaymentDetails('CartKey', $ck);
return view('user-layouts.order_details')
- ->with('array_payment_details', $array_payment_details)
- ->with('img_thumb', $item_thumbs)
- ->with('item_goup_array', $item_goup_array)
- ->with('order_item_array', $order_item_array);
+ ->with('array_payment_details', $array_payment_details)
+ ->with('img_thumb', $item_thumbs)
+ ->with('item_goup_array', $item_goup_array)
+ ->with('order_item_array', $order_item_array);
}
-
- public function sellDesign($designCode){
+
+ public function sellDesign($designCode)
+ {
$m = new UserModel;
$newMainModel = new MainModel;
$newTeamStoreModel = new TeamStoreModel;
@@ -504,7 +511,7 @@ class UserController extends Controller {
$array_client_designs = $m->selectClientDesignsbyCode($designCode);
$store_array = $newTeamStoreModel->selectTeamStore('Id', $store_id);
// check if its your design
- if($userId != $array_client_designs[0]->ClientId){
+ if ($userId != $array_client_designs[0]->ClientId) {
return redirect()->back();
}
@@ -514,13 +521,14 @@ class UserController extends Controller {
$array_cat_name = $newMainModel->selectCategoryName($array_client_designs[0]->TemplateCode);
return view('user-layouts.sell_design')
- ->with('array_client_designs', $array_client_designs)
- ->with('array_template_paths', $array_template_paths)
- ->with('store_array', $store_array)
- ->with('array_cat_name', $array_cat_name);
+ ->with('array_client_designs', $array_client_designs)
+ ->with('array_template_paths', $array_template_paths)
+ ->with('store_array', $store_array)
+ ->with('array_cat_name', $array_cat_name);
}
- public function buyDesign($designCode){
+ public function buyDesign($designCode)
+ {
$m = new UserModel;
$newMainModel = new MainModel;
$newTeamStoreModel = new TeamStoreModel;
@@ -529,7 +537,7 @@ class UserController extends Controller {
$array_client_designs = $m->selectClientDesignsbyCode($designCode);
// $store_array = $newTeamStoreModel->selectTeamStore('Id', $store_id);
// check if its your design
- if($userId != $array_client_designs[0]->ClientId){
+ if ($userId != $array_client_designs[0]->ClientId) {
return redirect()->back();
}
@@ -539,15 +547,15 @@ class UserController extends Controller {
$array_cat_name = $newMainModel->selectCategoryName($array_client_designs[0]->TemplateCode);
return view('user-layouts.buy_design')
- ->with('array_client_designs', $array_client_designs)
- ->with('array_template_paths', $array_template_paths)
- // ->with('store_array', $store_array)
- ->with('array_cat_name', $array_cat_name);
-
+ ->with('array_client_designs', $array_client_designs)
+ ->with('array_template_paths', $array_template_paths)
+ // ->with('store_array', $store_array)
+ ->with('array_cat_name', $array_cat_name);
}
//save item from my design //
- public function saveNewStoreItem(Request $request){
+ public function saveNewStoreItem(Request $request)
+ {
$post = $request->all();
$UserModel = new UserModel;
$newTeamStoreModel = new TeamStoreModel;
@@ -564,34 +572,36 @@ class UserController extends Controller {
$itemForm = $post['itemForm'];
$itemUrl = $store_array[0]->StoreUrl . '-' . $post['itemUrl'];
$itemPrivacy = $post['itemPrivacy'];
- $available_size = implode(",", $_POST['available_size']);
+ $available_size = implode(",", $_POST['available_size']);
$check_product_url = array(
'ProductURL' => $itemUrl
);
- $validator = Validator::make($check_product_url, [
- 'ProductURL' => 'unique:teamstore_products'
- ],
- [
- 'ProductURL.unique' => 'The Item URL has already been taken.',
- ]);
-
-
- if ($validator->fails())
- {
+ $validator = Validator::make(
+ $check_product_url,
+ [
+ 'ProductURL' => 'unique:teamstore_products'
+ ],
+ [
+ 'ProductURL.unique' => 'The Item URL has already been taken.',
+ ]
+ );
+
+
+ if ($validator->fails()) {
$errors = "";
// var_dump(($validator->errors()->all()));
- foreach($validator->errors()->all() as $error){
- $errors .= "
".$error."";
+ foreach ($validator->errors()->all() as $error) {
+ $errors .= "" . $error . "";
}
$message = '
ERROR:
- '.$errors.
- '';
+ ' . $errors .
+ '';
return response()->json(array(
'success' => false,
@@ -603,7 +613,7 @@ class UserController extends Controller {
'TeamStoreId' => $store_id,
'ProductName' => $itemName,
'ProductPrice' => str_replace('$ ', '', $itemPrice),
- 'ProductDescription'=> $itemDescription,
+ 'ProductDescription' => $itemDescription,
'ProductURL' => $itemUrl,
'ProductForm' => $itemForm,
'AvailableSizes' => $available_size,
@@ -617,11 +627,11 @@ class UserController extends Controller {
$array_template_paths = $UserModel->selectTemplatePaths('TemplateCode', $templateCode);
- foreach($array_template_paths as $key => $row1){
- if($key == 0){
+ foreach ($array_template_paths as $key => $row1) {
+ if ($key == 0) {
$thumb = $designCode . '-front-thumbnail.png';
$class = "active";
- }else{
+ } else {
$thumb = $designCode . '-' . strtolower($row1->Side) . '-thumbnail.png';
$class = null;
}
@@ -629,24 +639,22 @@ class UserController extends Controller {
$thumbs = $data = array(
'ProductId' => $id,
'Image' => $thumb,
- 'ImageClass' =>$class
+ 'ImageClass' => $class
);
-
- $UserModel->insertNewProductThumbnails($thumbs);
-
+ $UserModel->insertNewProductThumbnails($thumbs);
}
- $prod_code = array('ProductCode' => $getYear . '-' .str_pad($id, 10,'0', STR_PAD_LEFT));
- $i = $UserModel->updateProductCode($prod_code, $id);
-
+ $prod_code = array('ProductCode' => $getYear . '-' . str_pad($id, 10, '0', STR_PAD_LEFT));
+ $i = $UserModel->updateProductCode($prod_code, $id);
+
return response()->json(array(
'success' => true
));
-
}
- function addStoreItem(){
+ function addStoreItem()
+ {
$newTeamStoreModel = new TeamStoreModel;
$user_role = Auth::user()->role;
@@ -655,9 +663,10 @@ class UserController extends Controller {
$store_array = $newTeamStoreModel->selectTeamStore('Id', $store_id);
return view('user-layouts.add_item')->with('store_array', $store_array);
}
-
+
//manually uploading item
- function saveNewItem(Request $request){
+ function saveNewItem(Request $request)
+ {
$post = $request->all();
// var_dump($post['imgupload']);
@@ -676,36 +685,38 @@ class UserController extends Controller {
$itemForm = $post['itemForm'];
$itemUrl = $store_array[0]->StoreUrl . '-' . $post['itemUrl'];
$itemPrivacy = $post['itemPrivacy'];
- $available_size = implode(",", $_POST['available_size']);
+ $available_size = implode(",", $_POST['available_size']);
+
+
-
-
$check_product_url = array(
'ProductURL' => $itemUrl
);
- $validator = Validator::make($check_product_url, [
- 'ProductURL' => 'unique:teamstore_products'
- ],
- [
- 'ProductURL.unique' => 'The Item URL has already been taken.',
- ]);
-
-
- if ($validator->fails())
- {
+ $validator = Validator::make(
+ $check_product_url,
+ [
+ 'ProductURL' => 'unique:teamstore_products'
+ ],
+ [
+ 'ProductURL.unique' => 'The Item URL has already been taken.',
+ ]
+ );
+
+
+ if ($validator->fails()) {
$errors = "";
// var_dump(($validator->errors()->all()));
- foreach($validator->errors()->all() as $error){
- $errors .= "".$error."";
+ foreach ($validator->errors()->all() as $error) {
+ $errors .= "" . $error . "";
}
$message = '
ERROR:
- '.$errors.
- '';
+ ' . $errors .
+ '';
return response()->json(array(
'success' => false,
@@ -717,7 +728,7 @@ class UserController extends Controller {
'TeamStoreId' => $store_id,
'ProductName' => $itemName,
'ProductPrice' => str_replace('$ ', '', $itemPrice),
- 'ProductDescription'=> $itemDescription,
+ 'ProductDescription' => $itemDescription,
'ProductURL' => $itemUrl,
'ProductForm' => $itemForm,
'AvailableSizes' => $available_size,
@@ -729,27 +740,27 @@ class UserController extends Controller {
$id = $UserModel->insertNewProduct($data); // product item id
// echo $id;
- for($i = 0; $i < count($post['imgupload']); $i++){
- $rawName = date('Ymd') . "-" . time().'-'.$request->file('imgupload')[$i]->getClientOriginalName();
+ for ($i = 0; $i < count($post['imgupload']); $i++) {
+ $rawName = date('Ymd') . "-" . time() . '-' . $request->file('imgupload')[$i]->getClientOriginalName();
$imageExt = $request->file('imgupload')[$i]->getClientOriginalExtension();
- $custom_file_name = str_replace(' ','-',strtolower($rawName));
+ $custom_file_name = str_replace(' ', '-', strtolower($rawName));
$custom_file_name = preg_replace("/\.[^.\s]{3,4}$/", "", $custom_file_name);
- $NewImageName = $custom_file_name.'.'.$imageExt;
+ $NewImageName = $custom_file_name . '.' . $imageExt;
$thumbnail = $NewImageName;
- if($i == 0){
+ if ($i == 0) {
$imageClass = "active";
- }else{
+ } else {
$imageClass = null;
}
-
+
$thumbs = $data = array(
'ProductId' => $id,
'Image' => $thumbnail,
- 'ImageClass' =>$imageClass
+ 'ImageClass' => $imageClass
);
-
+
$u = $UserModel->insertNewProductThumbnails($thumbs);
// var_dump($thumbs);
Storage::disk('sftp')->put($thumbnail, fopen($request->file('imgupload')[$i], 'r+')); //live
@@ -757,68 +768,195 @@ class UserController extends Controller {
// var_dump($s);
}
- $prod_code = array('ProductCode' => $getYear . '-' .str_pad($id, 10,'0', STR_PAD_LEFT));
- $i = $UserModel->updateProductCode($prod_code, $id);
-
+ $prod_code = array('ProductCode' => $getYear . '-' . str_pad($id, 10, '0', STR_PAD_LEFT));
+ $i = $UserModel->updateProductCode($prod_code, $id);
- return response()->json(array(
- 'success' => true,
- 'message' => 'success'
- ));
- }
-
- 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('upload_images')[$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){
+ function saveNewItemFromDesigner(Request $request)
+ {
+
+ $post = $request->all();
+ // var_dump($post['imgupload']);
+ $UserModel = new UserModel;
+ $newTeamStoreModel = new TeamStoreModel;
+ $getYear = date('y');
+
+ $store_id = 1; // default merchbay store
+ $store_array = $newTeamStoreModel->selectTeamStore('Id', $store_id);
+ $client_design = $UserModel->selectClientDesignsbyCode($post['designCode']);
+ $userId = Auth::user()->id;
+
+ $templateCode = $client_design[0]->TemplateCode;
+ $designCode = $client_design[0]->DesignCode;
+ $itemName = $client_design[0]->DesignName;
+ $itemDescription = "Sublimated T-Shirt 100% moisture wicking polyester. Imported. Lightweight fabric helps wick away sweat to keep you dry and comfortable.";
+ $itemPrice = "1.00";
+ $itemForm = "tshirt-form";
+ $itemUrl = $store_array[0]->StoreUrl . '-' . $userId . '-' . $client_design[0]->DesignCode;
+ $itemPrivacy = "public";
+ $available_size = "youth,adult";
+
+
+ $product = $newTeamStoreModel->selectTeamStoreProducts('ProductURL', $itemUrl);
+ // var_dump(count($product));
+ if (count($product)) {
+ return response()->json(array(
+ 'success' => true,
+ 'message' => 'success',
+ "link" => '/store/merchbay-store/product/' . $itemUrl
+ ));
+ }
+
+
+ $check_product_url = array(
+ 'ProductURL' => $itemUrl
+ );
+
+ $validator = Validator::make(
+ $check_product_url,
+ [
+ 'ProductURL' => 'unique:teamstore_products'
+ ],
+ [
+ 'ProductURL.unique' => 'The Item URL has already been taken.',
+ ]
+ );
+
+
+ if ($validator->fails()) {
+ $errors = "";
+ // var_dump(($validator->errors()->all()));
+ foreach ($validator->errors()->all() as $error) {
+ $errors .= "" . $error . "";
+ }
+
+ $message = '
+
+
+
ERROR:
+ ' . $errors .
+ '';
+
+ return response()->json(array(
+ 'success' => false,
+ 'message' => $message
+ ));
+ }
+
+ $data = array(
+ 'TeamStoreId' => $store_id,
+ 'ProductName' => $itemName,
+ 'ProductPrice' => str_replace('$ ', '', $itemPrice),
+ 'ProductDescription' => $itemDescription,
+ 'ProductURL' => $itemUrl,
+ 'ProductForm' => $itemForm,
+ 'AvailableSizes' => $available_size,
+ 'PrivacyStatus' => $itemPrivacy,
+ 'TemplateCode' => $templateCode,
+ 'DesignCode' => $designCode,
+ // 'ShippingCostId' => 1
+ );
+
+
+ $id = $UserModel->insertNewProduct($data); // product item id
+ // echo $id;
+
+ $array_template_paths = $UserModel->selectTemplatePaths('TemplateCode', $templateCode);
+
+ $imageThumbs = array();
+ foreach ($array_template_paths as $key => $path) {
+ $imageThumbs[] = $designCode . "-" . strtolower($path->Side) . "-thumbnail.png";
+ }
+ // var_dump($imageThumbs);
+ // $images = explode(",", $post["imagesThumb"]);
+
+ for ($i = 0; $i < count($imageThumbs); $i++) {
+ $thumbnail = $imageThumbs[$i];
+
+ if ($i == 0) {
+ $imageClass = "active";
+ } else {
+ $imageClass = null;
+ }
+
+ $thumbs = $data = array(
+ 'ProductId' => $id,
+ 'Image' => $thumbnail,
+ 'ImageClass' => $imageClass
+ );
+
+ $UserModel->insertNewProductThumbnails($thumbs);
+ }
+
+ $prod_code = array('ProductCode' => $getYear . '-' . str_pad($id, 10, '0', STR_PAD_LEFT));
+ $i = $UserModel->updateProductCode($prod_code, $id);
+
+
+ return response()->json(array(
+ 'success' => true,
+ 'message' => 'success',
+ "link" => '/store/merchbay-store/product/' . $itemUrl
+ ));
+ }
+
+ 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('upload_images')[$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('sftp')->getDriver()->getAdapter()->getPathPrefix();
- if(file_exists($storagePath.$file)) {
- unlink($storagePath.$file);
+ if (file_exists($storagePath . $file)) {
+ unlink($storagePath . $file);
}
$i = $UserModel->deleteImageThumb('Id', $id);
@@ -828,10 +966,10 @@ class UserController extends Controller {
'message' => 'success',
'delete_row' => 'item-' . $id
));
-
}
-
- function updateActiveThumbnail(Request $request){
+
+ function updateActiveThumbnail(Request $request)
+ {
$post = $request->all();
$UserModel = new UserModel;
$i = $UserModel->updateActiveThumb($post['id'], $post['product_id']);
@@ -839,7 +977,8 @@ class UserController extends Controller {
}
- function saveThumbnailOrdering(Request $request){
+ function saveThumbnailOrdering(Request $request)
+ {
$post = $request->all();
$arrayItems = $post['item'];
$order = 1;
@@ -856,7 +995,8 @@ class UserController extends Controller {
));
}
- function saveItemOrdering(Request $request){
+ function saveItemOrdering(Request $request)
+ {
$post = $request->all();
$arrayItems = $post['order_number'];
$order = 1;
@@ -873,161 +1013,164 @@ class UserController extends Controller {
));
}
-
- function storeSettingUpdate(Request $request){
+
+ function storeSettingUpdate(Request $request)
+ {
$post = $request->all();
- $UserModel = new UserModel;
+ $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'];
- }
+ $store_id = Auth::user()->store_id;
+ $store_name = $post['store_name'];
+ $store_url = $post['store_url'];
+ $orig_store_url = $post['orig_store_url'];
- if($orig_store_url != $store_url){
+ if ($post['store_status'] == "Public") {
+ $store_status = "true";
+ } else {
+ $store_status = "false";
+ }
- $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 .= "".$error."";
- }
-
- return response()->json(array(
- 'success' => false,
- 'clearform' => false,
- 'message' => $errors
- ));
- }
+ 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'];
+ }
- $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
- );
+ if ($request->file('store_banner') != null) {
+ $store_banner_name = 'banner.' . $request->file('store_banner')->getClientOriginalExtension();
+ } else {
+ $store_banner_name = $post['orig_store_banner'];
+ }
- // var_dump($data);
-
- $UserModel->updateTeamstore($store_id, $data);
- // var_dump($res);
- // if($res){
- $filesystem = Storage::disk('sftp');
- $filesystem->getDriver()->getAdapter()->setDirectoryPerm(0755);
+ if ($orig_store_url != $store_url) {
- if($request->file('store_logo') != null){
- $filesystem->put('/merchbay/teamstore/'. $orig_store_url . '/' . $store_logo_name, fopen($request->file('store_logo'), 'r+'));
- }
+ $check_store_url = array(
+ 'StoreUrl' => $store_url
+ );
- if($request->file('store_banner') != null){
- $filesystem->put('/merchbay/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,
+ $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 .= "" . $error . "";
+ }
+
+ 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);
+
+
+ $UserModel->updateTeamstore($store_id, $data);
+ // var_dump($res);
+ // if($res){
+ $filesystem = Storage::disk('sftp');
+ $filesystem->getDriver()->getAdapter()->setDirectoryPerm(0755);
+
+ if ($request->file('store_logo') != null) {
+ $filesystem->put('/merchbay/teamstore/' . $orig_store_url . '/' . $store_logo_name, fopen($request->file('store_logo'), 'r+'));
+ }
+
+ if ($request->file('store_banner') != null) {
+ $filesystem->put('/merchbay/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(){
+ 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);
+ ->with('store_array', $store_array)
+ ->with('array_store_orders', $array_store_orders);
}
- function showStoreOrderDetails(Request $request){
+ function showStoreOrderDetails(Request $request)
+ {
$post = $request->all();
// var_dump($post['pid']);
$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();
+ ->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
+ 'item' => $array_item
));
}
-
- function itemStoreReArrange(){
+
+ function itemStoreReArrange()
+ {
$thumbnails = array();
$newUserModel = new UserModel;
$newTeamStoreModel = new TeamStoreModel;
@@ -1042,72 +1185,71 @@ class UserController extends Controller {
$thumbnails_array = $newTeamStoreModel->getProductThumbnails($pr_arr->Id);
- if(!empty($thumbnails_array)){
+ if (!empty($thumbnails_array)) {
foreach ($thumbnails_array as $t => $thumb) {
-
- if($thumb->ImageClass == 'custom'){
+
+ if ($thumb->ImageClass == 'custom') {
$displayThumbnails = $thumb->Image;
break;
}
-
- if($thumb->ImageClass == 'active'){
+
+ if ($thumb->ImageClass == 'active') {
$displayThumbnails = $thumb->Image;
break;
- }
+ }
}
-
- $thumbnails[] = array(
- 'folder' => $store_array[0]->ImageFolder,
- 'product_id' => $pr_arr->Id,
- 'thumb' => $displayThumbnails
- );
- }else{
$thumbnails[] = array(
- 'folder' => $store_array[0]->ImageFolder,
- 'product_id' => $pr_arr->Id,
- 'thumb' => "product-image-placeholder.png"
+ 'folder' => $store_array[0]->ImageFolder,
+ 'product_id' => $pr_arr->Id,
+ 'thumb' => $displayThumbnails
+ );
+ } else {
+ $thumbnails[] = array(
+ 'folder' => $store_array[0]->ImageFolder,
+ 'product_id' => $pr_arr->Id,
+ 'thumb' => "product-image-placeholder.png"
);
}
-
}
-
+
return view('user-layouts.store_items_arrange')->with('store_array', $store_array)
- ->with('product_array', $product_array)
- ->with('thumbnails', $thumbnails);
+ ->with('product_array', $product_array)
+ ->with('thumbnails', $thumbnails);
}
- function deleteStoreItem(Request $request){
+ function deleteStoreItem(Request $request)
+ {
//
$post = $request->all();
$UserModel = new UserModel;
$res = $UserModel->deleteStoreItem($post['id']);
-
- if($res){
+
+ if ($res) {
return response()->json(array(
'success' => true,
'message' => "Store item is successfully delete."
));
- }else{
+ } else {
return response()->json(array(
'success' => false,
'message' => "Something went wrong. Please try again!"
));
}
-
}
- function announcementIndex(){
+ function announcementIndex()
+ {
$UserModel = new UserModel;
$storeId = Auth::user()->store_id;
$getAnnouncement = $UserModel->getAnnouncement($storeId);
- if(count($getAnnouncement) > 0){
+ if (count($getAnnouncement) > 0) {
$data = $getAnnouncement[0];
- }else{
+ } else {
$data = (object) array(
'Id' => 0,
'StoreId' => "",
@@ -1117,13 +1259,13 @@ class UserController extends Controller {
);
}
return view('user-layouts.announcement')
- ->with("data", $data)
- ->render();
-
+ ->with("data", $data)
+ ->render();
}
- function announcementUpdateSave(Request $request){
+ function announcementUpdateSave(Request $request)
+ {
$post = $request->all();
$UserModel = new UserModel;
@@ -1136,11 +1278,11 @@ class UserController extends Controller {
);
// var_dump($getAnnouncement[0]->Id);
-
- if(count($getAnnouncement) > 0){
+
+ if (count($getAnnouncement) > 0) {
$response = $UserModel->updateAnnouncement($getAnnouncement[0]->Id, $data);
- }else{
- $data['IsActive'] = 0;
+ } else {
+ $data['IsActive'] = 0;
$response = $UserModel->saveNewAnnouncement($data);
}
@@ -1158,22 +1300,23 @@ class UserController extends Controller {
}
}
- function announcementUpdateStatus(Request $request){
+ function announcementUpdateStatus(Request $request)
+ {
$post = $request->all();
$UserModel = new UserModel;
$storeId = Auth::user()->store_id;
$getAnnouncement = $UserModel->getAnnouncement($storeId);
-
- if(!count($getAnnouncement)){
+
+ if (!count($getAnnouncement)) {
return response()->json(array(
'success' => false,
'message' => 'Please update your announcement first.'
));
}
-
+
$data = array(
'IsActive' => ($post['IsActive'] == 'true') ? 1 : 0
);
@@ -1191,12 +1334,12 @@ class UserController extends Controller {
}
- function getAddressBook() {
+ function getAddressBook()
+ {
$UserModel = new UserModel;
$userId = Auth::user()->id;
$array_address_book = $UserModel->selectAddresBook('UserId', $userId);
return $array_address_book;
}
-
}
diff --git a/app/Http/routes.php b/app/Http/routes.php
index 240ac33..79c3683 100755
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -23,7 +23,6 @@ Route::controllers([
'password' => 'Auth\PasswordController',
]);
-
// Route::get('/', 'MainController@index');
Route::get('/sportslist', 'MainController@sports');
Route::get('/sports/{url}', 'MainController@templatesCat');
@@ -147,6 +146,9 @@ Route::group(['middleware' => 'normaluser'], function () {
Route::get('user/announcement', 'user\UserController@announcementIndex');
Route::post('user/announcement/updateSave', 'user\UserController@announcementUpdateSave');
Route::post('user/announcement/status/update', 'user\UserController@announcementUpdateStatus');
+
+
+ Route::post('user/store-items/personal-design', 'user\UserController@saveNewItemFromDesigner');
});
Route::group(['middleware' => 'auth'], function () {
diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php
index ca3ea07..1aa01f0 100755
--- a/resources/views/auth/login.blade.php
+++ b/resources/views/auth/login.blade.php
@@ -40,7 +40,7 @@
-
Forgot your password?
+
Forgot your password?
diff --git a/resources/views/auth/password.blade.php b/resources/views/auth/password.blade.php
index 539d4d2..bacaee8 100755
--- a/resources/views/auth/password.blade.php
+++ b/resources/views/auth/password.blade.php
@@ -1,55 +1,64 @@
-@extends('app')
+@extends('merchbay_main')
-@section('content')
+@section('main-content')
-