Просмотр исходного кода

Merge branch 'master' of http://host.webmagistri.biz:3000/parisio/iao_team

Luca Parisio 9 месяцев назад
Родитель
Сommit
9921c8ec1a

+ 48 - 55
app/Http/Livewire/Member.php

@@ -349,17 +349,14 @@ class Member extends Component
             // Carico gli abbonamenti e i mesi
             $period = \Carbon\CarbonPeriod::create($c->date_from, '1 month', $c->date_to);
             $this->course_months_list = [];
-            foreach ($period as $dt)
-            {
+            foreach ($period as $dt) {
                 $this->course_months_list[] = $dt->format("m");
             }
 
             $course_subscription_ids = [];
             $this->course_price_list = [];
-            if ($c->prices != null)
-            {
-                foreach(json_decode($c->prices) as $z)
-                {
+            if ($c->prices != null) {
+                foreach (json_decode($c->prices) as $z) {
                     $this->course_price_list[$z->course_subscription_id] = $z->price;
                     if ($z->price > 0)
                         $course_subscription_ids[] = $z->course_subscription_id;
@@ -774,17 +771,14 @@ class Member extends Component
             // Carico gli abbonamenti e i mesi
             $period = \Carbon\CarbonPeriod::create($c->date_from, '1 month', $c->date_to);
             $this->course_months_list = [];
-            foreach ($period as $dt)
-            {
+            foreach ($period as $dt) {
                 $this->course_months_list[] = $dt->format("m");
             }
 
             $course_subscription_ids = [];
             $this->course_price_list = [];
-            if ($c->prices != null)
-            {
-                foreach(json_decode($c->prices) as $z)
-                {
+            if ($c->prices != null) {
+                foreach (json_decode($c->prices) as $z) {
                     $this->course_price_list[$z->course_subscription_id] = $z->price;
                     if ($z->price > 0)
                         $course_subscription_ids[] = $z->course_subscription_id;
@@ -792,7 +786,6 @@ class Member extends Component
             }
 
             $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->whereIn('id', $course_subscription_ids)->where('enabled', true)->get();
-
         } else {
             $this->course_price = 0;
             $this->course_subscription_price = 0;
@@ -1122,11 +1115,9 @@ class Member extends Component
             'email' => 'required',
             'phone' => 'required',
             'birth_nation_id' => 'required',
-            //'birth_place' => 'required',
             'address' => 'required',
             'zip_code' => 'required',
             'nation_id' => 'required',
-            'fiscal_code' => 'required',
             'birth_date' => 'before_or_equal:today'
         ];
 
@@ -1136,6 +1127,8 @@ class Member extends Component
         } else {
             $rules['birth_place'] = 'required';
         }
+        Log::info('isItaly', ['isItaly' => $this->isItaly]);
+        $this->isItaly = $this->checkIsItaly();
 
         if ($this->isItaly) {
             $rules['province_id'] = 'required';
@@ -1162,7 +1155,27 @@ class Member extends Component
 
         $this->emit('setErrorMsg', $zzz);
 
-        $this->validate($rules);
+        if ($this->under18) {
+            $rules['father_name'] = 'required_without:mother_name';
+            $rules['father_email'] = 'required_without:mother_email|email';
+            $rules['father_fiscal_code'] = 'required_without:mother_fiscal_code';
+            $rules['mother_name'] = 'required_without:father_name';
+            $rules['mother_email'] = 'required_without:father_email|email';
+            $rules['mother_fiscal_code'] = 'required_without:father_fiscal_code';
+        }
+
+        try {
+            $this->validate($rules);
+        } catch (\Illuminate\Validation\ValidationException $e) {
+            $this->isSaving = false;
+            $errorFields = array_keys($e->errors());
+            if (!empty($errorFields)) {
+                $this->emit('focus-error-field', $errorFields[0]);
+            }
+            Log::error('Validation failed', ['errors' => $e->errors()]);
+            return;
+        }
+
         try {
 
             $name = '';
@@ -1553,13 +1566,11 @@ class Member extends Component
             $rate->save();
 
             $go = true;
-            while($go)
-            {
+            while ($go) {
 
                 $mms = [];
                 $mms[] = date("n", strtotime($start));
-                for($jj=1; $jj<$r->months;$jj++)
-                {
+                for ($jj = 1; $jj < $r->months; $jj++) {
                     $mms[] = date('n', strtotime("+" . $jj . " months", strtotime($start)));
                 }
 
@@ -1576,8 +1587,7 @@ class Member extends Component
 
                 $start = date('Y-m-d', strtotime("+" . $r->months . " months", strtotime($start)));
 
-                if ($start > $this->course_date_to)
-                {
+                if ($start > $this->course_date_to) {
                     $go = false;
                     break;
                 }
@@ -1980,25 +1990,19 @@ class Member extends Component
 
         $price = $course["price"];
 
-        if (sizeof($this->payMonths) == 1)
-        {
+        if (sizeof($this->payMonths) == 1) {
             $month = $this->payMonths[0];
             $records = \App\Models\Record::where('member_course_id', $this->selectedCourseMember)->where('deleted', 0)->get();
-            foreach ($records as $record)
-            {
+            foreach ($records as $record) {
 
-                if (in_array($month, json_decode($record->months)))
-                {
+                if (in_array($month, json_decode($record->months))) {
 
-                    foreach ($record->rows as $row)
-                    {
+                    foreach ($record->rows as $row) {
 
 
-                        if ($row->causal_id == $c->causal_id && !str_contains(strtolower($row->note), 'iscrizione'))
-                        {
+                        if ($row->causal_id == $c->causal_id && !str_contains(strtolower($row->note), 'iscrizione')) {
                             $tot = sizeof(json_decode($row->when));
-                            foreach(json_decode($row->when) as $m)
-                            {
+                            foreach (json_decode($row->when) as $m) {
                                 $price -= $row->amount / $tot;
                             }
                         }
@@ -2058,21 +2062,16 @@ class Member extends Component
                 if ($mm->m == $m) {
                     if ($mm->status == "")
                         $this->payMonths[] = $m;
-                    if ($mm->status == "1")
-                    {
+                    if ($mm->status == "1") {
                         $mc = \App\Models\MemberCourse::findOrFail($selectedCourseMember);
                         $price = $mc->price;
                         $payed = 0;
                         $extraC = '';
                         $recordsPayed = \App\Models\Record::where('member_course_id', $selectedCourseMember)->where('deleted', 0)->get();
-                        foreach ($recordsPayed as $record)
-                        {
-                            if (in_array($m, json_decode($record->months)))
-                            {
-                                foreach ($record->rows as $row)
-                                {
-                                    if ($row->causal_id == $mc->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione'))
-                                    {
+                        foreach ($recordsPayed as $record) {
+                            if (in_array($m, json_decode($record->months))) {
+                                foreach ($record->rows as $row) {
+                                    if ($row->causal_id == $mc->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione')) {
                                         $tot = sizeof(json_decode($row->when));
                                         $payed += $row->amount / $tot;
                                     }
@@ -2138,22 +2137,17 @@ class Member extends Component
                         $class = "yellow";
                 }
 
-                if ($class == 'green')
-                {
+                if ($class == 'green') {
 
                     $mc = \App\Models\MemberCourse::findOrFail($selectedCourseMember);
                     $price = $mc->price;
                     $payed = 0;
                     $extraC = '';
                     $recordsPayed = \App\Models\Record::where('member_course_id', $selectedCourseMember)->where('deleted', 0)->get();
-                    foreach ($recordsPayed as $record)
-                    {
-                        if (in_array($m, json_decode($record->months)))
-                        {
-                            foreach ($record->rows as $row)
-                            {
-                                if ($row->causal_id == $mc->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione'))
-                                {
+                    foreach ($recordsPayed as $record) {
+                        if (in_array($m, json_decode($record->months))) {
+                            foreach ($record->rows as $row) {
+                                if ($row->causal_id == $mc->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione')) {
                                     $tot = sizeof(json_decode($row->when));
                                     $payed += $row->amount / $tot;
                                 }
@@ -2164,7 +2158,6 @@ class Member extends Component
                         $class = 'orange half';
                     //$class .= $extraC;
                 }
-
             }
         }
 

+ 1 - 1
app/Http/Livewire/User.php

@@ -114,7 +114,7 @@ class User extends Component
             \App\Models\User::find($id)->delete();
             session()->flash('success',"Dato eliminato");
         }catch(\Exception $e){
-            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+            session()->flash('error','Errore (' . $e->getMessage() . ')');
         }
     }
 }

+ 1 - 1
public/css/style.css

@@ -16535,7 +16535,7 @@ a:hover, a:visited {
 
 table.dataTable th.dt-type-numeric,
 table.dataTable td.dt-type-numeric {
-  /*text-align: left !important;*/
+  text-align: right !important;
 }
 
 .dt-buttons .buttons-collection.dropdown-toggle:hover {

+ 7 - 7
resources/views/livewire/member.blade.php

@@ -1142,7 +1142,7 @@
                                                             <td style="width:70%;border:0px;" colspan="3">
                                                                 <b>{{$member_course->course->name}}</b><br>
                                                             </td>
-                                                            
+
                                                             <td style="text-align:right;width:15%;border:0px;">
                                                                 @php
                                                                 $status = $member_course->getStatus();
@@ -1162,8 +1162,8 @@
                                                                     </div>
                                                                 </div>
                                                             </td>
-                                                            
-                                                            
+
+
                                                         </tr>
                                                         <tr>
                                                             <td style="width:20%">
@@ -1206,9 +1206,9 @@
                                                                 @endif
                                                             </td>
                                                             <td style="width:30%" colspan="2">
-                                                                {{date("d/m/Y", strtotime($member_course->date_from))}} - {{date("d/m/Y", strtotime($member_course->date_to))}}                                                                
+                                                                {{date("d/m/Y", strtotime($member_course->date_from))}} - {{date("d/m/Y", strtotime($member_course->date_to))}}
                                                             </td>
-                                                            
+
                                                         </tr>
                                                         @if(in_array($member_course->id, $showCourse))
                                                             @if(false)
@@ -2416,8 +2416,8 @@
                         }
                     },
                     { data: "phone"},
-                    { data: "age", "type": "num"},
-                    { data: "year"},
+                    { data: "age", "type": "num", className:"dt-type-numeric"},
+                    { data: "year", className:"dt-type-numeric"},
                     {
                         data: "status",
                         render: function (data){

+ 4 - 4
resources/views/livewire/receipt.blade.php

@@ -58,7 +58,7 @@
             <div class="col-md-3">
                 <div class="row">
                     <div class="col-md-12" style="margin-bottom:10px;">
-                        <b>Cerca Utente</b>
+                        <b>Utente</b>
                     </div>
                     <div class="col-12">
                         <select class="form-select filterMember" wire:model="filteredMemberId">
@@ -87,7 +87,7 @@
             <thead>
                 <tr>
                     <th scope="col">Anno</th>
-                    <th scope="col">Numero</th>
+                    <th scope="col">N°</th>
                     <th scope="col">Cognome</th>
                     <th scope="col">Nome</th>
                     <th scope="col">Stato</th>
@@ -350,7 +350,7 @@
                         data: 'year'
                     },
                     {
-                        data: 'number'
+                        data: 'number', className:"dt-type-numeric"
                     },
                     {
                         data: 'last_name'
@@ -370,7 +370,7 @@
                         data: 'date'
                     },
                     {
-                        data: 'totals'
+                        data: 'totals', className:"dt-type-numeric"
                     },
                     {
                         data: "action",

+ 1 - 1
resources/views/livewire/records_in.blade.php

@@ -1249,7 +1249,7 @@
                             return ret;
                         }
                     },
-                    { data: 'total'},
+                    { data: 'total',  className:"dt-type-numeric"},
                     { data: 'last_name' },
                     { data: 'first_name' },
                     { data: 'commercial' },

+ 5 - 5
resources/views/livewire/records_out.blade.php

@@ -250,14 +250,14 @@
                                 <div class="input-group mb-12">
                                     <div class="check--invoice d-flex align-items-center">
                                         <div class="form-check me-3">
-                                            <input class="form-check-input" type="radio" value="1" wire:model="commercial">
-                                            <label class="form-check-label" for="flexCheckChecked">&nbsp;Commerciale</label>
+                                            <input class="form-check-input" type="radio" value="1" wire:model="commercial" id="commercial_1">
+                                            <label class="form-check-label" for="commercial_1" style="cursor: pointer;">&nbsp;Commerciale</label>
                                         </div>
                                         <div class="form-check">
-                                            <input class="form-check-input" type="radio" value="0" wire:model="commercial">
-                                            <label class="form-check-label" for="flexCheck">&nbsp;Non Commerciale</label>
-                                        </div>
+                                            <input class="form-check-input" type="radio" value="0" wire:model="commercial" id="commercial_0">
+                                            <label class="form-check-label" for="commercial_0" style="cursor: pointer;">&nbsp;Non Commerciale</label>
                                         </div>
+                                    </div>
                                 </div>
                             </div>