Correccion mes en ticket

Correccion Bug Rut
parent 15dc9da3
......@@ -5,6 +5,7 @@ namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Symfony\Component\Translation\TranslatorInterface;
class Queue extends Model
{
......@@ -20,8 +21,61 @@ class Queue extends Model
}
public function getFormatedDateAttribute($value){
$date = Carbon::parse($this->created_at)->format('j-F-Y');
return $date;
$dateString = Carbon::parse($this->created_at)->format('Y-m-d');
$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(){
return $this->hasOne(Call::class);
......@@ -30,4 +84,5 @@ class Queue extends Model
public function getTokenNumberAttribute(){
return $this->letter.'-'.$this->number;
}
}
......@@ -75,7 +75,7 @@
</div>
<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>
<div class="rut">
<span><b>Ingrese su rut para poder solicitar su número de atención</b></span>
......@@ -91,7 +91,7 @@
<button onclick="escribirValor(9,event)">9</button>
<button onclick="escribirValor(-2,event)">K</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>
......@@ -139,6 +139,8 @@
function formatearRut(input){
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})$/)) {
value = value.replace(/^(\d{2})(\d{3})(\d{3})(\w{1})$/, '$1.$2.$3-$4');
......@@ -157,6 +159,8 @@
function formatearRutPorValor(val){
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})$/)) {
value = value.replace(/^(\d{2})(\d{3})(\d{3})(\w{1})$/, '$1.$2.$3-$4');
......@@ -177,7 +181,9 @@
event.preventDefault();
let inputValue = $("#rut").val();
if(number == -1){
inputValue = inputValue.slice(0,-1);
inputValue = $("#rut").val("");
$("#rut").focus();
return;
}else if(number == -2){
inputValue = inputValue+""+"K";
}else{
......@@ -198,8 +204,10 @@
else $('#phone_tab').hide()
if (value.ask_rut == 1) {
$('#rut_tab').show();
$('#rut_pad').show();
}else{
$('#rut_tab').hide();
$('#rut_pad').hide();
}
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