4_15_2019 update

This commit is contained in:
Frank John Begornia
2019-04-15 22:38:53 +08:00
parent 0fe1270756
commit c5862dfbf4
665 changed files with 401297 additions and 194 deletions

View File

@@ -32,7 +32,7 @@ class MainController extends Controller {
<!-- <h2 class="text-center">Basketball</h2> -->
<div>
<!-- <span class="badge">Sale</span> -->
<a href="<?php echo url('sports') . "/" . $row->URL; ?>"><img src="<?php echo './'. $row->Thumbnail; ?>" alt="" class="img img-responsive product-center" /></a>
<a href="<?php echo url('sports') . "/" . $row->URL; ?>"><img src="<?php echo url('/public'). '/'. $row->Thumbnail; ?>" alt="" class="img img-responsive product-center" /></a>
<h3 class="text-center sports-title"><?php echo $row->SportsName ?></h3>
</div>
</div>

View File

@@ -486,6 +486,14 @@ class DesignerController extends Controller {
$json_Shorts_Right = null;
}
if(isset($post['json_Shirts_Front'])){
$json_Jersey_Front = $post['json_Shirts_Front'];
}
if(isset($post['json_Shirts_Back'])){
$json_Jersey_Back = $post['json_Shirts_Back'];
}
try {
$design_info = array(
'ClientId' => $clientId,
@@ -509,8 +517,8 @@ class DesignerController extends Controller {
if($res){
// dd(Uuid::generate());
// return redirect('/designer/preview/'.$designCode);
return redirect('http://localhost/crew-designer/mydesign/'.$designCode.'/');
return redirect('/designer/preview/'.$designCode);
// return redirect('http://localhost/crew-designer/mydesign/'.$designCode.'/');
}
// else{

View File

@@ -27,24 +27,24 @@ class PaypalController extends Controller {
config('services.paypal.secret'));
$this->_apiContext->setConfig(array(
$this->_apiContext->setConfig(array(
'mode' => 'sandbox',
'service.EndPoint' => 'https://api.sandbox.paypal.com',
'http.ConnectionTimeOut' => 30,
'log.LogEnabled' => true,
'log.FileName' => storage_path('logs/paypal.log'),
'log.LogLevel' => 'FINE'
));
));
// live
// $this->_apiContext->setConfig(array(
// 'mode' => 'live',
// 'service.EndPoint' => 'https://api.paypal.com',
// 'http.ConnectionTimeOut' => 30,
// 'log.LogEnabled' => true,
// 'log.FileName' => storage_path('logs/paypal.log'),
// 'log.LogLevel' => 'FINE'
// ));
// live
// $this->_apiContext->setConfig(array(
// 'mode' => 'live',
// 'service.EndPoint' => 'https://api.paypal.com',
// 'http.ConnectionTimeOut' => 30,
// 'log.LogEnabled' => true,
// 'log.FileName' => storage_path('logs/paypal.log'),
// 'log.LogLevel' => 'FINE'
// ));
}

View File

@@ -23,21 +23,28 @@ class TeamStoreController extends Controller {
if (Auth::check()){
$user_role = Auth::user()->role;
$store_id = Auth::user()->store_id;
}else{
$user_role = null;
$store_id = null;
}
// if($request->session()->get('teamstore_data_array') == null){
// if($store_id != $store_array[0]->Id){
// return redirect()->back();
// }
// }else{
// if($user_role != "store_owner"){
// if($request->session()->get('teamstore_data_array')[0]->StoreUrl != $store_array[0]->StoreUrl){
// return redirect()->back();
// }
// }
// }
if($store_array[0]->Password != null){
if($request->session()->get('teamstore_data_array') == null){
if($store_id != $store_array[0]->Id){
return redirect('teamstore');
}
}else{
if($user_role != "store_owner"){
if($request->session()->get('teamstore_data_array')[0]->StoreUrl != $store_array[0]->StoreUrl){
return redirect()->back();
}
}
}
}
foreach ($product_array as $p => $pr_arr) {

View File

@@ -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
));
}
}

View File

@@ -119,6 +119,9 @@ Route::group(['middleware' => 'normaluser'], function () {
Route::get('user/email-verify', 'user\UserController@emailVerify');
Route::post('user/post/resend-verification', 'user\UserController@resendVericationCode');
Route::post('user/post/verify-code', 'user\UserController@verifyCode');
Route::get('user/my-designs/sell-design/{designCode}', 'user\UserController@sellDesign');
Route::post('user/my-designs/addstoreitem', 'user\UserController@saveNewStoreItem');
});

View File

@@ -12,13 +12,16 @@ class DesignerModel extends Model {
}
function selectTemplatePaths($templateid){
$i = DB::table('template_paths')->where('HashTemplateCode', $templateid)
$i = DB::table('template_paths')
->where('HashTemplateCode', $templateid)
->where('IsActive', 'TRUE')
->get();
return $i;
}
function selectTemplatePathsByTemplateCode($templateid){
$i = DB::table('template_paths')->where('TemplateCode', $templateid)
->where('IsActive', 'TRUE')
->get();
return $i;
}

View File

@@ -17,6 +17,7 @@ class TeamStoreModel extends Model {
{
$i = DB::table('teamstore_products')
->where($field, $teamstoreId)
->orderBy('Id', 'ASC')
->orderBy('Ordering', 'ASC')->get();
return $i;
}
@@ -111,7 +112,7 @@ class TeamStoreModel extends Model {
function myCartGroup($cartKey){
if($cartKey != ""){
$pdo = DB::connection()->getPdo();
$query = $pdo->prepare("SELECT *, COUNT(Id) AS qty, SUM(Price) * Quantity AS total_price FROM cart_tmp WHERE CartKey = :ck GROUP BY ProductId");
$query = $pdo->prepare("SELECT *, COUNT(Id) AS qty, Price * SUM(Quantity) AS total_price FROM cart_tmp WHERE CartKey = :ck GROUP BY ProductId");
$query->execute([':ck'=>$cartKey]);
$row = $query->fetchAll(\PDO::FETCH_OBJ);
return $row;

View File

@@ -91,8 +91,10 @@ class UserModel extends Model {
}
function selectTemplatePaths($field, $templateid){
$i = DB::table('template_paths')->where($field, $templateid)
->get();
$i = DB::table('template_paths')
->where($field, $templateid)
->where('IsActive', 'TRUE')
->get();
return $i;
}
@@ -142,15 +144,33 @@ class UserModel extends Model {
return $i;
}
function selectOrderItemWithStoreId($store_id, $ck){
$i = DB::table('orders')
->where('StoreId', $store_id)
->where('CartKey', $ck)
->get();
return $i;
}
function itemGroup($cartKey){
$pdo = DB::connection()->getPdo();
$query = $pdo->prepare("SELECT *, COUNT(Id) AS qty, SUM(Price) * Quantity AS total_price FROM orders WHERE CartKey = :ck GROUP BY ProductId");
$query = $pdo->prepare("SELECT *, COUNT(Id) AS qty, Price * SUM(Quantity) AS total_price FROM orders WHERE CartKey = :ck GROUP BY ProductId");
$query->execute([':ck'=>$cartKey]);
$row = $query->fetchAll(\PDO::FETCH_OBJ);
return $row;
}
function itemGroupWithStoreId($store_id, $cartKey){
$pdo = DB::connection()->getPdo();
$query = $pdo->prepare("SELECT *, COUNT(Id) AS qty, Price * SUM(Quantity) AS total_price FROM orders WHERE StoreId= :si AND CartKey = :ck GROUP BY ProductId");
$query->execute(array(':si'=>$store_id, ':ck'=>$cartKey));
$row = $query->fetchAll(\PDO::FETCH_OBJ);
return $row;
}
function selectDisplayItemThumb(){
$i = DB::table('teamstore_product_thumbnails')
@@ -158,4 +178,42 @@ class UserModel extends Model {
->get();
return $i;
}
}
function selectItemsStoreId($ck){
$i = DB::table('cart_tmp')
->select(DB::raw('StoreId'))
->where('CartKey', $ck)
->groupby('StoreId')
->get();
return $i;
}
function selectUserLogins($field, $value){
$i = DB::table('user_logins')
->where($field, $value)
->get();
return $i;
}
function insertNewProduct($data){
$pdo = DB::connection()->getPdo();
$i = DB::table('teamstore_products')->insert($data);
$id = DB::getPdo()->lastInsertId();
return $id;
}
function insertNewProductThumbnails($data){
$i = DB::table('teamstore_product_thumbnails')->insert($data);
return $i;
}
function updateProductCode($data, $id){
$i = DB::table('teamstore_products')->where('Id', $id)
->update($data);
return $i;
}
}