Fix associations to job order
This commit is contained in:
parent
75dc8cdcd1
commit
56a4fc7a9d
7 changed files with 140 additions and 1 deletions
|
|
@ -52,6 +52,12 @@ class Customer
|
|||
*/
|
||||
protected $vehicles;
|
||||
|
||||
// job orders made by customer
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="customer")
|
||||
*/
|
||||
protected $job_orders;
|
||||
|
||||
// if any of their mobile numbers have been confirmed
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
|
|
@ -63,6 +69,7 @@ class Customer
|
|||
$this->numbers = new ArrayCollection();
|
||||
$this->sessions = new ArrayCollection();
|
||||
$this->vehicles = new ArrayCollection();
|
||||
$this->job_orders = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getID()
|
||||
|
|
|
|||
|
|
@ -98,6 +98,12 @@ class CustomerVehicle
|
|||
*/
|
||||
protected $curr_battery;
|
||||
|
||||
// job orders that involve customer vehicle
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="cus_vehicle")
|
||||
*/
|
||||
protected $job_orders;
|
||||
|
||||
// vehicle using motolite battery?
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="job_order")
|
||||
|
|
@ -21,24 +23,89 @@ class JobOrder
|
|||
protected $id;
|
||||
|
||||
// date job order was created
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
protected $date_create;
|
||||
|
||||
// date and time of schedule
|
||||
// defaults to current date / time
|
||||
protected $schedule;
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
protected $date_schedule;
|
||||
|
||||
// date that the job order was fulfilled / delivered
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
protected $date_fulfill;
|
||||
|
||||
// coordinates of the customer vehicle that needs service
|
||||
/**
|
||||
* @ORM\Column(type="point")
|
||||
*/
|
||||
protected $coordinates;
|
||||
|
||||
// is it an advanced order (future date)
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $flag_advance;
|
||||
|
||||
// user that created the job order
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="job_orders")
|
||||
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $created_by;
|
||||
|
||||
// service type
|
||||
/**
|
||||
* @ORM\Column(type="string", length=12)
|
||||
*/
|
||||
protected $service_type;
|
||||
|
||||
// customer that requested job order
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="job_orders")
|
||||
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $customer;
|
||||
|
||||
// customer vehicle that needs servicing
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="CustomerVehicle", inversedBy="job_orders")
|
||||
* @ORM\JoinColumn(name="cvehicle_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $cus_vehicle;
|
||||
|
||||
// assigned outlet
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Outlet", inversedBy="job_orders")
|
||||
* @ORM\JoinColumn(name="outlet_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $outlet;
|
||||
|
||||
// assigned rider
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Rider", inversedBy="job_orders")
|
||||
* @ORM\JoinColumn(name="rider_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $rider;
|
||||
|
||||
// where requested job order came from (mobile or web)
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->date_create = new DateTime();
|
||||
$this->date_schedule = new DateTime();
|
||||
|
||||
$this->flag_advance = false;
|
||||
$this->source = 'mobile';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,13 @@ class Outlet
|
|||
*/
|
||||
protected $time_close;
|
||||
|
||||
// job orders assigned to outlet
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="outlet")
|
||||
*/
|
||||
protected $job_orders;
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ namespace App\Entity;
|
|||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="rider")
|
||||
|
|
@ -43,6 +45,16 @@ class Rider
|
|||
*/
|
||||
protected $hub;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="rider")
|
||||
*/
|
||||
protected $job_orders;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->job_orders = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return $this->id;
|
||||
|
|
|
|||
|
|
@ -67,9 +67,16 @@ class User implements AdvancedUserInterface, Serializable
|
|||
*/
|
||||
protected $email;
|
||||
|
||||
// job orders made by this user
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="created_by")
|
||||
*/
|
||||
protected $job_orders;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->roles = new ArrayCollection();
|
||||
$this->job_orders = new ArrayCollection();
|
||||
$this->enabled = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
33
src/Ramcar/ServiceType.php
Normal file
33
src/Ramcar/ServiceType.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class ServiceType
|
||||
{
|
||||
const BATTERY_REPLACEMENT = 'battery';
|
||||
const TIRE_REPAIR = 'tire';
|
||||
const OVERHEAT_ASSITANCE = 'overheat';
|
||||
const EMERGENCY_REFUEL = 'fuel';
|
||||
|
||||
const COLLECTION = [
|
||||
'battery' => 'Battery Replacement',
|
||||
'tire' => 'Tire Repair',
|
||||
'overheat' => 'Overheat Assistance',
|
||||
'fuel' => 'Emergency Refuel',
|
||||
];
|
||||
|
||||
|
||||
static public function getServiceTypes()
|
||||
{
|
||||
return self::COLLECTION;
|
||||
}
|
||||
|
||||
static public function validate($type_text)
|
||||
{
|
||||
if (isset(self::COLLECTION[$type_text]))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue