function sub_ar($c, $a) { global $f, $totali, $totalt, $totalb, $ttlb, $ttlt, $ttli, $nodept, $pdf, $width, $height, $header, $arr, $its13; $n = 0; $temp78 = 0; $temp88 = 0; // $m = 0; $proceed = 0; //echo '<br>entering sub_ar<br>';//forcheck!!!!! $arr = 'sub'; if ($a == 12) { for ($z = 0; $z < 90; $z = nextdpt($z)) { //regular arrangment which searches for 12 reg nos in other dept if ($z != $c && $totalt[$z] > 11 && $totalt[$z] != 13) { ezar($z, $a); $n = 1; break; } } if ($n != 1) { for ($z = 0; $z < 90; $z = nextdpt($z)) { $temp88 = $temp78 + $totalt[$z]; if ($temp78 < $a && $totalt[$z] != 0 && $temp88 != 1 && $temp88 <= $a && $z != $c) { $temp78 = $temp78 + $totalt[$z]; ezar($z, $totalt[$z]); } elseif ($temp78 == $a) { //for speed processing break; } //echo '<br>'.$temp78.' and a is '.$a.'<br>';//for check!!!! } if ($temp78 != $a && $totalt[$c] == 0) { $temp88 = $a - $temp78; for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] >= $temp88 && $totalt[$z] - $temp88 != 1 && $temp88 != 1) { $temp78 = $a; //echo 'not fulfilled at 12 and temp = '.$temp88;//for check!!! ezar($z, $temp88); break; } } } elseif ($temp78 != $a && $totalt[$c] != 0) { $temp88 = $a - $temp78; if ($temp88 > $totalt[$c]) { //if same dept doesnot contain sufficient reg nos $temp88 = $totalt[$c]; } ezar($c, $temp88); $temp78 = $a; } } } elseif ($a == 13) { $its13 = 1; for ($z = 0; $z < 90; $z = nextdpt($z)) { //regular arrangment which searches for 13 reg nos in other dept if ($z != $c && $totalt[$z] > 12 && $totalt[$z] != 14) { ezar($z, $a); $n = 1; break; } } if ($n != 1) { for ($z = 0; $z < 90; $z = nextdpt($z)) { $temp88 = $temp78 + $totalt[$z]; if ($temp78 < $a && $totalt[$z] != 0 && $temp88 != 1 && $temp88 <= $a && $z != $c) { $temp78 = $temp78 + $totalt[$z]; ezar($z, $totalt[$z]); } elseif ($temp78 == $a) { //for speed processing break; } } if ($temp78 != $a && $totalt[$c] == 0) { $temp88 = $a - $temp78; for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] >= $temp88 && $totalt[$z] - $temp88 != 1 && $temp88 != 1) { $temp78 = $a; //echo 'not fulfilled at 13 and temp = '.$temp88;//for check!!! ezar($z, $temp88); break; } } } elseif ($temp78 != $a && $totalt[$c] != 0) { $temp88 = $a - $temp78; if ($temp88 > $totalt[$c]) { //if same dept doesnot contain sufficient reg nos $temp88 = $totalt[$c]; } ezar($c, $temp88); $temp78 = $a; } } } }
function sub_ar($c, $a) { global $f, $totali, $totalt, $totalb, $ttlb, $ttlt, $ttli, $nodept, $pdf, $width, $height, $header; $n = 0; $m = 0; $proceed = 0; if ($a == 13) { $f = 12; } elseif ($a == 12) { $f = 13; } else { $f = 0; } if ($ttlt < 13 && $f == 12) { for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] != 0) { $temp32 = $totalt[$z]; ezar($z, $temp32); $proceed = 1; } } } elseif ($ttlt <= 13 && $f == 13) { for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] != 0) { $temp32 = $totalt[$z]; ezar($z, $temp32); $proceed = 1; } } } elseif ($f == 13) { $n = 0; for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] >= 13 && $totalt[$z] != 14 && $z != $c) { ezar($z, $f); $n = 0; $proceed = 1; break; } $n = 1; } } elseif ($f == 12) { $n = 0; for ($z = 0; $z < 90; $z = nextdpt($z)) { if ($totalt[$z] >= 12 && $totalt[$z] != 13 && $z != $c) { ezar($z, $f); $n = 0; $proceed = 1; break; } $n = 1; } } if ($n == 1) { $temp78 = 0; if ($f == 13) { $z = 0; while ($temp78 < 14 && $z < 90) { if ($temp78 + $totalt[$z] < 14 && $totalt[$z] != 0) { $temp78 = $temp78 + $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(); $proceed = 1; } $z = nextdpt($z); } if ($temp78 < 14 && $temp78 != $f) { $tetotal = $f - $temp78; //if($tetotal == 1) //{ if ($totalt[$c] != 0) { ezar($c, $tetotal); $pdf->myCell($width[0], $height[2], '', 'LR'); for ($i = 1; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'BLR'); } $pdf->Ln(); } $proceed = 1; $temp78 = $f; /* } else { $templarge = $totalt[0]; for($z = 0; $z<90; $z = nextdpt($z)) { if( ($templarge < $totalt[$z]) && ($z != $c) ) { $templarge = $totalt[$z]; } } }*/ } } elseif ($f == 12) { $z = 0; while ($temp78 < 13 && $z < 90) { if ($temp78 + $totalt[$z] < 13 && $totalt[$z] != 0) { $temp78 = $temp78 + $totalt[$z]; ezar($z, $totalt[$z]); $proceed = 1; $pdf->myCell($width[0], $height[2], '', 'LR'); for ($i = 1; $i < count($header); $i++) { $pdf->myCell($width[$i], $height[2], '', 'BLR'); } $pdf->Ln(); } $z = nextdpt($z); } if ($temp78 < 13 && $temp78 != $f) { ezar($c, $f - $temp78); $proceed = 1; $temp78 = $f; } } } if ($proceed == 0) { ezar($c, $f); } /* if($n == 1) //if there exists no 12 or 13 in a dept { $k = 0; $trial = 0;// 0 adds largest value // 1 adds smallest value // 2 subdivision $sub = 0; if($f == 13) { while($k <= 12) { if($trial == 0) { $z = large13($totalt); $m = $totalt[$z]; if(($k + $m) <= 13 && $m != 0) { $k = $k + $m; ezar($z, $m); } else $trial = 1; $temp88 = 1; } elseif($trial == 1) { $z = least13($totalt); $m = $totalt[$z]; if(($k + $m) <= 13 && $m != 0) { $k = $k + $m; ezar($z, $m); } else $trial = 2; $temp88 = 0; } elseif($trial == 2) { $z = least13($totalt); $m = $totalt[$z]; $sub = 0; while($k <= 13 && $m != 0) { if(($k + $m) < 14) { $sub = $sub + $m; $k = $k + $m; } $m = subdivide($m); } ezar($z, $sub); } } } elseif($f == 12) { while($k <= 11) { if($trial == 0) { $z = large($totalt); $m = $totalt[$z]; if(($k + $m) <= 12 && $m != 0) { $k = $k + $m; ezar($z, $m); } else $trial = 1; $temp88 = 1; } elseif($trial == 1) { $z = least($totalt); $m = $totalt[$z]; if(($k + $m) <= 12 && $m != 0) { $k = $k + $m; ezar($z, $m); } else $trial = 2; $temp88 = 0; } elseif($trial == 2) { $z = least($totalt); $m = $totalt[$z]; $sub = 0; while($m != 0) { if(($k + $m) <= 12) { $sub = $sub + $m; $k = $k + $m; } $m = subdivide($m); } ezar($z, $sub); } } } }*/ }