diff --git a/src/Entity/JOExtra.php b/src/Entity/JOExtra.php index 12974b33..7770c150 100644 --- a/src/Entity/JOExtra.php +++ b/src/Entity/JOExtra.php @@ -22,22 +22,27 @@ class JOExtra /** * @ORM\Column(type="string", nullable=true) */ - protected $after_speed_image_filename; + protected $image_1_filename; /** * @ORM\Column(type="string", nullable=true) */ - protected $after_plate_num_image_filename; + protected $image_2_filename; /** * @ORM\Column(type="string", nullable=true) */ - protected $after_batt_image_filename; + protected $image_3_filename; + + /** + * @ORM\Column(type="string", nullable=true) + */ + protected $image_4_filename; /** * @ORM\Column(type="array", nullable=true) */ - protected $after_other_images; + protected $other_images; /** * @ORM\Column(type="string", nullable=true) @@ -47,7 +52,7 @@ class JOExtra public function __construct() { - $this->after_other_images = new ArrayCollection(); + $this->other_images = new ArrayCollection(); } public function getID() @@ -55,59 +60,70 @@ class JOExtra return $this->id; } - public function setAfterSpeedImageFilename($image_filename) + public function setImage1Filename($image_filename) { - $this->after_speed_image_filename = $image_filename; + $this->image_1_filename = $image_filename; return $this; } - public function getAfterSpeedImageFilename() + public function getImage1Filename() { - return $this->after_speed_image_filename; + return $this->image_1_filename; } - public function setAfterPlateNumImageFilename($image_filename) + public function setImage2Filename($image_filename) { - $this->after_plate_num_image_filename = $image_filename; + $this->image_2_filename = $image_filename; return $this; } - public function getAfterPlateNumImageFilename() + public function getImage2Filename() { - return $this->after_plate_num_image_filename; + return $this->image_2_filename; } - public function setAfterBattImageFilename($image_filename) + public function setImage3Filename($image_filename) { - $this->after_batt_image_filename = $image_filename; + $this->image_3_filename = $image_filename; return $this; } - public function getAfterBattImageFilename() + public function getImage3Filename() { - return $this->after_batt_image_filename; + return $this->image_3_filename; } - public function getAfterOtherImages() + public function setImage4Filename($image_filename) { - return $this->after_other_images; + $this->image_4_filename = $image_filename; + return $this; } - public function setAfterOtherImages(array $images) + public function getImage4Filename() { - $this->after_other_images = new ArrayCollection(); + return $this->image_4_filename; + } + + public function getOtherImages() + { + return $this->other_images; + } + + public function setOtherImages(array $images) + { + $this->other_images = new ArrayCollection(); foreach ($images as $image_filename) { - $this->after_other_images->add($image_filename); + $this->other_images->add($image_filename); } return $this; } - public function clearAfterOtherImages() + public function clearOtherImages() { - $this->after_other_images = new ArrayCollection(); + $this->other_images = new ArrayCollection(); return $this; } diff --git a/src/Service/JobOrderHandler/CMBJobOrderHandler.php b/src/Service/JobOrderHandler/CMBJobOrderHandler.php index d19587a0..42f1b49b 100644 --- a/src/Service/JobOrderHandler/CMBJobOrderHandler.php +++ b/src/Service/JobOrderHandler/CMBJobOrderHandler.php @@ -1513,24 +1513,27 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $params['signature'] = null; if ($jo_extra != null) { - $a_speed_img = $jo_extra->getAfterSpeedImageFilename(); - $a_plate_img = $jo_extra->getAfterPlateNumImageFilename(); - $a_batt_img = $jo_extra->getAfterBattImageFilename(); + $img_1 = $jo_extra->getImage1Filename(); + $img_2 = $jo_extra->getImage2Filename(); + $img_3 = $jo_extra->getImage3Filename(); + $img_4 = $jo_extra->getImage4Filename(); - $a_other_images = $jo_extra->getAfterOtherImages(); + $other_images = $jo_extra->getOtherImages(); $cust_signature = $jo_extra->getCustomerSignature(); - if ($a_speed_img != null) - $pic_array['after_speed_img'] = $a_speed_img; - if ($a_plate_img != null) - $pic_array['after_plate_img'] = $a_plate_img; - if ($a_batt_img != null) - $pic_array['after_batt_img'] = $a_batt_img; + if ($img_1 != null) + $pic_array['image_1'] = $img_1; + if ($img_2 != null) + $pic_array['image_2'] = $img_2; + if ($img_3 != null) + $pic_array['image_3'] = $img_3; + if ($img_4 != null) + $pic_array['image_4'] = $img_4; - foreach ($a_other_images as $a_img) + foreach ($other_images as $img) { - $pic_array['a_other_images'][] = $a_img; + $pic_array['other_images'][] = $img; } $params['signature'] = $cust_signature; diff --git a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php index f414ead4..d435e0ca 100644 --- a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php @@ -755,27 +755,28 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface if ($odo <= 0) $odo = 0; - $after_images = [ - 'speedometer' => null, - 'plate_number' => null, - 'battery' => null, + $images = [ + 'image_1' => null, + 'image_2' => null, + 'image_3' => null, + 'image_4' => null, 'others' => [], ]; $jo_extra = $jo->getJOExtra(); if ($jo_extra != null) { - // after images - $after_images['speedometer'] = $this->getURLExtraImage($req, $jo_extra->getAfterSpeedImageFilename()); - $after_images['plate_number'] = $this->getURLExtraImage($req, $jo_extra->getAfterPlateNumImageFilename()); - $after_images['battery'] = $this->getURLExtraImage($req, $jo_extra->getAfterBattImageFilename()); + $images['image_1'] = $this->getURLExtraImage($req, $jo_extra->getImage1Filename()); + $images['image_2'] = $this->getURLExtraImage($req, $jo_extra->getImage2Filename()); + $images['image_3'] = $this->getURLExtraImage($req, $jo_extra->getImage3Filename()); + $images['image_4'] = $this->getURLExtraImage($req, $jo_extra->getImage4Filename()); // other images $other_images = []; - foreach ($jo_extra->getAfterOtherImages() as $others) + foreach ($jo_extra->getOtherImages() as $others) { $other_images[] = $this->getURLExtraImage($req, $others); } - $after_images['others'] = $other_images; + $images['others'] = $other_images; } // customer email @@ -856,7 +857,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface 'odometer' => $odo, // images - 'finish_photos' => $after_images, + 'finish_photos' => $images, // customer email 'customer_email' => $cust_email, @@ -1700,14 +1701,16 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface $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'); + $img_1_file = $req->files->get('img_1'); + $img_2_file = $req->files->get('img_2'); + $img_3_file = $req->files->get('img_3'); + $img_4_file = $req->files->get('img_4'); $other_img_files[]= $req->files->get('other_images'); - if ((empty($speed_img_file)) && - (empty($batt_img_file)) && - (empty($plate_num_img_file))) + if ((empty($img_1_file)) && + (empty($img_2_file)) && + (empty($img_3_file)) && + (empty($img_4_file))) { $data = [ 'title' => 'Failed Upload Arrive Photos', @@ -1717,20 +1720,20 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface } else { - $new_speed_filename = ''; - $new_batt_filename = ''; - $new_plate_num_filename = ''; + $new_img1_filename = ''; + $new_img2_filename = ''; + $new_img3_filename = ''; + $new_img4_filename = ''; $other_filenames = []; - if (!empty($speed_img_file)) + if (!empty($img_1_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(); + $orig_img1_filename = pathinfo($img_1_file->getClientOriginalName(), PATHINFO_FILENAME); + $new_img1_filename = uniqid() . '-'. $orig_img1_filename . '.' . $img_1_file->guessClientExtension(); try { - $speed_img_file->move($dest, $new_speed_filename); + $img_1_file->move($dest, $new_img1_filename); } catch (FileException $e) { @@ -1740,15 +1743,14 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface return $data; } } - if (!empty($batt_img_file)) + if (!empty($img_2_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(); + $orig_img2_filename = pathinfo($img_2_file->getClientOriginalName(), PATHINFO_FILENAME); + $new_img2_filename = uniqid() . '-' . $orig_img2_filename . '.' . $img_2_file->guessClientExtension(); try { - $batt_img_file->move($dest, $new_batt_filename); + $img_2_file->move($dest, $new_img2_filename); } catch (FileException $e) { @@ -1758,15 +1760,32 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface return $data; } } - if (!empty($plate_num_img_file)) + if (!empty($img_3_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(); + $orig_img3_filename = pathinfo($img_3_file->getClientOriginalName(), PATHINFO_FILENAME); + $new_img3_filename = uniqid() . '-' . $orig_img3_filename . '.' . $img_3_file->guessClientExtension(); try { - $plate_num_img_file->move($dest, $new_plate_num_filename); + $img_3_file->move($dest, $new_img3_filename); + } + catch (FileException $e) + { + $data = [ + 'error' => 'Error saving image files.' + ]; + return $data; + } + } + + if (!empty($img_4_file)) + { + $orig_img4_filename = pathinfo($img_4_file->getClientOriginalName(), PATHINFO_FILENAME); + $new_img4_filename = uniqid() . '-' . $orig_img4_filename . '.' . $img_4_file->guessClientExtension(); + + try + { + $img_4_file->move($dest, $new_img4_filename); } catch (FileException $e) { @@ -1809,17 +1828,18 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface // create JOExtra entity $jo_extra = new JOExtra(); - $jo_extra->setAfterSpeedImageFilename($new_speed_filename); - $jo_extra->setAfterBattImageFilename($new_batt_filename); - $jo_extra->setAfterPlateNumImageFilename($new_plate_num_filename); + $jo_extra->setImage1Filename($new_img1_filename); + $jo_extra->setImage2Filename($new_img2_filename); + $jo_extra->setImage3Filename($new_img3_filename); + $jo_extra->setImage4Filename($new_img4_filename); if (empty($other_filenames)) { - $jo_extra->clearAfterOtherImages(); + $jo_extra->clearOtherImages(); } else { - $jo_extra->setAfterOtherImages($other_filenames); + $jo_extra->setOtherImages($other_filenames); } $jo->setJOExtra($jo_extra); @@ -1828,17 +1848,18 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface } else { - $jo_extra->setAfterSpeedImageFilename($new_speed_filename); - $jo_extra->setAfterBattImageFilename($new_batt_filename); - $jo_extra->setAfterPlateNumImageFilename($new_plate_num_filename); + $jo_extra->setImage1Filename($new_img1_filename); + $jo_extra->setImage2Filename($new_img2_filename); + $jo_extra->setImage3Filename($new_img3_filename); + $jo_extra->setImage4Filename($new_img4_filename); if (empty($other_filenames)) { - $jo_extra->clearAfterOtherImages(); + $jo_extra->clearOtherImages(); } else { - $jo_extra->setAfterOtherImages($other_filenames); + $jo_extra->setOtherImages($other_filenames); } } diff --git a/templates/job-order/cmb.form.onestep.html.twig b/templates/job-order/cmb.form.onestep.html.twig index 6e53cf9e..94c45369 100644 --- a/templates/job-order/cmb.form.onestep.html.twig +++ b/templates/job-order/cmb.form.onestep.html.twig @@ -525,36 +525,39 @@
- +
{% for key, picture in jo_pictures %} - {% if key == 'after_speed_img' %} + {% if key == 'image_1' %}
-
{% endif %} - {% if key == 'after_plate_img' %} + {% if key == 'image_2' %}
-
{% endif %} - {% if key == 'after_batt_img' %} + {% if key == 'image_3' %}
-
{% endif %} + {% if key == 'image_4' %} +
+
+
+ {% endif %} + {% endfor %}
- +
{% for key, picture in jo_pictures %} - {% if key == 'a_other_images' %} - {% for pic in jo_pictures['a_other_images'] %} + {% if key == 'other_images' %} + {% for pic in jo_pictures['other_images'] %}