add currency for teamstore

This commit is contained in:
Frank John Begornia
2019-08-19 21:37:47 +08:00
parent e60bb3baf8
commit b7e81adf31
68 changed files with 9977 additions and 442 deletions

View File

@@ -115,9 +115,8 @@ class MainController extends Controller {
$cartKey = $request->session()->get('cartkey');
echo $i = $m->cartCount($cartKey);
echo $i = $m->cartCount($cartKey);
}else{
echo 0;
}

View File

@@ -284,9 +284,7 @@ class DesignerController extends Controller {
$newDesignerModel = new DesignerModel;
$clipart_cat_array = $newDesignerModel->selectClipartCategories();
$clipart_cat_array = $newDesignerModel->selectClipartCategories();
?>
<div class="row">
@@ -295,31 +293,39 @@ class DesignerController extends Controller {
</div>
</div>
<hr>
<!-- <div class="row">
<div class="form-group col-md-12">
<form role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q">
<div class="input-group-btn">
<button class="btn btn-default" type="button"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div> -->
<div id="show-clipart-content">
<div class="row">
<?php
foreach($clipart_cat_array as $row){
if($row->UserId != null){
if(!Auth::guest()){
if(Auth::user()->id == $row->UserId){
?>
<div class="form-group col-md-6">
<a href="#" class="clipart-category" data-id="<?php echo $row->Id ?>" data-type="category" data-title="<?php echo $row->CategoryName ?>">
<div style="height:100px; background-color:#f4f4f4; border-radius: 5px;" class="text-center">
<span style="position:absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 16px;"><?php echo $row->CategoryName ?></span>
</div>
</a>
</div>
<?php
}
}
}
}
foreach($clipart_cat_array as $row){
if($row->UserId == null){
?>
<div class="form-group col-md-6">
<a href="#" class="clipart-category" data-id="<?php echo $row->Id ?>" data-type="category" data-title="<?php echo $row->CategoryName ?>">
<div style="height:100px; background-color:#f4f4f4; border-radius: 5px;" class="text-center">
<span style="position:absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 16px;"><?php echo $row->CategoryName ?></span>
</div>
</a>
</div>
<div class="form-group col-md-6">
<a href="#" class="clipart-category" data-id="<?php echo $row->Id ?>" data-type="category" data-title="<?php echo $row->CategoryName ?>">
<div style="height:100px; background-color:#f4f4f4; border-radius: 5px;" class="text-center">
<span style="position:absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 16px;"><?php echo $row->CategoryName ?></span>
</div>
</a>
</div>
<?php
}
}
?>
</div>
@@ -1114,6 +1120,7 @@ class DesignerController extends Controller {
$post = $request->all();
$trCount = $post['itemCount'];
$tempCode = $post['tempCode'];
// $product_array = $m->selectTeamStoreProducts('ProductURL', $productURL);
$newDesignerModel = new DesignerModel;
$jersey_sizes = $newDesignerModel->getAvailableSizes($tempCode, 'JERSEY');
@@ -1149,6 +1156,64 @@ class DesignerController extends Controller {
<?php
}
public function addGamerField(Request $request){
$post = $request->all();
$trCount = $post['itemCount'];
$tempCode = $post['tempCode'];
$product_url = $post['product_url'];
$m = new TeamStoreModel;
$product_array = $m->selectTeamStoreProducts('ProductURL', $product_url);
$x = explode(",", $product_array[0]->AvailableSizes );
foreach($x as $s){
$h[] = $m->getSizesByBracket($s);
}
foreach($h as $d){
foreach($d as $g){
$sizes_array[] = $g;
}
}
?>
<tr class="<?php echo 'table-tr-' . $trCount ?>">
<td>
<input type="text" name="order_names[]" id="order_names" class="form-control input-sm inputName roster-input" placeholder="Gamer Tag" >
</td>
<td>
<input type="text" name="order_names2[]" id="order_names2" class="form-control input-sm inputName roster-input" placeholder="Name">
</td>
<td>
<select class="form-control input-sm order-size roster-input" name="order_size[]" id="<?php echo 'order_size_' . $trCount ?>" data-row-number="<?php echo $trCount ?>">
<?php
foreach($sizes_array as $size){
echo '<option value="'.$size->Size.'">'.$size->Size.'</option>';
}
?>
</select>
</td>
<td id="action-column" class="text-center roster-action-column" style="padding: 4px !important; border-top: none">
<span class="tr-remove-btn">
<button type="button" class="btn btn-danger btn-sm removeRow-gamer-field btn-roster-action" data-toggle="tooltip" title="Remove"><i class="fa fa-remove" aria-hidden="true"></i></button>
</span>
</td>
</tr>
<tr id="addnew-btn-tbl-row">
<td colspan="4" ><button type="button" id="addNewRow_gamer_field" class="btn btn-link btn-sm pull-left" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i> Add Row</button></td>
<!-- <td colspan="2" ><button type="button" class="btn btn-link btn-sm pull-right" data-toggle="tooltip" title="Add Another">Manage List</button></td> -->
<td style="padding: 4px !important; border-top: none"></td>
</tr>
<?php
}
}

View File

@@ -59,7 +59,7 @@ class PaypalController extends Controller {
if(Auth::guest()){
Session::flash('msg', 'Please login to proceed.');
Session::flash('msg', 'Please login your account to proceed.');
return Redirect::back();
}
@@ -68,42 +68,59 @@ class PaypalController extends Controller {
$m = new TeamStoreModel;
$paypal_model = new PayPalModel;
$m = new TeamStoreModel;
$paypal_model = new PayPalModel;
$last_id = $paypal_model->getLastIdPaymentDetails();
$invoice_num = str_pad($last_id[0]->Id, 4,'0',STR_PAD_LEFT);
$cartKey = $request->session()->get('cartkey');
$items = $m->myCart($cartKey);
$getSubtotal = $m->getSubtotal($cartKey);
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
$store_array = $m->selectTeamStore('Id', $grouped_item[0]->StoreId);
// var_dump($getSubtotal[0]->Subtotal);
foreach($items as $item){
if($item->VoucherId != null){
$voucherIds[] = $item->VoucherId;
$voucher = $m->selectVoucherWhereIn($voucherIds);
$item_id = $item->Id;
$totalValue = $voucher[0]->VoucherValue;
if($voucher[0]->VoucherType == "Percentage"){
$getPercentageValue = $totalValue / 100;
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
$data = array(
'Price' => $getDiscountValue * -1
);
$order_subtotal = $getSubtotal[0]->Subtotal;
$order_grandtotal = $getSubtotal[0]->Subtotal;
$m->updateVoucherValueInCart($data, $item_id);
}else{
$voucherData = array(
'totalValue'=> $totalValue,
'type'=>'Flat'
);
}
}
}
$order_items = array();
$updated_items = $m->myCart($cartKey);
$updated_getSubtotal = $m->getSubtotal($cartKey);
$order_subtotal = $updated_getSubtotal[0]->Subtotal;
$order_grandtotal = $updated_getSubtotal[0]->Subtotal;
$tax = $order_grandtotal * 0.10;
$order_items = array();
foreach($items as $key => $item){
if($item->Order == "Jersey"){
$itemOrder = " (Jersey Only)";
}elseif ($item->Order == "Shorts"){
$itemOrder = " (Shorts Only)";
}else{
$itemOrder = " (w/ Shorts)";
}
foreach($updated_items as $key => $item){
// $descriptions = "Name: " . $item->Name . " Number: " . $item->Number . " Size: " . $item->Size;"?"
$order_items[$key] = PayPal::Item();
$order_items[$key]->setName($item->ProductName);
$order_items[$key]->setCurrency('USD');
$order_items[$key]->setCurrency($store_array[0]->StoreCurrency);
$order_items[$key]->setQuantity($item->Quantity);
// $order_items[$key]->setDescription($descriptions);
// $order_items[$key]->setTax(10);
@@ -120,7 +137,7 @@ class PaypalController extends Controller {
$amount_details->setTax($tax);
$amount = PayPal::Amount();
$amount->setCurrency('USD');
$amount->setCurrency($store_array[0]->StoreCurrency);
$amount->setDetails($amount_details);
$amount->setTotal($order_grandtotal + $tax);
@@ -305,7 +322,6 @@ class PaypalController extends Controller {
$message->from('no-reply@crewsportswear.com', 'CREW Sportswear');
$message->cc('orders@crewsportswear.com', 'Orders From CREW Sportswear');
$message->to($data['receiver'])->subject($data['subject']);
});
// end email sending
@@ -319,8 +335,34 @@ class PaypalController extends Controller {
}
public function getCancel()
public function getCancel(Request $request)
{
$m = new TeamStoreModel;
$cartKey = $request->session()->get('cartkey');
$items = $m->myCart($cartKey);
$getSubtotal = $m->getSubtotal($cartKey);
foreach($items as $item){
if($item->VoucherId != null){
$voucherIds[] = $item->VoucherId;
$voucher = $m->selectVoucherWhereIn($voucherIds);
$item_id = $item->Id;
$totalValue = $voucher[0]->VoucherValue;
if($voucher[0]->VoucherType == "Percentage"){
$data = array(
'Price' => '00.00'
);
$m->updateVoucherValueInCart($data, $item_id);
}else{
$voucherData = array(
'totalValue'=> $totalValue,
'type'=>'Flat'
);
}
}
}
return redirect()->route('cart');
}

View File

@@ -278,13 +278,12 @@ class TeamStoreController extends Controller {
$cartKey = $cartKey = $request->session()->get('cartkey');
}
$product_array = $m->selectTeamStoreProducts('Id', $product_id);
$ProductPrice = $product_array[0]->ProductPrice;
$ProductURL = $product_array[0]->ProductURL;
$product_form = $product_array[0]->ProductForm;
$design_code = $product_array[0]->DesignCode;
$product_name = $product_array[0]->ProductName;
$ProductPrice = $product_array[0]->ProductPrice;
$ProductURL = $product_array[0]->ProductURL;
$product_form = $product_array[0]->ProductForm;
$design_code = $product_array[0]->DesignCode;
$product_name = $product_array[0]->ProductName;
if($product_form == "jersey-and-shorts-form"){
$order_names = $post['order_names'];
@@ -412,13 +411,34 @@ class TeamStoreController extends Controller {
'Quantity' => 1
);
}
}elseif($product_form == "name-name2-size-form"){
$order_names = $post['order_names'];
$order_names2 = $post['order_names2'];
$order_size = $post['order_size'];
foreach($order_names as $key => $val){
$items[] = array(
'ProductId' => $product_id,
'StoreURL' => $store_url,
'StoreId' => $store_id,
'FormUsed' => $product_form,
'CartKey' => $cartKey,
'DesignCode' => $design_code,
'ProductURL' => $ProductURL,
'ProductName' => $product_name,
'Name' => $order_names[$key],
'Name2' => $order_names2[$key],
'Size' => $order_size[$key],
'Price' => $ProductPrice,
'Quantity' => 1
);
}
}
$i = $m->insertToCart($items);
if($i){
if($i['i']){
return response()->json(array(
'success' => true
));
@@ -428,25 +448,197 @@ class TeamStoreController extends Controller {
return response()->json(array(
'success' => false,
'message' => "Something went wrong. Please refresh the page."
));
));
}
public function cart(Request $request){
$m = new TeamStoreModel;
$cartKey = $request->session()->get('cartkey');
$m = new TeamStoreModel;
$cartKey = $request->session()->get('cartkey');
$items = $m->myCart($cartKey);
$getSubtotal = $m->getSubtotal($cartKey);
$items_group = $m->myCartGroup($cartKey);
$items_group = $m->myCartGroup($cartKey);
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
if($grouped_item){
$defId = $grouped_item[0]->StoreId;
}else{
$defId = 0;
}
$item_thumbs = $m->selectDisplayCartThumb();
$store_array = $m->selectTeamStore('Id', $defId);
// var_dump($$grouped_item[0]->StoreId);
$voucherIds = array();
foreach($items as $item){
if($item->VoucherId != null){
$voucherIds[] = $item->VoucherId;
}
}
$vouchers = $m->selectVoucherWhereIn($voucherIds);
$totalValue = 0;
if(!empty($vouchers)){
foreach($vouchers as $voucher){
$totalValue = $totalValue + $voucher->VoucherValue;
if($voucher->VoucherType == "Percentage"){
$voucherData = array(
'totalValue'=> $totalValue,
'type'=>'Percentage'
);
}else{
$voucherData = array(
'totalValue'=> $totalValue,
'type'=>'Flat'
);
}
}
if($voucherData['type'] == "Percentage"){
$getPercentageValue = $voucherData['totalValue'] / 100;
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
$finalSubTotal = $getSubtotal[0]->Subtotal - $getDiscountValue;
}else{
//Flat voucher computation here..
}
}else{
$finalSubTotal = $getSubtotal[0]->Subtotal;
}
return view('sublayouts.cart')
->with('item_group', $items_group)
->with('row', $items)
->with('img_thumb', $item_thumbs)
->with('getSubtotal', $getSubtotal);
->with('item_group', $items_group)
->with('row', $items)
->with('img_thumb', $item_thumbs)
->with('getSubtotal', $finalSubTotal)
->with('store_array', $store_array);
}
public function addVoucher(Request $request){
$cartKey = $request->session()->get('cartkey');
if($cartKey == ""){
return false;
}
$TeamStoreModel = new TeamStoreModel;
$post = $request->all();
$grouped_item = $TeamStoreModel->selectTeamStoreGroupByCartKey($cartKey);
$store_id = $grouped_item[0]->StoreId;
$vocher = $post['voucher'];
$store_array = $TeamStoreModel->selectTeamStore('Id', $grouped_item[0]->StoreId);
$getSubtotal = $TeamStoreModel->getSubtotal($cartKey);
$data = array(
'store_id' => $store_id,
'voucher' => $vocher
);
$getVoucher = $TeamStoreModel->selectVoucher($data);
if($getVoucher){
$items = $TeamStoreModel->myCart($cartKey);
// check if if voucher is already in used;
foreach($items as $item){
if($getVoucher[0]->Id == $item->VoucherId){
return response()->json(array(
'success' => false,
'message' => 'This voucher is already in used.'
));
}
}
// insert vocuher to cart_tmp
$voucherData = array(
'VoucherId' => $getVoucher[0]->Id,
'StoreURL' => $store_array[0]->StoreUrl,
'StoreId' => $store_array[0]->Id,
'CartKey' => $cartKey,
'ProductName' => $getVoucher[0]->VoucherCode,
'Price' => '00.00',
'Quantity' => 1
);
$i = $TeamStoreModel->insertToCart($voucherData);
$lastId = $i['lastId'];
$removeItemURL = url('removeitem') . '/' . $lastId;
//get all voucher used.
$updated_items = $TeamStoreModel->myCart($cartKey);
foreach($updated_items as $item){
if($item->VoucherId != null){
$voucherIds[] = $item->VoucherId;
}
}
$vouchers = $TeamStoreModel->selectVoucherWhereIn($voucherIds);
$totalValue = 0;
if(!empty($vouchers)){
foreach($vouchers as $voucher){
$totalValue = $totalValue + $voucher->VoucherValue;
if($voucher->VoucherType == "Percentage"){
$voucherData = array(
'totalValue'=> $totalValue,
'type'=>'Percentage'
);
}else{
$voucherData = array(
'totalValue'=> $totalValue,
'type'=>'Flat'
);
}
}
if($voucherData['type'] == "Percentage"){
$getPercentageValue = $voucherData['totalValue'] / 100;
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
$finalSubTotal = $getSubtotal[0]->Subtotal - $getDiscountValue;
}else{
//Flat voucher computation here..
}
}else{
$finalSubTotal = $getSubtotal[0]->Subtotal;
}
if($getVoucher[0]->VoucherType == "Percentage"){
$offData = $getVoucher[0]->VoucherValue . '%';
}else{
$offData = $getVoucher[0]->VoucherValue . ' ' . $store_array[0]->StoreCurrency;
}
$message = '<div class="btn-group">
<button type="button" class="btn btn-default btn-xs">'.$getVoucher[0]->VoucherCode. ' ' .$offData. ' OFF</button>
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only"></span>
</button>
<ul class="dropdown-menu">
<li><a href="'.$removeItemURL.'"><i class="fa fa-times"></i> Remove</a></li>
</ul>
</div>';
// return success
return response()->json(array(
'success' => true,
'message' => $message,
'subtotal' =>$finalSubTotal
));
}else{
return response()->json(array(
'success' => false,
'message' => "Sorry, the voucher code is invalid. Please try again."
));
}
}
public function checkout(Request $request)

View File

@@ -485,20 +485,49 @@ class UserController extends Controller {
->with('array_cat_name', $array_cat_name);
}
public function buyDesign($designCode){
$m = new UserModel;
$newMainModel = new MainModel;
$newTeamStoreModel = new TeamStoreModel;
$userId = Auth::user()->id;
// $store_id = Auth::user()->store_id;
$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){
return redirect()->back();
}
// var_dump($store_array);
$array_template_paths = $m->selectTemplatePaths('TemplateCode', $array_client_designs[0]->TemplateCode);
$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);
}
//save item from my design //
public function saveNewStoreItem(Request $request){
$post = $request->all();
$UserModel = new UserModel;
$newTeamStoreModel = new TeamStoreModel;
$getYear = date('y');
$store_id = Auth::user()->store_id;
$store_array = $newTeamStoreModel->selectTeamStore('Id', $store_id);
$templateCode = $post['templateCode'];
$designCode = $post['designCode'];
$itemName = $post['itemName'];
$itemDescription = $post['itemDescription'];
$itemPrice = $post['itemPrice'];
$itemForm = $post['itemForm'];
$itemUrl = $post['itemUrl'];
$itemUrl = $store_array[0]->StoreUrl . '-' . $post['itemUrl'];
$itemPrivacy = $post['itemPrivacy'];
$available_size = implode(",", $_POST['available_size']);
@@ -601,13 +630,15 @@ class UserController extends Controller {
$getYear = date('y');
$store_id = Auth::user()->store_id;
$store_array = $newTeamStoreModel->selectTeamStore('Id', $store_id);
$templateCode = $post['templateCode'];
$designCode = $post['designCode'];
$itemName = $post['itemName'];
$itemDescription = $post['itemDescription'];
$itemPrice = $post['itemPrice'];
$itemForm = $post['itemForm'];
$itemUrl = $post['itemUrl'];
$itemUrl = $store_arrayp[0]->StoreUrl . '-' . $post['itemUrl'];
$itemPrivacy = $post['itemPrivacy'];
$available_size = implode(",", $_POST['available_size']);
@@ -671,10 +702,16 @@ class UserController extends Controller {
$NewImageName = $custom_file_name.'.'.$imageExt;
$thumbnail = $NewImageName;
if($i == 0){
$imageClass = "active";
}else{
$imageClass = null;
}
$thumbs = $data = array(
'ProductId' => $id,
'Image' => $thumbnail,
'ImageClass' =>null
'ImageClass' =>$imageClass
);
$u = $UserModel->insertNewProductThumbnails($thumbs);

View File

@@ -53,6 +53,7 @@ Route::post('/designer/a/add-new-row', 'designer\DesignerController@addNewRow');
Route::post('/designer/a/add-new-row-name-and-number', 'designer\DesignerController@addNewRowNameAndNumber');
Route::post('/designer/a/add-new-row-name-number-size', 'designer\DesignerController@addNewRowNameNumberAndSize');
Route::post('/designer/a/add-new-row-number', 'designer\DesignerController@addRowNumber');
Route::post('/designer/a/add-new-row-gamer-field', 'designer\DesignerController@addGamerField');
Route::post('/designer/a/save-roster', 'designer\DesignerController@saveRoster');
Route::group(['middleware' => ['auth']], function() {
@@ -86,7 +87,7 @@ Route::get('/teamstore', 'teamstore\TeamStoreController@storelist'); // old
Route::post('/teamstore/q/addnewrow', 'teamstore\TeamStoreController@addNewRow');
Route::post('/teamstore/q/add-to-cart', 'teamstore\TeamStoreController@addToCart');
Route::get('/teamstore/q/clearsession', 'teamstore\TeamStoreController@clearSession');
Route::post('/teamstore/q/add-voucher', 'teamstore\TeamStoreController@addVoucher');
// });
Route::post('/teamstore/checkpassword', 'teamstore\TeamStoreController@checkTeamStorePassword');
@@ -124,8 +125,11 @@ Route::group(['middleware' => 'normaluser'], function () {
Route::post('user/update-active-thumbnail', 'user\UserController@updateActiveThumbnail');
Route::post('user/post/save-thumbnail-ordering', 'user\UserController@saveThumbnailOrdering');
Route::get('user/my-designs/sell-design/{designCode}', 'user\UserController@sellDesign');
Route::post('user/my-designs/addstoreitem', 'user\UserController@saveNewStoreItem');
Route::get('user/my-designs/buy-design/{designCode}', 'user\UserController@buyDesign');
});