Files
@ 2c0531510745
Branch filter:
Location: SlatePermutate/class.schedule.php - annotation
2c0531510745
21.7 KiB
text/x-php
Schedules to Print now autofills with current selection for editing
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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 | 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 1a11bfb5181e 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c 27edaecc0d90 cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c ccafeb41b138 cebfe2251d8c cebfe2251d8c ccafeb41b138 cebfe2251d8c cebfe2251d8c 27edaecc0d90 f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 ccafeb41b138 ccafeb41b138 ccafeb41b138 ccafeb41b138 ccafeb41b138 ccafeb41b138 ccafeb41b138 ccafeb41b138 ccafeb41b138 ccafeb41b138 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 1a11bfb5181e 27edaecc0d90 27edaecc0d90 1a11bfb5181e 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 b254652ee789 b254652ee789 b254652ee789 b254652ee789 27edaecc0d90 d0b954ceb988 27edaecc0d90 27edaecc0d90 1a11bfb5181e 1a11bfb5181e 1a11bfb5181e 1a11bfb5181e 986e496149ed 986e496149ed bbc0c3b4c101 73f58d77e758 986e496149ed 986e496149ed fc6b04256a92 986e496149ed 986e496149ed 986e496149ed 986e496149ed 1a11bfb5181e 1a11bfb5181e 986e496149ed bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 bbc0c3b4c101 2c0531510745 986e496149ed 986e496149ed bbc0c3b4c101 986e496149ed 1a11bfb5181e 1a11bfb5181e 986e496149ed 27edaecc0d90 27edaecc0d90 27edaecc0d90 73f58d77e758 fc6b04256a92 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 fc6b04256a92 fc6b04256a92 fc6b04256a92 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 fc6b04256a92 27edaecc0d90 27edaecc0d90 fc6b04256a92 fc6b04256a92 fc6b04256a92 fc6b04256a92 fc6b04256a92 27edaecc0d90 27edaecc0d90 27edaecc0d90 cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c bbc0c3b4c101 cebfe2251d8c 1a11bfb5181e 27edaecc0d90 27edaecc0d90 cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c 27edaecc0d90 | <?php
//**************************************************
// class.schedule.php Author: Nathan Gelderloos
//
// Represents a schedule of a week. Stores the
// classes that are part of that week and calculates
// all the possible permutations.
//**************************************************
include_once 'errors.php';
include_once 'class.class.php';
include_once 'class.section.php';
include_once 'inc/class.page.php';
class Schedule
{
private $classStorage; // Classes array of classes
private $nclasses; // Integer number of classes
private $nPermutations = 0; // Integer number of real permutations
private $possiblePermutations; // Integer number of possible permutations
private $scheduleName; // String name of schedule
private $storage; // Integer array of valid schedules
private $title;
/**
* The input format of the sections. Only used for the UI. Valid
* values are 'numerous' for custom, 'numbered' for numeric, and 'lettered' for
* alphabetical.
*/
public $section_format;
/**
* \brief
* Create a schedule with the given name.
*/
function __construct($name)
{
$this->classStorage = array();
$this->nclasses = 0;
$this->scheduleName = $name;
$this->storage = array();
$this->title = "SlatePermutate - Scheduler";
$this->section_format = 'numerous';
}
//--------------------------------------------------
// Mutators and Accessors
//--------------------------------------------------
public function getName()
{
return $this->scheduleName;
}
//--------------------------------------------------
// Adds a new class to the schedule.
//--------------------------------------------------
function addClass($n)
{
$this->classStorage[$this->nclasses] = new Classes($n);
$this->nclasses++;
}
//--------------------------------------------------
// Adds a section to the desired class.
//--------------------------------------------------
function addSection($n, $l, $s, $e, $d)
{
$found = false;
$counter = 0;
while(!$found && ($counter < $this->nclasses))
{
$temp = $this->classStorage[$counter]->getName();
if((strcmp($temp,$n)) == 0)
{
$found = true;
} else {
$counter++;
}
}
if($counter == $this->nclasses)
{
echo "Could not find class: " . $n . "<br />";
} else {
$p = "unknown prof";
$this->classStorage[$counter]->addSection($l, $p, $s, $e, $d);
}
}
//--------------------------------------------------
// Finds all of the possible permutations and stores
// the results in the storage array.
//--------------------------------------------------
function findPossibilities()
{
$this->possiblePermutations = 1;
/* special case: there is nothing entered into the schedule and thus there is one, NULL permutation */
if (!$this->nclasses)
{
/* have an empty schedule */
$this->classStorage[0] = array();
$this->nPermutations = 1;
return;
}
$position = 0;
$counter = 0;
for($i = 0; $i < $this->nclasses; $i++)
{
$this->possiblePermutations = $this->possiblePermutations * $this->classStorage[$i]->getnsections();
$cs[$i] = 0; // Sets the counter array to all zeroes.
}
// Checks for conflicts in given classes, stores if none found
do
{
$conflict = false;
$upCounter = 0;
// Get first class to compare
while($upCounter < $this->nclasses)
{
$downCounter = $this->nclasses-1;
while($downCounter > $upCounter)
{
$start1 = $this->classStorage[$upCounter]->getSection($cs[$upCounter])->getStartTime();
$end1 = $this->classStorage[$upCounter]->getSection($cs[$upCounter])->getEndTime();
$start2 = $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getStartTime();
$end2 = $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getEndTime();
// If the two times overlap, then check if days overlap.
if(!$conflict && ((($start1 >= $start2) && ($start1 <= $end2)) || (($start2 >= $start1) && ($start2 <= $end1))))
{
// Monday
if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getM() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getM()))
{
$conflict = true;
}
// Tuesday
if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getTu() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getTu()))
{
$conflict = true;
}
// Wednesday
if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getW() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getW()))
{
$conflict = true;
}
// Thursday
if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getTh() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getTh()))
{
$conflict = true;
}
// Friday
if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getF() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getF()))
{
$conflict = true;
}
}
$downCounter--;
}
$upCounter++;
}
// Store to storage if no conflict is found.
if(!$conflict)
{
for($i = 0; $i < $this->nclasses; $i++)
{
$this->storage[$this->nPermutations][$i] = $cs[$i];
}
$this->nPermutations++;
}
// Increase the counter by one to get the next combination of class sections.
$cs[$position] = $cs[$position] + 1;
// Check to make sure the counter is still valid.
$valid = false;
while(!$valid)
{
if($cs[$position] == $this->classStorage[$position]->getnsections())
{
$cs[$position] = 0;
$position++;
// This is for the very last permutation. Even
// though the combination is not actually true
// the larger while loop will end before any
// new combinations are performed.
if($position == $this->nclasses)
{
$valid = true;
} else {
$cs[$position]++;
}
} else {
$valid = true;
$position = 0;
}
}
$counter++;
} while($counter < $this->possiblePermutations);
}
//--------------------------------------------------
// Prints out the possible permutations in tables.
//--------------------------------------------------
function writeoutTables()
{
$table = "";
$header = "";
$footer = "";
$M = -1;
$Tu = -1;
$W = -1;
$Th = -1;
$F = -1;
$filled = false;
$time = array(700,730,800,830,900,930,1000,1030,1100,1130,1200,1230,1300,1330,1400,1430,1500,1530,1600,1630,1700,1730,1800,1830,1900,1930,2000,2030,2100,2130, 2200);
// Reminder:
// border-style:top right bottom left
/* $header .= "<html><head><title>" . $this->getName() . " :: " . $this->title . "</title>\n\n<style type=\"text/css\">".
"\n.top{\n\tborder-style:solid solid none solid;\nbackground-color:#dddddd;\n}".
"\n.mid{\n\tborder-style:none solid none solid;\nbackground-color:#dddddd;\n}".
"\n.end{\n\tborder-style:none solid solid solid;\nbackground-color:#dddddd;\n}".
"\n.none{\n\tborder-style:none;\n}".
"\n.single{\n\tborder-style:solid;\n\tbackground-color:#dddddd;\n}".
"\ntd{\n\ttext-align:center;\nwidth:7em;\n}".
"\n.time{\n\tborder-style:none none solid none;\n}".
"\n.day{\n\tborder-style:none none solid solid;\n}".
"\n</style>".
"\n<script src=\"http://www.google.com/jsapi\"></script>".
"\n<script type=\"text/javascript\" charset=\"utf-8\">".
"\n\tgoogle.load(\"jquery\", \"1.3.2\");".
"\n\tgoogle.load(\"jqueryui\", \"1.7.2\");".
"\n</script>".
"\n<link rel=\"stylesheet\" href=\"styles/general.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\">".
"\n<link rel=\"stylesheet\" href=\"styles/glider.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\">".
"\n<script src=\"scripts/prototype.js\" type=\"text/javascript\" charset=\"utf-8\"></script>".
"\n<script src=\"scripts/effects.js\" type=\"text/javascript\" charset=\"utf-8\"></script>".
"\n<script src=\"scripts/glider.js\" type=\"text/javascript\" charset=\"utf-8\"></script>".
"\n</head><body>".
"\n\n<div id=\"header\">\n<h1><em>SlatePermutate</em> - Scheduler</h1><h3>Schedule name: " . $this->getName() . "</h3>\n</div><div id=\"content\">".
*/
$footcloser = '';
if(isset($_REQUEST['print']) && $_REQUEST['print'] != ''){
$headcode = array('jQuery', 'outputStyle', 'outputPrintStyle');
}
else {
$footcloser .="<script type=\"text/javascript\" charset=\"utf-8\">".
"\n\tvar my_glider = new Glider('my-glider', {duration:0});".
"\n</script>";
$headcode = array('outputStyle', 'gliderHeadcode');
}
$outputPage = new page($this->getName(), $headcode);
if(isset($_REQUEST['print'])){
echo '<script type="text/javascript">';
echo 'jQuery(document).ready( function() {';
/* If user entered items to print */
if($_REQUEST['print'] != 'all'){
echo 'jQuery(\'.section\').hide();';
$items = explode(',', $_REQUEST['print']);
foreach($items as $item){
echo 'jQuery(\'#section'.$item.'\').show();';
}
}
echo 'jQuery(\'#selectItemsInput\').hide();
jQuery(\'#selectItems\').click( function() {
jQuery(\'#selectItemsInput\').show();
});
jQuery(\'#cancelItems\').click( function() {
jQuery(\'#selectItemsInput\').hide();
});';
echo '});'; /* Close document.ready */
echo 'window.print();
</script>';
echo '<p><span id="selectItems"><a href="#">Select Schedules to Print</a></span> :: <a href="'.$_SERVER["SCRIPT_NAME"].'?savedkey=0">Return to normal view</a> :: <a href="input.php">Home</a></p>';
echo '<div id="selectItemsInput"><p><form action="'.$_SERVER["SCRIPT_NAME"].'?savedkey=0"><label><strong>Schedules to Print</strong> <em>(seperate with commas, "all" for all)</em></label><br /><input type="text" name="print" value="'.$_REQUEST['print'].'" /><input type="submit" value="submit" /><span id="cancelItems"><input type="button" value="cancel" /></span></form></p></div>';
}
else {
echo '<p><a href="'.$_SERVER["SCRIPT_NAME"].'?savedkey=0&print=all">Print</a> :: <a href="input.php">Home</a></p>';
}
echo "<p>There were a total of " . $this->possiblePermutations . " possible permutations. Only " . $this->nPermutations . " permutations had no class conflicts.</p>";
if($this->nPermutations > 0)
{
$table .= "<div id=\"my-glider\">\n"
. " <div class=\"controls\">\n";
for($nn = 1; $nn <= $this->nPermutations; $nn++)
{
$table .= "<a href=\"#section" . $nn . "\"> " . $nn . " </a>";
}
$table .= " </div> <!-- class=\"controls\" -->\n"
. " <div class=\"scroller\">"
. " <div class=\"scontent\">";
for($i = 0; $i < $this->nPermutations; $i++)
{
$table .= "<div class=\"section\" id=\"section" . ($i+1) . "\">";
// Beginning of table
$table .= "<table style=\"empty-cells:show;\" border=\"1\" cellspacing=\"0\">";
// Header row
$table .= "\n\t<tr>\n\t\t<td class=\"none\">" . ($i+1) . "</td>\n\t\t<td class=\"day\">Monday</td>\n\t\t<td class=\"day\">Tuesday</td>\n\t\t<td class=\"day\">Wednesday</td>\n\t\t<td class=\"day\">Thursday</td>\n\t\t<td class=\"day\">Friday</td>\n\t</tr>";
for($r = 0; $r < (count($time)-1); $r++)
{
// Beginning of new row
$temp = $time[$r];
if($temp > 1259)
{
$temp = $temp-1200;
}
$table .= "\n\t<tr>\n\t\t<td class=\"time\">" . $this->prettyTime($time[$r]) . "</td>";
//---------------MONDAY---------------
for($j = 0; $j < $this->nclasses; $j++)
{
if($M == -1)
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getM())
{
if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1]))
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
{
$table .= "\n\t\t<td class=\"top\">" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "</td>";
$M = $j;
$filled = true;
} else {
$table .= "\n\t\t<td class=\"single\">" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "</td>";
$filled = true;
}
}
}
} else {
if($j == $M)
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
{
$table .= "\n\t\t<td class=\"mid\"> </td>";
$filled = true;
} else {
$table .= "\n\t\t<td class=\"end\"> </td>";
$M = -1;
$filled = true;
}
}
}
}
// If the cell was not filled, fill it with an empty cell.
if(!$filled)
{
$table .= "\n\t\t<td class=\"none\"> </td>";
}
$filled = false;
//---------------TUESDAY---------------
for($j = 0; $j < $this->nclasses; $j++)
{
if($Tu == -1)
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getTu())
{
if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1]))
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
{
$table .= "\n\t\t<td class=\"top\">" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "</td>";
$Tu = $j;
$filled = true;
} else {
$table .= "\n\t\t<td class=\"single\">" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "</td>";
$filled = true;
}
}
}
} else {
if($j == $Tu)
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
{
$table .= "\n\t\t<td class=\"mid\"> </td>";
$filled = true;
} else {
$table .= "\n\t\t<td class=\"end\"> </td>";
$Tu = -1;
$filled = true;
}
}
}
}
// If the cell was not filled, fill it with an empty cell.
if(!$filled)
{
$table .= "\n\t\t<td class=\"none\"> </td>";
}
$filled = false;
//---------------WEDNESDAY---------------
for($j = 0; $j < $this->nclasses; $j++)
{
if($W == -1)
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getW())
{
if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1]))
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
{
$table .= "\n\t\t<td class=\"top\">" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "</td>";
$W = $j;
$filled = true;
} else {
$table .= "\n\t\t<td class=\"single\">" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "</td>";
$filled = true;
}
}
}
} else {
if($j == $W)
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
{
$table .= "\n\t\t<td class=\"mid\"> </td>";
$filled = true;
} else {
$table .= "\n\t\t<td class=\"end\"> </td>";
$W = -1;
$filled = true;
}
}
}
}
// If the cell was not filled, fill it with an empty cell.
if(!$filled)
{
$table .= "\n\t\t<td class=\"none\"> </td>";
}
$filled = false;
//---------------THURSDAY---------------
for($j = 0; $j < $this->nclasses; $j++)
{
if($Th == -1)
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getTh())
{
if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1]))
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
{
$table .= "\n\t\t<td class=\"top\">" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "</td>";
$Th = $j;
$filled = true;
} else {
$table .= "\n\t\t<td class=\"single\">" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "</td>";
$filled = true;
}
}
}
} else {
if($j == $Th)
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
{
$table .= "\n\t\t<td class=\"mid\"> </td>";
$filled = true;
} else {
$table .= "\n\t\t<td class=\"end\"> </td>";
$Th = -1;
$filled = true;
}
}
}
}
// If the cell was not filled, fill it with an empty cell.
if(!$filled)
{
$table .= "\n\t\t<td class=\"none\"> </td>";
}
$filled = false;
//---------------FRIDAY---------------
for($j = 0; $j < $this->nclasses; $j++)
{
if($F == -1)
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getF())
{
if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1]))
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
{
$table .= "\n\t\t<td class=\"top\">" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "</td>";
$F = $j;
$filled = true;
} else {
$table .= "\n\t\t<td class=\"single\">" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "</td>";
$filled = true;
}
}
}
} else {
if($j == $F)
{
if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
{
$table .= "\n\t\t<td class=\"mid\"> </td>";
$filled = true;
} else {
$table .= "\n\t\t<td class=\"end\"> </td>";
$F = -1;
$filled = true;
}
}
}
}
// If the cell was not filled, fill it with an empty cell.
if(!$filled)
{
$table .= "\n\t\t<td class=\"none\"> </td>";
}
$filled = false;
// End of row
$table .= "\n\t</tr>";
}
// End of table
$table .= '</table></div> <!-- id="section' . ($i + 1) . "\" -->\n";
}
echo $table
. " </div> <!-- class=\"scontent\" -->\n"
. " </div> <!-- class=\"scroller\" -->\n"
. "</div> <!-- id=\"my-glider\" -->\n"
. $footcloser; // Closes off the content div
} else {
echo '<html><body><p>There are no possible schedules. Please try again.</p></body></html>';
}
/* edit button */
if (!isset($savedkey))
{
if (isset($_REQUEST['savedkey']))
$savedkey = (int)$_REQUEST['savedkey'];
else
/*
* if this is a new saved schedule, it'll be the
* next item added to $_SESSION['saved']
*/
$savedkey = max(array_keys($_SESSION['saved'])) + 1;
}
echo '<form method="get" action="input.php"><p><input type="hidden" name="savedkey" value="' . $savedkey . '" /><input type="submit" value="edit" /></p></form>';
$outputPage->foot();
}
/**
* \brief
* Render the input table form for editing a saved schedule in input.php.
*
* This function's output must be synchronized with the
* associated javascript in scripts/scheduleInput.js.
*/
function input_form_render()
{
$out = '';
static $n = "\n";
foreach ($this->classStorage as $class_key => $class)
$out .= $class->input_form_render($class_key);
return $out;
}
//--------------------------------------------------
// Changes the title of the page.
//--------------------------------------------------
function changeTitle($t)
{
$this->title = $t;
}
//--------------------------------------------------
// Make the time "pretty."
//--------------------------------------------------
function prettyTime($t){
if($t > 1259)
{
$t = ($t-1200);
return substr($t, 0, strlen($t)-2) . ":" . substr($t, strlen($t)-2, strlen($t)) . " PM";
} else {
return substr($t, 0, strlen($t)-2) . ":" . substr($t, strlen($t)-2, strlen($t)) . " AM";
}
}
/**
* \brief
* fetch the number of classes
*/
function nclasses_get()
{
return $this->nclasses;
}
/*
* \brief
* fetch a specified class by its key
*/
function class_get($class_key)
{
return $this->classStorage[$class_key];
}
}
|