Hi
The module currently offers today as an option, is it possible to set this to only allow dates in the future to be selected? My current client would be delivering 2 days from now at the earliest but I can't figure out where to start to change the code! I'm guessing that somewhere I could add "+2", but I don't know where. Any help greatly appreciated

Comments

jon pollard’s picture

Hey, I figured this out!

There are 2 instances, one for horizontal dates, one for vertical:

Change this line:

'for ($delt = 0; $delt < $disp; $delt++) {'

to this

'for ($delt = 2; $delt < $disp; $delt++) {'

and dates displayed to the user will start 3 days from now. I haven't finished adding this to the site, so it isn't tried and tested yet, but it is looking good.

jon pollard’s picture

We've found a problem with this... the original fix hid the next three days regardless of whether they were delivery days or weekends. So if somebody bought on a Friday they were offered dates on a Tuesday. All a bit complicated.

I've come up with a different fix which adds an incrememental number to the td class for each order slot - you can then hide the slots you don't want to offer using css. I've only set this up for having the days in the left hand column, there is an option to have the table the other way around, but I don't have time to fix that!

Here is the module code - uc_deliverytimeslot.module from about line 389:

 // rows construction day on left column
  else {
    $headers = array_merge(array('&nbsp;', '&nbsp;'), _uc_deliverytimeslot_timeslot());
	
	//### set value $jj as 0
	$jj = 0;
    for ($delt = 0; $delt < $disp; $delt++) {
      $timestamps = _uc_deliverytimeslot_date(FALSE, $delt);
      $row = array();
      if (in_array(date('l', $timestamps), variable_get('uc_deliverytimeslot_week_days', _uc_deliverytimeslot_week_days()))) {

		//### add value $jj to class of table cells - we can then use css to hide this
        $row[] = array('data' => t('!day', array('!day' => date('l', $timestamps))), 'class' => 'deliveryday'.$jj);
        $row[] = array('data' => date('j', $timestamps) .' '. t('!month', array('!month' => date('F', $timestamps))), 'class' => 'deliverydate'.$jj);

        foreach ($timeslot as $sid => $slot) {
          // back button
          if (($set_day && $set_day == $timestamps) && ($set_sid == $sid)) {
            $checked = ' checked="checked"';
          }
          else {
            $checked = '';
			
          }
          $class = 'free'.$jj;
          $max = $data = '';
          $value = $timestamps .'|'. $sid;
          $sp_query = db_query("SELECT * FROM {uc_deliverytimeslot_special} WHERE date = %d AND sid = %d", $timestamps, $sid);
          $sp_det = db_fetch_array($sp_query);
          $booked_num = db_result(db_query("SELECT Count(*) as num FROM {uc_deliverytimeslot_order} WHERE date = %d AND sid = %d AND confirmed = 1", $timestamps, $sid));
		 
		  	//### increase value of $jj
			$jj++;

          if ($sp_det != 0) {
            $max = $sp_det['max_limit'];
          }
          else {
            $default_det = db_fetch_array(db_query("SELECT * FROM {uc_deliverytimeslot_default} WHERE day = '%s' AND sid = %d", date('l', $timestamps), $sid));
            $max = $default_det['max_limit'];
          }
          if (!$max || $max == 0) {
            $class = 'na';
          }
          elseif (($booked_num >= $max) && $checked == '') {
            $class = 'full';
          }
          else {
		  	//###
            $data = '<input type="radio" class="form-radio" value="'. $value .'" name="panes[deliverytimeslot][delivery_timeslot]" id="edit-panes-deliverytimeslot-delivery-timeslot-'. $value .'" '. $checked .'/>';
          }
          $row[] = array('data' => $data, 'class' => $class);
        }
      }
      else {
        $disp++;
		
      }
    $rows[] = $row;
jon pollard’s picture

Oh, and here is the css to hide the first 2 rows. Sorry it's all such a vile hack!

/* delivery timeslot*/
td.deliveryday0 ,
td.deliverydate0,
td.free0,
td.free1 {display:none; }

td.deliveryday2 ,
td.deliverydate2,
td.free2,
td.free3 {display:none; }