added sku and ready for tracking
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Models\ApiModel;
|
||||
use ArrayObject;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ApiController extends Controller
|
||||
{
|
||||
@@ -19,8 +20,8 @@ class ApiController extends Controller
|
||||
$ApiModel = new ApiModel;
|
||||
$post = $request->all();
|
||||
$response = $ApiModel->loginProductionUser($post['username'], $post['password']);
|
||||
|
||||
|
||||
|
||||
|
||||
if (!$response) {
|
||||
return response()->json(['status' => false, 'message' => "Invalid user"], 401);
|
||||
}
|
||||
@@ -48,14 +49,14 @@ class ApiController extends Controller
|
||||
"created_at" => date('Y-m-d H:i:s', strtotime($post['datetime']))
|
||||
);
|
||||
|
||||
|
||||
|
||||
$checkIfTrackExist = $ApiModel->checkIfTrackExist($post['StepId'], $post['productId'], $post['ordersId'], $post['invoice'], $post['quantityCounter']);
|
||||
if ($checkIfTrackExist) {
|
||||
return response()->json(['status' => false, 'message' => "Already scanned."], 500);
|
||||
}
|
||||
|
||||
// $selectNextStep = $ApiModel->selectNextStep($post['invoice']);
|
||||
|
||||
|
||||
// if(($selectNextStep->StepId + 1) != $post['StepId']){
|
||||
// return response()->json(['status' => false, 'message' => "Your account is not allowed to update this item."], 401);
|
||||
// }
|
||||
@@ -82,7 +83,7 @@ class ApiController extends Controller
|
||||
$ApiModel = new ApiModel;
|
||||
$invoice = Input::get('invoice');
|
||||
$getStep = Input::get('step');
|
||||
|
||||
|
||||
|
||||
// $response = $ApiModel->getTrackingStatus($invoice);
|
||||
$selectPaymentDetails = $ApiModel->selectPaymentDetails($invoice);
|
||||
@@ -104,7 +105,7 @@ class ApiController extends Controller
|
||||
$selectOrderList[$k]->table_fields = $table_fields[$k];
|
||||
$selectOrderList[$k]->product_images = $product_images[$k];
|
||||
}
|
||||
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'payment_details' => $selectPaymentDetails[0],
|
||||
@@ -119,9 +120,9 @@ class ApiController extends Controller
|
||||
$productid = Input::get('productid');
|
||||
$orderid = Input::get('orderid');
|
||||
$qcounter = Input::get('qcounter');
|
||||
|
||||
|
||||
$getStatus = $ApiModel->getStatus($invoice, $productid, $orderid, $qcounter);
|
||||
|
||||
|
||||
if (!$getStatus) {
|
||||
return response()->json(['status' => false, 'data' => ""], 404);
|
||||
}
|
||||
@@ -132,7 +133,8 @@ class ApiController extends Controller
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function getSteps(){
|
||||
public function getSteps()
|
||||
{
|
||||
$ApiModel = new ApiModel;
|
||||
$selectSteps = $ApiModel->selectSteps();
|
||||
|
||||
@@ -144,6 +146,39 @@ class ApiController extends Controller
|
||||
'status' => true,
|
||||
'data' => $selectSteps
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
public function getInvoices()
|
||||
{
|
||||
$ApiModel = new ApiModel;
|
||||
$userId = Input::get('id');
|
||||
|
||||
$selectInvoices = $ApiModel->selectInvoices($userId);
|
||||
|
||||
if (!$selectInvoices) {
|
||||
return response()->json(['status' => false, 'data' => ""], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'data' => $selectInvoices
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function trackingStatus()
|
||||
{
|
||||
$ApiModel = new ApiModel;
|
||||
$invoice = Input::get('invoice');
|
||||
|
||||
$getOrderStatus = $ApiModel->getOrderStatus($invoice);
|
||||
|
||||
if (!$getOrderStatus) {
|
||||
return response()->json(['status' => false, 'data' => ""], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'data' => $getOrderStatus
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\user\UserModel;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class CustomAuthController extends Controller
|
||||
{
|
||||
@@ -23,6 +24,8 @@ class CustomAuthController extends Controller
|
||||
$email = $post['email'];
|
||||
$password = $post['password'];
|
||||
|
||||
// $redirectUrl = Input::get('redirectUrl');
|
||||
|
||||
if (Auth::attempt(['email' => $email, 'password' => $password])) {
|
||||
|
||||
if (Auth::user()->role == 'admin') {
|
||||
@@ -49,7 +52,8 @@ class CustomAuthController extends Controller
|
||||
'success' => true,
|
||||
'message' => $message,
|
||||
'navbar' => $navbar,
|
||||
'save_design_button' => $save_design_button
|
||||
'save_design_button' => $save_design_button,
|
||||
'redirect' => $post['redirect']
|
||||
));
|
||||
} else {
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
@@ -8,8 +10,10 @@ use App\Models\MainModel;
|
||||
// use Illuminate\Support\Facades\Request;
|
||||
use Analytics;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class MainController extends Controller {
|
||||
class MainController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
@@ -17,25 +21,25 @@ class MainController extends Controller {
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
{
|
||||
return view('sublayouts.index');
|
||||
}
|
||||
|
||||
public function sports()
|
||||
{
|
||||
// if(Request::ajax()){
|
||||
$m = new MainModel;
|
||||
$fetchData = $m->selectAllSports();
|
||||
//var_dump($fetchData);
|
||||
$m = new MainModel;
|
||||
$fetchData = $m->selectAllSports();
|
||||
//var_dump($fetchData);
|
||||
|
||||
foreach ($fetchData as $row) {
|
||||
?>
|
||||
<div class="col-md-3 col-sm-6 col-xs-12 list-sport">
|
||||
<a href="<?php echo url('sports') . "/" . $row->URL; ?>"><img src="<?php echo config('site_config.uploads') . 'sports-thumbnails/' . $row->Thumbnail; ?>" alt="" class="img img-responsive product-center" /></a>
|
||||
<h3 class="text-center sports-title"><?php echo $row->SportsName ?></h3>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
foreach ($fetchData as $row) {
|
||||
?>
|
||||
<div class="col-md-3 col-sm-6 col-xs-12 list-sport">
|
||||
<a href="<?php echo url('sports') . "/" . $row->URL; ?>"><img src="<?php echo config('site_config.uploads') . 'sports-thumbnails/' . $row->Thumbnail; ?>" alt="" class="img img-responsive product-center" /></a>
|
||||
<h3 class="text-center sports-title"><?php echo $row->SportsName ?></h3>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
// }else{
|
||||
// return response()->view('errors/403');
|
||||
@@ -48,8 +52,8 @@ class MainController extends Controller {
|
||||
|
||||
$data = $m->selectSportsId($url);
|
||||
$categoryids = array();
|
||||
|
||||
foreach($data as $row){
|
||||
|
||||
foreach ($data as $row) {
|
||||
$categoryids[] = $row->Category;
|
||||
}
|
||||
|
||||
@@ -58,13 +62,13 @@ class MainController extends Controller {
|
||||
// $array_templateby_category = $m->selectTemplatesByCategory($url, $id);
|
||||
|
||||
// var_dump($array_category);
|
||||
|
||||
|
||||
return view('sublayouts.sports-category')
|
||||
->with('array_sports', $array_sports)
|
||||
->with('row', $array_category);
|
||||
->with('array_sports', $array_sports)
|
||||
->with('row', $array_category);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function templatesByCategory($url, $id)
|
||||
{
|
||||
$m = new MainModel;
|
||||
@@ -75,9 +79,9 @@ class MainController extends Controller {
|
||||
$array_category = $m->selectCategory($categoryids);
|
||||
// var_dump($array_category);
|
||||
return view('sublayouts.sports-styles')
|
||||
->with('cat', $url)
|
||||
->with('row', $data)
|
||||
->with('array_category', $array_category);
|
||||
->with('cat', $url)
|
||||
->with('row', $data)
|
||||
->with('array_category', $array_category);
|
||||
// if(count($data) > 1){
|
||||
// return view('sublayouts.sports-styles')
|
||||
// ->with('cat', $url)
|
||||
@@ -88,72 +92,81 @@ class MainController extends Controller {
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function fetchTemplates()
|
||||
{
|
||||
// if(Request::ajax()){
|
||||
// $m = new MainModel;
|
||||
//
|
||||
// $data = $m->selectSportsId($url);
|
||||
// echo $data[0]->id;
|
||||
//$fetchData = $m->selectSportsTemplates();
|
||||
// $m = new MainModel;
|
||||
//
|
||||
// $data = $m->selectSportsId($url);
|
||||
// echo $data[0]->id;
|
||||
//$fetchData = $m->selectSportsTemplates();
|
||||
|
||||
|
||||
//var_dump($fetchData);
|
||||
//var_dump($fetchData);
|
||||
|
||||
// }else{
|
||||
// return response()->view('errors/403');
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
//call this from blade view
|
||||
public static function getCountCart(){
|
||||
$m = new MainModel;
|
||||
|
||||
if(Session::get('cartkey')){
|
||||
|
||||
$cartKey = Session::get('cartkey');
|
||||
//call this from blade view
|
||||
public static function getCountCart()
|
||||
{
|
||||
$m = new MainModel;
|
||||
|
||||
if (Session::get('cartkey')) {
|
||||
|
||||
$cartKey = Session::get('cartkey');
|
||||
|
||||
echo $i = $m->cartCount($cartKey);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function countCart(Request $request){
|
||||
public function countCart(Request $request)
|
||||
{
|
||||
|
||||
$m = new MainModel;
|
||||
|
||||
if($request->session()->has('cartkey')){
|
||||
if ($request->session()->has('cartkey')) {
|
||||
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
|
||||
echo $i = $m->cartCount($cartKey);
|
||||
|
||||
}else{
|
||||
echo $i = $m->cartCount($cartKey);
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function removeCartItem($id){
|
||||
public function removeCartItem($id)
|
||||
{
|
||||
|
||||
$m = new MainModel;
|
||||
|
||||
$row = $m->removeItem($id);
|
||||
if($row > 0)
|
||||
{
|
||||
// \Session::flash('message', 'Record successfully deleted.');
|
||||
echo '<script>
|
||||
|
||||
$row = $m->removeItem($id);
|
||||
if ($row > 0) {
|
||||
// \Session::flash('message', 'Record successfully deleted.');
|
||||
echo '<script>
|
||||
alert("Item removed");
|
||||
</script>';
|
||||
return redirect('cart');
|
||||
}
|
||||
|
||||
}
|
||||
return redirect('cart');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function trackingPage()
|
||||
{
|
||||
|
||||
if (Auth::check()) {
|
||||
$userId = Auth::user()->id;
|
||||
} else {
|
||||
$userId = "";
|
||||
}
|
||||
return view('merchbay.track_order')
|
||||
->with('userId', $userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,6 +366,7 @@ class UserController extends Controller {
|
||||
$item_url = $post['item_url'];
|
||||
$data = array(
|
||||
'ProductName' => $post['itemName'],
|
||||
'ProductCode' => $post['sku'],
|
||||
'ProductPrice' => str_replace('$ ', '', $post['item_price']),
|
||||
'ProductDescription' => $post['itemDescription'],
|
||||
'PrivacyStatus' => $post['item_privacy'],
|
||||
|
||||
@@ -201,6 +201,8 @@ Route::group(array('middleware' => ['isAuthorized', 'cors'], 'prefix' => 'api'),
|
||||
Route::get('tracking', 'ApiController@getTrackingStatus');
|
||||
Route::get('order-status', 'ApiController@getOrderStatus');
|
||||
Route::get('steps', 'ApiController@getSteps');
|
||||
Route::get('invoices', 'ApiController@getInvoices');
|
||||
Route::get('tracking-status', 'ApiController@trackingStatus');
|
||||
});
|
||||
|
||||
Route::get('vue/designer', function() {
|
||||
@@ -213,4 +215,6 @@ Route:get('/privacy-policy', function() {
|
||||
|
||||
Route::get('/terms-of-use', function () {
|
||||
return view('merchbay.terms_of_use');
|
||||
});
|
||||
});
|
||||
|
||||
Route::get('/track-order', 'MainController@trackingPage');
|
||||
@@ -69,8 +69,17 @@ class ApiModel extends Model
|
||||
// ->get();
|
||||
// return $i;
|
||||
|
||||
$i = DB::table('orders')->select('orders.Id', 'orders.Name', 'orders.Name2', 'orders.Number', 'orders.Size', 'orders.JerseySize',
|
||||
'orders.ShortsSize', 'orders.Quantity', DB::raw('(SELECT COUNT(*) FROM tracking WHERE StepId = '.$stepid.' AND OrdersId = orders.Id) AS Status'))
|
||||
$i = DB::table('orders')->select(
|
||||
'orders.Id',
|
||||
'orders.Name',
|
||||
'orders.Name2',
|
||||
'orders.Number',
|
||||
'orders.Size',
|
||||
'orders.JerseySize',
|
||||
'orders.ShortsSize',
|
||||
'orders.Quantity',
|
||||
DB::raw('(SELECT COUNT(*) FROM tracking WHERE StepId = ' . $stepid . ' AND OrdersId = orders.Id) AS Status')
|
||||
)
|
||||
// ->leftjoin('tracking', 'orders.Id', '=', 'tracking.OrdersId')
|
||||
// ->where('tracking.StepId', $stepid)
|
||||
->where('orders.CartKey', $cartKey)
|
||||
@@ -97,56 +106,81 @@ class ApiModel extends Model
|
||||
function checkIfTrackExist($stepid, $productid, $orderid, $invoice, $qcounter)
|
||||
{
|
||||
$i = DB::table('tracking')
|
||||
->where('StepId', $stepid)
|
||||
->where('ProductId', $productid)
|
||||
->where('OrdersId', $orderid)
|
||||
->where('InvoiceNumber', $invoice)
|
||||
->where('QuantityCounter', $qcounter)
|
||||
->get();
|
||||
->where('StepId', $stepid)
|
||||
->where('ProductId', $productid)
|
||||
->where('OrdersId', $orderid)
|
||||
->where('InvoiceNumber', $invoice)
|
||||
->where('QuantityCounter', $qcounter)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function getCurrentTrackingSteps($invoice){
|
||||
function getCurrentTrackingSteps($invoice)
|
||||
{
|
||||
$i = DB::table('tracking')->select('StepId')
|
||||
->where('InvoiceNumber', $invoice)
|
||||
->groupBy('StepId')
|
||||
->orderBy('StepId', 'ASC')
|
||||
->get();
|
||||
->where('InvoiceNumber', $invoice)
|
||||
->groupBy('StepId')
|
||||
->orderBy('StepId', 'ASC')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function getStatus($invoice, $productid, $orderid, $qcounter){
|
||||
function getStatus($invoice, $productid, $orderid, $qcounter)
|
||||
{
|
||||
$i = DB::table('tracking')->select('production_user.Name', DB::raw('DATE_FORMAT(tracking.created_at, "%b %d, %Y - %H:%i") AS datetime'))
|
||||
->leftjoin('production_user', 'production_user.Id', '=', 'tracking.ScannedBy')
|
||||
->where('tracking.InvoiceNumber', $invoice)
|
||||
->where('tracking.ProductId', $productid)
|
||||
->where('tracking.OrdersId', $orderid)
|
||||
->where('tracking.QuantityCounter', $qcounter)
|
||||
->get();
|
||||
->leftjoin('production_user', 'production_user.Id', '=', 'tracking.ScannedBy')
|
||||
->where('tracking.InvoiceNumber', $invoice)
|
||||
->where('tracking.ProductId', $productid)
|
||||
->where('tracking.OrdersId', $orderid)
|
||||
->where('tracking.QuantityCounter', $qcounter)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectSteps(){
|
||||
function selectSteps()
|
||||
{
|
||||
$i = DB::table('tracking_steps')
|
||||
->orderBy('Order', 'ASC')
|
||||
->get();
|
||||
->orderBy('Order', 'ASC')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectCurrentStep($invoice){
|
||||
function selectCurrentStep($invoice)
|
||||
{
|
||||
$i = DB::table('tracking')->select('tracking_steps.*')
|
||||
->leftjoin('tracking_steps', 'tracking_steps.Id', '=', 'tracking.StepId')
|
||||
->where('tracking.InvoiceNumber', $invoice)
|
||||
->orderBy('tracking.StepId', 'DESC')
|
||||
->first();
|
||||
->leftjoin('tracking_steps', 'tracking_steps.Id', '=', 'tracking.StepId')
|
||||
->where('tracking.InvoiceNumber', $invoice)
|
||||
->orderBy('tracking.StepId', 'DESC')
|
||||
->first();
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
function selectCurrentStepOrder($stepOrder){
|
||||
function selectCurrentStepOrder($stepOrder)
|
||||
{
|
||||
$i = DB::table('tracking_steps')
|
||||
->where('Order', $stepOrder)
|
||||
->get();
|
||||
->where('Order', $stepOrder)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectInvoices($id)
|
||||
{
|
||||
$i = DB::table('payment_details')->select('payment_details.*', 'shipping_addresses.*')
|
||||
->leftjoin('shipping_addresses', 'payment_details.Id', '=', 'shipping_addresses.PaymentDetail_Id')
|
||||
->where('payment_details.UserId', $id)
|
||||
->orderBy('payment_details.Id', 'DESC')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function getOrderStatus($invoice)
|
||||
{
|
||||
$i = DB::table('tracking')
|
||||
->where('InvoiceNumber', $invoice)
|
||||
->groupBy('StepId')
|
||||
->orderBy('StepId', 'ASC')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,162 +1,180 @@
|
||||
<?php namespace App\Models\user;
|
||||
<?php
|
||||
|
||||
namespace App\Models\user;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UserModel extends Model {
|
||||
class UserModel extends Model
|
||||
{
|
||||
|
||||
function insertAddressBook($data){
|
||||
function insertAddressBook($data)
|
||||
{
|
||||
|
||||
$i = DB::table('user_address_book')->insert($data);
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectAddresBook($field, $userId){
|
||||
function selectAddresBook($field, $userId)
|
||||
{
|
||||
|
||||
$i = DB::table('user_address_book')
|
||||
->where($field,'=',$userId)
|
||||
->get();
|
||||
->where($field, '=', $userId)
|
||||
->get();
|
||||
return $i;
|
||||
|
||||
}
|
||||
|
||||
function saveUpdateAddressBook($data, $id){
|
||||
function saveUpdateAddressBook($data, $id)
|
||||
{
|
||||
$i = DB::table('user_address_book')->where('Id', $id)
|
||||
->update($data);
|
||||
|
||||
return $i;
|
||||
}
|
||||
->update($data);
|
||||
|
||||
function selectProfileInfo($id){
|
||||
|
||||
$i = DB::table('user_logins')->select('user_logins.name', 'user_logins.username', 'user_logins.email', 'user_logins.email_is_verified','user_logins.other_email', 'user_logins.role', 'user_logins.store_id', 'user_info.ContactNumber', 'user_info.Gender', 'user_info.Birthday')
|
||||
->leftjoin('user_info', 'user_info.UserId','=','user_logins.id')
|
||||
->where('user_logins.id','=',$id)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function saveUpdateUserLogins($data, $id){
|
||||
$i = DB::table('user_logins')->where('id', $id)
|
||||
->update($data);
|
||||
|
||||
return $i;
|
||||
function selectProfileInfo($id)
|
||||
{
|
||||
|
||||
$i = DB::table('user_logins')->select('user_logins.name', 'user_logins.username', 'user_logins.email', 'user_logins.email_is_verified', 'user_logins.other_email', 'user_logins.role', 'user_logins.store_id', 'user_info.ContactNumber', 'user_info.Gender', 'user_info.Birthday')
|
||||
->leftjoin('user_info', 'user_info.UserId', '=', 'user_logins.id')
|
||||
->where('user_logins.id', '=', $id)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function saveUpdateUserInfo($data, $id){
|
||||
|
||||
function saveUpdateUserLogins($data, $id)
|
||||
{
|
||||
$i = DB::table('user_logins')->where('id', $id)
|
||||
->update($data);
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function saveUpdateUserInfo($data, $id)
|
||||
{
|
||||
$exists = DB::table('user_info')->where('UserId', $id)->first();
|
||||
|
||||
if(!$exists){
|
||||
|
||||
if (!$exists) {
|
||||
$i = DB::table('user_info')->insert($data);
|
||||
}else{
|
||||
} else {
|
||||
$i = DB::table('user_info')
|
||||
->where('UserId', $id)
|
||||
->update($data);
|
||||
->where('UserId', $id)
|
||||
->update($data);
|
||||
}
|
||||
return $i;
|
||||
|
||||
}
|
||||
|
||||
function saveUpdatePassword($password, $id){
|
||||
|
||||
function saveUpdatePassword($password, $id)
|
||||
{
|
||||
|
||||
$i = DB::table('user_logins')->where('id', $id)
|
||||
->update(['password' => $password]);
|
||||
|
||||
return $i;
|
||||
}
|
||||
->update(['password' => $password]);
|
||||
|
||||
function selectPaymentDetails($field, $val){
|
||||
|
||||
$i = DB::table('payment_details')
|
||||
->where($field, $val)
|
||||
->get();
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectClientDesigns($userid){
|
||||
|
||||
$i = DB::table('client_designs')->where('ClientId', $userid)
|
||||
->orderBy('Id', 'DESC')
|
||||
->paginate(12) ;
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectClientDesignsbyCode($code){
|
||||
|
||||
$i = DB::table('client_designs')->where('DesignCode', $code)
|
||||
->get();
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectTemplatePaths($field, $templateid){
|
||||
$i = DB::table('template_paths')
|
||||
->where($field, $templateid)
|
||||
->where('IsActive', 'TRUE')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function updateClientDesign($data, $id){
|
||||
function selectPaymentDetails($field, $val)
|
||||
{
|
||||
|
||||
$i = DB::table('payment_details')
|
||||
->where($field, $val)
|
||||
->get();
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectClientDesigns($userid)
|
||||
{
|
||||
|
||||
$i = DB::table('client_designs')->where('ClientId', $userid)
|
||||
->orderBy('Id', 'DESC')
|
||||
->paginate(12);
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectClientDesignsbyCode($code)
|
||||
{
|
||||
|
||||
$i = DB::table('client_designs')->where('DesignCode', $code)
|
||||
->get();
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectTemplatePaths($field, $templateid)
|
||||
{
|
||||
$i = DB::table('template_paths')
|
||||
->where($field, $templateid)
|
||||
->where('IsActive', 'TRUE')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function updateClientDesign($data, $id)
|
||||
{
|
||||
$i = DB::table('client_designs')->where('DesignCode', $id)
|
||||
->update($data);
|
||||
|
||||
return $i;
|
||||
->update($data);
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectStoreInfo($storeId){
|
||||
function selectStoreInfo($storeId)
|
||||
{
|
||||
$i = DB::table('teamstores')->where('Id', $storeId)
|
||||
->get();
|
||||
|
||||
return $i;
|
||||
->get();
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function saveResendCode($data){
|
||||
function saveResendCode($data)
|
||||
{
|
||||
|
||||
$res = DB::table('email_verification_codes')->where("EmailAddress", $data['EmailAddress'])
|
||||
->get();
|
||||
|
||||
if($res){
|
||||
->get();
|
||||
|
||||
if ($res) {
|
||||
$i = DB::table('email_verification_codes')->where('EmailAddress', $data['EmailAddress'])
|
||||
->update($data);
|
||||
->update($data);
|
||||
return $i;
|
||||
}else{
|
||||
} else {
|
||||
$i = DB::table('email_verification_codes')->insert($data);
|
||||
return $i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function validateCode($data){
|
||||
|
||||
function validateCode($data)
|
||||
{
|
||||
|
||||
$i = DB::table('email_verification_codes')->where('EmailAddress', $data['EmailAddress'])
|
||||
->where('VerCode', $data['Code'])
|
||||
->get();
|
||||
->where('VerCode', $data['Code'])
|
||||
->get();
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectOrderItem($ck){
|
||||
$i = DB::table('orders')
|
||||
->where('CartKey', $ck)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectOrderItemWithStoreId($store_id, $ck){
|
||||
function selectOrderItem($ck)
|
||||
{
|
||||
$i = DB::table('orders')
|
||||
->where('StoreId', $store_id)
|
||||
->where('CartKey', $ck)
|
||||
->get();
|
||||
->where('CartKey', $ck)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectOrder($field, $value){
|
||||
function selectOrderItemWithStoreId($store_id, $ck)
|
||||
{
|
||||
$i = DB::table('orders')
|
||||
->where($field, $value)
|
||||
->get();
|
||||
->where('StoreId', $store_id)
|
||||
->where('CartKey', $ck)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectOrder($field, $value)
|
||||
{
|
||||
$i = DB::table('orders')
|
||||
->where($field, $value)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
@@ -172,213 +190,239 @@ class UserModel extends Model {
|
||||
// return $i;
|
||||
// }
|
||||
|
||||
function selectStoreOrders($store_id){
|
||||
$i = DB::table('orders')->select('orders.*', 'orders.Id as Order_Id', 'payment_details.InvoiceNumber', 'payment_details.Currency', 'payment_details.Payer_Email', 'payment_details.Payer_Firstname', 'payment_details.Payer_Lastname', 'shipping_addresses.*', DB::raw('(SELECT tracking_steps.StepLabel FROM tracking LEFT JOIN tracking_steps ON tracking_steps.Id = tracking.StepId WHERE tracking.InvoiceNumber = payment_details.InvoiceNumber ORDER BY tracking.Id DESC LIMIT 1 ) AS StepLabel'))
|
||||
->leftjoin('payment_details', 'payment_details.CartKey','=','orders.CartKey')
|
||||
->leftjoin('shipping_addresses', 'shipping_addresses.PaymentDetail_Id','=','payment_details.Id')
|
||||
->where('orders.StoreId', $store_id)
|
||||
->orderby('orders.DateCreated', 'DESC')
|
||||
->get();
|
||||
function selectStoreOrders($store_id)
|
||||
{
|
||||
$i = DB::table('orders')->select('orders.*', 'orders.Id as Order_Id', 'payment_details.InvoiceNumber', 'payment_details.Currency', 'payment_details.Payer_Email', 'payment_details.Payer_Firstname', 'payment_details.Payer_Lastname', 'shipping_addresses.*', DB::raw('(SELECT tracking_steps.StepLabel FROM tracking LEFT JOIN tracking_steps ON tracking_steps.Id = tracking.StepId WHERE tracking.InvoiceNumber = payment_details.InvoiceNumber ORDER BY tracking.Id DESC LIMIT 1 ) AS StepLabel'), 'teamstore_products.ProductCode')
|
||||
->leftjoin('payment_details', 'payment_details.CartKey', '=', 'orders.CartKey')
|
||||
->leftjoin('shipping_addresses', 'shipping_addresses.PaymentDetail_Id', '=', 'payment_details.Id')
|
||||
->leftjoin('teamstore_products', 'teamstore_products.Id', '=', 'orders.ProductId')
|
||||
->where('orders.StoreId', $store_id)
|
||||
->orderby('orders.DateCreated', 'DESC')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
function itemGroup($cartKey){
|
||||
function itemGroup($cartKey)
|
||||
{
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$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]);
|
||||
$query->execute([':ck' => $cartKey]);
|
||||
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||
return $row;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function itemGroupWithStoreId($store_id, $cartKey){
|
||||
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));
|
||||
$query->execute(array(':si' => $store_id, ':ck' => $cartKey));
|
||||
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||
return $row;
|
||||
|
||||
}
|
||||
|
||||
function selectDisplayItemThumb(){
|
||||
function selectDisplayItemThumb()
|
||||
{
|
||||
|
||||
$i = DB::table('teamstore_product_thumbnails')
|
||||
->where('ImageClass', 'active')
|
||||
->orderby('Ordering', 'ASC')
|
||||
->get();
|
||||
->where('ImageClass', 'active')
|
||||
->orderby('Ordering', 'ASC')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectDisplayItemThumbById($id){
|
||||
function selectDisplayItemThumbById($id)
|
||||
{
|
||||
|
||||
$i = DB::table('teamstore_product_thumbnails')
|
||||
->where('ProductId', $id)
|
||||
->where('ImageClass', 'active')
|
||||
->get();
|
||||
->where('ProductId', $id)
|
||||
->where('ImageClass', 'active')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function deleteImageThumb($field, $id){
|
||||
function deleteImageThumb($field, $id)
|
||||
{
|
||||
$i = DB::table('teamstore_product_thumbnails')
|
||||
->where($field, $id)
|
||||
->delete();
|
||||
->where($field, $id)
|
||||
->delete();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function deleteStoreItem($id){
|
||||
function deleteStoreItem($id)
|
||||
{
|
||||
$i = DB::table('teamstore_products')
|
||||
->where('Id', $id)
|
||||
->delete();
|
||||
->where('Id', $id)
|
||||
->delete();
|
||||
$this->deleteImageThumb('ProductId', $id);
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectItemsStoreId($ck){
|
||||
function selectItemsStoreId($ck)
|
||||
{
|
||||
|
||||
$i = DB::table('cart_tmp')
|
||||
->select(DB::raw('StoreId'))
|
||||
->where('CartKey', $ck)
|
||||
->groupby('StoreId')
|
||||
->get();
|
||||
->select(DB::raw('StoreId'))
|
||||
->where('CartKey', $ck)
|
||||
->groupby('StoreId')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
function selectUserLogins($field, $value){
|
||||
function selectUserLogins($field, $value)
|
||||
{
|
||||
|
||||
$i = DB::table('user_logins')
|
||||
->where($field, $value)
|
||||
->get();
|
||||
->where($field, $value)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
|
||||
function insertNewProduct($data){
|
||||
function insertNewProduct($data)
|
||||
{
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$i = DB::table('teamstore_products')->insert($data);
|
||||
$id = DB::getPdo()->lastInsertId();
|
||||
return $id;
|
||||
}
|
||||
|
||||
function insertNewProductThumbnails($data){
|
||||
function insertNewProductThumbnails($data)
|
||||
{
|
||||
$i = DB::table('teamstore_product_thumbnails')->insert($data);
|
||||
return $i;
|
||||
}
|
||||
|
||||
function updateProductCode($data, $id){
|
||||
function updateProductCode($data, $id)
|
||||
{
|
||||
$i = DB::table('teamstore_products')->where('Id', $id)
|
||||
->update($data);
|
||||
|
||||
return $i;
|
||||
->update($data);
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectTeamStoreName($ck){
|
||||
function selectTeamStoreName($ck)
|
||||
{
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$query = $pdo->prepare("SELECT t.Id, t.StoreName FROM orders AS o INNER JOIN teamstores AS t ON t.Id = o.StoreId WHERE o.CartKey = :ck GROUP BY o.StoreId ORDER BY t.StoreName ASC");
|
||||
$query->execute(array(':ck'=>$ck));
|
||||
$query->execute(array(':ck' => $ck));
|
||||
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function updateActiveThumb($id, $product_id){
|
||||
|
||||
function updateActiveThumb($id, $product_id)
|
||||
{
|
||||
DB::table('teamstore_product_thumbnails')->where('ProductId', $product_id)
|
||||
->update(['ImageClass' => null]);
|
||||
->update(['ImageClass' => null]);
|
||||
$i = DB::table('teamstore_product_thumbnails')->where('Id', $id)
|
||||
->update(['ImageClass' => 'active']);
|
||||
->update(['ImageClass' => 'active']);
|
||||
}
|
||||
|
||||
function updateThumbnailOrdering($order, $id){
|
||||
function updateThumbnailOrdering($order, $id)
|
||||
{
|
||||
$i = DB::table('teamstore_product_thumbnails')->where('Id', $id)
|
||||
->update(['Ordering' => $order]);
|
||||
->update(['Ordering' => $order]);
|
||||
}
|
||||
|
||||
function updateItemOrdering($order, $id){
|
||||
function updateItemOrdering($order, $id)
|
||||
{
|
||||
$i = DB::table('teamstore_products')->where('Id', $id)
|
||||
->update(['Ordering' => $order]);
|
||||
->update(['Ordering' => $order]);
|
||||
}
|
||||
|
||||
function updateTeamstore($id, $data){
|
||||
function updateTeamstore($id, $data)
|
||||
{
|
||||
|
||||
$i = DB::table('teamstores')
|
||||
->where("Id", $id)
|
||||
->update($data);
|
||||
->where("Id", $id)
|
||||
->update($data);
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectShippingAddress($field, $value){
|
||||
function selectShippingAddress($field, $value)
|
||||
{
|
||||
|
||||
$i = DB::table('shipping_addresses')
|
||||
->where($field, $value)
|
||||
->get();
|
||||
->where($field, $value)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectUserLoginsWhereIn($ids){
|
||||
function selectUserLoginsWhereIn($ids)
|
||||
{
|
||||
$i = DB::table('user_logins')
|
||||
->whereIn('store_id', $ids)
|
||||
->get();
|
||||
return $i;
|
||||
->whereIn('store_id', $ids)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectShippingCost(){
|
||||
function selectShippingCost()
|
||||
{
|
||||
$i = DB::table('shipping_cost')
|
||||
->get();
|
||||
return $i;
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
function countStoreOrder($storeId){
|
||||
function countStoreOrder($storeId)
|
||||
{
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$query = $pdo->prepare("SELECT SUM(o.Quantity) AS count_order FROM orders AS o WHERE o.StoreId = :storeId");
|
||||
$query->execute([':storeId'=>$storeId]);
|
||||
$query->execute([':storeId' => $storeId]);
|
||||
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||
return $row;
|
||||
}
|
||||
|
||||
function storeIncome($storeId){
|
||||
function storeIncome($storeId)
|
||||
{
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$query = $pdo->prepare("SELECT SUM(o.Price) AS store_income FROM orders AS o WHERE o.StoreId = :storeId");
|
||||
$query->execute([':storeId'=>$storeId]);
|
||||
$query->execute([':storeId' => $storeId]);
|
||||
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||
return $row;
|
||||
}
|
||||
|
||||
function countStoreProduct($storeId){
|
||||
function countStoreProduct($storeId)
|
||||
{
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$query = $pdo->prepare("SELECT COUNT(Id) AS store_product_count FROM teamstore_products AS tp WHERE tp.TeamStoreId = :storeId");
|
||||
$query->execute([':storeId'=>$storeId]);
|
||||
$query->execute([':storeId' => $storeId]);
|
||||
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||
return $row;
|
||||
}
|
||||
|
||||
function countStorePublishedProduct($storeId){
|
||||
function countStorePublishedProduct($storeId)
|
||||
{
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$query = $pdo->prepare("SELECT COUNT(Id) AS store_published_product FROM teamstore_products AS tp WHERE tp.TeamStoreId = :storeId AND PrivacyStatus = 'public'");
|
||||
$query->execute([':storeId'=>$storeId]);
|
||||
$query->execute([':storeId' => $storeId]);
|
||||
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||
return $row;
|
||||
}
|
||||
|
||||
function getAnnouncement($storeId){
|
||||
function getAnnouncement($storeId)
|
||||
{
|
||||
$i = DB::table('store_announcement')
|
||||
->where('StoreId', $storeId)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function saveNewAnnouncement($data){
|
||||
$i = DB::table('store_announcement')
|
||||
->insert($data);
|
||||
->where('StoreId', $storeId)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function updateAnnouncement($id, $data){
|
||||
function saveNewAnnouncement($data)
|
||||
{
|
||||
$i = DB::table('store_announcement')
|
||||
->where('Id', $id)
|
||||
->update($data);
|
||||
return $i;
|
||||
->insert($data);
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
|
||||
function updateAnnouncement($id, $data)
|
||||
{
|
||||
$i = DB::table('store_announcement')
|
||||
->where('Id', $id)
|
||||
->update($data);
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user