public function getPdfContent($request) {
    // Get all parameters from query.
    $parameters = $request->query->all();
    $category = !empty($parameters['categories']) ? $parameters['categories'] : '0';
    $rooms = !empty($parameters['rooms']) ? $parameters['rooms'] : '';
    $classnames = !empty($parameters['cn']) ? $parameters['cn'] : [];
    $location = !empty($parameters['locations']) ? $parameters['locations'] : '0';
    $date = !empty($parameters['date']) ? $parameters['date'] : '';
    $mode = !empty($parameters['mode']) ? $parameters['mode'] : 'activity';

    if (empty($date)) {
      $date = time();
    }
    else {
      $date = strtotime($date);
    }

    // Calculate first day of a week.
    $monday_timestamp = strtotime("last Monday", $date);
    if (date('D', $date) === 'Mon') {
      $monday_timestamp = $date;
    }
    $timestamp_start = $monday_timestamp;

    $result = [];
    // Create weekly schedule by getting results for every weekday.
    for ($i = 1; $i <= 7; $i++) {
      $date = DrupalDateTime::createFromTimestamp($timestamp_start);
      $result[$date->format('Y-m-d')] = $this->getData($request, $location, $date->format('F j, l 00:00:00'), $category);
      $timestamp_start += 86400;
    }
    if (!empty($rooms)) {
      $rooms = explode(',', $rooms);
    }
    // Group by activity.
    if ($mode == 'activity') {
      $result = $this->groupByActivity($result, $rooms, $classnames);
      $theme = 'openy_repeat__pdf__table__activity';
    }
    // Group by day.
    if ($mode == 'day') {
      $result = $this->groupByDay($result, $rooms, $classnames);
      $theme = 'openy_repeat__pdf__table__day';
    }

    $content = [
      'content' => $result,
      'theme' => $theme,
    ];

    return $content;
  }
public function getPdfContent($request) {
    // Get all parameters from query.
    $parameters = $request->query->all();
    $category = !empty($parameters['categories']) ? $parameters['categories'] : '0';
    $rooms = !empty($parameters['rooms']) ? $parameters['rooms'] : '';
    $classnames = !empty($parameters['cn']) ? $parameters['cn'] : [];
    $location = !empty($parameters['locations']) ? $parameters['locations'] : '0';
    $date = !empty($parameters['date']) ? $parameters['date'] : '';
    $mode = !empty($parameters['mode']) ? $parameters['mode'] : 'activity';

    if (empty($date)) {
      $date = time();
    }
    else {
      $date = strtotime($date);
    }

    // Calculate first day of a week.
    $monday_timestamp = strtotime("last Monday", $date);
    if (date('D', $date) === 'Mon') {
      $monday_timestamp = $date;
    }
    $timestamp_start = $monday_timestamp;

    $result = [];
    // Create weekly schedule by getting results for every weekday.
    for ($i = 1; $i <= 7; $i++) {
      $date = DrupalDateTime::createFromTimestamp($timestamp_start);
      $result[$date->format('Y-m-d')] = $this->getData($request, $location, $date->format('F j, l 00:00:00'), $category);
      $timestamp_start += 86400;
    }
    if (!empty($rooms)) {
      $rooms = explode(',', $rooms);
    }
    // Group by activity.
    if ($mode == 'activity') {
      $result = $this->groupByActivity($result, $rooms, $classnames);
      $theme = 'openy_repeat__pdf__table__activity';
    }
    // Group by day.
    if ($mode == 'day') {
      $result = $this->groupByDay($result, $rooms, $classnames);
      $theme = 'openy_repeat__pdf__table__day';
    }

    $content = [
      'content' => $result,
      'theme' => $theme,
    ];

    return $content;
  }
public function getPdfContent ( $ request ) { // Get all parameters from query. $ parameters = $ request -> query -> all ( ) ; $ category = ! empty ( $ parameters [ 'categories' ] ) ? $ parameters [ 'categories' ] : '0' ; $ rooms = ! empty ( $ parameters [ 'rooms' ] ) ? $ parameters [ 'rooms' ] : '' ; $ classnames = ! empty ( $ parameters [ 'cn' ] ) ? $ parameters [ 'cn' ] : [ ] ; $ location = ! empty ( $ parameters [ 'locations' ] ) ? $ parameters [ 'locations' ] : '0' ; $ date = ! empty ( $ parameters [ 'date' ] ) ? $ parameters [ 'date' ] : '' ; $ mode = ! empty ( $ parameters [ 'mode' ] ) ? $ parameters [ 'mode' ] : 'activity' ; if ( empty ( $ date ) ) { $ date = time ( ) ; } else { $ date = strtotime ( $ date ) ; } // Calculate first day of a week. $ monday_timestamp = strtotime ( "last Monday" , $ date ) ; if ( date ( 'D' , $ date ) === 'Mon' ) { $ monday_timestamp = $ date ; } $ timestamp_start = $ monday_timestamp ; $ result = [ ] ; // Create weekly schedule by getting results for every weekday. for ( $ i = 1 ; $ i <= 7 ; $ i ++ ) { $ date = DrupalDateTime :: createFromTimestamp ( $ timestamp_start ) ; $ result [ $ date -> format ( 'Y-m-d' ) ] = $ this -> getData ( $ request , $ location , $ date -> format ( 'F j, l 00:00:00' ) , $ category ) ; $ timestamp_start += 86400 ; } if ( ! empty ( $ rooms ) ) { $ rooms = explode ( ',' , $ rooms ) ; } // Group by activity. if ( $ mode == 'activity' ) { $ result = $ this -> groupByActivity ( $ result , $ rooms , $ classnames ) ; $ theme = 'openy_repeat__pdf__table__activity' ; } // Group by day. if ( $ mode == 'day' ) { $ result = $ this -> groupByDay ( $ result , $ rooms , $ classnames ) ; $ theme = 'openy_repeat__pdf__table__day' ; } $ content = [ 'content' => $ result , 'theme' => $ theme , ] ; return $ content ; }
Returns content for a PDF.
Returns content for a PDF .