Correccion mes en ticket

Correccion Bug Rut
parent 15dc9da3
...@@ -5,6 +5,7 @@ namespace App\Models; ...@@ -5,6 +5,7 @@ namespace App\Models;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Symfony\Component\Translation\TranslatorInterface;
class Queue extends Model class Queue extends Model
{ {
...@@ -20,8 +21,61 @@ class Queue extends Model ...@@ -20,8 +21,61 @@ class Queue extends Model
} }
public function getFormatedDateAttribute($value){ public function getFormatedDateAttribute($value){
$date = Carbon::parse($this->created_at)->format('j-F-Y'); $dateString = Carbon::parse($this->created_at)->format('Y-m-d');
return $date; $format = 'Y-m-d'; // input format
$date = Carbon::createFromFormat($format, $dateString);
$spanishMonths = [
'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',
'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'
];
$year= explode('-',$dateString)[0];
$month = explode('-',$dateString)[1];
$day = explode('-',$dateString)[2];
switch($month):
case '01':
$mntStr = $spanishMonths[0];
break;
case '02':
$mntStr = $spanishMonths[1];
break;
case '03':
$mntStr = $spanishMonths[2];
break;
case '04':
$mntStr = $spanishMonths[3];
break;
case '05':
$mntStr = $spanishMonths[4];
break;
case '06':
$mntStr = $spanishMonths[5];
break;
case '07':
$mntStr = $spanishMonths[6];
break;
case '08':
$mntStr = $spanishMonths[7];
break;
case '09':
$mntStr = $spanishMonths[8];
break;
case '10':
$mntStr = $spanishMonths[9];
break;
case '11':
$mntStr = $spanishMonths[10];
break;
case '12':
$mntStr = $spanishMonths[11];
break;
endswitch;
return $year."-".$mntStr."-".$day;
} }
public function call(){ public function call(){
return $this->hasOne(Call::class); return $this->hasOne(Call::class);
...@@ -30,4 +84,5 @@ class Queue extends Model ...@@ -30,4 +84,5 @@ class Queue extends Model
public function getTokenNumberAttribute(){ public function getTokenNumberAttribute(){
return $this->letter.'-'.$this->number; return $this->letter.'-'.$this->number;
} }
} }
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
</div> </div>
<div class="input-field col-lg-4 s4" id="rut_tab"> <div class="input-field col-lg-4 s4" id="rut_tab">
<input id="rut" name="rut" type="text" value="" oninput="formatearRut(this);" data-error=".rut"> <input id="rut" name="rut" type="text" value="" maxlength="12" oninput="formatearRut(this);" maxlength=13 data-error=".rut">
<label for="rut">{{__('messages.settings.rut')}}</label> <label for="rut">{{__('messages.settings.rut')}}</label>
<div class="rut"> <div class="rut">
<span><b>Ingrese su rut para poder solicitar su número de atención</b></span> <span><b>Ingrese su rut para poder solicitar su número de atención</b></span>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<button onclick="escribirValor(9,event)">9</button> <button onclick="escribirValor(9,event)">9</button>
<button onclick="escribirValor(-2,event)">K</button> <button onclick="escribirValor(-2,event)">K</button>
<button onclick="escribirValor(0,event)">0</button> <button onclick="escribirValor(0,event)">0</button>
<button onclick="escribirValor(-1,event)">Del</button> <button onclick="escribirValor(-1,event)">Borrar</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -139,7 +139,9 @@ ...@@ -139,7 +139,9 @@
function formatearRut(input){ function formatearRut(input){
let value = input.value.replace(/\./g, '').replace('-', ''); let value = input.value.replace(/\./g, '').replace('-', '');
let maxLength = 12;
if (value.length > maxLength) value = value.slice(0, maxLength);
if (value.match(/^(\d{2})(\d{3}){2}(\w{1})$/)) { if (value.match(/^(\d{2})(\d{3}){2}(\w{1})$/)) {
value = value.replace(/^(\d{2})(\d{3})(\d{3})(\w{1})$/, '$1.$2.$3-$4'); value = value.replace(/^(\d{2})(\d{3})(\d{3})(\w{1})$/, '$1.$2.$3-$4');
} }
...@@ -157,6 +159,8 @@ ...@@ -157,6 +159,8 @@
function formatearRutPorValor(val){ function formatearRutPorValor(val){
let value = val.replace(/\./g, '').replace('-', ''); let value = val.replace(/\./g, '').replace('-', '');
let maxLength = 12;
if (value.length > maxLength) value = value.slice(0, maxLength);
if (value.match(/^(\d{2})(\d{3}){2}(\w{1})$/)) { if (value.match(/^(\d{2})(\d{3}){2}(\w{1})$/)) {
value = value.replace(/^(\d{2})(\d{3})(\d{3})(\w{1})$/, '$1.$2.$3-$4'); value = value.replace(/^(\d{2})(\d{3})(\d{3})(\w{1})$/, '$1.$2.$3-$4');
...@@ -177,7 +181,9 @@ ...@@ -177,7 +181,9 @@
event.preventDefault(); event.preventDefault();
let inputValue = $("#rut").val(); let inputValue = $("#rut").val();
if(number == -1){ if(number == -1){
inputValue = inputValue.slice(0,-1); inputValue = $("#rut").val("");
$("#rut").focus();
return;
}else if(number == -2){ }else if(number == -2){
inputValue = inputValue+""+"K"; inputValue = inputValue+""+"K";
}else{ }else{
...@@ -198,8 +204,10 @@ ...@@ -198,8 +204,10 @@
else $('#phone_tab').hide() else $('#phone_tab').hide()
if (value.ask_rut == 1) { if (value.ask_rut == 1) {
$('#rut_tab').show(); $('#rut_tab').show();
$('#rut_pad').show();
}else{ }else{
$('#rut_tab').hide(); $('#rut_tab').hide();
$('#rut_pad').hide();
} }
service = value; service = value;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment