|
|
@@ -50,6 +50,7 @@ class RecordIN extends Component
|
|
|
}
|
|
|
|
|
|
public $courseId = 0;
|
|
|
+ public $course = null;
|
|
|
public $rateId = 0;
|
|
|
public $months = array();
|
|
|
|
|
|
@@ -74,7 +75,7 @@ class RecordIN extends Component
|
|
|
|
|
|
public $currentReceip;
|
|
|
|
|
|
- public $filterMember = 0, $filterPaymentMethod = 0, $filterCausals = 0, $filterFrom = '', $filterTo = '', $filterCommercial = 0;
|
|
|
+ public $filterMember = 0, $filterPaymentMethod = 0, $filterCausals = 0, $fitlerCourses = 0, $filterFrom = '', $filterTo = '', $filterCommercial = 0;
|
|
|
|
|
|
public $hasFilter = false;
|
|
|
|
|
|
@@ -99,6 +100,7 @@ class RecordIN extends Component
|
|
|
public $newMemberFiscalCodeExist = false;
|
|
|
|
|
|
public $causals = array();
|
|
|
+ public $courses = array();
|
|
|
public $payments = array();
|
|
|
public $members = array();
|
|
|
public $vats = array();
|
|
|
@@ -164,6 +166,12 @@ class RecordIN extends Component
|
|
|
public function hydrate()
|
|
|
{
|
|
|
$this->emit('load-select');
|
|
|
+
|
|
|
+ foreach ($this->rows as $i => $row) {
|
|
|
+ if (isset($row['course']) && is_array($row['course']) && isset($row['course']['id'])) {
|
|
|
+ $this->rows[$i]['course'] = \App\Models\Course::find($row['course']['id']);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*public function updated() {
|
|
|
@@ -264,7 +272,7 @@ class RecordIN extends Component
|
|
|
$this->backToRates = false;
|
|
|
$this->months = array();
|
|
|
$this->rows = array();
|
|
|
- $this->rows[] = array('causal_id' => isset($_GET["causalId"]) ? $_GET["causalId"] : null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')), 'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0, 'sconto' => 0);
|
|
|
+ $this->rows[] = array('causal_id' => isset($_GET["causalId"]) ? $_GET["causalId"] : null, 'course_id' => null, 'course' => null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')), 'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0, 'sconto' => 0);
|
|
|
$this->corrispettivo = [];
|
|
|
$this->emit('load-data-table');
|
|
|
}
|
|
|
@@ -331,6 +339,15 @@ class RecordIN extends Component
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function getCourses($records, $indentation)
|
|
|
+ {
|
|
|
+ foreach ($records as $record) {
|
|
|
+ $this->courses[] = array('id' => $record->id, 'name' => $record->getDetailsName(), 'text' => $record->getDetailsName(), 'level' => $indentation);
|
|
|
+ if (count($record->childs))
|
|
|
+ $this->getCourses($record->childs, $indentation + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function mount()
|
|
|
{
|
|
|
|
|
|
@@ -339,6 +356,7 @@ class RecordIN extends Component
|
|
|
}
|
|
|
|
|
|
$this->causals = array();
|
|
|
+ $this->courses = array();
|
|
|
|
|
|
$this->multiMonthFrom = date("n");
|
|
|
$this->multiYearFrom = date("Y");
|
|
|
@@ -351,6 +369,8 @@ class RecordIN extends Component
|
|
|
|
|
|
$this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->get(), 0);
|
|
|
|
|
|
+ $this->getCourses(\App\Models\Course::where('parent_id', null)->get(), 0);
|
|
|
+
|
|
|
//$this->buildTree(\App\Models\Causal::all(), null);
|
|
|
|
|
|
$this->refreshMembers();
|
|
|
@@ -387,7 +407,8 @@ class RecordIN extends Component
|
|
|
if (isset($_GET["courseId"])) {
|
|
|
$this->courseId = $_GET["courseId"];
|
|
|
$mc = \App\Models\MemberCourse::findOrFail($this->courseId);
|
|
|
- $course = \App\Models\Course::findOrFail($mc->course_id);
|
|
|
+ $this->course = \App\Models\Course::findOrFail($mc->course_id);
|
|
|
+ $this->rows[0]['course'] = $this->course;
|
|
|
}
|
|
|
if (isset($_GET["rateId"])) {
|
|
|
$this->rateId = $_GET["rateId"];
|
|
|
@@ -471,14 +492,20 @@ class RecordIN extends Component
|
|
|
|
|
|
$this->createSubscription = 1;
|
|
|
$this->courseId = $_GET["courseId"];
|
|
|
+ if ($this->courseId) {
|
|
|
+ $mc = \App\Models\MemberCourse::findOrFail($this->courseId);
|
|
|
+ $this->course = \App\Models\Course::findOrFail($mc->course_id);
|
|
|
+ }
|
|
|
$this->rateId = $_GET["rateId"];
|
|
|
$price = $_GET["subscription_price"] / 100 * 100;
|
|
|
$this->refreshAfter = 1;
|
|
|
if ($count == 1)
|
|
|
- $this->rows[] = array('causal_id' => null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')), 'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0);
|
|
|
+ $this->rows[] = array('causal_id' => null, 'course_id' => null, 'course' => null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')), 'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0);
|
|
|
$this->rows[$count]["causal_id"] = null;
|
|
|
+ $this->rows[$count]["course_id"] = $this->course->id ?? null;
|
|
|
+ $this->rows[$count]["course"] = $this->course ?? null;
|
|
|
$this->rows[$count]["amount"] = formatPrice($price);
|
|
|
- $this->rows[$count]["note"] = "Pagamento iscrizione " . $course->name;
|
|
|
+ $this->rows[$count]["note"] = "Pagamento iscrizione " . $this->course->name;
|
|
|
if (isset($_GET["subCausalId"])) {
|
|
|
$this->refreshAfter = 1;
|
|
|
$this->rows[$count]["causal_id"] = $_GET["subCausalId"];
|
|
|
@@ -498,6 +525,7 @@ class RecordIN extends Component
|
|
|
$this->filterMember = 0;
|
|
|
$this->filterPaymentMethod = 0;
|
|
|
$this->filterCausals = 0;
|
|
|
+ $this->filterCourses = 0;
|
|
|
$this->filterTo = '';
|
|
|
$this->filterFrom = '';
|
|
|
$this->filterCommercial = 0;
|
|
|
@@ -562,10 +590,16 @@ class RecordIN extends Component
|
|
|
'financial_movement' => $this->financial_movement,
|
|
|
'deleted' => $this->deleted
|
|
|
]);
|
|
|
+
|
|
|
+ if ($this->courseId) {
|
|
|
+ $mc = \App\Models\MemberCourse::findOrFail($this->courseId);
|
|
|
+ $this->course = \App\Models\Course::findOrFail($mc->course_id);
|
|
|
+ }
|
|
|
|
|
|
\App\Models\RecordRow::create([
|
|
|
'record_id' => $record->id,
|
|
|
'causal_id' => $this->corrispettivo_causal_id,
|
|
|
+ 'course_id' => $this->course->id ?? null,
|
|
|
'note' => '',
|
|
|
'amount' => $price,
|
|
|
'vat_id' => null,
|
|
|
@@ -684,6 +718,7 @@ class RecordIN extends Component
|
|
|
\App\Models\RecordRow::create([
|
|
|
'record_id' => $this->dataId,
|
|
|
'causal_id' => $row["causal_id"],
|
|
|
+ 'course_id' => $row["course_id"],
|
|
|
'note' => $row["note"],
|
|
|
'amount' => $rowNet,
|
|
|
'prediscount_amount' => $rowAmount,
|
|
|
@@ -814,7 +849,7 @@ class RecordIN extends Component
|
|
|
$this->add = false;
|
|
|
|
|
|
$rows = \App\Models\RecordRow::where('record_id', $this->dataId)
|
|
|
- ->select('causal_id', 'note', 'commercial', 'when', 'amount', 'prediscount_amount', 'sconto', 'vat_id')
|
|
|
+ ->select('causal_id', 'course_id', 'note', 'commercial', 'when', 'amount', 'prediscount_amount', 'sconto', 'vat_id')
|
|
|
->get();
|
|
|
|
|
|
$this->rows = [];
|
|
|
@@ -829,8 +864,18 @@ class RecordIN extends Component
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ $course = null;
|
|
|
+ if ($r->course_id) {
|
|
|
+ try {
|
|
|
+ $course = \App\Models\Course::findOrFail($r->course_id);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$this->rows[] = [
|
|
|
'causal_id' => $causalId,
|
|
|
+ 'course_id' => $r->course_id,
|
|
|
+ 'course' => $course,
|
|
|
'note' => $r->note,
|
|
|
'commercial' => $r->commercial,
|
|
|
'when' => json_decode($r->when),
|
|
|
@@ -995,6 +1040,7 @@ class RecordIN extends Component
|
|
|
\App\Models\RecordRow::create([
|
|
|
'record_id' => $this->dataId,
|
|
|
'causal_id' => $row["causal_id"],
|
|
|
+ 'course_id' => $row["course_id"],
|
|
|
'note' => $row["note"],
|
|
|
'vat_id' => $row["vat_id"],
|
|
|
'amount' => $rowNet,
|
|
|
@@ -1247,6 +1293,7 @@ class RecordIN extends Component
|
|
|
\App\Models\ReceiptRow::create([
|
|
|
'receip_id' => $receipt->id,
|
|
|
'causal_id' => $row["causal_id"],
|
|
|
+ 'course_id' => $row["course_id"],
|
|
|
'note' => $row["note"],
|
|
|
'vat_id' => $row["vat_id"],
|
|
|
'amount' => $rowNet,
|
|
|
@@ -1288,7 +1335,7 @@ class RecordIN extends Component
|
|
|
|
|
|
public function addRow()
|
|
|
{
|
|
|
- $this->rows[] = array('causal_id' => null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')), 'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0);
|
|
|
+ $this->rows[] = array('causal_id' => null, 'course_id' => null, 'course' => null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')), 'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0);
|
|
|
$this->emit('load-select');
|
|
|
}
|
|
|
|