function arrange() { global $ttlb, $ttli, $ttlt, $totalt, $totali, $totalb, $b, $e, $nodept, $width, $header, $pdf, $width, $height, $printdpt, $curhal, $print_hal; global $allhalls, $hall_no, $arr; $pdf->SetFont('Helvetica', '', 14); $pdf->AddPage(); $pdf->ImprovedTable($header, $width, $height); //$a = 1; $m; $retry = 0; $e12=1; $e13 = 1; $temp78 = 0; $n = 0; //local $temp88 $ttlt = counting('t'); $ttli = counting('i'); $hallcounter = -1; add('r', $ttlb); while ($ttli < $ttlb) { //echo '<br>beginning $ttli = '.$ttli.' $ttlb = '.$ttlb.'<br>';//for check!!! //echo '<br><b>New Hall:</b><br>';//for check!!! $hallcounter = $hallcounter + 1; //counts the hall number $curhal = $allhalls[$hallcounter]; //[$hallcounter]; //saves current hall inside $curhal for pdf use $hall_no = $hallcounter; $print_hal = 1; $arr = 'arr'; //echo '<b>'.$curhal.'</b><br>';//for check!!!! for ($z = 0; $z < 90; $z = nextdpt($z)) { $totalt[$z] = $totalb[$z] - $totali[$z]; } $ttlt = counting('t'); $ttli = counting('i'); if ($e == 12 || $e == 0) { $e = 13; } elseif ($e == 13) { $e = 12; } if ($ttlb <= 25) { for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] != 0) { ezar($z, $totalt[$z]); } } } elseif ($e == 13) { for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] > 14 || $totalt[$z] == 13) { //echo '<br>forcing ezar in 13<br>';//for check!!! ezar($z, 13); //echo '<br>forcing sub_ar in 13<br>';//for check!!! sub_ar($z, 12); //echo '<br>end sub_ar<br>';//for check!! $temp78 = 1; break; } } if ($temp78 != 1) { if ($n != 2) { //if dept contains 12 $n = 1; } else { //if not even 1 dept contains 12 $n = 2; } } $temp78 = 0; } elseif ($e == 12) { for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] > 13 || $totalt[$z] == 12) { ezar($z, 12); //echo 'hi sub<br>';//used to check whether an error has occured within this fn or sub_ar() sub_ar($z, 13); //echo 'bye sub';//same as above $temp78 = 1; break; } } if ($temp78 != 1) { $n = 2; } $temp78 = 0; } if ($n == 1) { for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] > 13 || $totalt[$z] == 12) { ezar($z, 12); sub_ar($z, 13); $temp78 = 1; break; } } if ($temp78 != 1) { $n = 2; } else { $n = 0; } $temp78 = 0; } if ($n == 2) { $temp78 = 0; for ($z = 0; $z < 90; $z = nextdpt($z)) { $temp88 = $temp78 + $totalt[$z]; if ($temp88 < 26 && $temp88 != 24 && $totalt[$z] != 0) { $temp78 = $temp78 + $totalt[$z]; ezar($z, $totalt[$z]); } } if ($temp78 <= 24) { //find large and get the rest //$z = large($z, 1) $temp88 = 25 - $temp78; //echo '$temp88 '.$temp88; //for check!!!!!! for ($z = 0; $z < 90; $z = nextdpt($z)) { $temp104 = $totalt[$z] - $temp88; if ($temp104 != 1 && $totalt[$z] != 0) { $temp78 = 25; ezar($z, $temp88); break; } } } $temp78 = 0; $n = 0; } //echo 'end $ttli = '.$ttli.' $ttlb = '.$ttlb.'<br><br>'; // for check!!!! } }
function arrange() { global $ttlb, $ttli, $ttlt, $totalt, $totali, $totalb, $b, $e, $nodept, $width, $header, $pdf, $width, $height, $printdpt, $curhal; $a = 1; $m; $retry = 0; $e12 = 1; $e13 = 1; while ($ttli < $ttlb) { $z = 0; while ($z < 90) { $totalt[$z] = $totalb[$z] - $totali[$z]; $z = nextdpt($z); } $ttli = counting('i'); $ttlt = counting('t'); $z = 0; if ($e == 12 || $e == 0) { $e = 13; } elseif ($e == 13) { $e = 12; } if ($ttlt <= 25) { //ec1ho "<b><br>1Exam Room No. ".$a."</b><br>"; for ($i = 0; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'TLR'); } $pdf->Ln(); $pdf->SetFont('', 'B'); //$curhal = 'D1'; $curhal = nexthal($curhal); $pdf->myCell($width[0], $height[1], $curhal, 'LR'); $printdpt = 1; $pdf->SetFont(''); $a = $a + 1; for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] != 0) { $temp22 = $totalt[$z]; ezar($z, $temp22); $pdf->myCell($width[0], $height[2], '', 'LR'); for ($i = 1; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'BLR'); } $pdf->Ln(); $printdpt = 0; } } for ($i = 0; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'BLR'); } $pdf->Ln(); } elseif ($e == 13) { $n = 0; for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] >= 13 && $totalt[$z] != 14) { //ec1ho "<b><br>2Exam Room No. ".$a."</b><br>"; for ($i = 0; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'TLR'); } $pdf->Ln(); $pdf->SetFont('', 'B'); //$curhal = 'D2'; $curhal = nexthal($curhal); $pdf->myCell($width[0], $height[1], $curhal, 'LR'); $pdf->SetFont(''); $printdpt = 1; $a = $a + 1; ezar($z, $e); $printdpt = 0; $pdf->myCell($width[0], $height[2], '', 'LR'); for ($i = 1; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'BLR'); } $pdf->Ln(); sub_ar($z, $e); for ($i = 0; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'BLR'); } $pdf->Ln(); $n = 0; $e13 = 1; break; } $n = 1; $e13 = $e13 + 1; } } elseif ($e == 12) { $n = 0; for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] >= 12 && $totalt[$z] != 13) { //ec1ho "<b><br>3Exam Room No. ".$a."</b><br>"; for ($i = 0; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'TLR'); } $pdf->Ln(); $pdf->SetFont('', 'B'); //$curhal = 'D3'; $curhal = nexthal($curhal); $pdf->myCell($width[0], $height[1], $curhal, 'LR'); $pdf->SetFont(''); $printdpt = 1; $a = $a + 1; ezar($z, $e); $pdf->myCell($width[0], $height[2], '', 'LR'); for ($i = 1; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'BLR'); } $pdf->Ln(); $printdpt = 0; sub_ar($z, $e); for ($i = 0; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'BLR'); } $pdf->Ln(); $n = 0; $e12 = 1; break; } $n = 1; $e12 = $e12 + 1; } } if (isset($n) && $e12 > 1 && $e13 > 1 && $ttlt != 0) { if ($n == 1) { //ec1ho "<b><br>4Exam Room No. ".$a."</b><br>"; for ($i = 0; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'TLR'); } $pdf->Ln(); $pdf->SetFont('', 'B'); //$curhal = 'D4'; $curhal = nexthal($curhal); for ($i = 0; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[1], '', 'BLR'); } $pdf->Ln(); $pdf->myCell($width[0], $height[1], 'S4', 'LR'); $pdf->SetFont(''); $a = $a + 1; $temp84 = 0; $z = 0; $printdpt = 1; while ($temp84 < 26 && $z < 90) { if ($temp84 + $totalt[$z] < 26 && $totalt[$z] != 0) { $temp84 = $temp84 + $totalt[$z]; ezar($z, $totalt[$z]); $pdf->myCell($width[0], $height[2], '', 'LR'); for ($i = 1; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'BLR'); } $pdf->Ln(); //$pdf->AddPage(); $printdpt = 0; } $z = nextdpt($z); } for ($i = 0; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'BLR'); } $pdf->Ln(); } } /*if($n == 1) // if there exists no 12 or 13 in all depts { $k = 0; $trial = 0;// 0 adds largest value // 1 adds smallest value // 2 subdivision $sub = 0; if($e == 13) { while($k <= 12) { if($trial == 0) { $z = large($totalt); $m = $totalt[$z]; if(($k + $m) <= 13 && $m != 0 && ($k + $m) != 12) { $k = $k + $m; ezar($z, $m); } else $trial = 1; $temp88 = 1; } elseif($trial == 1) { $z = least($totalt); $m = $totalt[$z]; if(($k + $m) <= 13 && $m != 0 && ($k + $m) != 12) { $k = $k + $m; ezar($z, $m); } else $trial = 2; $temp88 = 0; } elseif($trial == 2) { $z = least2($totalt); $m = $totalt[$z]; if(($k + $m) <= 13 && $m != 0 && ($k + $m) != 12) { $k = $k + $m; ezar($z, $m); } else $trial = 2; $temp88 = 0; } elseif($trial == 3) { $z = least_2($totalt); $m = $totalt[$z]; e1cho "z".$z."m".$m."<br>"; print_r($totalt); $sub = 0; while($k <= 13 && $m != 0) { if(($k + $m) < 14 && ($k + $m) != 12) { $sub = $sub + $m; $k = $k + $m; } $m = subdivide($m); } ezar($z, $sub); } } sub_ar(0 , $e); } elseif($e == 12) { while($k <= 11) { if($trial == 0) { $z = large13($totalt); $m = $totalt[$z]; if(($k + $m) <= 12 && $m != 0 && ($k + $m) != 11) { $k = $k + $m; ezar($z, $m); } else $trial = 1; $temp88 = 1; } elseif($trial == 1) { $z = least13($totalt); $m = $totalt[$z]; if(($k + $m) <= 12 && $m != 0 && ($k + $m) != 11) { $k = $k + $m; ezar($z, $m); } else $trial = 2; } elseif($trial == 2) { $z = least132($totalt); $m = $totalt[$z]; if(($k + $m) <= 12 && $m != 0 && ($k + $m) != 11) { $k = $k + $m; ezar($z, $m); } else $trial = 3; } elseif($trial == 3) {/* if($k == 11) { $z = large13($totalt); $m = $totalt[$z]; }/ $z = least13_2($totalt); e1cho "z=".$z."m=".$m."<br>"; print_r($totalt); e1cho "<br>"; $m = $totalt[$z]; $sub = 0; while($m != 0) { if(($k + $m) <= 12 && ($k + $m) != 11) { $sub = $sub + $m; $k = $k + $m; } $m = subdivide($m); } ezar($z, $sub); } } sub_ar(0 , $e); } }*/ } }