|
|
@@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Mail;
|
|
|
use Illuminate\Contracts\Validation\Validator;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use App\Http\Middleware\TenantMiddleware;
|
|
|
+use Illuminate\Support\Carbon;
|
|
|
|
|
|
class RecordIN extends Component
|
|
|
{
|
|
|
@@ -405,20 +406,62 @@ class RecordIN extends Component
|
|
|
$this->months = $months;
|
|
|
//$this->rows[0]["amount"] = formatPrice($price * sizeof($months));
|
|
|
$this->rows[0]["amount"] = formatPrice($price);
|
|
|
- foreach ($months as $idx => $m) {
|
|
|
- $this->rows[0]["when"][$idx]["month"] = $m;
|
|
|
- if ($m >= date("m"))
|
|
|
- $this->rows[0]["when"][$idx]["year"] = date("Y");
|
|
|
- else
|
|
|
- $this->rows[0]["when"][$idx]["year"] = date("Y") + 1;
|
|
|
|
|
|
- if ($idx > 0) {
|
|
|
- if ($this->rows[0]["when"][$idx - 1]["year"] != $this->rows[0]["when"][$idx]["year"])
|
|
|
- $desc .= " " . $this->rows[0]["when"][$idx - 1]["year"] . " ";
|
|
|
+ $rates = [];
|
|
|
+ if (isset($_GET["rateId"])) {
|
|
|
+ try {
|
|
|
+ $rateIds = explode(",", $_GET["rateId"]);
|
|
|
+ $rates = \App\Models\Rate::whereIn('id', $rateIds)->orderBy('date', 'asc')->get();
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ }
|
|
|
+
|
|
|
+ $order = [9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
|
+ $index = 0;
|
|
|
+ foreach ($rates as $rate) {
|
|
|
+ $rate_date = Carbon::createFromFormat("Y-m-d H:i:s", $rate->date);
|
|
|
+
|
|
|
+ $rate_months = json_decode($rate->months, true);
|
|
|
+ usort($rate_months, function ($a, $b) use ($order) {
|
|
|
+ $posA = array_search($a, $order);
|
|
|
+ $posB = array_search($b, $order);
|
|
|
+ return $posA <=> $posB;
|
|
|
+ });
|
|
|
+
|
|
|
+ foreach ($rate_months as $month) {
|
|
|
+ $rate_year = $rate_date->year;
|
|
|
+ $rate_month = $rate_date->month;
|
|
|
+ if ($rate_month < 9 && $rate_month >= 1) {
|
|
|
+ $rate_year -= 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($month >= 9 && $month <= 12) {
|
|
|
+ } elseif ($month < 9 && $month >= 1) {
|
|
|
+ $rate_year += 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->rows[0]["when"][$index]["month"] = $month;
|
|
|
+ $this->rows[0]["when"][$index]["year"] = $rate_year;
|
|
|
+ $index++;
|
|
|
+
|
|
|
+ $desc .= " " . $this->getMonth($month) . " " . $rate_year;
|
|
|
+ }
|
|
|
}
|
|
|
- $desc .= " " . $this->getMonth($m); // . " " . $this->rows[0]["when"][$idx]["year"];
|
|
|
}
|
|
|
- $desc .= " " . $this->rows[0]["when"][$idx]["year"];
|
|
|
+
|
|
|
+ // foreach ($months as $idx => $m) {
|
|
|
+ // $this->rows[0]["when"][$idx]["month"] = $m;
|
|
|
+ // if ($m >= date("m"))
|
|
|
+ // $this->rows[0]["when"][$idx]["year"] = date("Y");
|
|
|
+ // else
|
|
|
+ // $this->rows[0]["when"][$idx]["year"] = date("Y") + 1;
|
|
|
+
|
|
|
+ // if ($idx > 0) {
|
|
|
+ // if ($this->rows[0]["when"][$idx - 1]["year"] != $this->rows[0]["when"][$idx]["year"])
|
|
|
+ // $desc .= " " . $this->rows[0]["when"][$idx - 1]["year"] . " ";
|
|
|
+ // }
|
|
|
+ // $desc .= " " . $this->getMonth($m); // . " " . $this->rows[0]["when"][$idx]["year"];
|
|
|
+ // }
|
|
|
+ // $desc .= " " . $this->rows[0]["when"][$idx]["year"];
|
|
|
$this->rows[0]["note"] = $desc;
|
|
|
$count += 1;
|
|
|
}
|
|
|
@@ -464,7 +507,6 @@ class RecordIN extends Component
|
|
|
|
|
|
public function render()
|
|
|
{
|
|
|
-
|
|
|
$datas = [];
|
|
|
return view('livewire.records_in', ['datas' => $datas]);
|
|
|
}
|
|
|
@@ -682,14 +724,12 @@ class RecordIN extends Component
|
|
|
|
|
|
if ($this->rateId > 0) {
|
|
|
$rates = explode(",", $this->rateId);
|
|
|
- foreach($rates as $rid)
|
|
|
- {
|
|
|
+ foreach ($rates as $rid) {
|
|
|
$rate = \App\Models\Rate::findOrFail($rid);
|
|
|
$rate->status = 1;
|
|
|
$rate->record_id = $record->id;
|
|
|
$rate->save();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if ($this->backToRates) {
|