112 lines
2.7 KiB
PHP
112 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Component\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ShiftOnlineActions extends Model {
|
|
protected $table = 'shift_online_actions';
|
|
|
|
/**
|
|
* Get preCheck count
|
|
*/
|
|
public static function getPreCheckCount($order_id)
|
|
{
|
|
$count = self::where('order_code', intval($order_id))
|
|
->where('type_action', 21)
|
|
->count();
|
|
return $count;
|
|
}
|
|
|
|
/**
|
|
* Get preCheck count before edit
|
|
*/
|
|
public static function isPrintedBeforeEdit($order_id)
|
|
{
|
|
$actions = self::where('order_code', intval($order_id))
|
|
->orderBy('time', 'ASC')
|
|
->get();
|
|
$infos = [];
|
|
$delete_trigger = false;
|
|
foreach ($actions as $action) {
|
|
if ($action['type_action'] == 21 || $action['type_action'] == 5) {
|
|
$infos[] = array(
|
|
'action' => $action['type_action'],
|
|
'time' => $action['time']
|
|
);
|
|
}
|
|
}
|
|
foreach ($infos as $key => $info) {
|
|
if (isset($infos[$key+1])) {
|
|
if ($info['action'] == 21 && $infos[$key+1]['action'] == 5) {
|
|
$delete_trigger = true;
|
|
}
|
|
}
|
|
}
|
|
return $delete_trigger;
|
|
}
|
|
|
|
/**
|
|
* Check merge
|
|
*/
|
|
public static function hasMerge($order_id)
|
|
{
|
|
$count = self::where('order_code', intval($order_id))
|
|
->where('type_action', 31)
|
|
->count();
|
|
if ($count > 0) {
|
|
$result = true;
|
|
} else {
|
|
$result = false;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Check slice
|
|
*/
|
|
public static function hasSlice($order_id)
|
|
{
|
|
$count = self::where('order_code', intval($order_id))
|
|
->where('type_action', 35)
|
|
->count();
|
|
if ($count > 0) {
|
|
$result = true;
|
|
} else {
|
|
$result = false;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Check move
|
|
*/
|
|
public static function hasMove($order_id)
|
|
{
|
|
$count = self::where('order_code', intval($order_id))
|
|
->where('type_action', 39)
|
|
->count();
|
|
if ($count > 0) {
|
|
$result = true;
|
|
} else {
|
|
$result = false;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Check delete
|
|
*/
|
|
public static function hasDelete($order_id)
|
|
{
|
|
$count = self::where('order_code', intval($order_id))
|
|
->where('type_action', 5)
|
|
->count();
|
|
if ($count > 0) {
|
|
$result = true;
|
|
} else {
|
|
$result = false;
|
|
}
|
|
return $result;
|
|
}
|
|
} |