Merge branch '186-separate-long-lat-from-point-for-reports-generation' into 'master'
Resolve "Separate long lat from point for reports generation" Closes #186 See merge request jankstudio/resq!219
This commit is contained in:
commit
d5a012cbef
2 changed files with 65 additions and 0 deletions
50
src/Command/AdjustLongLatCommand.php
Normal file
50
src/Command/AdjustLongLatCommand.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?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\Common\Persistence\ObjectManager;
|
||||
|
||||
use App\Entity\JobOrder;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class AdjustLongLatCommand extends Command
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(ObjectManager $om)
|
||||
{
|
||||
$this->em = $om;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('joborder:adjust_longlat')
|
||||
->setDescription('Separate longitude and latitude from coordinate point.')
|
||||
->setHelp('Get longitude and latitude from existing point type coordinate. Separate into individual fields for reports purposes.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
// get entity manager
|
||||
$em = $this->em;
|
||||
|
||||
$job_orders = $em->getRepository(JobOrder::class)->findAll();
|
||||
|
||||
// fulfill each
|
||||
foreach ($job_orders as $jo)
|
||||
{
|
||||
$point = $jo->getCoordinates();
|
||||
$jo->setCoordinates($point);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
}
|
||||
}
|
||||
|
|
@ -64,6 +64,18 @@ class JobOrder
|
|||
*/
|
||||
protected $coordinates;
|
||||
|
||||
// we split up coordinates into long / lat for reports purposes
|
||||
/**
|
||||
* @ORM\Column(type="decimal", precision=11, scale=8)
|
||||
*/
|
||||
protected $coord_long;
|
||||
|
||||
// we split up coordinates into long / lat for reports purposes
|
||||
/**
|
||||
* @ORM\Column(type="decimal", precision=11, scale=8)
|
||||
*/
|
||||
protected $coord_lat;
|
||||
|
||||
// is it an advanced order (future date)
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
|
|
@ -350,6 +362,9 @@ class JobOrder
|
|||
public function setCoordinates(Point $point)
|
||||
{
|
||||
$this->coordinates = $point;
|
||||
|
||||
$this->coord_lat = $point->getLatitude();
|
||||
$this->coord_long = $point->getLongitude();
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue