optimized add form for store products
This commit is contained in:
@@ -1008,8 +1008,8 @@ class DesignerController extends Controller {
|
||||
|
||||
</select>
|
||||
</td>
|
||||
<td style="border-right: 1px solid #ddd;">
|
||||
<select class="form-control input-sm order-size roster-input" name="order_shorts_size[]" id="<?php echo 'order_shorts_size_' . $trCount ?>" data-row-number="<?php echo $trCount ?>">
|
||||
<td>
|
||||
<select class="form-control input-sm order-size roster-input" name="order_shorts_size[]" id="<?php echo 'order_shorts_size_' . $trCount ?>" style="border-right: 1px solid #ccc;" data-row-number="<?php echo $trCount ?>">
|
||||
<option value="none">none</option>
|
||||
<?php
|
||||
foreach($sizes_array as $s_size){
|
||||
@@ -1026,7 +1026,9 @@ class DesignerController extends Controller {
|
||||
|
||||
</tr>
|
||||
<tr id="addnew-btn-tbl-row">
|
||||
<td colspan="4" ><button type="button" id="addNewRow" 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="4" >
|
||||
<button type="button" id="addNewRow" 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>
|
||||
|
||||
@@ -234,84 +234,44 @@ class TeamStoreController extends Controller {
|
||||
public function addNewRow(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$itemCount = $post['itemCount'];
|
||||
$cssValue = $post['jersey_chk'];
|
||||
$product_id = $post['product_id'];
|
||||
$classname = "row" . $itemCount;
|
||||
$TeamStoreModel = new TeamStoreModel;
|
||||
|
||||
$item = $TeamStoreModel->selectTeamStoreProductByIdHash($post['p_id']);
|
||||
$x = explode(",", $item[0]->AvailableSizes);
|
||||
|
||||
foreach($x as $s){
|
||||
$h[] = $TeamStoreModel->getSizesByBracket($s);
|
||||
}
|
||||
|
||||
foreach($h as $d){
|
||||
foreach($d as $g){
|
||||
$sizes_array[] = $g;
|
||||
}
|
||||
}
|
||||
|
||||
if($item[0]->ProductAvailableQty != null){
|
||||
$soldQty = $m->getSoldQty($product_array[0]->Id);
|
||||
$availableQty = $item[0]->ProductAvailableQty - $soldQty[0]->SoldQty;
|
||||
}else{
|
||||
// echo 'no qty';
|
||||
$availableQty = null;
|
||||
}
|
||||
|
||||
$handle_form = view('teamstore-sublayouts.forms.' . $item[0]->ProductForm )
|
||||
->with('sizes_array', $sizes_array)
|
||||
->with('availableQty', $availableQty)
|
||||
->render();
|
||||
|
||||
return $handle_form;
|
||||
|
||||
|
||||
$m = new TeamStoreModel;
|
||||
$teams_array = array();
|
||||
$teams_array = $m->getTeams($product_id);
|
||||
$sizes_array = $m->getSizes();
|
||||
?>
|
||||
<tr class="<?php echo $classname; ?>">
|
||||
<td class="td-hide" style="<?php echo $cssValue; ?>">
|
||||
<input type="text" class="form-control input-sm capitalizeText cls-uniformName" name="uniformName[]" placeholder="i.e John Doe" data-error="#err-uniformName<?php echo $itemCount ?>" required >
|
||||
<span id="err-uniformName<?php echo $itemCount ?>" style="color: #dd4b39"></span>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control input-sm cls-uniformTeam" name="uniformTeam[]" data-error="#err-uniformTeam<?php echo $itemCount ?>" require>
|
||||
<option value="">Select Team</option>
|
||||
<?php
|
||||
|
||||
foreach($teams_array as $team){
|
||||
?><option value="<?php echo $team->Team ?>"><?php echo $team->Team ?></option><?php
|
||||
}
|
||||
|
||||
?>
|
||||
<option value="others">Others</option>
|
||||
</select>
|
||||
<span id="err-uniformTeam<?php echo $itemCount ?>" style="color: #dd4b39"></span>
|
||||
</td>
|
||||
<td>
|
||||
<div id="selectOptionNumber1">
|
||||
<select class="form-control input-sm cls-uniformNumber" name="uniformNumber[]" data-error="#err-uniformNumber<?php echo $itemCount ?>" require >
|
||||
<option value="">Select Number</option>
|
||||
<?php
|
||||
for($i = 0 ; $i < 100 ; $i++){
|
||||
?><option value="<?php echo $i ?>"><?php echo $i ?></option><?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<span id="err-uniformNumber<?php echo $itemCount ?>" style="color: #dd4b39"></span>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<div id="fetchSizes">
|
||||
<select class="form-control input-sm cls-uniformSize" name="uniformSize[]" data-error="#err-uniformSize<?php echo $itemCount ?>" require>
|
||||
<option value="">Select Size</option>
|
||||
<?php
|
||||
foreach($sizes_array as $size){
|
||||
?><option value="<?php echo $size->Size ?>"><?php echo $size->Size ?></option><?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<span id="err-uniformSize<?php echo $itemCount ?>" style="color: #dd4b39"></span>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="changeToRemoveBtn">
|
||||
<button type="button" class="btn btn-danger btn-sm removeRow" 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="5" ><button type="button" id="addNewRow" class="btn btn-success btn-sm pull-right" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i> Add Row</button></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function addToCart(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$m = new TeamStoreModel;
|
||||
|
||||
|
||||
$product_id = $post['product_id'];
|
||||
$store_url = $post['store_url'];
|
||||
$store_id = $post['store_id'];
|
||||
$hash_product_id = $post['p_id'];
|
||||
|
||||
if($request->session()->has('cartkey')){
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
@@ -320,13 +280,20 @@ class TeamStoreController extends Controller {
|
||||
$cartKey = $cartKey = $request->session()->get('cartkey');
|
||||
}
|
||||
|
||||
$product_array = $m->selectTeamStoreProducts('Id', $product_id);
|
||||
$product_array = $m->selectTeamStoreProductByIdHash($hash_product_id);
|
||||
$product_id = $product_array[0]->Id;
|
||||
$TeamStoreId = $product_array[0]->TeamStoreId;
|
||||
$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;
|
||||
|
||||
$teamstore_array = $m->selectTeamStore('Id', $TeamStoreId);
|
||||
|
||||
$store_url = $teamstore_array[0]->StoreUrl;
|
||||
$store_id = $teamstore_array[0]->Id;
|
||||
|
||||
if($product_form == "jersey-and-shorts-form"){
|
||||
$order_names = $post['order_names'];
|
||||
$order_number = $post['order_number'];
|
||||
@@ -476,6 +443,27 @@ class TeamStoreController extends Controller {
|
||||
'Quantity' => 1
|
||||
);
|
||||
}
|
||||
}elseif($product_form == "name-size"){
|
||||
|
||||
$order_names = $post['order_names'];
|
||||
$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],
|
||||
'Size' => $order_size[$key],
|
||||
'Price' => $ProductPrice,
|
||||
'Quantity' => 1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$i = $m->insertToCart($items);
|
||||
|
||||
Reference in New Issue
Block a user