Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

420
Views
Medio día en jQuery ui Datepicker

Actualmente estoy usando el script jQuery UI Datepicker para mostrar las fechas de disponibilidad de un alquiler. Utilicé la forma recomendada de alimentar el script con una serie de días deshabilitados, pero mi problema es que el día en que finaliza el alquiler también debería estar disponible como fecha de inicio para un nuevo alquiler. El cliente solicitó un triángulo rojo en el primer y último día para mostrar que debería estar disponible. ¿Cómo puedo lograr eso con este complemento?

 $(function() { <?php $date_range = array(); $select = mysql_query("SELECT * FROM reservation WHERE cid='$chalet[id]' and status='1'"); while ($r = mysql_fetch_array($select)) { $date_range1 = createDateRangeArray(date("Ymd", $r[arrive]), date("Ymd", $r[depart])); // How can i use those 2 arrays to detect the right triangle to display and make sure the day is selectable $first[] = reset($date_range1); $last[] = end($date_range1); $date_range = array_merge($date_range, $date_range1); } foreach ($date_range as $key => $values) { $dates .= '"' . $values . '", '; } if ($dates) { echo 'var disableddates = [' . substr($dates, 0, -2) . "];\n"; } else { echo "var disableddates = [];\n"; } ?> function DisableSpecificDates(date) { var string = jQuery.datepicker.formatDate('dd-mm-yy', date); return [disableddates.indexOf(string) == -1]; } $( "#calendrier" ).datepicker({ beforeShowDay: DisableSpecificDates }); });

El código anterior representa lo siguiente

ingrese la descripción de la imagen aquí:

Necesito que se vea así:

ingrese la descripción de la imagen aquí

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Espero que entiendas la idea, perdón si hay algún error ya que está escrito directamente del cerebro sin ninguna prueba. Esto agrega clases .arrival / .departure al día dado.

PHP:

 $arrivals = $departures = $disabledDates = array(); while ($r = mysql_fetch_array($select)) { $arrivals[] = $r['arrive']; $departures[] = $r['departure']; $disabledDates[] = ....

JS

 var arrivals = <?=json_encode($arrivals)?>; var departures = <?=json_encode($departures)?>; var disabledDates = <?=json_encode($disabledDates)?>; $( "#calendrier" ).datepicker({ beforeShowDay: function(date){ var myDate = jQuery.datepicker.formatDate('YYYY-mm-dd', date); if($.inArray(myDate, disabledDates)) return [false]; else if($.inArray(myDate, arrivals)) return [true, 'arrival', 'Arrival day']; else if($.inArray(myDate, departures)) return [true, 'departure', 'Departure day']; else return [true]; } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!