Add reference_jo_id field to hold the job order id for reference orders. Add a command to decouple reference job order from job order. #762
This commit is contained in:
parent
d78dc72c35
commit
96bd783ae9
2 changed files with 71 additions and 1 deletions
53
src/Command/SetJobOrderReferenceJOIdCommand.php
Normal file
53
src/Command/SetJobOrderReferenceJOIdCommand.php
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
class SetJobOrderReferenceJOIdCommand extends Command
|
||||||
|
{
|
||||||
|
protected $em;
|
||||||
|
|
||||||
|
public function __construct(EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
$this->em = $em;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this->setName('joborder:setreferencejoid')
|
||||||
|
->setDescription('Set job order reference jo id for existing job orders.')
|
||||||
|
->setHelp('Set job order reference jo id for existing job orders. Decoupling job order from reference job order.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
// get the job orders where ref_jo is not null
|
||||||
|
$query = $this->em->createQuery('SELECT jo FROM App\Entity\JobOrder jo WHERE jo.ref_jo IS NOT NULL');
|
||||||
|
|
||||||
|
$jos = $query->getResult();
|
||||||
|
|
||||||
|
foreach ($jos as $jo)
|
||||||
|
{
|
||||||
|
$ref_jo_id = $jo->getReferenceJO()->getID();
|
||||||
|
|
||||||
|
error_log('Setting reference jo id ' . $ref_jo_id . ' for job order ' . $jo->getID());
|
||||||
|
|
||||||
|
$jo->setReferenceJOId($ref_jo_id);
|
||||||
|
|
||||||
|
// set the ref_jo to null to decouple ref jo and jo
|
||||||
|
$jo->setReferenceJO(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->em->flush();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -435,6 +435,12 @@ class JobOrder
|
||||||
*/
|
*/
|
||||||
protected $inventory_count;
|
protected $inventory_count;
|
||||||
|
|
||||||
|
// reference JO id. We are now decoupling job order from itself
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="integer", nullable=true)
|
||||||
|
*/
|
||||||
|
protected $reference_jo_id;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->date_create = new DateTime();
|
$this->date_create = new DateTime();
|
||||||
|
|
@ -784,7 +790,7 @@ class JobOrder
|
||||||
return $this->tickets;
|
return $this->tickets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setReferenceJO(JobOrder $ref_jo)
|
public function setReferenceJO(JobOrder $ref_jo = null)
|
||||||
{
|
{
|
||||||
$this->ref_jo = $ref_jo;
|
$this->ref_jo = $ref_jo;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
@ -1237,4 +1243,15 @@ class JobOrder
|
||||||
return $this->inventory_count;
|
return $this->inventory_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setReferenceJOId($reference_jo_id)
|
||||||
|
{
|
||||||
|
$this->reference_jo_id = $reference_jo_id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReferenceJOId()
|
||||||
|
{
|
||||||
|
return $this->reference_jo_id;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue