Remove before pictures from job order. Also remove uploadArrive endpoint. #434
This commit is contained in:
parent
3de8b8762f
commit
9c2c1e5895
6 changed files with 3 additions and 328 deletions
|
|
@ -125,11 +125,6 @@ cmb_rapi_jo_odometer:
|
|||
controller: App\Controller\CMBRAPIController::setOdometer
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_jo_arrive_photos_upload:
|
||||
path: /cmbrapi/uploadarrivephotos
|
||||
controller: App\Controller\CMBRAPIController::uploadArrivePhotos
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_jo_finish_photos_upload:
|
||||
path: /cmbrapi/uploadfinishphotos
|
||||
controller: App\Controller\CMBRAPIController::uploadFinishPhotos
|
||||
|
|
|
|||
|
|
@ -239,15 +239,6 @@ class CMBRAPIController extends Controller
|
|||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function uploadArrivePhotos(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$data = $rapi_handler->uploadArrivePhotos($req);
|
||||
|
||||
$res = $this->generateResultFromHandler($data);
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function uploadFinishPhotos(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$data = $rapi_handler->uploadFinishPhotos($req);
|
||||
|
|
|
|||
|
|
@ -19,21 +19,6 @@ class JOExtra
|
|||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $before_speed_image_filename;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $before_plate_num_image_filename;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $before_batt_image_filename;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
|
|
@ -49,11 +34,6 @@ class JOExtra
|
|||
*/
|
||||
protected $after_batt_image_filename;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="array", nullable=true)
|
||||
*/
|
||||
protected $before_other_images;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="array", nullable=true)
|
||||
*/
|
||||
|
|
@ -67,7 +47,6 @@ class JOExtra
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
$this->before_other_images = new ArrayCollection();
|
||||
$this->after_other_images = new ArrayCollection();
|
||||
}
|
||||
|
||||
|
|
@ -76,38 +55,6 @@ class JOExtra
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
public function setBeforeSpeedImageFilename($image_filename)
|
||||
{
|
||||
$this->before_speed_image_filename = $image_filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBeforeSpeedImageFilename()
|
||||
{
|
||||
return $this->before_speed_image_filename;
|
||||
}
|
||||
|
||||
public function setBeforePlateNumImageFilename($image_filename)
|
||||
{
|
||||
$this->before_plate_num_image_filename = $image_filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBeforePlateNumImageFilename()
|
||||
{
|
||||
return $this->before_plate_num_image_filename;
|
||||
}
|
||||
|
||||
public function setBeforeBattImageFilename($image_filename)
|
||||
{
|
||||
$this->before_batt_image_filename = $image_filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBeforeBattImageFilename()
|
||||
{
|
||||
return $this->before_batt_image_filename;
|
||||
}
|
||||
public function setAfterSpeedImageFilename($image_filename)
|
||||
{
|
||||
$this->after_speed_image_filename = $image_filename;
|
||||
|
|
@ -141,29 +88,6 @@ class JOExtra
|
|||
return $this->after_batt_image_filename;
|
||||
}
|
||||
|
||||
public function getBeforeOtherImages()
|
||||
{
|
||||
return $this->before_other_images;
|
||||
}
|
||||
|
||||
public function setBeforeOtherImages(array $images)
|
||||
{
|
||||
$this->before_other_images = new ArrayCollection();
|
||||
|
||||
foreach ($images as $image_filename)
|
||||
{
|
||||
$this->before_other_images->add($image_filename);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function clearBeforeOtherImages()
|
||||
{
|
||||
$this->before_other_images = new ArrayCollection();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAfterOtherImages()
|
||||
{
|
||||
return $this->after_other_images;
|
||||
|
|
|
|||
|
|
@ -1478,6 +1478,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
$params['cvid'] = $obj->getCustomerVehicle()->getID();
|
||||
$params['vid'] = $obj->getCustomerVehicle()->getVehicle()->getID();
|
||||
$params['discounts'] = $this->generateDiscountOptions();
|
||||
$params['current_date'] = new DateTime();
|
||||
|
||||
// get service charges
|
||||
$sc_array = [];
|
||||
|
|
@ -1511,35 +1512,21 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
$params['signature'] = null;
|
||||
if ($jo_extra != null)
|
||||
{
|
||||
$b_speed_img = $jo_extra->getBeforeSpeedImageFilename();
|
||||
$a_speed_img = $jo_extra->getAfterSpeedImageFilename();
|
||||
$b_plate_img = $jo_extra->getBeforePlateNumImageFilename();
|
||||
$a_plate_img = $jo_extra->getAfterPlateNumImageFilename();
|
||||
$b_batt_img = $jo_extra->getBeforeBattImageFilename();
|
||||
$a_batt_img = $jo_extra->getAfterBattImageFilename();
|
||||
|
||||
$b_other_images = $jo_extra->getBeforeOtherImages();
|
||||
$a_other_images = $jo_extra->getAfterOtherImages();
|
||||
|
||||
$cust_signature = $jo_extra->getCustomerSignature();
|
||||
|
||||
if ($b_speed_img != null)
|
||||
$pic_array['before_speed_img'] = $b_speed_img;
|
||||
if ($a_speed_img != null)
|
||||
$pic_array['after_speed_img'] = $a_speed_img;
|
||||
if ($b_plate_img != null)
|
||||
$pic_array['before_plate_img'] = $b_plate_img;
|
||||
if ($a_plate_img != null)
|
||||
$pic_array['after_plate_img'] = $a_plate_img;
|
||||
if ($b_batt_img != null)
|
||||
$pic_array['before_batt_img'] = $b_batt_img;
|
||||
if ($a_batt_img != null)
|
||||
$pic_array['after_batt_img'] = $a_batt_img;
|
||||
|
||||
foreach($b_other_images as $b_img)
|
||||
{
|
||||
$pic_array['b_other_images'][] = $b_img;
|
||||
}
|
||||
foreach ($a_other_images as $a_img)
|
||||
{
|
||||
$pic_array['a_other_images'][] = $a_img;
|
||||
|
|
@ -2812,6 +2799,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
$params['cvid'] = $obj->getCustomerVehicle()->getID();
|
||||
$params['vid'] = $obj->getCustomerVehicle()->getVehicle()->getID();
|
||||
$params['discounts'] = $this->generateDiscountOptions();
|
||||
$params['current_date'] = new DateTime();
|
||||
|
||||
$this->fillDropdownParameters($params);
|
||||
$this->fillFormTags($params);
|
||||
|
|
|
|||
|
|
@ -666,13 +666,6 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
if ($odo <= 0)
|
||||
$odo = 0;
|
||||
|
||||
// get before images
|
||||
$before_images = [
|
||||
'speedometer' => null,
|
||||
'plate_number' => null,
|
||||
'battery' => null,
|
||||
'others' => [],
|
||||
];
|
||||
$after_images = [
|
||||
'speedometer' => null,
|
||||
'plate_number' => null,
|
||||
|
|
@ -682,19 +675,6 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
$jo_extra = $jo->getJOExtra();
|
||||
if ($jo_extra != null)
|
||||
{
|
||||
// before images
|
||||
$before_images['speedometer'] = $this->getURLExtraImage($req, $jo_extra->getBeforeSpeedImageFilename());
|
||||
$before_images['plate_number'] = $this->getURLExtraImage($req, $jo_extra->getBeforePlateNumImageFilename());
|
||||
$before_images['battery'] = $this->getURLExtraImage($req, $jo_extra->getBeforeBattImageFilename());
|
||||
|
||||
// other images
|
||||
$other_images = [];
|
||||
foreach ($jo_extra->getBeforeOtherImages() as $others)
|
||||
{
|
||||
$other_images[] = $this->getURLExtraImage($req, $others);
|
||||
}
|
||||
$before_images['others'] = $other_images;
|
||||
|
||||
// after images
|
||||
$after_images['speedometer'] = $this->getURLExtraImage($req, $jo_extra->getAfterSpeedImageFilename());
|
||||
$after_images['plate_number'] = $this->getURLExtraImage($req, $jo_extra->getAfterPlateNumImageFilename());
|
||||
|
|
@ -764,7 +744,6 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
'odometer' => $odo,
|
||||
|
||||
// images
|
||||
'arrive_photos' => $before_images,
|
||||
'finish_photos' => $after_images,
|
||||
|
||||
// customer email
|
||||
|
|
@ -1576,169 +1555,6 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
return $new_filename;
|
||||
}
|
||||
|
||||
public function uploadArrivePhotos(Request $req)
|
||||
{
|
||||
$required_params = [
|
||||
'jo_id',
|
||||
];
|
||||
$data = $this->checkActiveJO($req, $required_params, $jo);
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$data['title'] = 'Failed Upload Arrive Photos';
|
||||
return $data;
|
||||
}
|
||||
|
||||
$dest = $this->upload_dir;
|
||||
|
||||
$speed_img_file = $req->files->get('speedometer_img');
|
||||
$batt_img_file = $req->files->get('battery_img');
|
||||
$plate_num_img_file = $req->files->get('plate_number_img');
|
||||
$other_img_files[]= $req->files->get('other_images');
|
||||
|
||||
if ((empty($speed_img_file)) &&
|
||||
(empty($batt_img_file)) &&
|
||||
(empty($plate_num_img_file)))
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Failed Upload Arrive Photos',
|
||||
'error' => 'No image files received.'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_speed_filename = '';
|
||||
$new_batt_filename = '';
|
||||
$new_plate_num_filename = '';
|
||||
$other_filenames = [];
|
||||
|
||||
if (!empty($speed_img_file))
|
||||
{
|
||||
// save speedometer file
|
||||
$orig_speed_filename = pathinfo($speed_img_file->getClientOriginalName(), PATHINFO_FILENAME);
|
||||
$new_speed_filename = uniqid() . '-'. $orig_speed_filename . '.' . $speed_img_file->guessClientExtension();
|
||||
|
||||
try
|
||||
{
|
||||
$speed_img_file->move($dest, $new_speed_filename);
|
||||
}
|
||||
catch (FileException $e)
|
||||
{
|
||||
$data = [
|
||||
'error' => 'Error saving image files.'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
if (!empty($batt_img_file))
|
||||
{
|
||||
// save battery file
|
||||
$orig_batt_filename = pathinfo($batt_img_file->getClientOriginalName(), PATHINFO_FILENAME);
|
||||
$new_batt_filename = uniqid() . '-' . $orig_batt_filename . '.' . $batt_img_file->guessClientExtension();
|
||||
|
||||
try
|
||||
{
|
||||
$batt_img_file->move($dest, $new_batt_filename);
|
||||
}
|
||||
catch (FileException $e)
|
||||
{
|
||||
$data = [
|
||||
'error' => 'Error saving image files.'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
if (!empty($plate_num_img_file))
|
||||
{
|
||||
// save plate number file
|
||||
$orig_plate_num_filename = pathinfo($plate_num_img_file->getClientOriginalName(), PATHINFO_FILENAME);
|
||||
$new_plate_num_filename = uniqid() . '-' . $orig_plate_num_filename . '.' . $plate_num_img_file->guessClientExtension();
|
||||
|
||||
try
|
||||
{
|
||||
$plate_num_img_file->move($dest, $new_plate_num_filename);
|
||||
}
|
||||
catch (FileException $e)
|
||||
{
|
||||
$data = [
|
||||
'error' => 'Error saving image files.'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($other_img_files as $other_img_file)
|
||||
{
|
||||
if (!(empty($other_img_file)))
|
||||
{
|
||||
foreach($other_img_file as $other_img)
|
||||
{
|
||||
$orig_other_filename = pathinfo($other_img->getClientOriginalName(), PATHINFO_FILENAME);
|
||||
$new_other_filename = uniqid() . '-'. $orig_other_filename . '.' . $other_img->guessClientExtension();
|
||||
|
||||
$other_filenames[] = $new_other_filename;
|
||||
|
||||
try
|
||||
{
|
||||
$other_img->move($dest, $new_other_filename);
|
||||
}
|
||||
catch (FileException $e)
|
||||
{
|
||||
$data = [
|
||||
'error' => 'Error saving image files.'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$jo_extra = $jo->getJOExtra();
|
||||
if ($jo_extra == null)
|
||||
{
|
||||
// create JOExtra entity
|
||||
$jo_extra = new JOExtra();
|
||||
|
||||
$jo_extra->setBeforeSpeedImageFilename($new_speed_filename);
|
||||
$jo_extra->setBeforeBattImageFilename($new_batt_filename);
|
||||
$jo_extra->setBeforePlateNumImageFilename($new_plate_num_filename);
|
||||
|
||||
if (empty($other_filenames))
|
||||
{
|
||||
$jo_extra->clearBeforeOtherImages();
|
||||
}
|
||||
else
|
||||
{
|
||||
$jo_extra->setBeforeOtherImages($other_filenames);
|
||||
}
|
||||
|
||||
$jo->setJOExtra($jo_extra);
|
||||
|
||||
$this->em->persist($jo_extra);
|
||||
}
|
||||
else
|
||||
{
|
||||
$jo_extra->setBeforeSpeedImageFilename($new_speed_filename);
|
||||
$jo_extra->setBeforeBattImageFilename($new_batt_filename);
|
||||
$jo_extra->setBeforePlateNumImageFilename($new_plate_num_filename);
|
||||
|
||||
if (empty($other_filenames))
|
||||
{
|
||||
$jo_extra->clearBeforeOtherImages();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$jo_extra->setBeforeOtherImages($other_filenames);
|
||||
}
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function uploadFinishPhotos(Request $req)
|
||||
{
|
||||
$required_params = [
|
||||
|
|
|
|||
|
|
@ -511,48 +511,9 @@
|
|||
</div>
|
||||
<div class="col-lg-3">
|
||||
<label> Customer Signature </label>
|
||||
<div class="portrait-box" style="background-image: url('{{ '/uploads/jo_extra/' ~ signature }}');" ></div>
|
||||
<div class="portrait-box" style="background-image: url('{{ signature ? '/uploads/jo_extra/' ~ signature : '/assets/images/user.gif' }}');" ></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<label> Pictures Before Service</label>
|
||||
</div>
|
||||
{% for key, picture in jo_pictures %}
|
||||
{% if key == 'before_speed_img' %}
|
||||
<div class="col-lg-2">
|
||||
<label> Speedometer before Service </label>
|
||||
<div class="portrait-box" style="background-image: url('{{ '/uploads/jo_extra/' ~ picture }}');" ></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if key == 'before_plate_img' %}
|
||||
<div class="col-lg-2">
|
||||
<label> Plate Number before Service </label>
|
||||
<div class="portrait-box" style="background-image: url('{{ '/uploads/jo_extra/' ~ picture }}');" ></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if key == 'before_batt_img' %}
|
||||
<div class="col-lg-2">
|
||||
<label> Battery before Service </label>
|
||||
<div class="portrait-box" style="background-image: url('{{ '/uploads/jo_extra/' ~ picture }}');" ></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<label> Other Images before Service</label>
|
||||
</div>
|
||||
{% for key, picture in jo_pictures %}
|
||||
{% if key == 'b_other_images' %}
|
||||
{% for pic in jo_pictures['b_other_images'] %}
|
||||
<div class="col-lg-2">
|
||||
<div class="portrait-box" style="background-image: url('{{ '/uploads/jo_extra/' ~ pic }}');" ></div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<label> Pictures After Service</label>
|
||||
|
|
|
|||
Loading…
Reference in a new issue