summaryrefslogtreecommitdiffstats
path: root/includes/admin/views/_concerts_cal_dld.php
blob: f306a69b9c93fa38e323e93498890a57096cb451 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php

   // Fix PHP headers
    ob_start();

use Kigkonsult\Icalcreator\Vcalendar;
use DateTime;
use DateTimezone;


    function icalvalue(): string
    {
         $vcalendar = Vcalendar::factory( [ Vcalendar::UNIQUE_ID => "kigkonsult.se", ] )

    // with calendaring info
                 ->setMethod( Vcalendar::PUBLISH )
                 ->setXprop(
                      Vcalendar::X_WR_CALNAME,
                      "Calendar Sample"
                 )
                 ->setXprop(
                      Vcalendar::X_WR_CALDESC,
                      "This is a demo calendar"
                 )
                 ->setXprop(
                      Vcalendar::X_WR_RELCALID,
                      "3E26604A-50F4-4449-8B3E-E4F4932D05B5"
                 )
                 ->setXprop(
                      Vcalendar::X_WR_TIMEZONE,
                      "Europe/Stockholm"
                 );
                 
                    // create a new event
$event1 = $vcalendar->newVevent()
              ->setTransp( Vcalendar::OPAQUE )
              ->setClass( Vcalendar::P_BLIC )
              ->setSequence( 1 )
    // describe the event
              ->setSummary( 'Scheduled meeting with five occurrences' )
              ->setDescription(
                   'Agenda for the the meeting...',
                   [ Vcalendar::ALTREP =>
                       'CID:<FFFF__=0ABBE548DFE235B58f9e8a93d@coffeebean.com>' ]
              )
              ->setComment( 'It\'s going to be fun..' )
    // place the event
              ->setLocation( 'Kafé Ekorren Stockholm' )
              ->setGeo( '59.32206', '18.12485' )
    // set the time
              ->setDtstart(
                  new DateTime(
                      '20220421T090000',
                      new DateTimezone( 'Europe/Stockholm' )
                  )
              )
              ->setDtend(
                  new DateTime(
                      '20220421T100000',
                      new DateTimezone( 'Europe/Stockholm' )
                  )
              )
    // with recurrence rule


;

    // add alarm for the event
$alarm = $event1->newValarm()
             ->setAction( Vcalendar::DISPLAY )
    // copy description from event
             ->setDescription( $event1->getDescription())
    // fire off the alarm one day before
             ->setTrigger( '-P1D' );

    // alter day and time for one event in recurrence set
$event2 = $vcalendar->newVevent()
              ->setTransp( Vcalendar::OPAQUE )
              ->setClass( Vcalendar::P_BLIC )
    // reference to event in recurrence set
              ->setUid( $event1->getUid())
              ->setSequence( 2 )
    // pointer to event in the recurrence set
              ->setRecurrenceid( '20220505T090000 Europe/Stockholm' )
    // reason text
              ->setDescription(
                  'Altered day and time for event 2022-05-05',
                  [ Vcalendar::ALTREP =>
                      'CID:<FFFF__=0ABBE548DFE235B58f9e8a93d@coffeebean.com>' ]
              )
              ->setComment( 'Now we are working hard for two hours' )
    // the altered day and time with duration
              ->setDtstart(
                  new DateTime(
                      '20220504T100000',
                      new DateTimezone( 'Europe/Stockholm' )
                  )
              )
              ->setDuration( 'PT2H' )
    // add alarm (copy from event1)
              ->setComponent(
                  $event1->getComponent( Vcalendar::VALARM )
              );

$vcalendarString =
    // apply appropriate Vtimezone with Standard/DayLight components
    $vcalendar->vtimezonePopulate()
    // and create the (string) calendar
    ->createCalendar();
    
return($vcalendarString);
    }
	
	
	
function dldCal()
{


if(isset($_POST['download'])){
    $file = "test.ical";
    $txt = fopen($file, "w") or die("Unable to open file!");
fwrite($txt, icalvalue());
fclose($txt);
 
  $filename = "myzipfile.zip";

  if (file_exists($file)) {
     header('Content-Type: application/zip');
     header('Content-Disposition: attachment; filename="'.basename($file).'"');
     header('Content-Length: ' . filesize($file));
    ob_clean();
     flush();
    echo  readfile($file);
     // delete file
    // unlink($file);
     
  }
}
/*

            


header('Content-Type: text/calendar');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Content-Length:'. filesize($file));
header('Pragma: public');
ob_clean();
//flush();
readfile('test.ical');
//echo file_get_contents($file);

*/




}