119 lines
3.1 KiB
PHP
119 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ApiModel extends Model
|
|
{
|
|
|
|
function loginProductionUser($username, $password)
|
|
{
|
|
$i = DB::table('production_user')
|
|
->where('Username', $username)
|
|
->where('Password', $password)
|
|
->get();
|
|
return $i;
|
|
}
|
|
|
|
function selectTrackingStepLabel($id)
|
|
{
|
|
$i = DB::table('tracking_steps')->select('StepLabel')
|
|
->where('Id', $id)
|
|
->get();
|
|
return $i;
|
|
}
|
|
|
|
function getTrackingStatus($invoice)
|
|
{
|
|
$i = DB::table('tracking')->select('tracking.Id', 'tracking.InvoiceNumber', 'tracking_steps.StepLabel', 'production_user.Name', DB::raw('DATE_FORMAT(tracking.created_at, "%b %d, %Y") AS date'), DB::raw('DATE_FORMAT(tracking.created_at, "%H:%i") AS time'))
|
|
->leftjoin('tracking_steps', 'tracking_steps.Id', '=', 'tracking.StepId')
|
|
->leftjoin('production_user', 'production_user.Id', '=', 'tracking.ScannedBy')
|
|
->where('tracking.InvoiceNumber', '=', $invoice)
|
|
->orderBy('tracking.created_at', 'DESC')
|
|
->get();
|
|
return $i;
|
|
}
|
|
|
|
function selectPaymentDetails($invoice)
|
|
{
|
|
$i = DB::table('payment_details')
|
|
->where('InvoiceNumber', $invoice)
|
|
->get();
|
|
return $i;
|
|
}
|
|
|
|
function selectOrderList($cartKey)
|
|
{
|
|
$i = DB::table('orders')->select('ProductId', 'ProductName', 'CartKey')
|
|
->where('CartKey', $cartKey)
|
|
->groupBy('ProductId')
|
|
->get();
|
|
return $i;
|
|
}
|
|
|
|
function selectProductImages($productId)
|
|
{
|
|
$i = DB::table('teamstore_product_thumbnails')
|
|
->where('ProductId', $productId)
|
|
->get();
|
|
return $i;
|
|
}
|
|
|
|
function selectOrderListTableFields($cartKey, $productId)
|
|
{
|
|
$i = DB::table('orders')->select('Id', 'Name', 'Name2', 'Number', 'Size', 'JerseySize', 'ShortsSize', 'Quantity')
|
|
->where('CartKey', $cartKey)
|
|
->where('ProductId', $productId)
|
|
->get();
|
|
return $i;
|
|
}
|
|
|
|
function insertTracking($data)
|
|
{
|
|
$i = DB::table('tracking')->insert($data);
|
|
return $i;
|
|
}
|
|
|
|
// function selectNextStep($invoice)
|
|
// {
|
|
// $i = DB::table('tracking')->select('StepId')
|
|
// ->where('InvoiceNumber', $invoice)
|
|
// ->orderBy('StepId', 'DESC')->first();
|
|
// return $i;
|
|
// }
|
|
|
|
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();
|
|
return $i;
|
|
}
|
|
|
|
function getCurrentTrackingSteps($invoice){
|
|
$i = DB::table('tracking')->select('StepId')
|
|
->where('InvoiceNumber', $invoice)
|
|
->groupBy('StepId')
|
|
->orderBy('StepId', 'ASC')
|
|
->get();
|
|
return $i;
|
|
}
|
|
|
|
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();
|
|
return $i;
|
|
}
|
|
}
|