4_15_2019 update
This commit is contained in:
@@ -12,6 +12,7 @@ use Illuminate\Support\Facades\Hash;
|
||||
use Paypal;
|
||||
use View;
|
||||
use Mail;
|
||||
use Validator;
|
||||
|
||||
class UserController extends Controller {
|
||||
|
||||
@@ -441,8 +442,8 @@ class UserController extends Controller {
|
||||
|
||||
public function orderDetails($ck){
|
||||
$newUserModel = new UserModel;
|
||||
$order_item_array = $newUserModel->selectOrderItem($ck);
|
||||
$item_goup_array = $newUserModel->itemGroup($ck);
|
||||
$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')
|
||||
@@ -452,4 +453,123 @@ class UserController extends Controller {
|
||||
->with('order_item_array', $order_item_array);
|
||||
}
|
||||
|
||||
public function sellDesign($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.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);
|
||||
}
|
||||
|
||||
|
||||
public function saveNewStoreItem(Request $request){
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
$getYear = date('y');
|
||||
|
||||
$store_id = Auth::user()->store_id;
|
||||
$templateCode = $post['templateCode'];
|
||||
$designCode = $post['designCode'];
|
||||
$itemName = $post['itemName'];
|
||||
$itemDescription = $post['itemDescription'];
|
||||
$itemPrice = $post['itemPrice'];
|
||||
$itemForm = $post['itemForm'];
|
||||
$itemUrl = $post['itemUrl'];
|
||||
$itemPrivacy = $post['itemPrivacy'];
|
||||
|
||||
$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 .= "<li>".$error."</li>";
|
||||
}
|
||||
|
||||
$message = '
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> ERROR:</h4>
|
||||
'.$errors.
|
||||
'</div>';
|
||||
|
||||
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,
|
||||
'PrivacyStatus' => $itemPrivacy,
|
||||
'TemplateCode' => $templateCode,
|
||||
'DesignCode' => $designCode,
|
||||
);
|
||||
|
||||
$id = $UserModel->insertNewProduct($data); // product item id
|
||||
// echo $i;
|
||||
|
||||
$array_template_paths = $UserModel->selectTemplatePaths('TemplateCode', $templateCode);
|
||||
|
||||
foreach($array_template_paths as $key => $row1){
|
||||
if($key == 0){
|
||||
$thumb = $designCode . '-front-thumbnail.png';
|
||||
$class = "active";
|
||||
}else{
|
||||
$thumb = $designCode . '-' . strtolower($row1->Side) . '-thumbnail.png';
|
||||
$class = null;
|
||||
}
|
||||
|
||||
$thumbs = $data = array(
|
||||
'ProductId' => $id,
|
||||
'Image' => $thumb,
|
||||
'ImageClass' =>$class
|
||||
);
|
||||
|
||||
$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
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user