resq/src/Ramcar/HubCriteria.php
2021-06-23 10:39:49 +00:00

149 lines
3.4 KiB
PHP

<?php
namespace App\Ramcar;
use CrEOF\Spatial\PHP\Types\Geometry\Point;
use DateTime;
class HubCriteria
{
protected $point; // coordinates of source
protected $limit_results; // number of results to return
protected $limit_distance; // distance limit for search in km
protected $flag_inventory_check; // flag if we need to check for inventory
protected $jo_type; // jo service needed
protected $date_time; // date and time to check if hub is open or not
protected $items; // array of items: items[sku] = quantity to check for
protected $payment_method; // payment method of JO
protected $flag_emergency; // flag if emergency or not
protected $flag_round_robin; // flag if we use round robin or not
public function __construct()
{
// TODO: default values might still change
$this->limit_results = 10;
$this->limit_distance = 500;
$this->jo_type = '';
$this->date_time = null;
$this->flag_inventory_check = false;
$this->items = [];
$this->payment_method = '';
$flag_emergency = false;
$flag_round_robin = false;
}
public function setPoint(Point $point)
{
$this->point = $point;
return $this;
}
public function getPoint()
{
return $this->point;
}
public function setLimitResults($limit_results)
{
$this->limit_results = $limit_results;
return $this;
}
public function getLimitResults()
{
return $this->limit_results;
}
public function setLimitDistance($limit_distance)
{
$this->limit_distance = $limit_distance;
return $this;
}
public function getLimitDistance()
{
return $this->limit_distance;
}
public function setInventoryCheck($flag_inventory_check = true)
{
$this->flag_inventory_check = $flag_inventory_check;
return $this;
}
public function hasInventoryCheck()
{
return $this->flag_inventory_check;
}
public function setJoType($jo_type)
{
// TODO: validate the jo type
$this->jo_type = $jo_type;
return $this;
}
public function getJoType()
{
return $this->jo_type;
}
public function setDateTime(DateTime $date_time)
{
$this->date_time = $date_time;
return $this;
}
public function getDateTime()
{
return $this->date_time;
}
public function addItem($sku, $quantity)
{
// at this point, sku is assumed to be a valid item
$this->items[$sku] = $quantity;
return $this;
}
public function getItems()
{
return $this->items;
}
public function setPaymentMethod($payment_method)
{
$this->payment_method = $payment_method;
return $this;
}
public function getPaymentMethod()
{
return $this->payment_method;
}
public function setEmergency($flag_emergency = true)
{
$this->flag_emergency = $flag_emergency;
return $this;
}
public function isEmergency()
{
return $this->flag_emergency;
}
public function setRoundRobin($flag_round_robin = true)
{
$this->flag_round_robin = $flag_round_robin;
return $this;
}
public function isRoundRobin()
{
return $this->flag_round_robin;
}
}