PageRenderTime 43ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/functions/ListOutput.fnc.php

https://bitbucket.org/Mab879/johtaja-schools
PHP | 6500 lines | 6333 code | 97 blank | 70 comment | 274 complexity | de456a62b92e4d06deddf339118472b4 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. #**************************************************************************
  3. # openSIS is a free student information system for public and non-public
  4. # schools from Open Solutions for Education, Inc. web: www.os4ed.com
  5. #
  6. # openSIS is web-based, open source, and comes packed with features that
  7. # include student demographic info, scheduling, grade book, attendance,
  8. # report cards, eligibility, transcripts, parent portal,
  9. # student portal and more.
  10. #
  11. # Visit the openSIS web site at http://www.opensis.com to learn more.
  12. # If you have question regarding this system or the license, please send
  13. # an email to info@os4ed.com.
  14. #
  15. # This program is released under the terms of the GNU General Public License as
  16. # published by the Free Software Foundation, version 2 of the License.
  17. # See license.txt.
  18. #
  19. # This program is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. # GNU General Public License for more details.
  23. #
  24. # You should have received a copy of the GNU General Public License
  25. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. #
  27. #***************************************************************************************
  28. function ListOutput($result,$column_names,$singular='',$plural='',$link=false,$group=false,$options=false,$for_window='')
  29. {
  30. if(!isset($options['save']))
  31. $options['save'] = true;
  32. if(!isset($options['print']))
  33. $options['print'] = true;
  34. if(!isset($options['search']))
  35. $options['search'] = true;
  36. if(!isset($options['center']))
  37. $options['center'] = true;
  38. if(!isset($options['count']))
  39. $options['count'] = true;
  40. if(!isset($options['sort']))
  41. $options['sort'] = true;
  42. if(!$link)
  43. $link = array();
  44. if(isset($_REQUEST['page'])){
  45. if($_REQUEST['list_type']==$singular){
  46. $Request_page=$_REQUEST['page'];
  47. }
  48. }
  49. if(!isset($options['add']))
  50. {
  51. if(!AllowEdit() || $_REQUEST['_openSIS_PDF'])
  52. {
  53. if($link)
  54. {
  55. unset($link['add']);
  56. unset($link['remove']);
  57. }
  58. }
  59. }
  60. // PREPARE LINKS ---
  61. $result_count = $display_count = count($result);
  62. $num_displayed = 150;
  63. $extra = "page=$_REQUEST[page]&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search']);
  64. $tmp_REQUEST = $_REQUEST;
  65. unset($tmp_REQUEST['page']);
  66. unset($tmp_REQUEST['LO_sort']);
  67. unset($tmp_REQUEST['LO_direction']);
  68. unset($tmp_REQUEST['LO_search']);
  69. unset($tmp_REQUEST['remove_prompt']);
  70. unset($tmp_REQUEST['remove_name']);
  71. unset($tmp_REQUEST['LO_save']);
  72. unset($tmp_REQUEST['PHPSESSID']);
  73. $PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);
  74. // END PREPARE LINKS ---
  75. // UN-GROUPING
  76. $group_count = count($group);
  77. if(!is_array($group))
  78. $group_count = false;
  79. //$side_color = Preferences('COLOR');
  80. $side_color = 'class=odd';
  81. if($group_count && $result_count)
  82. {
  83. $color = 'class=even';
  84. $group_result = $result;
  85. unset($result);
  86. $result[0] = '';
  87. foreach($group_result as $item1)
  88. {
  89. if($group_count==1)
  90. {
  91. if($color=='class=even')
  92. $color = $side_color;
  93. else
  94. $color = 'class=even';
  95. }
  96. foreach($item1 as $item2)
  97. {
  98. if($group_count==1)
  99. {
  100. $i++;
  101. if(count($group[0]) && $i!=1)
  102. {
  103. foreach($group[0] as $column)
  104. $item2[$column] = str_replace('<!-- <!--','<!--','<!-- '.str_replace('-->','--><!--',$item2[$column])).' -->';
  105. }
  106. $item2['row_color'] = $color;
  107. $result[] = $item2;
  108. }
  109. else
  110. {
  111. if($group_count==2)
  112. {
  113. if($color=='class=even')
  114. $color = $side_color;
  115. else
  116. $color = 'class=even';
  117. }
  118. foreach($item2 as $item3)
  119. {
  120. if($group_count==2)
  121. {
  122. $i++;
  123. if(count($group[0]) && $i!=1)
  124. {
  125. foreach($group[0] as $column)
  126. $item3[$column] = '<!-- '.$item3[$column].' -->';
  127. }
  128. if(count($group[1]) && $i!=1)
  129. {
  130. foreach($group[1] as $column)
  131. $item3[$column] = '<!-- '.$item3[$column].' -->';
  132. }
  133. $item3['row_color'] = $color;
  134. $result[] = $item3;
  135. }
  136. else
  137. {
  138. if($group_count==3)
  139. {
  140. if($color=='class=even')
  141. $color = $side_color;
  142. else
  143. $color = 'class=even';
  144. }
  145. foreach($item3 as $item4)
  146. {
  147. if($group_count==3)
  148. {
  149. $i++;
  150. if(count($group[2]) && $i!=1)
  151. {
  152. foreach($group[2] as $column)
  153. unset($item4[$column]);
  154. }
  155. $item4['row_color'] = $color;
  156. $result[] = $item4;
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. $i = 0;
  164. }
  165. unset($result[0]);
  166. $result_count = count($result);
  167. unset($_REQUEST['LO_sort']);
  168. }
  169. // END UN-GROUPING
  170. $_LIST['output'] = true;
  171. // PRINT HEADINGS, PREPARE PDF, AND SORT THE LIST ---
  172. if($_LIST['output']!=false)
  173. {
  174. if($result_count != 0)
  175. {
  176. $count = 0;
  177. $remove = count($link['remove']['variables']);
  178. $cols = count($column_names);
  179. // HANDLE SEARCHES ---
  180. if($result_count && $_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')
  181. {
  182. $_REQUEST['LO_search'] = $search_term = str_replace('\\\"','"',$_REQUEST['LO_search']);
  183. $_REQUEST['LO_search'] = $search_term = ereg_replace('[^a-zA-Z0-9 _"]*','',strtolower($search_term));
  184. if(substr($search_term,0,0)!='"' && substr($search_term,-1)!='"')
  185. {
  186. $search_term = ereg_replace('"','',$search_term);
  187. while($space_pos = strpos($search_term,' '))
  188. {
  189. $terms[strtolower(substr($search_term,0,$space_pos))] = 1;
  190. $search_term = substr($search_term,($space_pos+1));
  191. }
  192. $terms[trim($search_term)] = 1;
  193. }
  194. else
  195. {
  196. $search_term = ereg_replace('"','',$search_term);
  197. $terms[trim($search_term)] = 1;
  198. }
  199. unset($terms['of']); unset($terms['the']); unset($terms['a']); unset($terms['an']); unset($terms['in']);
  200. foreach($result as $key=>$value)
  201. {
  202. $values[$key] = 0;
  203. foreach($value as $name=>$val)
  204. {
  205. $val = ereg_replace('[^a-zA-Z0-9 _]+','',strtolower($val));
  206. if(strtolower($_REQUEST['LO_search'])==$val)
  207. $values[$key] += 25;
  208. foreach($terms as $term=>$one)
  209. {
  210. if(ereg($term,$val))
  211. $values[$key] += 3;
  212. }
  213. }
  214. if($values[$key]==0)
  215. {
  216. unset($values[$key]);
  217. unset($result[$key]);
  218. $result_count--;
  219. $display_count--;
  220. }
  221. }
  222. if($result_count)
  223. {
  224. array_multisort($values,SORT_DESC,$result);
  225. $result = ReindexResults($result);
  226. $values = ReindexResults($values);
  227. $last_value = 1;
  228. $scale = (100/$values[$last_value]);
  229. for($i=$last_value;$i<=$result_count;$i++)
  230. $result[$i]['RELEVANCE'] = '<!--' . ((int) ($values[$i]*$scale)) . '--><IMG SRC="assets/pixel_grey.gif" width=' . ((int) ($values[$i]*$scale)) . ' height=10>';
  231. }
  232. $column_names['RELEVANCE'] = "Relevance";
  233. if(is_array($group) && count($group))
  234. {
  235. $options['count'] == false;
  236. $display_zero = true;
  237. }
  238. }
  239. // END SEARCHES ---
  240. if($_REQUEST['LO_sort'])
  241. {
  242. foreach($result as $sort)
  243. {
  244. if(substr($sort[$_REQUEST['LO_sort']],0,4)!='<!--')
  245. $sort_array[] = $sort[$_REQUEST['LO_sort']];
  246. else
  247. $sort_array[] = substr($sort[$_REQUEST['LO_sort']],4,strpos($sort[$_REQUEST['LO_sort']],'-->')-5);
  248. }
  249. if($_REQUEST['LO_direction']==-1)
  250. $dir = SORT_DESC;
  251. else
  252. $dir = SORT_ASC;
  253. if($result_count>1)
  254. {
  255. if(is_int($sort_array[1]) || is_double($sort_array[1]))
  256. array_multisort($sort_array,$dir,SORT_NUMERIC,$result);
  257. else
  258. array_multisort($sort_array,$dir,$result);
  259. for($i=$result_count-1;$i>=0;$i--)
  260. $result[$i+1] = $result[$i];
  261. unset($result[0]);
  262. }
  263. }
  264. }
  265. // HANDLE SAVING THE LIST ---
  266. if($_REQUEST['LO_save']=='1')
  267. {
  268. if(!$options['save_delimiter'] && Preferences('DELIMITER')=='CSV')
  269. $options['save_delimiter'] = 'comma';
  270. switch($options['save_delimiter'])
  271. {
  272. case 'comma':
  273. $extension = 'csv';
  274. break;
  275. case 'xml':
  276. $extension = 'xml';
  277. break;
  278. default:
  279. $extension = 'xls';
  280. break;
  281. }
  282. ob_end_clean();
  283. if($options['save_delimiter']!='xml')
  284. {
  285. foreach($column_names as $key=>$value)
  286. $output .= str_replace('&nbsp;',' ',eregi_replace('<BR>',' ',ereg_replace('<!--.*-->','',$value))) . ($options['save_delimiter']=='comma'?',':"\t");
  287. $output .= "\n";
  288. }
  289. foreach($result as $item)
  290. {
  291. foreach($column_names as $key=>$value)
  292. {
  293. if($options['save_delimiter']=='comma' && !$options['save_quotes'])
  294. $item[$key] = str_replace(',',';',$item[$key]);
  295. $item[$key] = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$item[$key]);
  296. $item[$key] = eregi_replace('<SELECT.*</SELECT\>','',$item[$key]);
  297. $output .= ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='xml'?'<'.str_replace(' ','',$value).'>':'') . ereg_replace('<[^>]+>','',ereg_replace("<div onclick='[^']+'>",'',ereg_replace(' +',' ',ereg_replace('&[^;]+;','',str_replace('<BR>&middot;',' : ',str_replace('&nbsp;',' ',$item[$key])))))) . ($options['save_delimiter']=='xml'?'</'.str_replace(' ','',$value).'>'."\n":'') . ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='comma'?',':"\t");
  298. }
  299. $output .= "\n";
  300. }
  301. header("Cache-Control: public");
  302. header("Pragma: ");
  303. header("Content-Type: application/$extension");
  304. header("Content-Disposition: inline; filename=\"".ProgramTitle().".$extension\"\n");
  305. if($options['save_eval'])
  306. eval($options['save_eval']);
  307. echo $output;
  308. exit();
  309. }
  310. // END SAVING THE LIST ---
  311. if($options['center'])
  312. #echo '<CENTER>';
  313. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  314. {
  315. #echo "<TABLE border=0 cellspacing=3 cellpadding=6>" ;
  316. if(isset($_REQUEST['_openSIS_PDF']))
  317. #echo " width=98%";
  318. echo " <TR><TD align=center>";
  319. }
  320. if($options['count'] || $display_zero)
  321. {
  322. if(($result_count==0 || $display_count==0) && $plural)
  323. echo "<div style=text-align:left><table cellpadding=5 cellspacing=5 class=alert_box ><tr><td class=alert></td><td class=alert_msg ><b>No $plural were found.</b></td></tr><tr><td colspan=2 class=clear></td></tr></table></div>";
  324. elseif($result_count==0 || $display_count==0)
  325. echo '<div style=text-align:left><table cellpadding=5 cellspacing=5 class=alert_box ><tr><td class=alert></td><td class=alert_msg ><b>None were found.</b></td></tr><tr><td colspan=2 class=clear></td></tr></table></div>';
  326. }
  327. if($result_count != 0 || ($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search'))
  328. {
  329. if(!isset($_REQUEST['_openSIS_PDF']))
  330. {
  331. if(!$Request_page)
  332. $Request_page = 1;
  333. if(!$_REQUEST['LO_direction'])
  334. $_REQUEST['LO_direction'] = 1;
  335. $start = ($Request_page - 1) * $num_displayed + 1;
  336. $stop = $start + ($num_displayed-1);
  337. if($stop > $result_count)
  338. $stop = $result_count;
  339. if($result_count > $num_displayed)
  340. {
  341. echo $where_message = "<strong><br>
  342. $start through $stop</strong>";
  343. echo "<div style=text-align:right;margin-top:-14px;padding-right:15px><strong>Go to Page ";
  344. if(ceil($result_count/$num_displayed) <= 10)
  345. {
  346. for($i=1;$i<=ceil($result_count/$num_displayed);$i++)
  347. {
  348. if($i!=$Request_page){
  349. if($for_window=='for_window'){
  350. $pages .= "<A HREF=".str_replace('Modules.php', 'for_window.php', $PHP_tmp_SELF)."&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i&list_type=$singular>$i</A>, ";
  351. }else{
  352. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i&list_type=$singular>$i</A>, ";
  353. }
  354. }else{
  355. $pages .= "$i, ";}
  356. }
  357. $pages = substr($pages,0,-2) ;
  358. }
  359. else
  360. {
  361. for($i=1;$i<=7;$i++)
  362. {
  363. if($i!=$Request_page)
  364. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  365. else
  366. $pages .= "$i, ";
  367. }
  368. $pages = substr($pages,0,-2) . " ... ";
  369. for($i=ceil($result_count/$num_displayed)-2;$i<=ceil($result_count/$num_displayed);$i++)
  370. {
  371. if($i!=$Request_page)
  372. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  373. else
  374. $pages .= "$i, ";
  375. }
  376. $pages = substr($pages,0,-2) . " &nbsp;<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=" . ($Request_page +1) . ">Next Page</A><BR>";
  377. }
  378. echo $pages;
  379. //echo '</td></tr></table></div>';
  380. echo '</strong></div>';
  381. //echo '<BR>';
  382. }
  383. }
  384. else
  385. {
  386. $start = 1;
  387. $stop = $result_count;
  388. if($cols>8 || $_REQUEST['expanded_view'])
  389. {
  390. $_SESSION['orientation'] = 'landscape';
  391. $repeat_headers = 16;
  392. }
  393. else
  394. $repeat_headers = 27;
  395. if($options['print'])
  396. {
  397. $html = explode('<!-- new page -->',strtolower(ob_get_contents()));
  398. $html = $html[count($html)-1];
  399. echo '</TD></TR></TABLE>';
  400. $br = (substr_count($html,'<br>')) + (substr_count($html,'</p>')) + (substr_count($html,'</tr>')) + (substr_count($html,'</h1>')) + (substr_count($html,'</h2>')) + (substr_count($html,'</h3>')) + (substr_count($html,'</h4>')) + (substr_count($html,'</h5>'));
  401. if($br%2!=0)
  402. {
  403. $br++;
  404. echo '<BR>';
  405. }
  406. }
  407. else
  408. echo '</TD></TR></TABLE>';
  409. }
  410. // END MISC ---
  411. // WIDTH = 100%
  412. echo '<TABLE width=98% border=0 cellspacing=0 cellpadding=0><TR>';
  413. // SEARCH BOX & MORE HEADERS
  414. if($where_message || ($singular && $plural) || (!isset($_REQUEST['_openSIS_PDF']) && $options['search']))
  415. {
  416. echo '<TD align=center>';
  417. echo '<TABLE cellpadding=1 width=100% border=0 class=\"grid\">';
  418. echo "<TR><TD align=left valign=middle>";
  419. if($singular && $plural && $options['count'])
  420. {
  421. if($display_count > 1)
  422. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>$display_count $plural were found.</b></td></tr></table>";
  423. elseif($display_count==1)
  424. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>1 $singular was found.</b></td></tr></table>";
  425. #if($where_message)
  426. # echo '<br>'.$where_message;
  427. }
  428. if($options['save'] && !isset($_REQUEST['_openSIS_PDF']) && $result_count > 0)
  429. //echo str_replace("Modules.php", "for_export.php", $PHP_tmp_SELF);
  430. echo "<table cellpadding=0 cellspacing=0 class=download align=left ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&LO_save=1&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0 alt=\"Download\" title=\"Download\"></a></td></tr></table>";
  431. //echo "<br><br><table class=download ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0></a></td><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true >Download</A></td></tr></table>";
  432. echo '</TD>';
  433. $colspan = 1;
  434. if(!isset($_REQUEST['_openSIS_PDF']) && $options['search'])
  435. {
  436. $_REQUEST['portal_search']='true';
  437. $tmp_REQUEST = $_REQUEST;
  438. unset($tmp_REQUEST['LO_search']);
  439. unset($tmp_REQUEST['page']);
  440. echo '<TD height="50" align=right valign=middle style="white-space:nowrap;">&nbsp;&nbsp;';
  441. echo "<INPUT type=text class='cell_medium' id=LO_search name=LO_search value='".(($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')?$_REQUEST['LO_search']:'Search\' style=\'color:BBBBBB\''),"' onfocus='if(this.value==\"Search\") this.value=\"\"; this.style.color=\"000000\";' onblur='if(this.value==\"\") {this.value=\"Search\"; this.style.color=\"BBBBBB\";}' onkeypress='if(event.keyCode==13){document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+this.value; return false;} '>&nbsp;&nbsp;<INPUT type=button class='btn_go' value=Go onclick='document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+document.getElementById(\"LO_search\").value;'></TD>";
  442. $colspan++;
  443. }
  444. echo "</TR>";
  445. echo '<TR style="height:0;"><TD width=100% align=center colspan='.$colspan.'><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV></TD></TR></TABLE>';
  446. }
  447. else
  448. echo '<TD width=100% align=right><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV>';
  449. // END SEARCH BOX ----
  450. echo '</TD></TR><TR><TD>';
  451. // SHADOW
  452. if(!isset($_REQUEST['_openSIS_PDF']))
  453. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  454. echo "<TABLE cellpadding=6 width=96% cellspacing=1 class=\"grid\" align=center>";
  455. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  456. echo '<THEAD>';
  457. if(!isset($_REQUEST['_openSIS_PDF']))
  458. echo '<TR>';
  459. $i =1;
  460. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  461. {
  462. //THIS LINE IS FOR COLUMN HEADING
  463. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV></TD>";
  464. $i++;
  465. }
  466. if($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))
  467. {
  468. foreach($column_names as $key=>$value)
  469. {
  470. if($_REQUEST['LO_sort'] == $key)
  471. $direction = -1 * $_REQUEST['LO_direction'];
  472. else
  473. $direction = 1;
  474. //THIS LINE IS FOR COLUMN HEADING
  475. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV>";
  476. echo "<A ";
  477. if($options['sort']){
  478. if($for_window=='for_window'){
  479. echo "HREF=#";
  480. }else {
  481. echo "HREF=$PHP_tmp_SELF&page=$_REQUEST[page]&LO_sort=$key&LO_direction=$direction&LO_search=".urlencode($_REQUEST['LO_search']);
  482. }
  483. }
  484. echo " class=column_heading><b>$value</b></A>";
  485. if($i==1)
  486. echo "<DIV id=LOy0 style='position: relative;'></DIV>";
  487. echo "</TD>";
  488. $i++;
  489. }
  490. //echo '<TD width=0><DIV id=LO'.$i.'></DIV></TD>';
  491. echo "</TR>";
  492. }
  493. $color = 'class=even';
  494. //style="height: 300px; overflow: auto; padding-right: 16px;"
  495. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  496. echo '</THEAD><TBODY>';
  497. // mab - enable add link as first or last
  498. if($result_count!=0 && $link['add']['first'] && ($stop-$start)>=$link['add']['first'])
  499. {
  500. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  501. // $cols++;
  502. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  503. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  504. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  505. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  506. elseif($link['add']['html'] && $cols)
  507. {
  508. echo "<TR $color>";
  509. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  510. echo "<TD class=even align=left>".$link['add']['html']['remove']."</TD>";
  511. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  512. echo "<TD class=even align=left>".button('add')."</TD>";
  513. foreach($column_names as $key=>$value)
  514. {
  515. echo "<TD class=even align=left >".$link['add']['html'][$key]."</TD>";
  516. }
  517. echo "</TR>";
  518. $count++;
  519. }
  520. }
  521. for($i=$start;$i<=$stop;$i++)
  522. {
  523. $item = $result[$i];
  524. if(isset($_REQUEST['_openSIS_PDF']) && $options['print'] && count($item))
  525. {
  526. foreach($item as $key=>$value)
  527. {
  528. $value = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$value);
  529. $value = eregi_replace('<SELECT.*</SELECT\>','',$value);
  530. if(strpos($value,'LO_field')===false)
  531. $item[$key] = str_replace(' ','&nbsp;',ereg_replace("<div onclick='[^']+'>",'',$value));
  532. else
  533. $item[$key] = ereg_replace("<div onclick='[^']+'>",'',$value);
  534. }
  535. }
  536. if($item['row_color'])
  537. $color = $item['row_color'];
  538. elseif($color=='class=even')
  539. $color = $side_color;
  540. else
  541. $color = 'class=even';
  542. //$color = '#EDF3FE';
  543. if(isset($_REQUEST['_openSIS_PDF']) && $count%$repeat_headers==0)
  544. {
  545. if($count!=0)
  546. {
  547. echo '</TABLE><TABLE cellpadding=6 width=820 class=\"grid\">';
  548. echo '<!-- NEW PAGE -->';
  549. }
  550. echo "<TR>";
  551. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  552. echo "<TD class=grid></TD>";
  553. if($cols)
  554. {
  555. foreach($column_names as $key=>$value)
  556. {
  557. echo "<TD class=grid >" . str_replace(' ','&nbsp;',$value) . "</TD>";
  558. }
  559. }
  560. echo "</TR>";
  561. }
  562. if($count==0)
  563. $count = $br;
  564. echo "<TR $color>";
  565. $count++;
  566. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  567. {
  568. $button_title = $link['remove']['title'];
  569. //if(!$button_title)
  570. //$button_title = 'Remove';
  571. $button_link = $link['remove']['link'];
  572. if(count($link['remove']['variables']))
  573. {
  574. foreach($link['remove']['variables'] as $var=>$val)
  575. $button_link .= "&$var=" . urlencode($item[$val]);
  576. }
  577. echo "<TD $color>" . button('remove',$button_title,$button_link) . "</TD>";
  578. }
  579. if($cols)
  580. {
  581. foreach($column_names as $key=>$value)
  582. {
  583. if($link[$key] && !isset($_REQUEST['_openSIS_PDF']))
  584. {
  585. echo "<TD $color >";
  586. if($key=='FULL_NAME')
  587. echo '<DIV id=LOy'.($count-$br).' style="height: 100%; min-height: 100%; position: relative;">';
  588. if($link[$key]['js']===true)
  589. {
  590. echo "<A HREF=# onclick='window.open(\"{$link[$key][link]}";
  591. if(count($link[$key]['variables']))
  592. {
  593. foreach($link[$key]['variables'] as $var=>$val)
  594. echo "&$var=".urlencode($item[$val]);
  595. }
  596. echo "\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'";
  597. if($link[$key]['extra'])
  598. echo ' '.$link[$key]['extra'];
  599. echo ">";
  600. }
  601. else
  602. {
  603. echo "<A HREF={$link[$key][link]}";
  604. if(count($link[$key]['variables']))
  605. {
  606. foreach($link[$key]['variables'] as $var=>$val)
  607. echo "&$var=".urlencode($item[$val]);
  608. }
  609. if($link[$key]['extra'])
  610. echo ' '.$link[$key]['extra'];
  611. echo " onclick='grabA(this); return false;'>";
  612. }
  613. if($color==Preferences('HIGHLIGHT'))
  614. echo '';
  615. else
  616. echo '<b>';
  617. echo $item[$key];
  618. echo '</b>';
  619. if(!$item[$key])
  620. echo '***';
  621. echo "</A>";
  622. if($key=='FULL_NAME')
  623. echo '</DIV>';
  624. echo "</TD>";
  625. }
  626. else
  627. {
  628. echo "<TD $color >";
  629. if($key=='FULL_NAME')
  630. echo '<DIV id=LOy'.($count-$br).' style="position: relative;">';
  631. if($color==Preferences('HIGHLIGHT'))
  632. echo '';
  633. echo $item[$key];
  634. if(!$item[$key])
  635. echo '&nbsp;';
  636. if($key=='FULL_NAME')
  637. echo '<DIV>';
  638. echo "</TD>";
  639. }
  640. }
  641. }
  642. echo "</TR>";
  643. }
  644. if($result_count!=0 && (!$link['add']['first'] || $link['add']['first'] && ($stop-$start)<$link['add']['first']))
  645. {
  646. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  647. // $cols++;
  648. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  649. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  650. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  651. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  652. elseif($link['add']['html'] && $cols)
  653. {
  654. if($count%2)
  655. $color = 'class=even';
  656. else
  657. $color = $side_color;
  658. echo "<TR $color>";
  659. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  660. echo "<TD class=even align=left>".$link['add']['html']['remove']."</TD>";
  661. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  662. echo "<TD class=even align=left class=grid_button>".button('add')."</TD>";
  663. foreach($column_names as $key=>$value)
  664. {
  665. echo "<TD class=even align=left valign=top>".$link['add']['html'][$key]."</TD>";
  666. }
  667. echo "</TR>";
  668. }
  669. }
  670. if($result_count!=0)
  671. {
  672. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  673. echo '</TBODY>';
  674. echo "</TABLE>";
  675. // SHADOW
  676. if(!isset($_REQUEST['_openSIS_PDF']))
  677. echo '</TD ></TR></TABLE>';
  678. echo "</TD ></TR>";
  679. echo "</TABLE>";
  680. if($options['center'])
  681. echo '';
  682. }
  683. // END PRINT THE LIST ---
  684. }
  685. if($result_count==0)
  686. {
  687. // mab - problem with table closing if not opened above - do same conditional?
  688. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  689. #echo '<td>'; //edited for Search in parents (user>> associate student with parents)
  690. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  691. echo '<table width=120px cellspacing=8 cellpadding=6 ><tr><TD align=left class=lone_add >' . button('add',$link['add']['title'],$link['add']['link']) . '</td></tr></table>';
  692. elseif(($link['add']['html'] || $link['add']['span']) && count($column_names) && !isset($_REQUEST['_openSIS_PDF']))
  693. {
  694. $color = $side_color;
  695. if($options['center'])
  696. #echo '<CENTER>';
  697. // WIDTH=100%
  698. //echo "<TABLE cellpadding=1 bgcolor=#f8f8f9 width=100%><TR><TD>";
  699. // SHADOW
  700. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  701. if($link['add']['html'])
  702. {
  703. /*Here also change the colour for left corner*/
  704. echo "<TABLE cellpadding=6 cellspacing=1 width=96% class=\"grid\"><TR><TD class=subtabs></TD>";
  705. foreach($column_names as $key=>$value)
  706. {
  707. //Here to change the ListOutput Header Colour
  708. echo "<TD class=subtabs><A><b>" . str_replace(' ','&nbsp;',$value) . "</b></A></TD>";
  709. }
  710. echo "</TR>";
  711. echo "<TR class=odd>";
  712. if($link['add']['html']['remove'])
  713. echo "<TD >".$link['add']['html']['remove']."</TD>";
  714. else
  715. echo "<TD>".button('add')."</TD>";
  716. foreach($column_names as $key=>$value)
  717. {
  718. echo "<TD >".$link['add']['html'][$key]."</TD>";
  719. }
  720. echo "</TR>";
  721. echo "</TABLE>";
  722. }
  723. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  724. echo "<TABLE><TR><TD align=center>".button('add').$link['add']['span']."</TD></TR></TABLE>";
  725. // SHADOW
  726. //echo '</TD></TR></TABLE>';
  727. echo "</TD></TR></TABLE>";
  728. if($options['center'])
  729. echo '</CENTER>';
  730. }
  731. }
  732. if($result_count!=0)
  733. {
  734. if($options['yscroll'])
  735. {
  736. echo '<div id="LOy_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  737. echo '<TABLE cellpadding=6 id=LOy_table>';
  738. $i = 1;
  739. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  740. {
  741. $color = $side_color;
  742. foreach($result as $item)
  743. {
  744. echo "<TR><TD $color id=LO_row$i>";
  745. if($color==Preferences('HIGHLIGHT'))
  746. echo '';
  747. echo $item['FULL_NAME'];
  748. if(!$item['FULL_NAME'])
  749. echo '&nbsp;';
  750. if($color==Preferences('HIGHLIGHT'))
  751. echo '';
  752. echo "</TD></TR>";
  753. $i++;
  754. if($item['row_color'])
  755. $color = $item['row_color'];
  756. elseif($color=='class=even')
  757. $color = $side_color;
  758. else
  759. $color = 'class=even';
  760. }
  761. }
  762. echo '</TABLE>';
  763. echo '</div>';
  764. }
  765. echo '<div id="LOx_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  766. echo '<TABLE cellpadding=6 id=LOx_table><TR>';
  767. $i = 1;
  768. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  769. {
  770. echo "<TD class=grid id=LO_col$i></TD>";
  771. $i++;
  772. }
  773. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  774. {
  775. foreach($column_names as $key=>$value)
  776. {
  777. echo '<TD class=grid id=LO_col'.$i.'><A class=column_heading><b>'.str_replace('controller','',$value).'</b></A></TD>';
  778. $i++;
  779. }
  780. }
  781. echo '</TR></TABLE>';
  782. echo '</div>';
  783. }
  784. }
  785. }
  786. function ListOutputMod($result,$column_names,$singular='',$plural='',$link=false,$group=false,$options=false)
  787. {
  788. if(!isset($options['save']))
  789. $options['save'] = true;
  790. if(!isset($options['print']))
  791. $options['print'] = true;
  792. if(!isset($options['search']))
  793. $options['search'] = true;
  794. if(!isset($options['center']))
  795. $options['center'] = true;
  796. if(!isset($options['count']))
  797. $options['count'] = true;
  798. if(!isset($options['sort']))
  799. $options['sort'] = true;
  800. if(!$link)
  801. $link = array();
  802. if(!isset($options['add']))
  803. {
  804. if(!AllowEdit() || $_REQUEST['_openSIS_PDF'])
  805. {
  806. if($link)
  807. {
  808. unset($link['add']);
  809. unset($link['remove']);
  810. }
  811. }
  812. }
  813. // PREPARE LINKS ---
  814. $result_count = $display_count = count($result);
  815. $num_displayed = 100000;
  816. $extra = "page=$_REQUEST[page]&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search']);
  817. $tmp_REQUEST = $_REQUEST;
  818. unset($tmp_REQUEST['page']);
  819. unset($tmp_REQUEST['LO_sort']);
  820. unset($tmp_REQUEST['LO_direction']);
  821. unset($tmp_REQUEST['LO_search']);
  822. unset($tmp_REQUEST['remove_prompt']);
  823. unset($tmp_REQUEST['remove_name']);
  824. unset($tmp_REQUEST['LO_save']);
  825. unset($tmp_REQUEST['PHPSESSID']);
  826. $PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);
  827. // END PREPARE LINKS ---
  828. // UN-GROUPING
  829. $group_count = count($group);
  830. if(!is_array($group))
  831. $group_count = false;
  832. //$side_color = Preferences('COLOR');
  833. $side_color = 'class=odd';
  834. if($group_count && $result_count)
  835. {
  836. $color = 'class=even';
  837. $group_result = $result;
  838. unset($result);
  839. $result[0] = '';
  840. foreach($group_result as $item1)
  841. {
  842. if($group_count==1)
  843. {
  844. if($color=='class=even')
  845. $color = $side_color;
  846. else
  847. $color = 'class=even';
  848. }
  849. foreach($item1 as $item2)
  850. {
  851. if($group_count==1)
  852. {
  853. $i++;
  854. if(count($group[0]) && $i!=1)
  855. {
  856. foreach($group[0] as $column)
  857. $item2[$column] = str_replace('<!-- <!--','<!--','<!-- '.str_replace('-->','--><!--',$item2[$column])).' -->';
  858. }
  859. $item2['row_color'] = $color;
  860. $result[] = $item2;
  861. }
  862. else
  863. {
  864. if($group_count==2)
  865. {
  866. if($color=='class=even')
  867. $color = $side_color;
  868. else
  869. $color = 'class=even';
  870. }
  871. foreach($item2 as $item3)
  872. {
  873. if($group_count==2)
  874. {
  875. $i++;
  876. if(count($group[0]) && $i!=1)
  877. {
  878. foreach($group[0] as $column)
  879. $item3[$column] = '<!-- '.$item3[$column].' -->';
  880. }
  881. if(count($group[1]) && $i!=1)
  882. {
  883. foreach($group[1] as $column)
  884. $item3[$column] = '<!-- '.$item3[$column].' -->';
  885. }
  886. $item3['row_color'] = $color;
  887. $result[] = $item3;
  888. }
  889. else
  890. {
  891. if($group_count==3)
  892. {
  893. if($color=='class=even')
  894. $color = $side_color;
  895. else
  896. $color = 'class=even';
  897. }
  898. foreach($item3 as $item4)
  899. {
  900. if($group_count==3)
  901. {
  902. $i++;
  903. if(count($group[2]) && $i!=1)
  904. {
  905. foreach($group[2] as $column)
  906. unset($item4[$column]);
  907. }
  908. $item4['row_color'] = $color;
  909. $result[] = $item4;
  910. }
  911. }
  912. }
  913. }
  914. }
  915. }
  916. $i = 0;
  917. }
  918. unset($result[0]);
  919. $result_count = count($result);
  920. unset($_REQUEST['LO_sort']);
  921. }
  922. // END UN-GROUPING
  923. $_LIST['output'] = true;
  924. // PRINT HEADINGS, PREPARE PDF, AND SORT THE LIST ---
  925. if($_LIST['output']!=false)
  926. {
  927. if($result_count != 0)
  928. {
  929. $count = 0;
  930. $remove = count($link['remove']['variables']);
  931. $cols = count($column_names);
  932. // HANDLE SEARCHES ---
  933. if($result_count && $_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')
  934. {
  935. $_REQUEST['LO_search'] = $search_term = str_replace('\\\"','"',$_REQUEST['LO_search']);
  936. $_REQUEST['LO_search'] = $search_term = ereg_replace('[^a-zA-Z0-9 _"]*','',strtolower($search_term));
  937. if(substr($search_term,0,0)!='"' && substr($search_term,-1)!='"')
  938. {
  939. $search_term = ereg_replace('"','',$search_term);
  940. while($space_pos = strpos($search_term,' '))
  941. {
  942. $terms[strtolower(substr($search_term,0,$space_pos))] = 1;
  943. $search_term = substr($search_term,($space_pos+1));
  944. }
  945. $terms[trim($search_term)] = 1;
  946. }
  947. else
  948. {
  949. $search_term = ereg_replace('"','',$search_term);
  950. $terms[trim($search_term)] = 1;
  951. }
  952. unset($terms['of']); unset($terms['the']); unset($terms['a']); unset($terms['an']); unset($terms['in']);
  953. foreach($result as $key=>$value)
  954. {
  955. $values[$key] = 0;
  956. foreach($value as $name=>$val)
  957. {
  958. $val = ereg_replace('[^a-zA-Z0-9 _]+','',strtolower($val));
  959. if(strtolower($_REQUEST['LO_search'])==$val)
  960. $values[$key] += 25;
  961. foreach($terms as $term=>$one)
  962. {
  963. if(ereg($term,$val))
  964. $values[$key] += 3;
  965. }
  966. }
  967. if($values[$key]==0)
  968. {
  969. unset($values[$key]);
  970. unset($result[$key]);
  971. $result_count--;
  972. $display_count--;
  973. }
  974. }
  975. if($result_count)
  976. {
  977. array_multisort($values,SORT_DESC,$result);
  978. $result = ReindexResults($result);
  979. $values = ReindexResults($values);
  980. $last_value = 1;
  981. $scale = (100/$values[$last_value]);
  982. for($i=$last_value;$i<=$result_count;$i++)
  983. $result[$i]['RELEVANCE'] = '<!--' . ((int) ($values[$i]*$scale)) . '--><IMG SRC="assets/pixel_grey.gif" width=' . ((int) ($values[$i]*$scale)) . ' height=10>';
  984. }
  985. $column_names['RELEVANCE'] = "Relevance";
  986. if(is_array($group) && count($group))
  987. {
  988. $options['count'] == false;
  989. $display_zero = true;
  990. }
  991. }
  992. // END SEARCHES ---
  993. if($_REQUEST['LO_sort'])
  994. {
  995. foreach($result as $sort)
  996. {
  997. if(substr($sort[$_REQUEST['LO_sort']],0,4)!='<!--')
  998. $sort_array[] = $sort[$_REQUEST['LO_sort']];
  999. else
  1000. $sort_array[] = substr($sort[$_REQUEST['LO_sort']],4,strpos($sort[$_REQUEST['LO_sort']],'-->')-5);
  1001. }
  1002. if($_REQUEST['LO_direction']==-1)
  1003. $dir = SORT_DESC;
  1004. else
  1005. $dir = SORT_ASC;
  1006. if($result_count>1)
  1007. {
  1008. if(is_int($sort_array[1]) || is_double($sort_array[1]))
  1009. array_multisort($sort_array,$dir,SORT_NUMERIC,$result);
  1010. else
  1011. array_multisort($sort_array,$dir,$result);
  1012. for($i=$result_count-1;$i>=0;$i--)
  1013. $result[$i+1] = $result[$i];
  1014. unset($result[0]);
  1015. }
  1016. }
  1017. }
  1018. // HANDLE SAVING THE LIST ---
  1019. if($_REQUEST['LO_save']=='1')
  1020. {
  1021. if(!$options['save_delimiter'] && Preferences('DELIMITER')=='CSV')
  1022. $options['save_delimiter'] = 'comma';
  1023. switch($options['save_delimiter'])
  1024. {
  1025. case 'comma':
  1026. $extension = 'csv';
  1027. break;
  1028. case 'xml':
  1029. $extension = 'xml';
  1030. break;
  1031. default:
  1032. $extension = 'xls';
  1033. break;
  1034. }
  1035. ob_end_clean();
  1036. if($options['save_delimiter']!='xml')
  1037. {
  1038. foreach($column_names as $key=>$value)
  1039. $output .= str_replace('&nbsp;',' ',eregi_replace('<BR>',' ',ereg_replace('<!--.*-->','',$value))) . ($options['save_delimiter']=='comma'?',':"\t");
  1040. $output .= "\n";
  1041. }
  1042. foreach($result as $item)
  1043. {
  1044. foreach($column_names as $key=>$value)
  1045. {
  1046. if($options['save_delimiter']=='comma' && !$options['save_quotes'])
  1047. $item[$key] = str_replace(',',';',$item[$key]);
  1048. $item[$key] = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$item[$key]);
  1049. $item[$key] = eregi_replace('<SELECT.*</SELECT\>','',$item[$key]);
  1050. $output .= ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='xml'?'<'.str_replace(' ','',$value).'>':'') . ereg_replace('<[^>]+>','',ereg_replace("<div onclick='[^']+'>",'',ereg_replace(' +',' ',ereg_replace('&[^;]+;','',str_replace('<BR>&middot;',' : ',str_replace('&nbsp;',' ',$item[$key])))))) . ($options['save_delimiter']=='xml'?'</'.str_replace(' ','',$value).'>'."\n":'') . ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='comma'?',':"\t");
  1051. }
  1052. $output .= "\n";
  1053. }
  1054. header("Cache-Control: public");
  1055. header("Pragma: ");
  1056. header("Content-Type: application/$extension");
  1057. header("Content-Disposition: inline; filename=\"".ProgramTitle().".$extension\"\n");
  1058. if($options['save_eval'])
  1059. eval($options['save_eval']);
  1060. echo $output;
  1061. exit();
  1062. }
  1063. // END SAVING THE LIST ---
  1064. if($options['center'])
  1065. #echo '<CENTER>';
  1066. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  1067. {
  1068. echo "<TABLE border=0 align=center";
  1069. if(isset($_REQUEST['_openSIS_PDF']))
  1070. echo " width=100%";
  1071. echo " ><TR><TD align=center>";
  1072. }
  1073. if($options['count'] || $display_zero)
  1074. {
  1075. if(($result_count==0 || $display_count==0) && $plural)
  1076. echo "<div style=text-align:left><table cellpadding=5 cellspacing=5 class=alert_box ><tr><td class=alert></td><td class=alert_msg ><b>No $plural were found.</b></td></tr></table></div>";
  1077. elseif($result_count==0 || $display_count==0)
  1078. echo '<div style=text-align:left><table cellpadding=5 cellspacing=5 class=alert_box ><tr><td class=alert></td><td class=alert_msg ><b>None were found.</b></td></tr></table></div>';
  1079. }
  1080. if($result_count != 0 || ($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search'))
  1081. {
  1082. if(!isset($_REQUEST['_openSIS_PDF']))
  1083. {
  1084. if(!$_REQUEST['page'])
  1085. $_REQUEST['page'] = 1;
  1086. if(!$_REQUEST['LO_direction'])
  1087. $_REQUEST['LO_direction'] = 1;
  1088. $start = ($_REQUEST['page'] - 1) * $num_displayed + 1;
  1089. $stop = $start + ($num_displayed-1);
  1090. if($stop > $result_count)
  1091. $stop = $result_count;
  1092. if($result_count > $num_displayed)
  1093. {
  1094. $where_message = "<SMALL>Displaying $start through $stop</SMALL>";
  1095. echo "Go to Page ";
  1096. if(ceil($result_count/$num_displayed) <= 10)
  1097. {
  1098. for($i=1;$i<=ceil($result_count/$num_displayed);$i++)
  1099. {
  1100. if($i!=$_REQUEST['page'])
  1101. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  1102. else
  1103. $pages .= "$i, ";
  1104. }
  1105. $pages = substr($pages,0,-2) . "<BR>";
  1106. }
  1107. else
  1108. {
  1109. for($i=1;$i<=7;$i++)
  1110. {
  1111. if($i!=$_REQUEST['page'])
  1112. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  1113. else
  1114. $pages .= "$i, ";
  1115. }
  1116. $pages = substr($pages,0,-2) . " ... ";
  1117. for($i=ceil($result_count/$num_displayed)-2;$i<=ceil($result_count/$num_displayed);$i++)
  1118. {
  1119. if($i!=$_REQUEST['page'])
  1120. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  1121. else
  1122. $pages .= "$i, ";
  1123. }
  1124. $pages = substr($pages,0,-2) . " &nbsp;<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=" . ($_REQUEST['page'] +1) . ">Next Page</A><BR>";
  1125. }
  1126. echo $pages;
  1127. echo '</TD></TR></TABLE>';
  1128. echo '<BR>';
  1129. }
  1130. }
  1131. else
  1132. {
  1133. $start = 1;
  1134. $stop = $result_count;
  1135. if($cols>8 || $_REQUEST['expanded_view'])
  1136. {
  1137. $_SESSION['orientation'] = 'landscape';
  1138. $repeat_headers = 16;
  1139. }
  1140. else
  1141. $repeat_headers = 27;
  1142. if($options['print'])
  1143. {
  1144. $html = explode('<!-- new page -->',strtolower(ob_get_contents()));
  1145. $html = $html[count($html)-1];
  1146. echo '</TD></TR></TABLE>';
  1147. $br = (substr_count($html,'<br>')) + (substr_count($html,'</p>')) + (substr_count($html,'</tr>')) + (substr_count($html,'</h1>')) + (substr_count($html,'</h2>')) + (substr_count($html,'</h3>')) + (substr_count($html,'</h4>')) + (substr_count($html,'</h5>'));
  1148. if($br%2!=0)
  1149. {
  1150. $br++;
  1151. echo '<BR>';
  1152. }
  1153. }
  1154. else
  1155. echo '</TD></TR></TABLE>';
  1156. }
  1157. // END MISC ---
  1158. // WIDTH = 100%
  1159. echo '<TABLE cellpadding=6 cellspacing=1 border=0 width=96% align=center><TR>';
  1160. // SEARCH BOX & MORE HEADERS
  1161. if($where_message || ($singular && $plural) || (!isset($_REQUEST['_openSIS_PDF']) && $options['search']))
  1162. {
  1163. echo '<TD align=center>';
  1164. echo '<TABLE cellpadding=1 cellspacing=0 width=100% >';
  1165. echo "<TR><TD align=center>";
  1166. /*
  1167. if($singular && $plural && $options['count'])
  1168. {
  1169. if($display_count > 1)
  1170. echo "<b>$display_count $plural were found.</b> &nbsp; &nbsp;";
  1171. elseif($display_count==1)
  1172. echo "<b>1 $singular was found.</b> &nbsp; &nbsp;";
  1173. if($where_message)
  1174. echo '<BR>'.$where_message;
  1175. }
  1176. if($options['save'] && !isset($_REQUEST['_openSIS_PDF']) && $result_count > 0)
  1177. echo "<A HREF=$PHP_tmp_SELF&$extra&LO_save=1&_openSIS_PDF=true><IMG SRC=assets/download.gif border=0 vspace=0 hspace=0></A>";
  1178. echo '</TD>';
  1179. $colspan = 1; */
  1180. if(!isset($_REQUEST['_openSIS_PDF']) && $options['search'])
  1181. {
  1182. $tmp_REQUEST = $_REQUEST;
  1183. unset($tmp_REQUEST['LO_search']);
  1184. unset($tmp_REQUEST['page']);
  1185. echo '<TD align=right>';
  1186. //echo "<INPUT type=text id=LO_search name=LO_search value='".(($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')?$_REQUEST['LO_search']:'Search\' style=\'color:BBBBBB\''),"' onfocus='if(this.value==\"Search\") this.value=\"\"; this.style.color=\"000000\";' onblur='if(this.value==\"\") {this.value=\"Search\"; this.style.color=\"BBBBBB\";}' onkeypress='if(event.keyCode==13){document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+this.value; return false;} '><INPUT type=button value=Go onclick='document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+document.getElementById(\"LO_search\").value;'></TD>";
  1187. $colspan++;
  1188. }
  1189. echo "</TR>";
  1190. echo '<TR style="height:0;"><TD width=100% style="height:0;" height=0 align=right colspan='.$colspan.'><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV></TD></TR></TABLE>';
  1191. }
  1192. else
  1193. echo '<TD width=100% align=right><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV>';
  1194. // END SEARCH BOX ----
  1195. echo '</TD></TR><TR><TD>';
  1196. // SHADOW
  1197. if(!isset($_REQUEST['_openSIS_PDF']))
  1198. echo '<TABLE width=100% cellpadding=0 cellspacing=0 border=0 align=center><TR><TD align=center >';
  1199. echo "<TABLE cellpadding=6 cellspacing=1 width=100% class=grid>";
  1200. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  1201. echo '<THEAD>';
  1202. if(!isset($_REQUEST['_openSIS_PDF']))
  1203. echo '<TR>';
  1204. $i =1;
  1205. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  1206. {
  1207. //THIS LINE IS FOR COLUMN HEADING
  1208. echo "<TD class=\"subtabs\"><DIV id=LOx$i style='position: relative;'></DIV></TD>";
  1209. $i++;
  1210. }
  1211. if($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))
  1212. {
  1213. foreach($column_names as $key=>$value)
  1214. {
  1215. if($_REQUEST['LO_sort'] == $key)
  1216. $direction = -1 * $_REQUEST['LO_direction'];
  1217. else
  1218. $direction = 1;
  1219. //THIS LINE IS FOR COLUMN HEADING
  1220. echo "<TD class=\"subtabs\"><DIV id=LOx$i style='position: relative;'></DIV>";
  1221. echo "<A ";
  1222. if($options['sort'])
  1223. echo "HREF=$PHP_tmp_SELF&page=$_REQUEST[page]&LO_sort=$key&LO_direction=$direction&LO_search=".urlencode($_REQUEST['LO_search']);
  1224. echo " class=column_heading><b>$value</b></A>";
  1225. if($i==1)
  1226. echo "<DIV id=LOy0 style='position: relative;'></DIV>";
  1227. echo "</TD>";
  1228. $i++;
  1229. }
  1230. //echo '<TD width=0><DIV id=LO'.$i.'></DIV></TD>';
  1231. echo "</TR>";
  1232. }
  1233. $color = 'class=even';
  1234. //style="height: 300px; overflow: auto; padding-right: 16px;"
  1235. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  1236. echo '</THEAD><TBODY>';
  1237. // mab - enable add link as first or last
  1238. if($result_count!=0 && $link['add']['first'] && ($stop-$start)>=$link['add']['first'])
  1239. {
  1240. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  1241. // $cols++;
  1242. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  1243. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  1244. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  1245. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  1246. elseif($link['add']['html'] && $cols)
  1247. {
  1248. echo "<TR $color>";
  1249. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  1250. echo "<TD $color>".$link['add']['html']['remove']."</TD>";
  1251. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  1252. echo "<TD $color>".button('add')."</TD>";
  1253. foreach($column_names as $key=>$value)
  1254. {
  1255. echo "<TD $color >".$link['add']['html'][$key]."</TD>";
  1256. }
  1257. echo "</TR>";
  1258. $count++;
  1259. }
  1260. }
  1261. for($i=$start;$i<=$stop;$i++)
  1262. {
  1263. $item = $result[$i];
  1264. if(isset($_REQUEST['_openSIS_PDF']) && $options['print'] && count($item))
  1265. {
  1266. foreach($item as $key=>$value)
  1267. {
  1268. $value = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$value);
  1269. $value = eregi_replace('<SELECT.*</SELECT\>','',$value);
  1270. if(strpos($value,'LO_field')===false)
  1271. $item[$key] = str_replace(' ','&nbsp;',ereg_replace("<div onclick='[^']+'>",'',$value));
  1272. else
  1273. $item[$key] = ereg_replace("<div onclick='[^']+'>",'',$value);
  1274. }
  1275. }
  1276. if($item['row_color'])
  1277. $color = $item['row_color'];
  1278. elseif($color=='class=even')
  1279. $color = $side_color;
  1280. else
  1281. $color = 'class=even';
  1282. //$color = '#EDF3FE';
  1283. if(isset($_REQUEST['_openSIS_PDF']) && $count%$repeat_headers==0)
  1284. {
  1285. if($count!=0)
  1286. {
  1287. echo '</TABLE><TABLE cellpadding=6 cellspacing=1 width=830 cellspacing=0 class=\"grid\">';
  1288. echo '<!-- NEW PAGE -->';
  1289. }
  1290. echo "<TR>";
  1291. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  1292. echo "<TD class=grid></TD>";
  1293. if($cols)
  1294. {
  1295. foreach($column_names as $key=>$value)
  1296. {
  1297. echo "<TD class=grid >" . str_replace(' ','&nbsp;',$value) . "</TD>";
  1298. }
  1299. }
  1300. echo "</TR>";
  1301. }
  1302. if($count==0)
  1303. $count = $br;
  1304. echo "<TR $color>";
  1305. $count++;
  1306. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  1307. {
  1308. $button_title = $link['remove']['title'];
  1309. //if(!$button_title)
  1310. //$button_title = 'Remove';
  1311. $button_link = $link['remove']['link'];
  1312. if(count($link['remove']['variables']))
  1313. {
  1314. foreach($link['remove']['variables'] as $var=>$val)
  1315. $button_link .= "&$var=" . urlencode($item[$val]);
  1316. }
  1317. echo "<TD $color>" . button('remove',$button_title,$button_link) . "</TD>";
  1318. }
  1319. if($cols)
  1320. {
  1321. foreach($column_names as $key=>$value)
  1322. {
  1323. if($link[$key] && !isset($_REQUEST['_openSIS_PDF']))
  1324. {
  1325. echo "<TD $color >";
  1326. if($key=='FULL_NAME')
  1327. echo '<DIV id=LOy'.($count-$br).' style="height: 100%; min-height: 100%; position: relative;">';
  1328. if($link[$key]['js']===true)
  1329. {
  1330. echo "<A HREF=# onclick='window.open(\"{$link[$key][link]}";
  1331. if(count($link[$key]['variables']))
  1332. {
  1333. foreach($link[$key]['variables'] as $var=>$val)
  1334. echo "&$var=".urlencode($item[$val]);
  1335. }
  1336. echo "\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'";
  1337. if($link[$key]['extra'])
  1338. echo ' '.$link[$key]['extra'];
  1339. echo ">";
  1340. }
  1341. else
  1342. {
  1343. echo "<A HREF={$link[$key][link]}";
  1344. if(count($link[$key]['variables']))
  1345. {
  1346. foreach($link[$key]['variables'] as $var=>$val)
  1347. echo "&$var=".urlencode($item[$val]);
  1348. }
  1349. if($link[$key]['extra'])
  1350. echo ' '.$link[$key]['extra'];
  1351. echo ">";
  1352. }
  1353. if($color==Preferences('HIGHLIGHT'))
  1354. echo '';
  1355. else
  1356. echo '';
  1357. echo $item[$key];
  1358. echo '';
  1359. if(!$item[$key])
  1360. echo '***';
  1361. echo "</A>";
  1362. if($key=='FULL_NAME')
  1363. echo '</DIV>';
  1364. echo "</TD>";
  1365. }
  1366. else
  1367. {
  1368. echo "<TD $color >";
  1369. if($key=='FULL_NAME')
  1370. echo '<DIV id=LOy'.($count-$br).' style="position: relative;">';
  1371. if($color==Preferences('HIGHLIGHT'))
  1372. echo '';
  1373. echo $item[$key];
  1374. if(!$item[$key])
  1375. echo '&nbsp;';
  1376. if($key=='FULL_NAME')
  1377. echo '<DIV>';
  1378. echo "</TD>";
  1379. }
  1380. }
  1381. }
  1382. echo "</TR>";
  1383. }
  1384. if($result_count!=0 && (!$link['add']['first'] || $link['add']['first'] && ($stop-$start)<$link['add']['first']))
  1385. {
  1386. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  1387. // $cols++;
  1388. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  1389. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  1390. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  1391. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  1392. elseif($link['add']['html'] && $cols)
  1393. {
  1394. if($count%2)
  1395. $color = 'class=even';
  1396. else
  1397. $color = $side_color;
  1398. echo "<TR $color>";
  1399. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  1400. echo "<TD $color>".$link['add']['html']['remove']."</TD>";
  1401. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  1402. echo "<TD $color align=center>".button('add')."</TD>";
  1403. foreach($column_names as $key=>$value)
  1404. {
  1405. echo "<TD $color >".$link['add']['html'][$key]."</TD>";
  1406. }
  1407. echo "</TR>";
  1408. }
  1409. }
  1410. if($result_count!=0)
  1411. {
  1412. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  1413. echo '</TBODY>';
  1414. echo "</TABLE>";
  1415. // SHADOW
  1416. if(!isset($_REQUEST['_openSIS_PDF']))
  1417. echo '</TD></TR></TABLE>';
  1418. echo "</TD></TR>";
  1419. echo "</TABLE>";
  1420. if($options['center'])
  1421. echo '</CENTER>';
  1422. }
  1423. // END PRINT THE LIST ---
  1424. }
  1425. if($result_count==0)
  1426. {
  1427. // mab - problem with table closing if not opened above - do same conditional?
  1428. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  1429. echo '</TD></TR></TABLE>';
  1430. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  1431. echo '<center>' . button('add',$link['add']['title'],$link['add']['link']) . '</center>';
  1432. elseif(($link['add']['html'] || $link['add']['span']) && count($column_names) && !isset($_REQUEST['_openSIS_PDF']))
  1433. {
  1434. $color = $side_color;
  1435. if($options['center'])
  1436. echo '<CENTER>';
  1437. // WIDTH=100%
  1438. //echo "<TABLE cellpadding=1 bgcolor=#f8f8f9 width=100%><TR><TD>";
  1439. // SHADOW
  1440. echo '<TABLE cellpadding=6 cellspacing=1 width=760 class=\"grid\" ><TR><TD>';
  1441. if($link['add']['html'])
  1442. {
  1443. /*Here also change the colour for left corner*/
  1444. echo "<TABLE cellpadding=6 cellspacing=1 width=760px class=\"grid\"><TR><TD class=subtabs ></TD>";
  1445. foreach($column_names as $key=>$value)
  1446. {
  1447. //Here to change the ListOutput Header Colour
  1448. echo "<TD class=subtabs ><A><b>" . str_replace(' ','&nbsp;',$value) . "</b></A></TD>";
  1449. }
  1450. echo "</TR>";
  1451. echo "<TR class=odd>";
  1452. if($link['add']['html']['remove'])
  1453. echo "<TD>".$link['add']['html']['remove']."</TD>";
  1454. else
  1455. echo "<TD >".button('add')."</TD>";
  1456. foreach($column_names as $key=>$value)
  1457. {
  1458. echo "<TD >".$link['add']['html'][$key]."</TD>";
  1459. }
  1460. echo "</TR>";
  1461. echo "</TABLE>";
  1462. }
  1463. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  1464. echo "<TABLE ><TR><TD align=left>".button('add').$link['add']['span']."</TD></TR></TABLE>";
  1465. // SHADOW
  1466. //echo '</TD></TR></TABLE>';
  1467. echo "</TD></TR></TABLE>";
  1468. if($options['center'])
  1469. echo '</CENTER>';
  1470. }
  1471. }
  1472. if($result_count!=0)
  1473. {
  1474. if($options['yscroll'])
  1475. {
  1476. echo '<div id="LOy_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  1477. echo '<TABLE cellpadding=6 id=LOy_table>';
  1478. $i = 1;
  1479. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  1480. {
  1481. $color = $side_color;
  1482. foreach($result as $item)
  1483. {
  1484. echo "<TR><TD $color id=LO_row$i>";
  1485. if($color==Preferences('HIGHLIGHT'))
  1486. echo '';
  1487. echo $item['FULL_NAME'];
  1488. if(!$item['FULL_NAME'])
  1489. echo '&nbsp;';
  1490. if($color==Preferences('HIGHLIGHT'))
  1491. echo '';
  1492. echo "</TD></TR>";
  1493. $i++;
  1494. if($item['row_color'])
  1495. $color = $item['row_color'];
  1496. elseif($color=='class=even')
  1497. $color = $side_color;
  1498. else
  1499. $color = 'class=even';
  1500. }
  1501. }
  1502. echo '</TABLE>';
  1503. echo '</div>';
  1504. }
  1505. echo '<div id="LOx_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  1506. echo '<TABLE cellpadding=6 id=LOx_table><TR>';
  1507. $i = 1;
  1508. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  1509. {
  1510. echo "<TD class=grid id=LO_col$i></TD>";
  1511. $i++;
  1512. }
  1513. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  1514. {
  1515. foreach($column_names as $key=>$value)
  1516. {
  1517. echo '<TD class=grid id=LO_col'.$i.'><A class=column_heading><b>'.str_replace('controller','',$value).'</b></A></TD>';
  1518. $i++;
  1519. }
  1520. }
  1521. echo '</TR></TABLE>';
  1522. echo '</div>';
  1523. }
  1524. }
  1525. }
  1526. function ListOutputPrint_Report($result,$column_names,$singular='',$plural='',$link=false,$group=false,$options=false)
  1527. {
  1528. if(!isset($options['save']))
  1529. $options['save'] = true;
  1530. if(!isset($options['print']))
  1531. $options['print'] = true;
  1532. if(!isset($options['search']))
  1533. $options['search'] = true;
  1534. if(!isset($options['center']))
  1535. $options['center'] = true;
  1536. if(!isset($options['count']))
  1537. $options['count'] = true;
  1538. if(!isset($options['sort']))
  1539. $options['sort'] = true;
  1540. if(!$link)
  1541. $link = array();
  1542. if(!isset($options['add']))
  1543. {
  1544. if(!AllowEdit() || $_REQUEST['_openSIS_PDF'])
  1545. {
  1546. if($link)
  1547. {
  1548. unset($link['add']);
  1549. unset($link['remove']);
  1550. }
  1551. }
  1552. }
  1553. // PREPARE LINKS ---
  1554. $result_count = $display_count = count($result);
  1555. $num_displayed = 100000;
  1556. $extra = "page=$_REQUEST[page]&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search']);
  1557. $tmp_REQUEST = $_REQUEST;
  1558. unset($tmp_REQUEST['page']);
  1559. unset($tmp_REQUEST['LO_sort']);
  1560. unset($tmp_REQUEST['LO_direction']);
  1561. unset($tmp_REQUEST['LO_search']);
  1562. unset($tmp_REQUEST['remove_prompt']);
  1563. unset($tmp_REQUEST['remove_name']);
  1564. unset($tmp_REQUEST['LO_save']);
  1565. unset($tmp_REQUEST['PHPSESSID']);
  1566. $PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);
  1567. // END PREPARE LINKS ---
  1568. // UN-GROUPING
  1569. $group_count = count($group);
  1570. if(!is_array($group))
  1571. $group_count = false;
  1572. //$side_color = Preferences('COLOR');
  1573. $side_color = 'bgcolor="#f5f5f5"';
  1574. if($group_count && $result_count)
  1575. {
  1576. $color = 'style=" background-color:#fff; padding:3px 4px 3px 4px;"';
  1577. $group_result = $result;
  1578. unset($result);
  1579. $result[0] = '';
  1580. foreach($group_result as $item1)
  1581. {
  1582. if($group_count==1)
  1583. {
  1584. if($color=='bgcolor="#f5f5f5"')
  1585. $color = $side_color;
  1586. else
  1587. $color = 'bgcolor="#f5f5f5"';
  1588. }
  1589. foreach($item1 as $item2)
  1590. {
  1591. if($group_count==1)
  1592. {
  1593. $i++;
  1594. if(count($group[0]) && $i!=1)
  1595. {
  1596. foreach($group[0] as $column)
  1597. $item2[$column] = str_replace('<!-- <!--','<!--','<!-- '.str_replace('-->','--><!--',$item2[$column])).' -->';
  1598. }
  1599. $item2['row_color'] = $color;
  1600. $result[] = $item2;
  1601. }
  1602. else
  1603. {
  1604. if($group_count==2)
  1605. {
  1606. if($color=='bgcolor="#ffffff"')
  1607. $color = $side_color;
  1608. else
  1609. $color = 'bgcolor="#ffffff"';
  1610. }
  1611. foreach($item2 as $item3)
  1612. {
  1613. if($group_count==2)
  1614. {
  1615. $i++;
  1616. if(count($group[0]) && $i!=1)
  1617. {
  1618. foreach($group[0] as $column)
  1619. $item3[$column] = '<!-- '.$item3[$column].' -->';
  1620. }
  1621. if(count($group[1]) && $i!=1)
  1622. {
  1623. foreach($group[1] as $column)
  1624. $item3[$column] = '<!-- '.$item3[$column].' -->';
  1625. }
  1626. $item3['row_color'] = $color;
  1627. $result[] = $item3;
  1628. }
  1629. else
  1630. {
  1631. if($group_count==3)
  1632. {
  1633. if($color=='bgcolor="#ffffff"')
  1634. $color = $side_color;
  1635. else
  1636. $color = 'bgcolor="#ffffff"';
  1637. }
  1638. foreach($item3 as $item4)
  1639. {
  1640. if($group_count==3)
  1641. {
  1642. $i++;
  1643. if(count($group[2]) && $i!=1)
  1644. {
  1645. foreach($group[2] as $column)
  1646. unset($item4[$column]);
  1647. }
  1648. $item4['row_color'] = $color;
  1649. $result[] = $item4;
  1650. }
  1651. }
  1652. }
  1653. }
  1654. }
  1655. }
  1656. $i = 0;
  1657. }
  1658. unset($result[0]);
  1659. $result_count = count($result);
  1660. unset($_REQUEST['LO_sort']);
  1661. }
  1662. // END UN-GROUPING
  1663. $_LIST['output'] = true;
  1664. // PRINT HEADINGS, PREPARE PDF, AND SORT THE LIST ---
  1665. if($_LIST['output']!=false)
  1666. {
  1667. if($result_count != 0)
  1668. {
  1669. $count = 0;
  1670. $remove = count($link['remove']['variables']);
  1671. $cols = count($column_names);
  1672. // HANDLE SEARCHES ---
  1673. if($result_count && $_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')
  1674. {
  1675. $_REQUEST['LO_search'] = $search_term = str_replace('\\\"','"',$_REQUEST['LO_search']);
  1676. $_REQUEST['LO_search'] = $search_term = ereg_replace('[^a-zA-Z0-9 _"]*','',strtolower($search_term));
  1677. if(substr($search_term,0,0)!='"' && substr($search_term,-1)!='"')
  1678. {
  1679. $search_term = ereg_replace('"','',$search_term);
  1680. while($space_pos = strpos($search_term,' '))
  1681. {
  1682. $terms[strtolower(substr($search_term,0,$space_pos))] = 1;
  1683. $search_term = substr($search_term,($space_pos+1));
  1684. }
  1685. $terms[trim($search_term)] = 1;
  1686. }
  1687. else
  1688. {
  1689. $search_term = ereg_replace('"','',$search_term);
  1690. $terms[trim($search_term)] = 1;
  1691. }
  1692. unset($terms['of']); unset($terms['the']); unset($terms['a']); unset($terms['an']); unset($terms['in']);
  1693. foreach($result as $key=>$value)
  1694. {
  1695. $values[$key] = 0;
  1696. foreach($value as $name=>$val)
  1697. {
  1698. $val = ereg_replace('[^a-zA-Z0-9 _]+','',strtolower($val));
  1699. if(strtolower($_REQUEST['LO_search'])==$val)
  1700. $values[$key] += 25;
  1701. foreach($terms as $term=>$one)
  1702. {
  1703. if(ereg($term,$val))
  1704. $values[$key] += 3;
  1705. }
  1706. }
  1707. if($values[$key]==0)
  1708. {
  1709. unset($values[$key]);
  1710. unset($result[$key]);
  1711. $result_count--;
  1712. $display_count--;
  1713. }
  1714. }
  1715. if($result_count)
  1716. {
  1717. array_multisort($values,SORT_DESC,$result);
  1718. $result = ReindexResults($result);
  1719. $values = ReindexResults($values);
  1720. $last_value = 1;
  1721. $scale = (100/$values[$last_value]);
  1722. for($i=$last_value;$i<=$result_count;$i++)
  1723. $result[$i]['RELEVANCE'] = '<!--' . ((int) ($values[$i]*$scale)) . '--><IMG SRC="assets/pixel_grey.gif" width=' . ((int) ($values[$i]*$scale)) . ' height=10>';
  1724. }
  1725. $column_names['RELEVANCE'] = "Relevance";
  1726. if(is_array($group) && count($group))
  1727. {
  1728. $options['count'] == false;
  1729. $display_zero = true;
  1730. }
  1731. }
  1732. // END SEARCHES ---
  1733. if($_REQUEST['LO_sort'])
  1734. {
  1735. foreach($result as $sort)
  1736. {
  1737. if(substr($sort[$_REQUEST['LO_sort']],0,4)!='<!--')
  1738. $sort_array[] = $sort[$_REQUEST['LO_sort']];
  1739. else
  1740. $sort_array[] = substr($sort[$_REQUEST['LO_sort']],4,strpos($sort[$_REQUEST['LO_sort']],'-->')-5);
  1741. }
  1742. if($_REQUEST['LO_direction']==-1)
  1743. $dir = SORT_DESC;
  1744. else
  1745. $dir = SORT_ASC;
  1746. if($result_count>1)
  1747. {
  1748. if(is_int($sort_array[1]) || is_double($sort_array[1]))
  1749. array_multisort($sort_array,$dir,SORT_NUMERIC,$result);
  1750. else
  1751. array_multisort($sort_array,$dir,$result);
  1752. for($i=$result_count-1;$i>=0;$i--)
  1753. $result[$i+1] = $result[$i];
  1754. unset($result[0]);
  1755. }
  1756. }
  1757. }
  1758. // HANDLE SAVING THE LIST ---
  1759. if($_REQUEST['LO_save']=='1')
  1760. {
  1761. if(!$options['save_delimiter'] && Preferences('DELIMITER')=='CSV')
  1762. $options['save_delimiter'] = 'comma';
  1763. switch($options['save_delimiter'])
  1764. {
  1765. case 'comma':
  1766. $extension = 'csv';
  1767. break;
  1768. case 'xml':
  1769. $extension = 'xml';
  1770. break;
  1771. default:
  1772. $extension = 'xls';
  1773. break;
  1774. }
  1775. ob_end_clean();
  1776. if($options['save_delimiter']!='xml')
  1777. {
  1778. foreach($column_names as $key=>$value)
  1779. $output .= str_replace('&nbsp;',' ',eregi_replace('<BR>',' ',ereg_replace('<!--.*-->','',$value))) . ($options['save_delimiter']=='comma'?',':"\t");
  1780. $output .= "\n";
  1781. }
  1782. foreach($result as $item)
  1783. {
  1784. foreach($column_names as $key=>$value)
  1785. {
  1786. if($options['save_delimiter']=='comma' && !$options['save_quotes'])
  1787. $item[$key] = str_replace(',',';',$item[$key]);
  1788. $item[$key] = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$item[$key]);
  1789. $item[$key] = eregi_replace('<SELECT.*</SELECT\>','',$item[$key]);
  1790. $output .= ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='xml'?'<'.str_replace(' ','',$value).'>':'') . ereg_replace('<[^>]+>','',ereg_replace("<div onclick='[^']+'>",'',ereg_replace(' +',' ',ereg_replace('&[^;]+;','',str_replace('<BR>&middot;',' : ',str_replace('&nbsp;',' ',$item[$key])))))) . ($options['save_delimiter']=='xml'?'</'.str_replace(' ','',$value).'>'."\n":'') . ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='comma'?',':"\t");
  1791. }
  1792. $output .= "\n";
  1793. }
  1794. header("Cache-Control: public");
  1795. header("Pragma: ");
  1796. header("Content-Type: application/$extension");
  1797. header("Content-Disposition: inline; filename=\"".ProgramTitle().".$extension\"\n");
  1798. if($options['save_eval'])
  1799. eval($options['save_eval']);
  1800. echo $output;
  1801. exit();
  1802. }
  1803. // END SAVING THE LIST ---
  1804. if($options['center'])
  1805. #echo '<CENTER>';
  1806. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  1807. {
  1808. #echo "<TABLE border=0 cellspacing=3 cellpadding=6>" ;
  1809. if(isset($_REQUEST['_openSIS_PDF']))
  1810. #echo " width=98%";
  1811. echo " <TR><TD align=center>";
  1812. }
  1813. if($options['count'] || $display_zero)
  1814. {
  1815. if(($result_count==0 || $display_count==0) && $plural)
  1816. echo "<div style=text-align:left><table cellpadding=1 cellspacing=0 ><tr><td ></td><td ><b>No $plural were found.</b></td></tr><tr><td colspan=2 ></td></tr></table></div>";
  1817. elseif($result_count==0 || $display_count==0)
  1818. echo '<div style=text-align:left><table cellpadding=1 cellspacing=0 ><tr><td ></td><td ><b>None were found.</b></td></tr><tr><td colspan=2></td></tr></table></div>';
  1819. }
  1820. if($result_count != 0 || ($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search'))
  1821. {
  1822. if(!isset($_REQUEST['_openSIS_PDF']))
  1823. {
  1824. if(!$_REQUEST['page'])
  1825. $_REQUEST['page'] = 1;
  1826. if(!$_REQUEST['LO_direction'])
  1827. $_REQUEST['LO_direction'] = 1;
  1828. $start = ($_REQUEST['page'] - 1) * $num_displayed + 1;
  1829. $stop = $start + ($num_displayed-1);
  1830. if($stop > $result_count)
  1831. $stop = $result_count;
  1832. if($result_count > $num_displayed)
  1833. {
  1834. $where_message = "<SMALL>Displaying $start through $stop</SMALL>";
  1835. echo "Go to Page ";
  1836. if(ceil($result_count/$num_displayed) <= 10)
  1837. {
  1838. for($i=1;$i<=ceil($result_count/$num_displayed);$i++)
  1839. {
  1840. if($i!=$_REQUEST['page'])
  1841. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  1842. else
  1843. $pages .= "$i, ";
  1844. }
  1845. $pages = substr($pages,0,-2) . "<BR>";
  1846. }
  1847. else
  1848. {
  1849. for($i=1;$i<=7;$i++)
  1850. {
  1851. if($i!=$_REQUEST['page'])
  1852. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  1853. else
  1854. $pages .= "$i, ";
  1855. }
  1856. $pages = substr($pages,0,-2) . " ... ";
  1857. for($i=ceil($result_count/$num_displayed)-2;$i<=ceil($result_count/$num_displayed);$i++)
  1858. {
  1859. if($i!=$_REQUEST['page'])
  1860. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  1861. else
  1862. $pages .= "$i, ";
  1863. }
  1864. $pages = substr($pages,0,-2) . " &nbsp;<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=" . ($_REQUEST['page'] +1) . ">Next Page</A><BR>";
  1865. }
  1866. echo $pages;
  1867. echo '</TD></TR></TABLE>';
  1868. echo '<BR>';
  1869. }
  1870. }
  1871. else
  1872. {
  1873. $start = 1;
  1874. $stop = $result_count;
  1875. if($cols>8 || $_REQUEST['expanded_view'])
  1876. {
  1877. $_SESSION['orientation'] = 'landscape';
  1878. $repeat_headers = 16;
  1879. }
  1880. else
  1881. $repeat_headers = 26;
  1882. if($options['print'])
  1883. {
  1884. $html = explode('',strtolower(ob_get_contents()));
  1885. $html = $html[count($html)-1];
  1886. echo '</TD></TR></TABLE>';
  1887. $br = (substr_count($html,'<br>')) + (substr_count($html,'</p>')) + (substr_count($html,'</tr>')) + (substr_count($html,'</h1>')) + (substr_count($html,'</h2>')) + (substr_count($html,'</h3>')) + (substr_count($html,'</h4>')) + (substr_count($html,'</h5>'));
  1888. if($br%2!=0)
  1889. {
  1890. $br++;
  1891. echo '<BR>';
  1892. }
  1893. }
  1894. else
  1895. echo '</TD></TR></TABLE>';
  1896. }
  1897. // END MISC ---
  1898. // WIDTH = 100%
  1899. echo '<TABLE width=98% border=0 cellspacing=0 cellpadding=0><TR>';
  1900. // SEARCH BOX & MORE HEADERS
  1901. if($where_message || ($singular && $plural) || (!isset($_REQUEST['_openSIS_PDF']) && $options['search']))
  1902. {
  1903. echo '<TD align=center>';
  1904. //echo '<TABLE cellpadding=1 width=100% border=1 style="border-collapse:collapse" >';
  1905. //echo "<TR><TD align=left valign=middle>";
  1906. //if($singular && $plural && $options['count'])
  1907. //{
  1908. /*f($display_count > 1)
  1909. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>$display_count $plural were found.</b></td></tr></table>";
  1910. elseif($display_count==1)
  1911. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>1 $singular was found.</b></td></tr></table>";*/
  1912. //if($where_message)
  1913. //echo '<br>'.$where_message;
  1914. //}
  1915. if($options['save'] && !isset($_REQUEST['_openSIS_PDF']) && $result_count > 0)
  1916. //echo str_replace("Modules.php", "for_export.php", $PHP_tmp_SELF);
  1917. //echo "<table cellpadding=0 cellspacing=0 class=download align=left ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&LO_save=1&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0 alt=\"Download\" title=\"Download\"></a></td></tr></table>";
  1918. //echo "<br><br><table class=download ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0></a></td><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true >Download</A></td></tr></table>";
  1919. echo '</TD>';
  1920. $colspan = 1;
  1921. if(!isset($_REQUEST['_openSIS_PDF']) && $options['search'])
  1922. {
  1923. $tmp_REQUEST = $_REQUEST;
  1924. unset($tmp_REQUEST['LO_search']);
  1925. unset($tmp_REQUEST['page']);
  1926. echo '<TD height="50" align=right valign=middle>';
  1927. echo "<INPUT type=text class='cell_medium' id=LO_search name=LO_search value='".(($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')?$_REQUEST['LO_search']:'Search\' style=\'color:BBBBBB\''),"' onfocus='if(this.value==\"Search\") this.value=\"\"; this.style.color=\"000000\";' onblur='if(this.value==\"\") {this.value=\"Search\"; this.style.color=\"BBBBBB\";}' onkeypress='if(event.keyCode==13){document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+this.value; return false;} '>&nbsp;&nbsp;<INPUT type=button class='btn_go' value=Go onclick='document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+document.getElementById(\"LO_search\").value;'></TD>";
  1928. $colspan++;
  1929. }
  1930. echo "</TR>";
  1931. echo '<TR style="height:0;"><TD width=100% align=center colspan='.$colspan.'><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV></TD></TR></TABLE>';
  1932. }
  1933. else
  1934. echo '<TD width=100% align=right><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV>';
  1935. // END SEARCH BOX ----
  1936. echo '</TD></TR><TR><TD>';
  1937. // SHADOW
  1938. if(!isset($_REQUEST['_openSIS_PDF']))
  1939. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  1940. echo "<TABLE cellpadding=6 width=100% cellspacing=1 border=\"1px solid #a9d5e9 \" style=\"border-collapse:collapse\" align=center>";
  1941. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  1942. echo '<THEAD>';
  1943. if(!isset($_REQUEST['_openSIS_PDF']))
  1944. echo '<TR>';
  1945. $i =1;
  1946. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  1947. {
  1948. //THIS LINE IS FOR COLUMN HEADING
  1949. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV></TD>";
  1950. $i++;
  1951. }
  1952. if($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))
  1953. {
  1954. foreach($column_names as $key=>$value)
  1955. {
  1956. if($_REQUEST['LO_sort'] == $key)
  1957. $direction = -1 * $_REQUEST['LO_direction'];
  1958. else
  1959. $direction = 1;
  1960. //THIS LINE IS FOR COLUMN HEADING
  1961. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV>";
  1962. echo "<A ";
  1963. if($options['sort'])
  1964. echo "HREF=$PHP_tmp_SELF&page=$_REQUEST[page]&LO_sort=$key&LO_direction=$direction&LO_search=".urlencode($_REQUEST['LO_search']);
  1965. echo " class=column_heading><b>$value</b></A>";
  1966. if($i==1)
  1967. echo "<DIV id=LOy0 style='position: relative;'></DIV>";
  1968. echo "</TD>";
  1969. $i++;
  1970. }
  1971. //echo '<TD width=0><DIV id=LO'.$i.'></DIV></TD>';
  1972. echo "</TR>";
  1973. }
  1974. $color = 'bgcolor="#ffffff"';
  1975. //style="height: 300px; overflow: auto; padding-right: 16px;"
  1976. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  1977. echo '</THEAD><TBODY>';
  1978. // mab - enable add link as first or last
  1979. if($result_count!=0 && $link['add']['first'] && ($stop-$start)>=$link['add']['first'])
  1980. {
  1981. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  1982. // $cols++;
  1983. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  1984. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  1985. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  1986. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  1987. elseif($link['add']['html'] && $cols)
  1988. {
  1989. echo "<TR $color>";
  1990. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  1991. echo "<TD class=even align=left>".$link['add']['html']['remove']."</TD>";
  1992. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  1993. echo "<TD class=even align=left>".button('add')."</TD>";
  1994. foreach($column_names as $key=>$value)
  1995. {
  1996. echo "<TD class=even align=left >".$link['add']['html'][$key]."</TD>";
  1997. }
  1998. echo "</TR>";
  1999. $count++;
  2000. }
  2001. }
  2002. for($i=$start;$i<=$stop;$i++)
  2003. {
  2004. $item = $result[$i];
  2005. if(isset($_REQUEST['_openSIS_PDF']) && $options['print'] && count($item))
  2006. {
  2007. foreach($item as $key=>$value)
  2008. {
  2009. $value = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$value);
  2010. $value = eregi_replace('<SELECT.*</SELECT\>','',$value);
  2011. if(strpos($value,'LO_field')===false)
  2012. $item[$key] = str_replace(' ','&nbsp;',ereg_replace("<div onclick='[^']+'>",'',$value));
  2013. else
  2014. $item[$key] = ereg_replace("<div onclick='[^']+'>",'',$value);
  2015. }
  2016. }
  2017. if($item['row_color'])
  2018. $color = $item['row_color'];
  2019. elseif($color=='bgcolor="#ffffff"')
  2020. $color = $side_color;
  2021. else
  2022. $color = 'bgcolor="#ffffff"';
  2023. //$color = '#EDF3FE';
  2024. if(isset($_REQUEST['_openSIS_PDF']) && $count%$repeat_headers==0)
  2025. {
  2026. if($count!=0)
  2027. {
  2028. echo '</TABLE>';
  2029. echo "<div style=\"page-break-after: always;\"></div>";
  2030. echo "<table width=100% style=\" font-family:Arial; font-size:12px;\" >";
  2031. echo "<tr><td style=\"font-size:15px; font-weight:bold; padding-top:20px;\">". GetSchool(UserSchool())."<div style=\"font-size:12px;\">Student Advanced Report</div></td><td align=right style=\"padding-top:20px;\">". ProperDate(DBDate()) ."<br />Powered by openSIS</td></tr><tr><td colspan=2 style=\"border-top:1px solid #333;\">&nbsp;</td></tr></table>";
  2032. echo '<TABLE cellpadding=6 width=100% cellspacing=1 border="1px solid #a9d5e9 " style="border-collapse:collapse" align=center>';
  2033. }
  2034. echo "<TR>";
  2035. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  2036. echo "<TD bgcolor=#d3d3d3></TD>";
  2037. if($cols)
  2038. {
  2039. foreach($column_names as $key=>$value)
  2040. {
  2041. echo "<TD bgcolor=#d3d3d3 >" . str_replace(' ','&nbsp;',$value) . "</TD>";
  2042. }
  2043. }
  2044. echo "</TR>";
  2045. }
  2046. if($count==0)
  2047. $count = $br;
  2048. echo "<TR $color>";
  2049. $count++;
  2050. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  2051. {
  2052. $button_title = $link['remove']['title'];
  2053. $button_link = $link['remove']['link'];
  2054. if(count($link['remove']['variables']))
  2055. {
  2056. foreach($link['remove']['variables'] as $var=>$val)
  2057. $button_link .= "&$var=" . urlencode($item[$val]);
  2058. }
  2059. echo "<TD $color>" . button('remove',$button_title,$button_link) . "</TD>";
  2060. }
  2061. if($cols)
  2062. {
  2063. foreach($column_names as $key=>$value)
  2064. {
  2065. if($link[$key] && !isset($_REQUEST['_openSIS_PDF']))
  2066. {
  2067. echo "<TD $color >";
  2068. if($key=='FULL_NAME')
  2069. echo '<DIV id=LOy'.($count-$br).' style="height: 100%; min-height: 100%; position: relative;">';
  2070. if($link[$key]['js']===true)
  2071. {
  2072. echo "<A HREF=# onclick='window.open(\"{$link[$key][link]}";
  2073. if(count($link[$key]['variables']))
  2074. {
  2075. foreach($link[$key]['variables'] as $var=>$val)
  2076. echo "&$var=".urlencode($item[$val]);
  2077. }
  2078. echo "\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'";
  2079. if($link[$key]['extra'])
  2080. echo ' '.$link[$key]['extra'];
  2081. echo ">";
  2082. }
  2083. else
  2084. {
  2085. echo "<A HREF={$link[$key][link]}";
  2086. if(count($link[$key]['variables']))
  2087. {
  2088. foreach($link[$key]['variables'] as $var=>$val)
  2089. echo "&$var=".urlencode($item[$val]);
  2090. }
  2091. if($link[$key]['extra'])
  2092. echo ' '.$link[$key]['extra'];
  2093. echo " onclick='grabA(this); return false;'>";
  2094. }
  2095. if($color==Preferences('HIGHLIGHT'))
  2096. echo '';
  2097. else
  2098. echo '<b>';
  2099. echo $item[$key];
  2100. echo '</b>';
  2101. if(!$item[$key])
  2102. echo '***';
  2103. echo "</A>";
  2104. if($key=='FULL_NAME')
  2105. echo '</DIV>';
  2106. echo "</TD>";
  2107. }
  2108. else
  2109. {
  2110. echo "<TD $color >";
  2111. if($key=='FULL_NAME')
  2112. echo '<DIV id=LOy'.($count-$br).' style="position: relative;">';
  2113. if($color==Preferences('HIGHLIGHT'))
  2114. echo '';
  2115. //echo $item[$key];
  2116. if(count(explode(',',$item[$key])) > 1)
  2117. {
  2118. $room=explode(',',$item[$key]);
  2119. for($v=0;$v<count(explode(',',$item[$key])); $v++)
  2120. {
  2121. echo $room[$v].'<br/>';
  2122. }
  2123. }
  2124. else
  2125. echo $item[$key];
  2126. if(!$item[$key])
  2127. echo '&nbsp;';
  2128. if($key=='FULL_NAME')
  2129. echo '<DIV>';
  2130. echo "</TD>";
  2131. }
  2132. }
  2133. }
  2134. echo "</TR>";
  2135. }
  2136. if($result_count!=0 && (!$link['add']['first'] || $link['add']['first'] && ($stop-$start)<$link['add']['first']))
  2137. {
  2138. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  2139. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  2140. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  2141. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  2142. elseif($link['add']['html'] && $cols)
  2143. {
  2144. if($count%2)
  2145. $color = 'bgcolor=#ffffff';
  2146. else
  2147. $color = $side_color;
  2148. echo "<TR $color>";
  2149. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  2150. echo "<TD bgcolor=#ffffff align=left>".$link['add']['html']['remove']."</TD>";
  2151. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  2152. echo "<TD bgcolor=#ffffff align=left >".button('add')."</TD>";
  2153. foreach($column_names as $key=>$value)
  2154. {
  2155. echo "<TD bgcolor=#ffffff align=left valign=top>".$link['add']['html'][$key]."</TD>";
  2156. }
  2157. echo "</TR>";
  2158. }
  2159. }
  2160. if($result_count!=0)
  2161. {
  2162. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  2163. echo '</TBODY>';
  2164. echo "</TABLE>";
  2165. if(!isset($_REQUEST['_openSIS_PDF']))
  2166. echo '</TD ></TR></TABLE>';
  2167. echo "</TD ></TR>";
  2168. echo "</TABLE>";
  2169. if($options['center'])
  2170. echo '';
  2171. }
  2172. }
  2173. if($result_count==0)
  2174. {
  2175. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  2176. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  2177. echo '<table width=120px cellspacing=8 cellpadding=6 ><tr><TD align=left class=lone_add >' . button('add',$link['add']['title'],$link['add']['link']) . '</td></tr></table>';
  2178. elseif(($link['add']['html'] || $link['add']['span']) && count($column_names) && !isset($_REQUEST['_openSIS_PDF']))
  2179. {
  2180. $color = $side_color;
  2181. if($options['center'])
  2182. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  2183. if($link['add']['html'])
  2184. {
  2185. echo "<TABLE cellpadding=6 cellspacing=1 width=96% class=\"grid\"><TR><TD class=subtabs></TD>";
  2186. foreach($column_names as $key=>$value)
  2187. {
  2188. echo "<TD class=subtabs><A><b>" . str_replace(' ','&nbsp;',$value) . "</b></A></TD>";
  2189. }
  2190. echo "</TR>";
  2191. echo "<TR class=odd>";
  2192. if($link['add']['html']['remove'])
  2193. echo "<TD >".$link['add']['html']['remove']."</TD>";
  2194. else
  2195. echo "<TD>".button('add')."</TD>";
  2196. foreach($column_names as $key=>$value)
  2197. {
  2198. echo "<TD >".$link['add']['html'][$key]."</TD>";
  2199. }
  2200. echo "</TR>";
  2201. echo "</TABLE>";
  2202. }
  2203. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  2204. echo "<TABLE><TR><TD align=center>".button('add').$link['add']['span']."</TD></TR></TABLE>";
  2205. echo "</TD></TR></TABLE>";
  2206. if($options['center'])
  2207. echo '</CENTER>';
  2208. }
  2209. }
  2210. if($result_count!=0)
  2211. {
  2212. if($options['yscroll'])
  2213. {
  2214. echo '<div id="LOy_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  2215. echo '<TABLE cellpadding=6 id=LOy_table>';
  2216. $i = 1;
  2217. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  2218. {
  2219. $color = $side_color;
  2220. foreach($result as $item)
  2221. {
  2222. echo "<TR><TD $color id=LO_row$i>";
  2223. if($color==Preferences('HIGHLIGHT'))
  2224. echo '';
  2225. echo $item['FULL_NAME'];
  2226. if(!$item['FULL_NAME'])
  2227. echo '&nbsp;';
  2228. if($color==Preferences('HIGHLIGHT'))
  2229. echo '';
  2230. echo "</TD></TR>";
  2231. $i++;
  2232. if($item['row_color'])
  2233. $color = $item['row_color'];
  2234. elseif($color=='class=even')
  2235. $color = $side_color;
  2236. else
  2237. $color = 'class=even';
  2238. }
  2239. }
  2240. echo '</TABLE>';
  2241. echo '</div>';
  2242. }
  2243. echo '<div id="LOx_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">'; echo '<div style="page-break-before: inherit;">&nbsp;</div>';
  2244. echo '<TABLE cellpadding=6 id=LOx_table><TR>';
  2245. $i = 1;
  2246. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  2247. {
  2248. echo "<TD class=grid id=LO_col$i></TD>";
  2249. $i++;
  2250. }
  2251. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  2252. {
  2253. foreach($column_names as $key=>$value)
  2254. {
  2255. echo '<TD class=grid id=LO_col'.$i.'><A class=column_heading><b>'.str_replace('controller','',$value).'</b></A></TD>';
  2256. $i++;
  2257. }
  2258. }
  2259. echo '</TR></TABLE>';
  2260. echo '</div>';
  2261. }
  2262. }
  2263. }
  2264. function ListOutputPrint($result,$column_names,$singular='',$plural='',$link=false,$group=false,$options=false)
  2265. {
  2266. if(!isset($options['save']))
  2267. $options['save'] = true;
  2268. if(!isset($options['print']))
  2269. $options['print'] = true;
  2270. if(!isset($options['search']))
  2271. $options['search'] = true;
  2272. if(!isset($options['center']))
  2273. $options['center'] = true;
  2274. if(!isset($options['count']))
  2275. $options['count'] = true;
  2276. if(!isset($options['sort']))
  2277. $options['sort'] = true;
  2278. if(!$link)
  2279. $link = array();
  2280. if(!isset($options['add']))
  2281. {
  2282. if(!AllowEdit() || $_REQUEST['_openSIS_PDF'])
  2283. {
  2284. if($link)
  2285. {
  2286. unset($link['add']);
  2287. unset($link['remove']);
  2288. }
  2289. }
  2290. }
  2291. // PREPARE LINKS ---
  2292. $result_count = $display_count = count($result);
  2293. $num_displayed = 100000;
  2294. $extra = "page=$_REQUEST[page]&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search']);
  2295. $tmp_REQUEST = $_REQUEST;
  2296. unset($tmp_REQUEST['page']);
  2297. unset($tmp_REQUEST['LO_sort']);
  2298. unset($tmp_REQUEST['LO_direction']);
  2299. unset($tmp_REQUEST['LO_search']);
  2300. unset($tmp_REQUEST['remove_prompt']);
  2301. unset($tmp_REQUEST['remove_name']);
  2302. unset($tmp_REQUEST['LO_save']);
  2303. unset($tmp_REQUEST['PHPSESSID']);
  2304. $PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);
  2305. // END PREPARE LINKS ---
  2306. // UN-GROUPING
  2307. $group_count = count($group);
  2308. if(!is_array($group))
  2309. $group_count = false;
  2310. //$side_color = Preferences('COLOR');
  2311. $side_color = 'bgcolor="#f5f5f5"';
  2312. if($group_count && $result_count)
  2313. {
  2314. $color = 'style=" background-color:#fff; padding:3px 4px 3px 4px;"';
  2315. $group_result = $result;
  2316. unset($result);
  2317. $result[0] = '';
  2318. foreach($group_result as $item1)
  2319. {
  2320. if($group_count==1)
  2321. {
  2322. if($color=='bgcolor="#f5f5f5"')
  2323. $color = $side_color;
  2324. else
  2325. $color = 'bgcolor="#f5f5f5"';
  2326. }
  2327. foreach($item1 as $item2)
  2328. {
  2329. if($group_count==1)
  2330. {
  2331. $i++;
  2332. if(count($group[0]) && $i!=1)
  2333. {
  2334. foreach($group[0] as $column)
  2335. $item2[$column] = str_replace('<!-- <!--','<!--','<!-- '.str_replace('-->','--><!--',$item2[$column])).' -->';
  2336. }
  2337. $item2['row_color'] = $color;
  2338. $result[] = $item2;
  2339. }
  2340. else
  2341. {
  2342. if($group_count==2)
  2343. {
  2344. if($color=='bgcolor="#ffffff"')
  2345. $color = $side_color;
  2346. else
  2347. $color = 'bgcolor="#ffffff"';
  2348. }
  2349. foreach($item2 as $item3)
  2350. {
  2351. if($group_count==2)
  2352. {
  2353. $i++;
  2354. if(count($group[0]) && $i!=1)
  2355. {
  2356. foreach($group[0] as $column)
  2357. $item3[$column] = '<!-- '.$item3[$column].' -->';
  2358. }
  2359. if(count($group[1]) && $i!=1)
  2360. {
  2361. foreach($group[1] as $column)
  2362. $item3[$column] = '<!-- '.$item3[$column].' -->';
  2363. }
  2364. $item3['row_color'] = $color;
  2365. $result[] = $item3;
  2366. }
  2367. else
  2368. {
  2369. if($group_count==3)
  2370. {
  2371. if($color=='bgcolor="#ffffff"')
  2372. $color = $side_color;
  2373. else
  2374. $color = 'bgcolor="#ffffff"';
  2375. }
  2376. foreach($item3 as $item4)
  2377. {
  2378. if($group_count==3)
  2379. {
  2380. $i++;
  2381. if(count($group[2]) && $i!=1)
  2382. {
  2383. foreach($group[2] as $column)
  2384. unset($item4[$column]);
  2385. }
  2386. $item4['row_color'] = $color;
  2387. $result[] = $item4;
  2388. }
  2389. }
  2390. }
  2391. }
  2392. }
  2393. }
  2394. $i = 0;
  2395. }
  2396. unset($result[0]);
  2397. $result_count = count($result);
  2398. unset($_REQUEST['LO_sort']);
  2399. }
  2400. // END UN-GROUPING
  2401. $_LIST['output'] = true;
  2402. // PRINT HEADINGS, PREPARE PDF, AND SORT THE LIST ---
  2403. if($_LIST['output']!=false)
  2404. {
  2405. if($result_count != 0)
  2406. {
  2407. $count = 0;
  2408. $remove = count($link['remove']['variables']);
  2409. $cols = count($column_names);
  2410. // HANDLE SEARCHES ---
  2411. if($result_count && $_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')
  2412. {
  2413. $_REQUEST['LO_search'] = $search_term = str_replace('\\\"','"',$_REQUEST['LO_search']);
  2414. $_REQUEST['LO_search'] = $search_term = ereg_replace('[^a-zA-Z0-9 _"]*','',strtolower($search_term));
  2415. if(substr($search_term,0,0)!='"' && substr($search_term,-1)!='"')
  2416. {
  2417. $search_term = ereg_replace('"','',$search_term);
  2418. while($space_pos = strpos($search_term,' '))
  2419. {
  2420. $terms[strtolower(substr($search_term,0,$space_pos))] = 1;
  2421. $search_term = substr($search_term,($space_pos+1));
  2422. }
  2423. $terms[trim($search_term)] = 1;
  2424. }
  2425. else
  2426. {
  2427. $search_term = ereg_replace('"','',$search_term);
  2428. $terms[trim($search_term)] = 1;
  2429. }
  2430. unset($terms['of']); unset($terms['the']); unset($terms['a']); unset($terms['an']); unset($terms['in']);
  2431. foreach($result as $key=>$value)
  2432. {
  2433. $values[$key] = 0;
  2434. foreach($value as $name=>$val)
  2435. {
  2436. $val = ereg_replace('[^a-zA-Z0-9 _]+','',strtolower($val));
  2437. if(strtolower($_REQUEST['LO_search'])==$val)
  2438. $values[$key] += 25;
  2439. foreach($terms as $term=>$one)
  2440. {
  2441. if(ereg($term,$val))
  2442. $values[$key] += 3;
  2443. }
  2444. }
  2445. if($values[$key]==0)
  2446. {
  2447. unset($values[$key]);
  2448. unset($result[$key]);
  2449. $result_count--;
  2450. $display_count--;
  2451. }
  2452. }
  2453. if($result_count)
  2454. {
  2455. array_multisort($values,SORT_DESC,$result);
  2456. $result = ReindexResults($result);
  2457. $values = ReindexResults($values);
  2458. $last_value = 1;
  2459. $scale = (100/$values[$last_value]);
  2460. for($i=$last_value;$i<=$result_count;$i++)
  2461. $result[$i]['RELEVANCE'] = '<!--' . ((int) ($values[$i]*$scale)) . '--><IMG SRC="assets/pixel_grey.gif" width=' . ((int) ($values[$i]*$scale)) . ' height=10>';
  2462. }
  2463. $column_names['RELEVANCE'] = "Relevance";
  2464. if(is_array($group) && count($group))
  2465. {
  2466. $options['count'] == false;
  2467. $display_zero = true;
  2468. }
  2469. }
  2470. // END SEARCHES ---
  2471. if($_REQUEST['LO_sort'])
  2472. {
  2473. foreach($result as $sort)
  2474. {
  2475. if(substr($sort[$_REQUEST['LO_sort']],0,4)!='<!--')
  2476. $sort_array[] = $sort[$_REQUEST['LO_sort']];
  2477. else
  2478. $sort_array[] = substr($sort[$_REQUEST['LO_sort']],4,strpos($sort[$_REQUEST['LO_sort']],'-->')-5);
  2479. }
  2480. if($_REQUEST['LO_direction']==-1)
  2481. $dir = SORT_DESC;
  2482. else
  2483. $dir = SORT_ASC;
  2484. if($result_count>1)
  2485. {
  2486. if(is_int($sort_array[1]) || is_double($sort_array[1]))
  2487. array_multisort($sort_array,$dir,SORT_NUMERIC,$result);
  2488. else
  2489. array_multisort($sort_array,$dir,$result);
  2490. for($i=$result_count-1;$i>=0;$i--)
  2491. $result[$i+1] = $result[$i];
  2492. unset($result[0]);
  2493. }
  2494. }
  2495. }
  2496. // HANDLE SAVING THE LIST ---
  2497. if($_REQUEST['LO_save']=='1')
  2498. {
  2499. if(!$options['save_delimiter'] && Preferences('DELIMITER')=='CSV')
  2500. $options['save_delimiter'] = 'comma';
  2501. switch($options['save_delimiter'])
  2502. {
  2503. case 'comma':
  2504. $extension = 'csv';
  2505. break;
  2506. case 'xml':
  2507. $extension = 'xml';
  2508. break;
  2509. default:
  2510. $extension = 'xls';
  2511. break;
  2512. }
  2513. ob_end_clean();
  2514. if($options['save_delimiter']!='xml')
  2515. {
  2516. foreach($column_names as $key=>$value)
  2517. $output .= str_replace('&nbsp;',' ',eregi_replace('<BR>',' ',ereg_replace('<!--.*-->','',$value))) . ($options['save_delimiter']=='comma'?',':"\t");
  2518. $output .= "\n";
  2519. }
  2520. foreach($result as $item)
  2521. {
  2522. foreach($column_names as $key=>$value)
  2523. {
  2524. if($options['save_delimiter']=='comma' && !$options['save_quotes'])
  2525. $item[$key] = str_replace(',',';',$item[$key]);
  2526. $item[$key] = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$item[$key]);
  2527. $item[$key] = eregi_replace('<SELECT.*</SELECT\>','',$item[$key]);
  2528. $output .= ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='xml'?'<'.str_replace(' ','',$value).'>':'') . ereg_replace('<[^>]+>','',ereg_replace("<div onclick='[^']+'>",'',ereg_replace(' +',' ',ereg_replace('&[^;]+;','',str_replace('<BR>&middot;',' : ',str_replace('&nbsp;',' ',$item[$key])))))) . ($options['save_delimiter']=='xml'?'</'.str_replace(' ','',$value).'>'."\n":'') . ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='comma'?',':"\t");
  2529. }
  2530. $output .= "\n";
  2531. }
  2532. header("Cache-Control: public");
  2533. header("Pragma: ");
  2534. header("Content-Type: application/$extension");
  2535. header("Content-Disposition: inline; filename=\"".ProgramTitle().".$extension\"\n");
  2536. if($options['save_eval'])
  2537. eval($options['save_eval']);
  2538. echo $output;
  2539. exit();
  2540. }
  2541. // END SAVING THE LIST ---
  2542. if($options['center'])
  2543. #echo '<CENTER>';
  2544. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  2545. {
  2546. #echo "<TABLE border=0 cellspacing=3 cellpadding=6>" ;
  2547. if(isset($_REQUEST['_openSIS_PDF']))
  2548. #echo " width=98%";
  2549. echo " <TR><TD align=center>";
  2550. }
  2551. if($options['count'] || $display_zero)
  2552. {
  2553. if(($result_count==0 || $display_count==0) && $plural)
  2554. echo "<div style=text-align:left><table cellpadding=1 cellspacing=0 ><tr><td ></td><td ><b>No $plural were found.</b></td></tr><tr><td colspan=2 ></td></tr></table></div>";
  2555. elseif($result_count==0 || $display_count==0)
  2556. echo '<div style=text-align:left><table cellpadding=1 cellspacing=0 ><tr><td ></td><td ><b>None were found.</b></td></tr><tr><td colspan=2></td></tr></table></div>';
  2557. }
  2558. if($result_count != 0 || ($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search'))
  2559. {
  2560. if(!isset($_REQUEST['_openSIS_PDF']))
  2561. {
  2562. if(!$_REQUEST['page'])
  2563. $_REQUEST['page'] = 1;
  2564. if(!$_REQUEST['LO_direction'])
  2565. $_REQUEST['LO_direction'] = 1;
  2566. $start = ($_REQUEST['page'] - 1) * $num_displayed + 1;
  2567. $stop = $start + ($num_displayed-1);
  2568. if($stop > $result_count)
  2569. $stop = $result_count;
  2570. if($result_count > $num_displayed)
  2571. {
  2572. $where_message = "<SMALL>Displaying $start through $stop</SMALL>";
  2573. echo "Go to Page ";
  2574. if(ceil($result_count/$num_displayed) <= 10)
  2575. {
  2576. for($i=1;$i<=ceil($result_count/$num_displayed);$i++)
  2577. {
  2578. if($i!=$_REQUEST['page'])
  2579. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  2580. else
  2581. $pages .= "$i, ";
  2582. }
  2583. $pages = substr($pages,0,-2) . "<BR>";
  2584. }
  2585. else
  2586. {
  2587. for($i=1;$i<=7;$i++)
  2588. {
  2589. if($i!=$_REQUEST['page'])
  2590. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  2591. else
  2592. $pages .= "$i, ";
  2593. }
  2594. $pages = substr($pages,0,-2) . " ... ";
  2595. for($i=ceil($result_count/$num_displayed)-2;$i<=ceil($result_count/$num_displayed);$i++)
  2596. {
  2597. if($i!=$_REQUEST['page'])
  2598. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  2599. else
  2600. $pages .= "$i, ";
  2601. }
  2602. $pages = substr($pages,0,-2) . " &nbsp;<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=" . ($_REQUEST['page'] +1) . ">Next Page</A><BR>";
  2603. }
  2604. echo $pages;
  2605. echo '</TD></TR></TABLE>';
  2606. echo '<BR>';
  2607. }
  2608. }
  2609. else
  2610. {
  2611. $start = 1;
  2612. $stop = $result_count;
  2613. if($cols>8 || $_REQUEST['expanded_view'])
  2614. {
  2615. $_SESSION['orientation'] = 'landscape';
  2616. $repeat_headers = 16;
  2617. }
  2618. else
  2619. $repeat_headers = 26;
  2620. if($options['print'])
  2621. {
  2622. $html = explode('',strtolower(ob_get_contents()));
  2623. $html = $html[count($html)-1];
  2624. echo '</TD></TR></TABLE>';
  2625. $br = (substr_count($html,'<br>')) + (substr_count($html,'</p>')) + (substr_count($html,'</tr>')) + (substr_count($html,'</h1>')) + (substr_count($html,'</h2>')) + (substr_count($html,'</h3>')) + (substr_count($html,'</h4>')) + (substr_count($html,'</h5>'));
  2626. if($br%2!=0)
  2627. {
  2628. $br++;
  2629. echo '<BR>';
  2630. }
  2631. }
  2632. else
  2633. echo '</TD></TR></TABLE>';
  2634. }
  2635. // END MISC ---
  2636. // WIDTH = 100%
  2637. echo '<TABLE width=98% border=0 cellspacing=0 cellpadding=0><TR>';
  2638. // SEARCH BOX & MORE HEADERS
  2639. if($where_message || ($singular && $plural) || (!isset($_REQUEST['_openSIS_PDF']) && $options['search']))
  2640. {
  2641. echo '<TD align=center>';
  2642. //echo '<TABLE cellpadding=1 width=100% border=1 style="border-collapse:collapse" >';
  2643. //echo "<TR><TD align=left valign=middle>";
  2644. //if($singular && $plural && $options['count'])
  2645. //{
  2646. /*f($display_count > 1)
  2647. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>$display_count $plural were found.</b></td></tr></table>";
  2648. elseif($display_count==1)
  2649. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>1 $singular was found.</b></td></tr></table>";*/
  2650. //if($where_message)
  2651. //echo '<br>'.$where_message;
  2652. //}
  2653. if($options['save'] && !isset($_REQUEST['_openSIS_PDF']) && $result_count > 0)
  2654. //echo str_replace("Modules.php", "for_export.php", $PHP_tmp_SELF);
  2655. //echo "<table cellpadding=0 cellspacing=0 class=download align=left ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&LO_save=1&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0 alt=\"Download\" title=\"Download\"></a></td></tr></table>";
  2656. //echo "<br><br><table class=download ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0></a></td><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true >Download</A></td></tr></table>";
  2657. echo '</TD>';
  2658. $colspan = 1;
  2659. if(!isset($_REQUEST['_openSIS_PDF']) && $options['search'])
  2660. {
  2661. $tmp_REQUEST = $_REQUEST;
  2662. unset($tmp_REQUEST['LO_search']);
  2663. unset($tmp_REQUEST['page']);
  2664. echo '<TD height="50" align=right valign=middle>';
  2665. echo "<INPUT type=text class='cell_medium' id=LO_search name=LO_search value='".(($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')?$_REQUEST['LO_search']:'Search\' style=\'color:BBBBBB\''),"' onfocus='if(this.value==\"Search\") this.value=\"\"; this.style.color=\"000000\";' onblur='if(this.value==\"\") {this.value=\"Search\"; this.style.color=\"BBBBBB\";}' onkeypress='if(event.keyCode==13){document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+this.value; return false;} '>&nbsp;&nbsp;<INPUT type=button class='btn_go' value=Go onclick='document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+document.getElementById(\"LO_search\").value;'></TD>";
  2666. $colspan++;
  2667. }
  2668. echo "</TR>";
  2669. echo '<TR style="height:0;"><TD width=100% align=center colspan='.$colspan.'><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV></TD></TR></TABLE>';
  2670. }
  2671. else
  2672. echo '<TD width=100% align=right><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV>';
  2673. // END SEARCH BOX ----
  2674. echo '</TD></TR><TR><TD>';
  2675. // SHADOW
  2676. if(!isset($_REQUEST['_openSIS_PDF']))
  2677. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  2678. echo "<TABLE cellpadding=6 width=100% cellspacing=1 border=\"1px solid #a9d5e9 \" style=\"border-collapse:collapse\" align=center>";
  2679. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  2680. echo '<THEAD>';
  2681. if(!isset($_REQUEST['_openSIS_PDF']))
  2682. echo '<TR>';
  2683. $i =1;
  2684. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  2685. {
  2686. //THIS LINE IS FOR COLUMN HEADING
  2687. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV></TD>";
  2688. $i++;
  2689. }
  2690. if($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))
  2691. {
  2692. foreach($column_names as $key=>$value)
  2693. {
  2694. if($_REQUEST['LO_sort'] == $key)
  2695. $direction = -1 * $_REQUEST['LO_direction'];
  2696. else
  2697. $direction = 1;
  2698. //THIS LINE IS FOR COLUMN HEADING
  2699. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV>";
  2700. echo "<A ";
  2701. if($options['sort'])
  2702. echo "HREF=$PHP_tmp_SELF&page=$_REQUEST[page]&LO_sort=$key&LO_direction=$direction&LO_search=".urlencode($_REQUEST['LO_search']);
  2703. echo " class=column_heading><b>$value</b></A>";
  2704. if($i==1)
  2705. echo "<DIV id=LOy0 style='position: relative;'></DIV>";
  2706. echo "</TD>";
  2707. $i++;
  2708. }
  2709. //echo '<TD width=0><DIV id=LO'.$i.'></DIV></TD>';
  2710. echo "</TR>";
  2711. }
  2712. $color = 'bgcolor="#ffffff"';
  2713. //style="height: 300px; overflow: auto; padding-right: 16px;"
  2714. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  2715. echo '</THEAD><TBODY>';
  2716. // mab - enable add link as first or last
  2717. if($result_count!=0 && $link['add']['first'] && ($stop-$start)>=$link['add']['first'])
  2718. {
  2719. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  2720. // $cols++;
  2721. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  2722. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  2723. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  2724. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  2725. elseif($link['add']['html'] && $cols)
  2726. {
  2727. echo "<TR $color>";
  2728. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  2729. echo "<TD class=even align=left>".$link['add']['html']['remove']."</TD>";
  2730. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  2731. echo "<TD class=even align=left>".button('add')."</TD>";
  2732. foreach($column_names as $key=>$value)
  2733. {
  2734. echo "<TD class=even align=left >".$link['add']['html'][$key]."</TD>";
  2735. }
  2736. echo "</TR>";
  2737. $count++;
  2738. }
  2739. }
  2740. for($i=$start;$i<=$stop;$i++)
  2741. {
  2742. $item = $result[$i];
  2743. if(isset($_REQUEST['_openSIS_PDF']) && $options['print'] && count($item))
  2744. {
  2745. foreach($item as $key=>$value)
  2746. {
  2747. $value = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$value);
  2748. $value = eregi_replace('<SELECT.*</SELECT\>','',$value);
  2749. if(strpos($value,'LO_field')===false)
  2750. $item[$key] = str_replace(' ','&nbsp;',ereg_replace("<div onclick='[^']+'>",'',$value));
  2751. else
  2752. $item[$key] = ereg_replace("<div onclick='[^']+'>",'',$value);
  2753. }
  2754. }
  2755. if($item['row_color'])
  2756. $color = $item['row_color'];
  2757. elseif($color=='bgcolor="#ffffff"')
  2758. $color = $side_color;
  2759. else
  2760. $color = 'bgcolor="#ffffff"';
  2761. //$color = '#EDF3FE';
  2762. if(isset($_REQUEST['_openSIS_PDF']) && $count%$repeat_headers==0)
  2763. {
  2764. if($count!=0)
  2765. {
  2766. echo '</TABLE>';
  2767. echo "<div style=\"page-break-after: always;\"></div>";
  2768. echo "<table width=100% style=\" font-family:Arial; font-size:12px;\" >";
  2769. echo "<tr><td style=\"font-size:15px; font-weight:bold; padding-top:20px;\">". GetSchool(UserSchool())."<div style=\"font-size:12px;\">Student Advanced Report</div></td><td align=right style=\"padding-top:20px;\">". ProperDate(DBDate()) ."<br />Powered by openSIS</td></tr><tr><td colspan=2 style=\"border-top:1px solid #333;\">&nbsp;</td></tr></table>";
  2770. echo '<TABLE cellpadding=6 width=100% cellspacing=1 border="1px solid #a9d5e9 " style="border-collapse:collapse" align=center>';
  2771. }
  2772. echo "<TR>";
  2773. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  2774. echo "<TD bgcolor=#d3d3d3></TD>";
  2775. if($cols)
  2776. {
  2777. foreach($column_names as $key=>$value)
  2778. {
  2779. echo "<TD bgcolor=#d3d3d3 >" . str_replace(' ','&nbsp;',$value) . "</TD>";
  2780. }
  2781. }
  2782. echo "</TR>";
  2783. }
  2784. if($count==0)
  2785. $count = $br;
  2786. echo "<TR $color>";
  2787. $count++;
  2788. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  2789. {
  2790. $button_title = $link['remove']['title'];
  2791. $button_link = $link['remove']['link'];
  2792. if(count($link['remove']['variables']))
  2793. {
  2794. foreach($link['remove']['variables'] as $var=>$val)
  2795. $button_link .= "&$var=" . urlencode($item[$val]);
  2796. }
  2797. echo "<TD $color>" . button('remove',$button_title,$button_link) . "</TD>";
  2798. }
  2799. if($cols)
  2800. {
  2801. foreach($column_names as $key=>$value)
  2802. {
  2803. if($link[$key] && !isset($_REQUEST['_openSIS_PDF']))
  2804. {
  2805. echo "<TD $color >";
  2806. if($key=='FULL_NAME')
  2807. echo '<DIV id=LOy'.($count-$br).' style="height: 100%; min-height: 100%; position: relative;">';
  2808. if($link[$key]['js']===true)
  2809. {
  2810. echo "<A HREF=# onclick='window.open(\"{$link[$key][link]}";
  2811. if(count($link[$key]['variables']))
  2812. {
  2813. foreach($link[$key]['variables'] as $var=>$val)
  2814. echo "&$var=".urlencode($item[$val]);
  2815. }
  2816. echo "\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'";
  2817. if($link[$key]['extra'])
  2818. echo ' '.$link[$key]['extra'];
  2819. echo ">";
  2820. }
  2821. else
  2822. {
  2823. echo "<A HREF={$link[$key][link]}";
  2824. if(count($link[$key]['variables']))
  2825. {
  2826. foreach($link[$key]['variables'] as $var=>$val)
  2827. echo "&$var=".urlencode($item[$val]);
  2828. }
  2829. if($link[$key]['extra'])
  2830. echo ' '.$link[$key]['extra'];
  2831. echo " onclick='grabA(this); return false;'>";
  2832. }
  2833. if($color==Preferences('HIGHLIGHT'))
  2834. echo '';
  2835. else
  2836. echo '<b>';
  2837. echo $item[$key];
  2838. echo '</b>';
  2839. if(!$item[$key])
  2840. echo '***';
  2841. echo "</A>";
  2842. if($key=='FULL_NAME')
  2843. echo '</DIV>';
  2844. echo "</TD>";
  2845. }
  2846. else
  2847. {
  2848. echo "<TD $color >";
  2849. if($key=='FULL_NAME')
  2850. echo '<DIV id=LOy'.($count-$br).' style="position: relative;">';
  2851. if($color==Preferences('HIGHLIGHT'))
  2852. echo '';
  2853. echo $item[$key];
  2854. if(!$item[$key])
  2855. echo '&nbsp;';
  2856. if($key=='FULL_NAME')
  2857. echo '<DIV>';
  2858. echo "</TD>";
  2859. }
  2860. }
  2861. }
  2862. echo "</TR>";
  2863. }
  2864. if($result_count!=0 && (!$link['add']['first'] || $link['add']['first'] && ($stop-$start)<$link['add']['first']))
  2865. {
  2866. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  2867. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  2868. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  2869. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  2870. elseif($link['add']['html'] && $cols)
  2871. {
  2872. if($count%2)
  2873. $color = 'bgcolor=#ffffff';
  2874. else
  2875. $color = $side_color;
  2876. echo "<TR $color>";
  2877. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  2878. echo "<TD bgcolor=#ffffff align=left>".$link['add']['html']['remove']."</TD>";
  2879. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  2880. echo "<TD bgcolor=#ffffff align=left >".button('add')."</TD>";
  2881. foreach($column_names as $key=>$value)
  2882. {
  2883. echo "<TD bgcolor=#ffffff align=left valign=top>".$link['add']['html'][$key]."</TD>";
  2884. }
  2885. echo "</TR>";
  2886. }
  2887. }
  2888. if($result_count!=0)
  2889. {
  2890. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  2891. echo '</TBODY>';
  2892. echo "</TABLE>";
  2893. if(!isset($_REQUEST['_openSIS_PDF']))
  2894. echo '</TD ></TR></TABLE>';
  2895. echo "</TD ></TR>";
  2896. echo "</TABLE>";
  2897. if($options['center'])
  2898. echo '';
  2899. }
  2900. }
  2901. if($result_count==0)
  2902. {
  2903. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  2904. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  2905. echo '<table width=120px cellspacing=8 cellpadding=6 ><tr><TD align=left class=lone_add >' . button('add',$link['add']['title'],$link['add']['link']) . '</td></tr></table>';
  2906. elseif(($link['add']['html'] || $link['add']['span']) && count($column_names) && !isset($_REQUEST['_openSIS_PDF']))
  2907. {
  2908. $color = $side_color;
  2909. if($options['center'])
  2910. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  2911. if($link['add']['html'])
  2912. {
  2913. echo "<TABLE cellpadding=6 cellspacing=1 width=96% class=\"grid\"><TR><TD class=subtabs></TD>";
  2914. foreach($column_names as $key=>$value)
  2915. {
  2916. echo "<TD class=subtabs><A><b>" . str_replace(' ','&nbsp;',$value) . "</b></A></TD>";
  2917. }
  2918. echo "</TR>";
  2919. echo "<TR class=odd>";
  2920. if($link['add']['html']['remove'])
  2921. echo "<TD >".$link['add']['html']['remove']."</TD>";
  2922. else
  2923. echo "<TD>".button('add')."</TD>";
  2924. foreach($column_names as $key=>$value)
  2925. {
  2926. echo "<TD >".$link['add']['html'][$key]."</TD>";
  2927. }
  2928. echo "</TR>";
  2929. echo "</TABLE>";
  2930. }
  2931. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  2932. echo "<TABLE><TR><TD align=center>".button('add').$link['add']['span']."</TD></TR></TABLE>";
  2933. echo "</TD></TR></TABLE>";
  2934. if($options['center'])
  2935. echo '</CENTER>';
  2936. }
  2937. }
  2938. if($result_count!=0)
  2939. {
  2940. if($options['yscroll'])
  2941. {
  2942. echo '<div id="LOy_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  2943. echo '<TABLE cellpadding=6 id=LOy_table>';
  2944. $i = 1;
  2945. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  2946. {
  2947. $color = $side_color;
  2948. foreach($result as $item)
  2949. {
  2950. echo "<TR><TD $color id=LO_row$i>";
  2951. if($color==Preferences('HIGHLIGHT'))
  2952. echo '';
  2953. echo $item['FULL_NAME'];
  2954. if(!$item['FULL_NAME'])
  2955. echo '&nbsp;';
  2956. if($color==Preferences('HIGHLIGHT'))
  2957. echo '';
  2958. echo "</TD></TR>";
  2959. $i++;
  2960. if($item['row_color'])
  2961. $color = $item['row_color'];
  2962. elseif($color=='class=even')
  2963. $color = $side_color;
  2964. else
  2965. $color = 'class=even';
  2966. }
  2967. }
  2968. echo '</TABLE>';
  2969. echo '</div>';
  2970. }
  2971. echo '<div id="LOx_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">'; echo '<div style="page-break-before: inherit;">&nbsp;</div>';
  2972. echo '<TABLE cellpadding=6 id=LOx_table><TR>';
  2973. $i = 1;
  2974. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  2975. {
  2976. echo "<TD class=grid id=LO_col$i></TD>";
  2977. $i++;
  2978. }
  2979. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  2980. {
  2981. foreach($column_names as $key=>$value)
  2982. {
  2983. echo '<TD class=grid id=LO_col'.$i.'><A class=column_heading><b>'.str_replace('controller','',$value).'</b></A></TD>';
  2984. $i++;
  2985. }
  2986. }
  2987. echo '</TR></TABLE>';
  2988. echo '</div>';
  2989. }
  2990. }
  2991. }
  2992. function ListOutputCustom($result,$column_names,$singular='',$plural='',$link=false,$group=false,$options=false)
  2993. {
  2994. if(!isset($options['save']))
  2995. $options['save'] = true;
  2996. if(!isset($options['print']))
  2997. $options['print'] = true;
  2998. if(!isset($options['search']))
  2999. $options['search'] = true;
  3000. if(!isset($options['center']))
  3001. $options['center'] = true;
  3002. if(!isset($options['count']))
  3003. $options['count'] = true;
  3004. if(!isset($options['sort']))
  3005. $options['sort'] = true;
  3006. if(!$link)
  3007. $link = array();
  3008. if(!isset($options['add']))
  3009. {
  3010. if(!AllowEdit() || $_REQUEST['_openSIS_PDF'])
  3011. {
  3012. if($link)
  3013. {
  3014. unset($link['add']);
  3015. unset($link['remove']);
  3016. }
  3017. }
  3018. }
  3019. // PREPARE LINKS ---
  3020. $result_count = $display_count = count($result);
  3021. $num_displayed = 100000;
  3022. $extra = "page=$_REQUEST[page]&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search']);
  3023. $tmp_REQUEST = $_REQUEST;
  3024. unset($tmp_REQUEST['page']);
  3025. unset($tmp_REQUEST['LO_sort']);
  3026. unset($tmp_REQUEST['LO_direction']);
  3027. unset($tmp_REQUEST['LO_search']);
  3028. unset($tmp_REQUEST['remove_prompt']);
  3029. unset($tmp_REQUEST['remove_name']);
  3030. unset($tmp_REQUEST['LO_save']);
  3031. unset($tmp_REQUEST['PHPSESSID']);
  3032. $PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);
  3033. // END PREPARE LINKS ---
  3034. // UN-GROUPING
  3035. $group_count = count($group);
  3036. if(!is_array($group))
  3037. $group_count = false;
  3038. //$side_color = Preferences('COLOR');
  3039. $side_color = 'bgcolor="#f5f5f5"';
  3040. if($group_count && $result_count)
  3041. {
  3042. $color = 'style=" background-color:#fff; padding:3px 4px 3px 4px;"';
  3043. $group_result = $result;
  3044. unset($result);
  3045. $result[0] = '';
  3046. foreach($group_result as $item1)
  3047. {
  3048. if($group_count==1)
  3049. {
  3050. if($color=='bgcolor="#f5f5f5"')
  3051. $color = $side_color;
  3052. else
  3053. $color = 'bgcolor="#f5f5f5"';
  3054. }
  3055. foreach($item1 as $item2)
  3056. {
  3057. if($group_count==1)
  3058. {
  3059. $i++;
  3060. if(count($group[0]) && $i!=1)
  3061. {
  3062. foreach($group[0] as $column)
  3063. $item2[$column] = str_replace('<!-- <!--','<!--','<!-- '.str_replace('-->','--><!--',$item2[$column])).' -->';
  3064. }
  3065. $item2['row_color'] = $color;
  3066. $result[] = $item2;
  3067. }
  3068. else
  3069. {
  3070. if($group_count==2)
  3071. {
  3072. if($color=='bgcolor="#ffffff"')
  3073. $color = $side_color;
  3074. else
  3075. $color = 'bgcolor="#ffffff"';
  3076. }
  3077. foreach($item2 as $item3)
  3078. {
  3079. if($group_count==2)
  3080. {
  3081. $i++;
  3082. if(count($group[0]) && $i!=1)
  3083. {
  3084. foreach($group[0] as $column)
  3085. $item3[$column] = '<!-- '.$item3[$column].' -->';
  3086. }
  3087. if(count($group[1]) && $i!=1)
  3088. {
  3089. foreach($group[1] as $column)
  3090. $item3[$column] = '<!-- '.$item3[$column].' -->';
  3091. }
  3092. $item3['row_color'] = $color;
  3093. $result[] = $item3;
  3094. }
  3095. else
  3096. {
  3097. if($group_count==3)
  3098. {
  3099. if($color=='bgcolor="#ffffff"')
  3100. $color = $side_color;
  3101. else
  3102. $color = 'bgcolor="#ffffff"';
  3103. }
  3104. foreach($item3 as $item4)
  3105. {
  3106. if($group_count==3)
  3107. {
  3108. $i++;
  3109. if(count($group[2]) && $i!=1)
  3110. {
  3111. foreach($group[2] as $column)
  3112. unset($item4[$column]);
  3113. }
  3114. $item4['row_color'] = $color;
  3115. $result[] = $item4;
  3116. }
  3117. }
  3118. }
  3119. }
  3120. }
  3121. }
  3122. $i = 0;
  3123. }
  3124. unset($result[0]);
  3125. $result_count = count($result);
  3126. unset($_REQUEST['LO_sort']);
  3127. }
  3128. // END UN-GROUPING
  3129. $_LIST['output'] = true;
  3130. // PRINT HEADINGS, PREPARE PDF, AND SORT THE LIST ---
  3131. if($_LIST['output']!=false)
  3132. {
  3133. if($result_count != 0)
  3134. {
  3135. $count = 0;
  3136. $remove = count($link['remove']['variables']);
  3137. $cols = count($column_names);
  3138. // HANDLE SEARCHES ---
  3139. if($result_count && $_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')
  3140. {
  3141. $_REQUEST['LO_search'] = $search_term = str_replace('\\\"','"',$_REQUEST['LO_search']);
  3142. $_REQUEST['LO_search'] = $search_term = ereg_replace('[^a-zA-Z0-9 _"]*','',strtolower($search_term));
  3143. if(substr($search_term,0,0)!='"' && substr($search_term,-1)!='"')
  3144. {
  3145. $search_term = ereg_replace('"','',$search_term);
  3146. while($space_pos = strpos($search_term,' '))
  3147. {
  3148. $terms[strtolower(substr($search_term,0,$space_pos))] = 1;
  3149. $search_term = substr($search_term,($space_pos+1));
  3150. }
  3151. $terms[trim($search_term)] = 1;
  3152. }
  3153. else
  3154. {
  3155. $search_term = ereg_replace('"','',$search_term);
  3156. $terms[trim($search_term)] = 1;
  3157. }
  3158. unset($terms['of']); unset($terms['the']); unset($terms['a']); unset($terms['an']); unset($terms['in']);
  3159. foreach($result as $key=>$value)
  3160. {
  3161. $values[$key] = 0;
  3162. foreach($value as $name=>$val)
  3163. {
  3164. $val = ereg_replace('[^a-zA-Z0-9 _]+','',strtolower($val));
  3165. if(strtolower($_REQUEST['LO_search'])==$val)
  3166. $values[$key] += 25;
  3167. foreach($terms as $term=>$one)
  3168. {
  3169. if(ereg($term,$val))
  3170. $values[$key] += 3;
  3171. }
  3172. }
  3173. if($values[$key]==0)
  3174. {
  3175. unset($values[$key]);
  3176. unset($result[$key]);
  3177. $result_count--;
  3178. $display_count--;
  3179. }
  3180. }
  3181. if($result_count)
  3182. {
  3183. array_multisort($values,SORT_DESC,$result);
  3184. $result = ReindexResults($result);
  3185. $values = ReindexResults($values);
  3186. $last_value = 1;
  3187. $scale = (100/$values[$last_value]);
  3188. for($i=$last_value;$i<=$result_count;$i++)
  3189. $result[$i]['RELEVANCE'] = '<!--' . ((int) ($values[$i]*$scale)) . '--><IMG SRC="assets/pixel_grey.gif" width=' . ((int) ($values[$i]*$scale)) . ' height=10>';
  3190. }
  3191. $column_names['RELEVANCE'] = "Relevance";
  3192. if(is_array($group) && count($group))
  3193. {
  3194. $options['count'] == false;
  3195. $display_zero = true;
  3196. }
  3197. }
  3198. // END SEARCHES ---
  3199. if($_REQUEST['LO_sort'])
  3200. {
  3201. foreach($result as $sort)
  3202. {
  3203. if(substr($sort[$_REQUEST['LO_sort']],0,4)!='<!--')
  3204. $sort_array[] = $sort[$_REQUEST['LO_sort']];
  3205. else
  3206. $sort_array[] = substr($sort[$_REQUEST['LO_sort']],4,strpos($sort[$_REQUEST['LO_sort']],'-->')-5);
  3207. }
  3208. if($_REQUEST['LO_direction']==-1)
  3209. $dir = SORT_DESC;
  3210. else
  3211. $dir = SORT_ASC;
  3212. if($result_count>1)
  3213. {
  3214. if(is_int($sort_array[1]) || is_double($sort_array[1]))
  3215. array_multisort($sort_array,$dir,SORT_NUMERIC,$result);
  3216. else
  3217. array_multisort($sort_array,$dir,$result);
  3218. for($i=$result_count-1;$i>=0;$i--)
  3219. $result[$i+1] = $result[$i];
  3220. unset($result[0]);
  3221. }
  3222. }
  3223. }
  3224. // HANDLE SAVING THE LIST ---
  3225. if($_REQUEST['LO_save']=='1')
  3226. {
  3227. if(!$options['save_delimiter'] && Preferences('DELIMITER')=='CSV')
  3228. $options['save_delimiter'] = 'comma';
  3229. switch($options['save_delimiter'])
  3230. {
  3231. case 'comma':
  3232. $extension = 'csv';
  3233. break;
  3234. case 'xml':
  3235. $extension = 'xml';
  3236. break;
  3237. default:
  3238. $extension = 'xls';
  3239. break;
  3240. }
  3241. ob_end_clean();
  3242. if($options['save_delimiter']!='xml')
  3243. {
  3244. foreach($column_names as $key=>$value)
  3245. $output .= str_replace('&nbsp;',' ',eregi_replace('<BR>',' ',ereg_replace('<!--.*-->','',$value))) . ($options['save_delimiter']=='comma'?',':"\t");
  3246. $output .= "\n";
  3247. }
  3248. foreach($result as $item)
  3249. {
  3250. foreach($column_names as $key=>$value)
  3251. {
  3252. if($options['save_delimiter']=='comma' && !$options['save_quotes'])
  3253. $item[$key] = str_replace(',',';',$item[$key]);
  3254. $item[$key] = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$item[$key]);
  3255. $item[$key] = eregi_replace('<SELECT.*</SELECT\>','',$item[$key]);
  3256. $output .= ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='xml'?'<'.str_replace(' ','',$value).'>':'') . ereg_replace('<[^>]+>','',ereg_replace("<div onclick='[^']+'>",'',ereg_replace(' +',' ',ereg_replace('&[^;]+;','',str_replace('<BR>&middot;',' : ',str_replace('&nbsp;',' ',$item[$key])))))) . ($options['save_delimiter']=='xml'?'</'.str_replace(' ','',$value).'>'."\n":'') . ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='comma'?',':"\t");
  3257. }
  3258. $output .= "\n";
  3259. }
  3260. header("Cache-Control: public");
  3261. header("Pragma: ");
  3262. header("Content-Type: application/$extension");
  3263. header("Content-Disposition: inline; filename=\"".ProgramTitle().".$extension\"\n");
  3264. if($options['save_eval'])
  3265. eval($options['save_eval']);
  3266. echo $output;
  3267. exit();
  3268. }
  3269. // END SAVING THE LIST ---
  3270. if($options['center'])
  3271. #echo '<CENTER>';
  3272. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  3273. {
  3274. #echo "<TABLE border=0 cellspacing=3 cellpadding=6>" ;
  3275. if(isset($_REQUEST['_openSIS_PDF']))
  3276. #echo " width=98%";
  3277. echo " <TR><TD align=center>";
  3278. }
  3279. if($options['count'] || $display_zero)
  3280. {
  3281. if(($result_count==0 || $display_count==0) && $plural)
  3282. echo "<div style=text-align:left><table cellpadding=1 cellspacing=0 ><tr><td ></td><td ><b>No $plural were found.</b></td></tr><tr><td colspan=2 ></td></tr></table></div>";
  3283. elseif($result_count==0 || $display_count==0)
  3284. echo '<div style=text-align:left><table cellpadding=1 cellspacing=0 ><tr><td ></td><td ><b>None were found.</b></td></tr><tr><td colspan=2></td></tr></table></div>';
  3285. }
  3286. if($result_count != 0 || ($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search'))
  3287. {
  3288. if(!isset($_REQUEST['_openSIS_PDF']))
  3289. {
  3290. if(!$_REQUEST['page'])
  3291. $_REQUEST['page'] = 1;
  3292. if(!$_REQUEST['LO_direction'])
  3293. $_REQUEST['LO_direction'] = 1;
  3294. $start = ($_REQUEST['page'] - 1) * $num_displayed + 1;
  3295. $stop = $start + ($num_displayed-1);
  3296. if($stop > $result_count)
  3297. $stop = $result_count;
  3298. if($result_count > $num_displayed)
  3299. {
  3300. $where_message = "<SMALL>Displaying $start through $stop</SMALL>";
  3301. echo "Go to Page ";
  3302. if(ceil($result_count/$num_displayed) <= 10)
  3303. {
  3304. for($i=1;$i<=ceil($result_count/$num_displayed);$i++)
  3305. {
  3306. if($i!=$_REQUEST['page'])
  3307. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  3308. else
  3309. $pages .= "$i, ";
  3310. }
  3311. $pages = substr($pages,0,-2) . "<BR>";
  3312. }
  3313. else
  3314. {
  3315. for($i=1;$i<=7;$i++)
  3316. {
  3317. if($i!=$_REQUEST['page'])
  3318. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  3319. else
  3320. $pages .= "$i, ";
  3321. }
  3322. $pages = substr($pages,0,-2) . " ... ";
  3323. for($i=ceil($result_count/$num_displayed)-2;$i<=ceil($result_count/$num_displayed);$i++)
  3324. {
  3325. if($i!=$_REQUEST['page'])
  3326. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  3327. else
  3328. $pages .= "$i, ";
  3329. }
  3330. $pages = substr($pages,0,-2) . " &nbsp;<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=" . ($_REQUEST['page'] +1) . ">Next Page</A><BR>";
  3331. }
  3332. echo $pages;
  3333. echo '</TD></TR></TABLE>';
  3334. echo '<BR>';
  3335. }
  3336. }
  3337. else
  3338. {
  3339. $start = 1;
  3340. $stop = $result_count;
  3341. if($cols>8 || $_REQUEST['expanded_view'])
  3342. {
  3343. $_SESSION['orientation'] = 'landscape';
  3344. $repeat_headers = 16;
  3345. }
  3346. else
  3347. $repeat_headers = 22;
  3348. if($options['print'])
  3349. {
  3350. $html = explode('',strtolower(ob_get_contents()));
  3351. $html = $html[count($html)-1];
  3352. echo '</TD></TR></TABLE>';
  3353. $br = (substr_count($html,'<br>')) + (substr_count($html,'</p>')) + (substr_count($html,'</tr>')) + (substr_count($html,'</h1>')) + (substr_count($html,'</h2>')) + (substr_count($html,'</h3>')) + (substr_count($html,'</h4>')) + (substr_count($html,'</h5>'));
  3354. if($br%2!=0)
  3355. {
  3356. $br++;
  3357. echo '<BR>';
  3358. }
  3359. }
  3360. else
  3361. echo '</TD></TR></TABLE>';
  3362. }
  3363. // END MISC ---
  3364. // WIDTH = 100%
  3365. echo '<TABLE width=98% border=0 cellspacing=0 cellpadding=0><TR>';
  3366. // SEARCH BOX & MORE HEADERS
  3367. if($where_message || ($singular && $plural) || (!isset($_REQUEST['_openSIS_PDF']) && $options['search']))
  3368. {
  3369. echo '<TD align=center>';
  3370. //echo '<TABLE cellpadding=1 width=100% border=1 style="border-collapse:collapse" >';
  3371. //echo "<TR><TD align=left valign=middle>";
  3372. //if($singular && $plural && $options['count'])
  3373. //{
  3374. /*f($display_count > 1)
  3375. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>$display_count $plural were found.</b></td></tr></table>";
  3376. elseif($display_count==1)
  3377. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>1 $singular was found.</b></td></tr></table>";*/
  3378. //if($where_message)
  3379. //echo '<br>'.$where_message;
  3380. //}
  3381. if($options['save'] && !isset($_REQUEST['_openSIS_PDF']) && $result_count > 0)
  3382. //echo str_replace("Modules.php", "for_export.php", $PHP_tmp_SELF);
  3383. //echo "<table cellpadding=0 cellspacing=0 class=download align=left ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&LO_save=1&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0 alt=\"Download\" title=\"Download\"></a></td></tr></table>";
  3384. //echo "<br><br><table class=download ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0></a></td><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true >Download</A></td></tr></table>";
  3385. echo '</TD>';
  3386. $colspan = 1;
  3387. if(!isset($_REQUEST['_openSIS_PDF']) && $options['search'])
  3388. {
  3389. $tmp_REQUEST = $_REQUEST;
  3390. unset($tmp_REQUEST['LO_search']);
  3391. unset($tmp_REQUEST['page']);
  3392. echo '<TD height="50" align=right valign=middle>';
  3393. echo "<INPUT type=text class='cell_medium' id=LO_search name=LO_search value='".(($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')?$_REQUEST['LO_search']:'Search\' style=\'color:BBBBBB\''),"' onfocus='if(this.value==\"Search\") this.value=\"\"; this.style.color=\"000000\";' onblur='if(this.value==\"\") {this.value=\"Search\"; this.style.color=\"BBBBBB\";}' onkeypress='if(event.keyCode==13){document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+this.value; return false;} '>&nbsp;&nbsp;<INPUT type=button class='btn_go' value=Go onclick='document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+document.getElementById(\"LO_search\").value;'></TD>";
  3394. $colspan++;
  3395. }
  3396. echo "</TR>";
  3397. echo '<TR style="height:0;"><TD width=100% align=center colspan='.$colspan.'><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV></TD></TR></TABLE>';
  3398. }
  3399. else
  3400. echo '<TD width=100% align=right><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV>';
  3401. // END SEARCH BOX ----
  3402. echo '</TD></TR><TR><TD>';
  3403. // SHADOW
  3404. if(!isset($_REQUEST['_openSIS_PDF']))
  3405. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  3406. echo "<TABLE cellpadding=6 width=100% cellspacing=1 border=\"1px solid #a9d5e9 \" style=\"border-collapse:collapse\" align=center>";
  3407. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  3408. echo '<THEAD>';
  3409. if(!isset($_REQUEST['_openSIS_PDF']))
  3410. echo '<TR>';
  3411. $i =1;
  3412. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  3413. {
  3414. //THIS LINE IS FOR COLUMN HEADING
  3415. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV></TD>";
  3416. $i++;
  3417. }
  3418. if($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))
  3419. {
  3420. foreach($column_names as $key=>$value)
  3421. {
  3422. if($_REQUEST['LO_sort'] == $key)
  3423. $direction = -1 * $_REQUEST['LO_direction'];
  3424. else
  3425. $direction = 1;
  3426. //THIS LINE IS FOR COLUMN HEADING
  3427. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV>";
  3428. echo "<A ";
  3429. if($options['sort'])
  3430. echo "HREF=$PHP_tmp_SELF&page=$_REQUEST[page]&LO_sort=$key&LO_direction=$direction&LO_search=".urlencode($_REQUEST['LO_search']);
  3431. echo " class=column_heading><b>$value</b></A>";
  3432. if($i==1)
  3433. echo "<DIV id=LOy0 style='position: relative;'></DIV>";
  3434. echo "</TD>";
  3435. $i++;
  3436. }
  3437. //echo '<TD width=0><DIV id=LO'.$i.'></DIV></TD>';
  3438. echo "</TR>";
  3439. }
  3440. $color = 'bgcolor="#ffffff"';
  3441. //style="height: 300px; overflow: auto; padding-right: 16px;"
  3442. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  3443. echo '</THEAD><TBODY>';
  3444. // mab - enable add link as first or last
  3445. if($result_count!=0 && $link['add']['first'] && ($stop-$start)>=$link['add']['first'])
  3446. {
  3447. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  3448. // $cols++;
  3449. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  3450. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  3451. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  3452. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  3453. elseif($link['add']['html'] && $cols)
  3454. {
  3455. echo "<TR $color>";
  3456. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  3457. echo "<TD class=even align=left>".$link['add']['html']['remove']."</TD>";
  3458. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  3459. echo "<TD class=even align=left>".button('add')."</TD>";
  3460. foreach($column_names as $key=>$value)
  3461. {
  3462. echo "<TD class=even align=left >".$link['add']['html'][$key]."</TD>";
  3463. }
  3464. echo "</TR>";
  3465. $count++;
  3466. }
  3467. }
  3468. for($i=$start;$i<=$stop;$i++)
  3469. {
  3470. $item = $result[$i];
  3471. if(isset($_REQUEST['_openSIS_PDF']) && $options['print'] && count($item))
  3472. {
  3473. foreach($item as $key=>$value)
  3474. {
  3475. $value = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$value);
  3476. $value = eregi_replace('<SELECT.*</SELECT\>','',$value);
  3477. if(strpos($value,'LO_field')===false)
  3478. $item[$key] = str_replace(' ','&nbsp;',ereg_replace("<div onclick='[^']+'>",'',$value));
  3479. else
  3480. $item[$key] = ereg_replace("<div onclick='[^']+'>",'',$value);
  3481. }
  3482. }
  3483. if($item['row_color'])
  3484. $color = $item['row_color'];
  3485. elseif($color=='bgcolor="#ffffff"')
  3486. $color = $side_color;
  3487. else
  3488. $color = 'bgcolor="#ffffff"';
  3489. //$color = '#EDF3FE';
  3490. if(isset($_REQUEST['_openSIS_PDF']) && $count%$repeat_headers==0)
  3491. {
  3492. if($count!=0)
  3493. {
  3494. echo '</TABLE>';
  3495. echo "<div style=\"page-break-after: always;\"></div>";
  3496. echo "<table width=100% style=\" font-family:Arial; font-size:12px;\" >";
  3497. #echo "<tr><td style=\"font-size:15px; font-weight:bold; padding-top:20px;\">". GetSchool(UserSchool())."<div style=\"font-size:12px;\">Student Advanced Report</div></td><td align=right style=\"padding-top:20px;\">". ProperDate(DBDate()) ."<br />Powered by openSIS</td></tr><tr><td colspan=2 style=\"border-top:1px solid #333;\">&nbsp;</td></tr></table>";
  3498. echo '</table>';
  3499. echo '<TABLE cellpadding=6 width=100% cellspacing=1 border="1px solid #a9d5e9 " style="border-collapse:collapse" align=center>';
  3500. }
  3501. echo "<TR>";
  3502. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  3503. echo "<TD bgcolor=#d3d3d3></TD>";
  3504. if($cols)
  3505. {
  3506. foreach($column_names as $key=>$value)
  3507. {
  3508. echo "<TD bgcolor=#d3d3d3 >" . str_replace(' ','&nbsp;',$value) . "</TD>";
  3509. }
  3510. }
  3511. echo "</TR>";
  3512. }
  3513. if($count==0)
  3514. $count = $br;
  3515. echo "<TR $color>";
  3516. $count++;
  3517. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  3518. {
  3519. $button_title = $link['remove']['title'];
  3520. $button_link = $link['remove']['link'];
  3521. if(count($link['remove']['variables']))
  3522. {
  3523. foreach($link['remove']['variables'] as $var=>$val)
  3524. $button_link .= "&$var=" . urlencode($item[$val]);
  3525. }
  3526. echo "<TD $color>" . button('remove',$button_title,$button_link) . "</TD>";
  3527. }
  3528. if($cols)
  3529. {
  3530. foreach($column_names as $key=>$value)
  3531. {
  3532. if($link[$key] && !isset($_REQUEST['_openSIS_PDF']))
  3533. {
  3534. echo "<TD $color >";
  3535. if($key=='FULL_NAME')
  3536. echo '<DIV id=LOy'.($count-$br).' style="height: 100%; min-height: 100%; position: relative;">';
  3537. if($link[$key]['js']===true)
  3538. {
  3539. echo "<A HREF=# onclick='window.open(\"{$link[$key][link]}";
  3540. if(count($link[$key]['variables']))
  3541. {
  3542. foreach($link[$key]['variables'] as $var=>$val)
  3543. echo "&$var=".urlencode($item[$val]);
  3544. }
  3545. echo "\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'";
  3546. if($link[$key]['extra'])
  3547. echo ' '.$link[$key]['extra'];
  3548. echo ">";
  3549. }
  3550. else
  3551. {
  3552. echo "<A HREF={$link[$key][link]}";
  3553. if(count($link[$key]['variables']))
  3554. {
  3555. foreach($link[$key]['variables'] as $var=>$val)
  3556. echo "&$var=".urlencode($item[$val]);
  3557. }
  3558. if($link[$key]['extra'])
  3559. echo ' '.$link[$key]['extra'];
  3560. echo " onclick='grabA(this); return false;'>";
  3561. }
  3562. if($color==Preferences('HIGHLIGHT'))
  3563. echo '';
  3564. else
  3565. echo '<b>';
  3566. echo $item[$key];
  3567. echo '</b>';
  3568. if(!$item[$key])
  3569. echo '***';
  3570. echo "</A>";
  3571. if($key=='FULL_NAME')
  3572. echo '</DIV>';
  3573. echo "</TD>";
  3574. }
  3575. else
  3576. {
  3577. echo "<TD $color >";
  3578. if($key=='FULL_NAME')
  3579. echo '<DIV id=LOy'.($count-$br).' style="position: relative;">';
  3580. if($color==Preferences('HIGHLIGHT'))
  3581. echo '';
  3582. echo $item[$key];
  3583. if(!$item[$key])
  3584. echo '&nbsp;';
  3585. if($key=='FULL_NAME')
  3586. echo '<DIV>';
  3587. echo "</TD>";
  3588. }
  3589. }
  3590. }
  3591. echo "</TR>";
  3592. }
  3593. if($result_count!=0 && (!$link['add']['first'] || $link['add']['first'] && ($stop-$start)<$link['add']['first']))
  3594. {
  3595. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  3596. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  3597. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  3598. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  3599. elseif($link['add']['html'] && $cols)
  3600. {
  3601. if($count%2)
  3602. $color = 'bgcolor=#ffffff';
  3603. else
  3604. $color = $side_color;
  3605. echo "<TR $color>";
  3606. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  3607. echo "<TD bgcolor=#ffffff align=left>".$link['add']['html']['remove']."</TD>";
  3608. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  3609. echo "<TD bgcolor=#ffffff align=left >".button('add')."</TD>";
  3610. foreach($column_names as $key=>$value)
  3611. {
  3612. echo "<TD bgcolor=#ffffff align=left valign=top>".$link['add']['html'][$key]."</TD>";
  3613. }
  3614. echo "</TR>";
  3615. }
  3616. }
  3617. if($result_count!=0)
  3618. {
  3619. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  3620. echo '</TBODY>';
  3621. echo "</TABLE>";
  3622. if(!isset($_REQUEST['_openSIS_PDF']))
  3623. echo '</TD ></TR></TABLE>';
  3624. echo "</TD ></TR>";
  3625. echo "</TABLE>";
  3626. if($options['center'])
  3627. echo '';
  3628. }
  3629. }
  3630. if($result_count==0)
  3631. {
  3632. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  3633. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  3634. echo '<table width=120px cellspacing=8 cellpadding=6 ><tr><TD align=left class=lone_add >' . button('add',$link['add']['title'],$link['add']['link']) . '</td></tr></table>';
  3635. elseif(($link['add']['html'] || $link['add']['span']) && count($column_names) && !isset($_REQUEST['_openSIS_PDF']))
  3636. {
  3637. $color = $side_color;
  3638. if($options['center'])
  3639. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  3640. if($link['add']['html'])
  3641. {
  3642. echo "<TABLE cellpadding=6 cellspacing=1 width=96% class=\"grid\"><TR><TD class=subtabs></TD>";
  3643. foreach($column_names as $key=>$value)
  3644. {
  3645. echo "<TD class=subtabs><A><b>" . str_replace(' ','&nbsp;',$value) . "</b></A></TD>";
  3646. }
  3647. echo "</TR>";
  3648. echo "<TR class=odd>";
  3649. if($link['add']['html']['remove'])
  3650. echo "<TD >".$link['add']['html']['remove']."</TD>";
  3651. else
  3652. echo "<TD>".button('add')."</TD>";
  3653. foreach($column_names as $key=>$value)
  3654. {
  3655. echo "<TD >".$link['add']['html'][$key]."</TD>";
  3656. }
  3657. echo "</TR>";
  3658. echo "</TABLE>";
  3659. }
  3660. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  3661. echo "<TABLE><TR><TD align=center>".button('add').$link['add']['span']."</TD></TR></TABLE>";
  3662. echo "</TD></TR></TABLE>";
  3663. if($options['center'])
  3664. echo '</CENTER>';
  3665. }
  3666. }
  3667. if($result_count!=0)
  3668. {
  3669. if($options['yscroll'])
  3670. {
  3671. echo '<div id="LOy_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  3672. echo '<TABLE cellpadding=6 id=LOy_table>';
  3673. $i = 1;
  3674. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  3675. {
  3676. $color = $side_color;
  3677. foreach($result as $item)
  3678. {
  3679. echo "<TR><TD $color id=LO_row$i>";
  3680. if($color==Preferences('HIGHLIGHT'))
  3681. echo '';
  3682. echo $item['FULL_NAME'];
  3683. if(!$item['FULL_NAME'])
  3684. echo '&nbsp;';
  3685. if($color==Preferences('HIGHLIGHT'))
  3686. echo '';
  3687. echo "</TD></TR>";
  3688. $i++;
  3689. if($item['row_color'])
  3690. $color = $item['row_color'];
  3691. elseif($color=='class=even')
  3692. $color = $side_color;
  3693. else
  3694. $color = 'class=even';
  3695. }
  3696. }
  3697. echo '</TABLE>';
  3698. echo '</div>';
  3699. }
  3700. echo '<div id="LOx_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">'; echo '<div style="page-break-before: inherit;">&nbsp;</div>';
  3701. echo '<TABLE cellpadding=6 id=LOx_table><TR>';
  3702. $i = 1;
  3703. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  3704. {
  3705. echo "<TD class=grid id=LO_col$i></TD>";
  3706. $i++;
  3707. }
  3708. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  3709. {
  3710. foreach($column_names as $key=>$value)
  3711. {
  3712. echo '<TD class=grid id=LO_col'.$i.'><A class=column_heading><b>'.str_replace('controller','',$value).'</b></A></TD>';
  3713. $i++;
  3714. }
  3715. }
  3716. echo '</TR></TABLE>';
  3717. echo '</div>';
  3718. }
  3719. }
  3720. }
  3721. ############# Print Catalog function ##############################
  3722. function PrintCatalog($result,$column_names,$singular='',$plural='',$link=false,$group=false,$options=false)
  3723. {
  3724. if(!isset($options['save']))
  3725. $options['save'] = true;
  3726. if(!isset($options['print']))
  3727. $options['print'] = true;
  3728. if(!isset($options['search']))
  3729. $options['search'] = true;
  3730. if(!isset($options['center']))
  3731. $options['center'] = true;
  3732. if(!isset($options['count']))
  3733. $options['count'] = true;
  3734. if(!isset($options['sort']))
  3735. $options['sort'] = true;
  3736. if(!$link)
  3737. $link = array();
  3738. if(!isset($options['add']))
  3739. {
  3740. if(!AllowEdit() || $_REQUEST['_openSIS_PDF'])
  3741. {
  3742. if($link)
  3743. {
  3744. unset($link['add']);
  3745. unset($link['remove']);
  3746. }
  3747. }
  3748. }
  3749. // PREPARE LINKS ---
  3750. $result_count = $display_count = count($result);
  3751. $num_displayed = 100000;
  3752. $extra = "page=$_REQUEST[page]&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search']);
  3753. $tmp_REQUEST = $_REQUEST;
  3754. unset($tmp_REQUEST['page']);
  3755. unset($tmp_REQUEST['LO_sort']);
  3756. unset($tmp_REQUEST['LO_direction']);
  3757. unset($tmp_REQUEST['LO_search']);
  3758. unset($tmp_REQUEST['remove_prompt']);
  3759. unset($tmp_REQUEST['remove_name']);
  3760. unset($tmp_REQUEST['LO_save']);
  3761. unset($tmp_REQUEST['PHPSESSID']);
  3762. $PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);
  3763. // END PREPARE LINKS ---
  3764. // UN-GROUPING
  3765. $group_count = count($group);
  3766. if(!is_array($group))
  3767. $group_count = false;
  3768. //$side_color = Preferences('COLOR');
  3769. $side_color = 'bgcolor="#f5f5f5"';
  3770. if($group_count && $result_count)
  3771. {
  3772. $color = 'style=" background-color:#fff; padding:3px 4px 3px 4px;"';
  3773. $group_result = $result;
  3774. unset($result);
  3775. $result[0] = '';
  3776. foreach($group_result as $item1)
  3777. {
  3778. if($group_count==1)
  3779. {
  3780. if($color=='bgcolor="#f5f5f5"')
  3781. $color = $side_color;
  3782. else
  3783. $color = 'bgcolor="#f5f5f5"';
  3784. }
  3785. foreach($item1 as $item2)
  3786. {
  3787. if($group_count==1)
  3788. {
  3789. $i++;
  3790. if(count($group[0]) && $i!=1)
  3791. {
  3792. foreach($group[0] as $column)
  3793. $item2[$column] = str_replace('<!-- <!--','<!--','<!-- '.str_replace('-->','--><!--',$item2[$column])).' -->';
  3794. }
  3795. $item2['row_color'] = $color;
  3796. $result[] = $item2;
  3797. }
  3798. else
  3799. {
  3800. if($group_count==2)
  3801. {
  3802. if($color=='bgcolor="#ffffff"')
  3803. $color = $side_color;
  3804. else
  3805. $color = 'bgcolor="#ffffff"';
  3806. }
  3807. foreach($item2 as $item3)
  3808. {
  3809. if($group_count==2)
  3810. {
  3811. $i++;
  3812. if(count($group[0]) && $i!=1)
  3813. {
  3814. foreach($group[0] as $column)
  3815. $item3[$column] = '<!-- '.$item3[$column].' -->';
  3816. }
  3817. if(count($group[1]) && $i!=1)
  3818. {
  3819. foreach($group[1] as $column)
  3820. $item3[$column] = '<!-- '.$item3[$column].' -->';
  3821. }
  3822. $item3['row_color'] = $color;
  3823. $result[] = $item3;
  3824. }
  3825. else
  3826. {
  3827. if($group_count==3)
  3828. {
  3829. if($color=='bgcolor="#ffffff"')
  3830. $color = $side_color;
  3831. else
  3832. $color = 'bgcolor="#ffffff"';
  3833. }
  3834. foreach($item3 as $item4)
  3835. {
  3836. if($group_count==3)
  3837. {
  3838. $i++;
  3839. if(count($group[2]) && $i!=1)
  3840. {
  3841. foreach($group[2] as $column)
  3842. unset($item4[$column]);
  3843. }
  3844. $item4['row_color'] = $color;
  3845. $result[] = $item4;
  3846. }
  3847. }
  3848. }
  3849. }
  3850. }
  3851. }
  3852. $i = 0;
  3853. }
  3854. unset($result[0]);
  3855. $result_count = count($result);
  3856. unset($_REQUEST['LO_sort']);
  3857. }
  3858. // END UN-GROUPING
  3859. $_LIST['output'] = true;
  3860. // PRINT HEADINGS, PREPARE PDF, AND SORT THE LIST ---
  3861. if($_LIST['output']!=false)
  3862. {
  3863. if($result_count != 0)
  3864. {
  3865. $count = 0;
  3866. $remove = count($link['remove']['variables']);
  3867. $cols = count($column_names);
  3868. // HANDLE SEARCHES ---
  3869. if($result_count && $_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')
  3870. {
  3871. $_REQUEST['LO_search'] = $search_term = str_replace('\\\"','"',$_REQUEST['LO_search']);
  3872. $_REQUEST['LO_search'] = $search_term = ereg_replace('[^a-zA-Z0-9 _"]*','',strtolower($search_term));
  3873. if(substr($search_term,0,0)!='"' && substr($search_term,-1)!='"')
  3874. {
  3875. $search_term = ereg_replace('"','',$search_term);
  3876. while($space_pos = strpos($search_term,' '))
  3877. {
  3878. $terms[strtolower(substr($search_term,0,$space_pos))] = 1;
  3879. $search_term = substr($search_term,($space_pos+1));
  3880. }
  3881. $terms[trim($search_term)] = 1;
  3882. }
  3883. else
  3884. {
  3885. $search_term = ereg_replace('"','',$search_term);
  3886. $terms[trim($search_term)] = 1;
  3887. }
  3888. unset($terms['of']); unset($terms['the']); unset($terms['a']); unset($terms['an']); unset($terms['in']);
  3889. foreach($result as $key=>$value)
  3890. {
  3891. $values[$key] = 0;
  3892. foreach($value as $name=>$val)
  3893. {
  3894. $val = ereg_replace('[^a-zA-Z0-9 _]+','',strtolower($val));
  3895. if(strtolower($_REQUEST['LO_search'])==$val)
  3896. $values[$key] += 25;
  3897. foreach($terms as $term=>$one)
  3898. {
  3899. if(ereg($term,$val))
  3900. $values[$key] += 3;
  3901. }
  3902. }
  3903. if($values[$key]==0)
  3904. {
  3905. unset($values[$key]);
  3906. unset($result[$key]);
  3907. $result_count--;
  3908. $display_count--;
  3909. }
  3910. }
  3911. if($result_count)
  3912. {
  3913. array_multisort($values,SORT_DESC,$result);
  3914. $result = ReindexResults($result);
  3915. $values = ReindexResults($values);
  3916. $last_value = 1;
  3917. $scale = (100/$values[$last_value]);
  3918. for($i=$last_value;$i<=$result_count;$i++)
  3919. $result[$i]['RELEVANCE'] = '<!--' . ((int) ($values[$i]*$scale)) . '--><IMG SRC="assets/pixel_grey.gif" width=' . ((int) ($values[$i]*$scale)) . ' height=10>';
  3920. }
  3921. $column_names['RELEVANCE'] = "Relevance";
  3922. if(is_array($group) && count($group))
  3923. {
  3924. $options['count'] == false;
  3925. $display_zero = true;
  3926. }
  3927. }
  3928. // END SEARCHES ---
  3929. if($_REQUEST['LO_sort'])
  3930. {
  3931. foreach($result as $sort)
  3932. {
  3933. if(substr($sort[$_REQUEST['LO_sort']],0,4)!='<!--')
  3934. $sort_array[] = $sort[$_REQUEST['LO_sort']];
  3935. else
  3936. $sort_array[] = substr($sort[$_REQUEST['LO_sort']],4,strpos($sort[$_REQUEST['LO_sort']],'-->')-5);
  3937. }
  3938. if($_REQUEST['LO_direction']==-1)
  3939. $dir = SORT_DESC;
  3940. else
  3941. $dir = SORT_ASC;
  3942. if($result_count>1)
  3943. {
  3944. if(is_int($sort_array[1]) || is_double($sort_array[1]))
  3945. array_multisort($sort_array,$dir,SORT_NUMERIC,$result);
  3946. else
  3947. array_multisort($sort_array,$dir,$result);
  3948. for($i=$result_count-1;$i>=0;$i--)
  3949. $result[$i+1] = $result[$i];
  3950. unset($result[0]);
  3951. }
  3952. }
  3953. }
  3954. // HANDLE SAVING THE LIST ---
  3955. if($_REQUEST['LO_save']=='1')
  3956. {
  3957. if(!$options['save_delimiter'] && Preferences('DELIMITER')=='CSV')
  3958. $options['save_delimiter'] = 'comma';
  3959. switch($options['save_delimiter'])
  3960. {
  3961. case 'comma':
  3962. $extension = 'csv';
  3963. break;
  3964. case 'xml':
  3965. $extension = 'xml';
  3966. break;
  3967. default:
  3968. $extension = 'xls';
  3969. break;
  3970. }
  3971. ob_end_clean();
  3972. if($options['save_delimiter']!='xml')
  3973. {
  3974. foreach($column_names as $key=>$value)
  3975. $output .= str_replace('&nbsp;',' ',eregi_replace('<BR>',' ',ereg_replace('<!--.*-->','',$value))) . ($options['save_delimiter']=='comma'?',':"\t");
  3976. $output .= "\n";
  3977. }
  3978. foreach($result as $item)
  3979. {
  3980. foreach($column_names as $key=>$value)
  3981. {
  3982. if($options['save_delimiter']=='comma' && !$options['save_quotes'])
  3983. $item[$key] = str_replace(',',';',$item[$key]);
  3984. $item[$key] = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$item[$key]);
  3985. $item[$key] = eregi_replace('<SELECT.*</SELECT\>','',$item[$key]);
  3986. $output .= ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='xml'?'<'.str_replace(' ','',$value).'>':'') . ereg_replace('<[^>]+>','',ereg_replace("<div onclick='[^']+'>",'',ereg_replace(' +',' ',ereg_replace('&[^;]+;','',str_replace('<BR>&middot;',' : ',str_replace('&nbsp;',' ',$item[$key])))))) . ($options['save_delimiter']=='xml'?'</'.str_replace(' ','',$value).'>'."\n":'') . ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='comma'?',':"\t");
  3987. }
  3988. $output .= "\n";
  3989. }
  3990. header("Cache-Control: public");
  3991. header("Pragma: ");
  3992. header("Content-Type: application/$extension");
  3993. header("Content-Disposition: inline; filename=\"".ProgramTitle().".$extension\"\n");
  3994. if($options['save_eval'])
  3995. eval($options['save_eval']);
  3996. echo $output;
  3997. exit();
  3998. }
  3999. // END SAVING THE LIST ---
  4000. if($options['center'])
  4001. #echo '<CENTER>';
  4002. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  4003. {
  4004. #echo "<TABLE border=0 cellspacing=3 cellpadding=6>" ;
  4005. if(isset($_REQUEST['_openSIS_PDF']))
  4006. #echo " width=98%";
  4007. echo " <TR><TD align=center>";
  4008. }
  4009. if($options['count'] || $display_zero)
  4010. {
  4011. if(($result_count==0 || $display_count==0) && $plural)
  4012. echo "<div style=text-align:left><table cellpadding=1 cellspacing=0 ><tr><td ></td><td ><b>No $plural were found.</b></td></tr><tr><td colspan=2 ></td></tr></table></div>";
  4013. elseif($result_count==0 || $display_count==0)
  4014. echo '<div style=text-align:left><table cellpadding=1 cellspacing=0 ><tr><td ></td><td ><b>None were found.</b></td></tr><tr><td colspan=2></td></tr></table></div>';
  4015. }
  4016. if($result_count != 0 || ($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search'))
  4017. {
  4018. if(!isset($_REQUEST['_openSIS_PDF']))
  4019. {
  4020. if(!$_REQUEST['page'])
  4021. $_REQUEST['page'] = 1;
  4022. if(!$_REQUEST['LO_direction'])
  4023. $_REQUEST['LO_direction'] = 1;
  4024. $start = ($_REQUEST['page'] - 1) * $num_displayed + 1;
  4025. $stop = $start + ($num_displayed-1);
  4026. if($stop > $result_count)
  4027. $stop = $result_count;
  4028. if($result_count > $num_displayed)
  4029. {
  4030. $where_message = "<SMALL>Displaying $start through $stop</SMALL>";
  4031. echo "Go to Page ";
  4032. if(ceil($result_count/$num_displayed) <= 10)
  4033. {
  4034. for($i=1;$i<=ceil($result_count/$num_displayed);$i++)
  4035. {
  4036. if($i!=$_REQUEST['page'])
  4037. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  4038. else
  4039. $pages .= "$i, ";
  4040. }
  4041. $pages = substr($pages,0,-2) . "<BR>";
  4042. }
  4043. else
  4044. {
  4045. for($i=1;$i<=7;$i++)
  4046. {
  4047. if($i!=$_REQUEST['page'])
  4048. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  4049. else
  4050. $pages .= "$i, ";
  4051. }
  4052. $pages = substr($pages,0,-2) . " ... ";
  4053. for($i=ceil($result_count/$num_displayed)-2;$i<=ceil($result_count/$num_displayed);$i++)
  4054. {
  4055. if($i!=$_REQUEST['page'])
  4056. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  4057. else
  4058. $pages .= "$i, ";
  4059. }
  4060. $pages = substr($pages,0,-2) . " &nbsp;<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=" . ($_REQUEST['page'] +1) . ">Next Page</A><BR>";
  4061. }
  4062. echo $pages;
  4063. echo '</TD></TR></TABLE>';
  4064. echo '<BR>';
  4065. }
  4066. }
  4067. else
  4068. {
  4069. $start = 1;
  4070. $stop = $result_count;
  4071. if($cols>8 || $_REQUEST['expanded_view'])
  4072. {
  4073. $_SESSION['orientation'] = 'landscape';
  4074. $repeat_headers = 16;
  4075. }
  4076. else
  4077. $repeat_headers = 26;
  4078. if($options['print'])
  4079. {
  4080. $html = explode('',strtolower(ob_get_contents()));
  4081. $html = $html[count($html)-1];
  4082. echo '</TD></TR></TABLE>';
  4083. $br = (substr_count($html,'<br>')) + (substr_count($html,'</p>')) + (substr_count($html,'</tr>')) + (substr_count($html,'</h1>')) + (substr_count($html,'</h2>')) + (substr_count($html,'</h3>')) + (substr_count($html,'</h4>')) + (substr_count($html,'</h5>'));
  4084. if($br%2!=0)
  4085. {
  4086. $br++;
  4087. echo '<BR>';
  4088. }
  4089. }
  4090. else
  4091. echo '</TD></TR></TABLE>';
  4092. }
  4093. // END MISC ---
  4094. // WIDTH = 100%
  4095. echo '<TABLE width=98% border=0 cellspacing=0 cellpadding=0><TR>';
  4096. // SEARCH BOX & MORE HEADERS
  4097. if($where_message || ($singular && $plural) || (!isset($_REQUEST['_openSIS_PDF']) && $options['search']))
  4098. {
  4099. echo '<TD align=center>';
  4100. //echo '<TABLE cellpadding=1 width=100% border=1 style="border-collapse:collapse" >';
  4101. //echo "<TR><TD align=left valign=middle>";
  4102. //if($singular && $plural && $options['count'])
  4103. //{
  4104. /*f($display_count > 1)
  4105. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>$display_count $plural were found.</b></td></tr></table>";
  4106. elseif($display_count==1)
  4107. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>1 $singular was found.</b></td></tr></table>";*/
  4108. //if($where_message)
  4109. //echo '<br>'.$where_message;
  4110. //}
  4111. if($options['save'] && !isset($_REQUEST['_openSIS_PDF']) && $result_count > 0)
  4112. //echo str_replace("Modules.php", "for_export.php", $PHP_tmp_SELF);
  4113. //echo "<table cellpadding=0 cellspacing=0 class=download align=left ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&LO_save=1&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0 alt=\"Download\" title=\"Download\"></a></td></tr></table>";
  4114. //echo "<br><br><table class=download ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0></a></td><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true >Download</A></td></tr></table>";
  4115. echo '</TD>';
  4116. $colspan = 1;
  4117. if(!isset($_REQUEST['_openSIS_PDF']) && $options['search'])
  4118. {
  4119. $tmp_REQUEST = $_REQUEST;
  4120. unset($tmp_REQUEST['LO_search']);
  4121. unset($tmp_REQUEST['page']);
  4122. echo '<TD height="50" align=right valign=middle>';
  4123. echo "<INPUT type=text class='cell_medium' id=LO_search name=LO_search value='".(($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')?$_REQUEST['LO_search']:'Search\' style=\'color:BBBBBB\''),"' onfocus='if(this.value==\"Search\") this.value=\"\"; this.style.color=\"000000\";' onblur='if(this.value==\"\") {this.value=\"Search\"; this.style.color=\"BBBBBB\";}' onkeypress='if(event.keyCode==13){document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+this.value; return false;} '>&nbsp;&nbsp;<INPUT type=button class='btn_go' value=Go onclick='document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+document.getElementById(\"LO_search\").value;'></TD>";
  4124. $colspan++;
  4125. }
  4126. echo "</TR>";
  4127. echo '<TR style="height:0;"><TD width=100% align=center colspan='.$colspan.'><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV></TD></TR></TABLE>';
  4128. }
  4129. else
  4130. echo '<TD width=100% align=right><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV>';
  4131. // END SEARCH BOX ----
  4132. echo '</TD></TR><TR><TD>';
  4133. // SHADOW
  4134. if(!isset($_REQUEST['_openSIS_PDF']))
  4135. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  4136. echo "<TABLE cellpadding=6 width=100% cellspacing=1 border=\"1px solid #a9d5e9 \" style=\"border-collapse:collapse\" align=center>";
  4137. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  4138. echo '<THEAD>';
  4139. if(!isset($_REQUEST['_openSIS_PDF']))
  4140. echo '<TR>';
  4141. $i =1;
  4142. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  4143. {
  4144. //THIS LINE IS FOR COLUMN HEADING
  4145. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV></TD>";
  4146. $i++;
  4147. }
  4148. if($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))
  4149. {
  4150. foreach($column_names as $key=>$value)
  4151. {
  4152. if($_REQUEST['LO_sort'] == $key)
  4153. $direction = -1 * $_REQUEST['LO_direction'];
  4154. else
  4155. $direction = 1;
  4156. //THIS LINE IS FOR COLUMN HEADING
  4157. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV>";
  4158. echo "<A ";
  4159. if($options['sort'])
  4160. echo "HREF=$PHP_tmp_SELF&page=$_REQUEST[page]&LO_sort=$key&LO_direction=$direction&LO_search=".urlencode($_REQUEST['LO_search']);
  4161. echo " class=column_heading><b>$value</b></A>";
  4162. if($i==1)
  4163. echo "<DIV id=LOy0 style='position: relative;'></DIV>";
  4164. echo "</TD>";
  4165. $i++;
  4166. }
  4167. //echo '<TD width=0><DIV id=LO'.$i.'></DIV></TD>';
  4168. echo "</TR>";
  4169. }
  4170. $color = 'bgcolor="#ffffff"';
  4171. //style="height: 300px; overflow: auto; padding-right: 16px;"
  4172. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  4173. echo '</THEAD><TBODY>';
  4174. // mab - enable add link as first or last
  4175. if($result_count!=0 && $link['add']['first'] && ($stop-$start)>=$link['add']['first'])
  4176. {
  4177. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  4178. // $cols++;
  4179. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  4180. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  4181. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  4182. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  4183. elseif($link['add']['html'] && $cols)
  4184. {
  4185. echo "<TR $color>";
  4186. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  4187. echo "<TD class=even align=left>".$link['add']['html']['remove']."</TD>";
  4188. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  4189. echo "<TD class=even align=left>".button('add')."</TD>";
  4190. foreach($column_names as $key=>$value)
  4191. {
  4192. echo "<TD class=even align=left >".$link['add']['html'][$key]."</TD>";
  4193. }
  4194. echo "</TR>";
  4195. $count++;
  4196. }
  4197. }
  4198. for($i=$start;$i<=$stop;$i++)
  4199. {
  4200. $item = $result[$i];
  4201. if(isset($_REQUEST['_openSIS_PDF']) && $options['print'] && count($item))
  4202. {
  4203. foreach($item as $key=>$value)
  4204. {
  4205. $value = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$value);
  4206. $value = eregi_replace('<SELECT.*</SELECT\>','',$value);
  4207. if(strpos($value,'LO_field')===false)
  4208. $item[$key] = str_replace(' ','&nbsp;',ereg_replace("<div onclick='[^']+'>",'',$value));
  4209. else
  4210. $item[$key] = ereg_replace("<div onclick='[^']+'>",'',$value);
  4211. }
  4212. }
  4213. if($item['row_color'])
  4214. $color = $item['row_color'];
  4215. elseif($color=='bgcolor="#ffffff"')
  4216. $color = $side_color;
  4217. else
  4218. $color = 'bgcolor="#ffffff"';
  4219. //$color = '#EDF3FE';
  4220. if(isset($_REQUEST['_openSIS_PDF']) && $count%$repeat_headers==0)
  4221. {
  4222. if($count!=0)
  4223. {
  4224. echo '</TABLE>';
  4225. echo "<div style=\"page-break-after: always;\"></div>";
  4226. echo "<table width=100% style=\" font-family:Arial; font-size:12px;\" >";
  4227. echo "<tr><td style=\"font-size:15px; font-weight:bold; padding-top:20px;\">". GetSchool(UserSchool())."<div style=\"font-size:12px;\">Student Advanced Report</div></td><td align=right style=\"padding-top:20px;\">". ProperDate(DBDate()) ."<br />Powered by openSIS</td></tr><tr><td colspan=2 style=\"border-top:1px solid #333;\">&nbsp;</td></tr></table>";
  4228. echo '<TABLE cellpadding=6 width=100% cellspacing=1 border="1px solid #a9d5e9 " style="border-collapse:collapse" align=center>';
  4229. }
  4230. echo "<TR>";
  4231. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  4232. echo "<TD bgcolor=#d3d3d3></TD>";
  4233. if($cols)
  4234. {
  4235. foreach($column_names as $key=>$value)
  4236. {
  4237. echo "<TD bgcolor=#d3d3d3 >" . str_replace(' ','&nbsp;',$value) . "</TD>";
  4238. }
  4239. }
  4240. echo "</TR>";
  4241. }
  4242. if($count==0)
  4243. $count = $br;
  4244. echo "<TR $color>";
  4245. $count++;
  4246. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  4247. {
  4248. $button_title = $link['remove']['title'];
  4249. $button_link = $link['remove']['link'];
  4250. if(count($link['remove']['variables']))
  4251. {
  4252. foreach($link['remove']['variables'] as $var=>$val)
  4253. $button_link .= "&$var=" . urlencode($item[$val]);
  4254. }
  4255. echo "<TD $color>" . button('remove',$button_title,$button_link) . "</TD>";
  4256. }
  4257. if($cols)
  4258. {
  4259. foreach($column_names as $key=>$value)
  4260. {
  4261. if($link[$key] && !isset($_REQUEST['_openSIS_PDF']))
  4262. {
  4263. echo "<TD $color >";
  4264. if($key=='FULL_NAME')
  4265. echo '<DIV id=LOy'.($count-$br).' style="height: 100%; min-height: 100%; position: relative;">';
  4266. if($link[$key]['js']===true)
  4267. {
  4268. echo "<A HREF=# onclick='window.open(\"{$link[$key][link]}";
  4269. if(count($link[$key]['variables']))
  4270. {
  4271. foreach($link[$key]['variables'] as $var=>$val)
  4272. echo "&$var=".urlencode($item[$val]);
  4273. }
  4274. echo "\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'";
  4275. if($link[$key]['extra'])
  4276. echo ' '.$link[$key]['extra'];
  4277. echo ">";
  4278. }
  4279. else
  4280. {
  4281. echo "<A HREF={$link[$key][link]}";
  4282. if(count($link[$key]['variables']))
  4283. {
  4284. foreach($link[$key]['variables'] as $var=>$val)
  4285. echo "&$var=".urlencode($item[$val]);
  4286. }
  4287. if($link[$key]['extra'])
  4288. echo ' '.$link[$key]['extra'];
  4289. echo " onclick='grabA(this); return false;'>";
  4290. }
  4291. if($color==Preferences('HIGHLIGHT'))
  4292. echo '';
  4293. else
  4294. echo '<b>';
  4295. echo $item[$key];
  4296. echo '</b>';
  4297. if(!$item[$key])
  4298. echo '***';
  4299. echo "</A>";
  4300. if($key=='FULL_NAME')
  4301. echo '</DIV>';
  4302. echo "</TD>";
  4303. }
  4304. else
  4305. {
  4306. echo "<TD $color >";
  4307. if($key=='FULL_NAME')
  4308. echo '<DIV id=LOy'.($count-$br).' style="position: relative;">';
  4309. if($color==Preferences('HIGHLIGHT'))
  4310. echo '';
  4311. echo $item[$key];
  4312. if(!$item[$key])
  4313. echo '&nbsp;';
  4314. if($key=='FULL_NAME')
  4315. echo '<DIV>';
  4316. echo "</TD>";
  4317. }
  4318. }
  4319. }
  4320. echo "</TR>";
  4321. }
  4322. if($result_count!=0 && (!$link['add']['first'] || $link['add']['first'] && ($stop-$start)<$link['add']['first']))
  4323. {
  4324. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  4325. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  4326. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  4327. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  4328. elseif($link['add']['html'] && $cols)
  4329. {
  4330. if($count%2)
  4331. $color = 'bgcolor=#ffffff';
  4332. else
  4333. $color = $side_color;
  4334. echo "<TR $color>";
  4335. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  4336. echo "<TD bgcolor=#ffffff align=left>".$link['add']['html']['remove']."</TD>";
  4337. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  4338. echo "<TD bgcolor=#ffffff align=left >".button('add')."</TD>";
  4339. foreach($column_names as $key=>$value)
  4340. {
  4341. echo "<TD bgcolor=#ffffff align=left valign=top>".$link['add']['html'][$key]."</TD>";
  4342. }
  4343. echo "</TR>";
  4344. }
  4345. }
  4346. if($result_count!=0)
  4347. {
  4348. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  4349. echo '</TBODY>';
  4350. echo "</TABLE>";
  4351. if(!isset($_REQUEST['_openSIS_PDF']))
  4352. echo '</TD ></TR></TABLE>';
  4353. echo "</TD ></TR>";
  4354. echo "</TABLE>";
  4355. if($options['center'])
  4356. echo '';
  4357. }
  4358. }
  4359. if($result_count==0)
  4360. {
  4361. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  4362. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  4363. echo '<table width=120px cellspacing=8 cellpadding=6 ><tr><TD align=left class=lone_add >' . button('add',$link['add']['title'],$link['add']['link']) . '</td></tr></table>';
  4364. elseif(($link['add']['html'] || $link['add']['span']) && count($column_names) && !isset($_REQUEST['_openSIS_PDF']))
  4365. {
  4366. $color = $side_color;
  4367. if($options['center'])
  4368. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  4369. if($link['add']['html'])
  4370. {
  4371. echo "<TABLE cellpadding=6 cellspacing=1 width=96% class=\"grid\"><TR><TD class=subtabs></TD>";
  4372. foreach($column_names as $key=>$value)
  4373. {
  4374. echo "<TD class=subtabs><A><b>" . str_replace(' ','&nbsp;',$value) . "</b></A></TD>";
  4375. }
  4376. echo "</TR>";
  4377. echo "<TR class=odd>";
  4378. if($link['add']['html']['remove'])
  4379. echo "<TD >".$link['add']['html']['remove']."</TD>";
  4380. else
  4381. echo "<TD>".button('add')."</TD>";
  4382. foreach($column_names as $key=>$value)
  4383. {
  4384. echo "<TD >".$link['add']['html'][$key]."</TD>";
  4385. }
  4386. echo "</TR>";
  4387. echo "</TABLE>";
  4388. }
  4389. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  4390. echo "<TABLE><TR><TD align=center>".button('add').$link['add']['span']."</TD></TR></TABLE>";
  4391. echo "</TD></TR></TABLE>";
  4392. if($options['center'])
  4393. echo '</CENTER>';
  4394. }
  4395. }
  4396. if($result_count!=0)
  4397. {
  4398. if($options['yscroll'])
  4399. {
  4400. echo '<div id="LOy_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  4401. echo '<TABLE cellpadding=6 id=LOy_table>';
  4402. $i = 1;
  4403. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  4404. {
  4405. $color = $side_color;
  4406. foreach($result as $item)
  4407. {
  4408. echo "<TR><TD $color id=LO_row$i>";
  4409. if($color==Preferences('HIGHLIGHT'))
  4410. echo '';
  4411. echo $item['FULL_NAME'];
  4412. if(!$item['FULL_NAME'])
  4413. echo '&nbsp;';
  4414. if($color==Preferences('HIGHLIGHT'))
  4415. echo '';
  4416. echo "</TD></TR>";
  4417. $i++;
  4418. if($item['row_color'])
  4419. $color = $item['row_color'];
  4420. elseif($color=='class=even')
  4421. $color = $side_color;
  4422. else
  4423. $color = 'class=even';
  4424. }
  4425. }
  4426. echo '</TABLE>';
  4427. echo '</div>';
  4428. }
  4429. echo '<div id="LOx_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">'; echo '<div style="page-break-before: inherit;">&nbsp;</div>';
  4430. echo '<TABLE cellpadding=6 id=LOx_table><TR>';
  4431. $i = 1;
  4432. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  4433. {
  4434. echo "<TD class=grid id=LO_col$i></TD>";
  4435. $i++;
  4436. }
  4437. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  4438. {
  4439. foreach($column_names as $key=>$value)
  4440. {
  4441. echo '<TD class=grid id=LO_col'.$i.'><A class=column_heading><b>'.str_replace('controller','',$value).'</b></A></TD>';
  4442. $i++;
  4443. }
  4444. }
  4445. echo '</TR></TABLE>';
  4446. echo '</div>';
  4447. }
  4448. }
  4449. }
  4450. ####################Print Catalog Function ENds Here ###########################################################
  4451. #### ------------------------------- List Output For Missing Attn. ---------------------------------------------- ###
  4452. function ListOutput_missing_attn($result,$column_names,$singular='',$plural='',$link=false,$group=false,$options=false)
  4453. {
  4454. if(!isset($options['save']))
  4455. $options['save'] = true;
  4456. if(!isset($options['print']))
  4457. $options['print'] = true;
  4458. if(!isset($options['search']))
  4459. $options['search'] = true;
  4460. if(!isset($options['center']))
  4461. $options['center'] = true;
  4462. if(!isset($options['count']))
  4463. $options['count'] = true;
  4464. if(!isset($options['sort']))
  4465. $options['sort'] = true;
  4466. if(!$link)
  4467. $link = array();
  4468. if(!isset($options['add']))
  4469. {
  4470. if(!AllowEdit() || $_REQUEST['_openSIS_PDF'])
  4471. {
  4472. if($link)
  4473. {
  4474. unset($link['add']);
  4475. unset($link['remove']);
  4476. }
  4477. }
  4478. }
  4479. // PREPARE LINKS ---
  4480. $result_count = $display_count = count($result);
  4481. $num_displayed = 150;
  4482. $extra = "page=$_REQUEST[page]&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search']);
  4483. $tmp_REQUEST = $_REQUEST;
  4484. unset($tmp_REQUEST['page']);
  4485. unset($tmp_REQUEST['LO_sort']);
  4486. unset($tmp_REQUEST['LO_direction']);
  4487. unset($tmp_REQUEST['LO_search']);
  4488. unset($tmp_REQUEST['remove_prompt']);
  4489. unset($tmp_REQUEST['remove_name']);
  4490. unset($tmp_REQUEST['LO_save']);
  4491. unset($tmp_REQUEST['PHPSESSID']);
  4492. $PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);
  4493. // END PREPARE LINKS ---
  4494. // UN-GROUPING
  4495. $group_count = count($group);
  4496. if(!is_array($group))
  4497. $group_count = false;
  4498. //$side_color = Preferences('COLOR');
  4499. $side_color = 'class=odd';
  4500. if($group_count && $result_count)
  4501. {
  4502. $color = 'class=even';
  4503. $group_result = $result;
  4504. unset($result);
  4505. $result[0] = '';
  4506. foreach($group_result as $item1)
  4507. {
  4508. if($group_count==1)
  4509. {
  4510. if($color=='class=even')
  4511. $color = $side_color;
  4512. else
  4513. $color = 'class=even';
  4514. }
  4515. foreach($item1 as $item2)
  4516. {
  4517. if($group_count==1)
  4518. {
  4519. $i++;
  4520. if(count($group[0]) && $i!=1)
  4521. {
  4522. foreach($group[0] as $column)
  4523. $item2[$column] = str_replace('<!-- <!--','<!--','<!-- '.str_replace('-->','--><!--',$item2[$column])).' -->';
  4524. }
  4525. $item2['row_color'] = $color;
  4526. $result[] = $item2;
  4527. }
  4528. else
  4529. {
  4530. if($group_count==2)
  4531. {
  4532. if($color=='class=even')
  4533. $color = $side_color;
  4534. else
  4535. $color = 'class=even';
  4536. }
  4537. foreach($item2 as $item3)
  4538. {
  4539. if($group_count==2)
  4540. {
  4541. $i++;
  4542. if(count($group[0]) && $i!=1)
  4543. {
  4544. foreach($group[0] as $column)
  4545. $item3[$column] = '<!-- '.$item3[$column].' -->';
  4546. }
  4547. if(count($group[1]) && $i!=1)
  4548. {
  4549. foreach($group[1] as $column)
  4550. $item3[$column] = '<!-- '.$item3[$column].' -->';
  4551. }
  4552. $item3['row_color'] = $color;
  4553. $result[] = $item3;
  4554. }
  4555. else
  4556. {
  4557. if($group_count==3)
  4558. {
  4559. if($color=='class=even')
  4560. $color = $side_color;
  4561. else
  4562. $color = 'class=even';
  4563. }
  4564. foreach($item3 as $item4)
  4565. {
  4566. if($group_count==3)
  4567. {
  4568. $i++;
  4569. if(count($group[2]) && $i!=1)
  4570. {
  4571. foreach($group[2] as $column)
  4572. unset($item4[$column]);
  4573. }
  4574. $item4['row_color'] = $color;
  4575. $result[] = $item4;
  4576. }
  4577. }
  4578. }
  4579. }
  4580. }
  4581. }
  4582. $i = 0;
  4583. }
  4584. unset($result[0]);
  4585. $result_count = count($result);
  4586. unset($_REQUEST['LO_sort']);
  4587. }
  4588. // END UN-GROUPING
  4589. $_LIST['output'] = true;
  4590. // PRINT HEADINGS, PREPARE PDF, AND SORT THE LIST ---
  4591. if($_LIST['output']!=false)
  4592. {
  4593. if($result_count != 0)
  4594. {
  4595. $count = 0;
  4596. $remove = count($link['remove']['variables']);
  4597. $cols = count($column_names);
  4598. // HANDLE SEARCHES ---
  4599. if($result_count && $_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')
  4600. {
  4601. $_REQUEST['LO_search'] = $search_term = str_replace('\\\"','"',$_REQUEST['LO_search']);
  4602. $_REQUEST['LO_search'] = $search_term = ereg_replace('[^a-zA-Z0-9 _"]*','',strtolower($search_term));
  4603. if(substr($search_term,0,0)!='"' && substr($search_term,-1)!='"')
  4604. {
  4605. $search_term = ereg_replace('"','',$search_term);
  4606. while($space_pos = strpos($search_term,' '))
  4607. {
  4608. $terms[strtolower(substr($search_term,0,$space_pos))] = 1;
  4609. $search_term = substr($search_term,($space_pos+1));
  4610. }
  4611. $terms[trim($search_term)] = 1;
  4612. }
  4613. else
  4614. {
  4615. $search_term = ereg_replace('"','',$search_term);
  4616. $terms[trim($search_term)] = 1;
  4617. }
  4618. unset($terms['of']); unset($terms['the']); unset($terms['a']); unset($terms['an']); unset($terms['in']);
  4619. foreach($result as $key=>$value)
  4620. {
  4621. $values[$key] = 0;
  4622. foreach($value as $name=>$val)
  4623. {
  4624. $val = ereg_replace('[^a-zA-Z0-9 _]+','',strtolower($val));
  4625. if(strtolower($_REQUEST['LO_search'])==$val)
  4626. $values[$key] += 25;
  4627. foreach($terms as $term=>$one)
  4628. {
  4629. if(ereg($term,$val))
  4630. $values[$key] += 3;
  4631. }
  4632. }
  4633. if($values[$key]==0)
  4634. {
  4635. unset($values[$key]);
  4636. unset($result[$key]);
  4637. $result_count--;
  4638. $display_count--;
  4639. }
  4640. }
  4641. if($result_count)
  4642. {
  4643. array_multisort($values,SORT_DESC,$result);
  4644. $result = ReindexResults($result);
  4645. $values = ReindexResults($values);
  4646. $last_value = 1;
  4647. $scale = (100/$values[$last_value]);
  4648. for($i=$last_value;$i<=$result_count;$i++)
  4649. $result[$i]['RELEVANCE'] = '<!--' . ((int) ($values[$i]*$scale)) . '--><IMG SRC="assets/pixel_grey.gif" width=' . ((int) ($values[$i]*$scale)) . ' height=10>';
  4650. }
  4651. $column_names['RELEVANCE'] = "Relevance";
  4652. if(is_array($group) && count($group))
  4653. {
  4654. $options['count'] == false;
  4655. $display_zero = true;
  4656. }
  4657. }
  4658. // END SEARCHES ---
  4659. if($_REQUEST['LO_sort'])
  4660. {
  4661. foreach($result as $sort)
  4662. {
  4663. if(substr($sort[$_REQUEST['LO_sort']],0,4)!='<!--')
  4664. $sort_array[] = $sort[$_REQUEST['LO_sort']];
  4665. else
  4666. $sort_array[] = substr($sort[$_REQUEST['LO_sort']],4,strpos($sort[$_REQUEST['LO_sort']],'-->')-5);
  4667. }
  4668. if($_REQUEST['LO_direction']==-1)
  4669. $dir = SORT_DESC;
  4670. else
  4671. $dir = SORT_ASC;
  4672. if($result_count>1)
  4673. {
  4674. if(is_int($sort_array[1]) || is_double($sort_array[1]))
  4675. array_multisort($sort_array,$dir,SORT_NUMERIC,$result);
  4676. else
  4677. array_multisort($sort_array,$dir,$result);
  4678. for($i=$result_count-1;$i>=0;$i--)
  4679. $result[$i+1] = $result[$i];
  4680. unset($result[0]);
  4681. }
  4682. }
  4683. }
  4684. // HANDLE SAVING THE LIST ---
  4685. if($_REQUEST['LO_save']=='1')
  4686. {
  4687. if(!$options['save_delimiter'] && Preferences('DELIMITER')=='CSV')
  4688. $options['save_delimiter'] = 'comma';
  4689. switch($options['save_delimiter'])
  4690. {
  4691. case 'comma':
  4692. $extension = 'csv';
  4693. break;
  4694. case 'xml':
  4695. $extension = 'xml';
  4696. break;
  4697. default:
  4698. $extension = 'xls';
  4699. break;
  4700. }
  4701. ob_end_clean();
  4702. if($options['save_delimiter']!='xml')
  4703. {
  4704. foreach($column_names as $key=>$value)
  4705. $output .= str_replace('&nbsp;',' ',eregi_replace('<BR>',' ',ereg_replace('<!--.*-->','',$value))) . ($options['save_delimiter']=='comma'?',':"\t");
  4706. $output .= "\n";
  4707. }
  4708. foreach($result as $item)
  4709. {
  4710. foreach($column_names as $key=>$value)
  4711. {
  4712. if($options['save_delimiter']=='comma' && !$options['save_quotes'])
  4713. $item[$key] = str_replace(',',';',$item[$key]);
  4714. $item[$key] = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$item[$key]);
  4715. $item[$key] = eregi_replace('<SELECT.*</SELECT\>','',$item[$key]);
  4716. $output .= ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='xml'?'<'.str_replace(' ','',$value).'>':'') . ereg_replace('<[^>]+>','',ereg_replace("<div onclick='[^']+'>",'',ereg_replace(' +',' ',ereg_replace('&[^;]+;','',str_replace('<BR>&middot;',' : ',str_replace('&nbsp;',' ',$item[$key])))))) . ($options['save_delimiter']=='xml'?'</'.str_replace(' ','',$value).'>'."\n":'') . ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='comma'?',':"\t");
  4717. }
  4718. $output .= "\n";
  4719. }
  4720. header("Cache-Control: public");
  4721. header("Pragma: ");
  4722. header("Content-Type: application/$extension");
  4723. header("Content-Disposition: inline; filename=\"".ProgramTitle().".$extension\"\n");
  4724. if($options['save_eval'])
  4725. eval($options['save_eval']);
  4726. echo $output;
  4727. exit();
  4728. }
  4729. // END SAVING THE LIST ---
  4730. if($options['center'])
  4731. #echo '<CENTER>';
  4732. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  4733. {
  4734. #echo "<TABLE border=0 cellspacing=3 cellpadding=6>" ;
  4735. if(isset($_REQUEST['_openSIS_PDF']))
  4736. #echo " width=98%";
  4737. echo " <TR><TD align=center>";
  4738. }
  4739. if($options['count'] || $display_zero)
  4740. {
  4741. if(($result_count==0 || $display_count==0) && $plural)
  4742. echo "<div style=text-align:left><table cellpadding=5 cellspacing=5 class=alert_box ><tr><td class=alert></td><td class=alert_msg ><b>No $plural were found.</b></td></tr><tr><td colspan=2 class=clear></td></tr></table></div>";
  4743. elseif($result_count==0 || $display_count==0)
  4744. echo '<div style=text-align:left><table cellpadding=5 cellspacing=5 class=alert_box ><tr><td class=alert></td><td class=alert_msg ><b>None were found.</b></td></tr><tr><td colspan=2 class=clear></td></tr></table></div>';
  4745. }
  4746. if($result_count != 0 || ($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search'))
  4747. {
  4748. if(!isset($_REQUEST['_openSIS_PDF']))
  4749. {
  4750. if(!$_REQUEST['page'])
  4751. $_REQUEST['page'] = 1;
  4752. if(!$_REQUEST['LO_direction'])
  4753. $_REQUEST['LO_direction'] = 1;
  4754. $start = ($_REQUEST['page'] - 1) * $num_displayed + 1;
  4755. $stop = $start + ($num_displayed-1);
  4756. if($stop > $result_count)
  4757. $stop = $result_count;
  4758. if($result_count > $num_displayed)
  4759. {
  4760. echo "<br>";
  4761. echo "<div style=text-align:center><strtong>Displaying $start through $stop</strong></div>";
  4762. echo "<div style=text-align:right;padding-right:40px;margin-top:-15px;><strong>Go to Page ";
  4763. if(ceil($result_count/$num_displayed) <= 10)
  4764. {
  4765. for($i=1;$i<=ceil($result_count/$num_displayed);$i++)
  4766. {
  4767. if($i!=$_REQUEST['page'])
  4768. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  4769. else
  4770. $pages .= "$i, ";
  4771. }
  4772. $pages = substr($pages,0,-2) . "<BR>";
  4773. }
  4774. else
  4775. {
  4776. for($i=1;$i<=7;$i++)
  4777. {
  4778. if($i!=$_REQUEST['page'])
  4779. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  4780. else
  4781. $pages .= "$i, ";
  4782. }
  4783. $pages = substr($pages,0,-2) . " ... ";
  4784. for($i=ceil($result_count/$num_displayed)-2;$i<=ceil($result_count/$num_displayed);$i++)
  4785. {
  4786. if($i!=$_REQUEST['page'])
  4787. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  4788. else
  4789. $pages .= "$i, ";
  4790. }
  4791. $pages = substr($pages,0,-2) . " &nbsp;<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=" . ($_REQUEST['page'] +1) . ">Next Page</A><BR>";
  4792. }
  4793. echo $pages;
  4794. #echo '</TD></TR></TABLE>';
  4795. echo '</div>';
  4796. echo '<BR>';
  4797. }
  4798. }
  4799. else
  4800. {
  4801. $start = 1;
  4802. $stop = $result_count;
  4803. if($cols>8 || $_REQUEST['expanded_view'])
  4804. {
  4805. $_SESSION['orientation'] = 'landscape';
  4806. $repeat_headers = 16;
  4807. }
  4808. else
  4809. $repeat_headers = 27;
  4810. if($options['print'])
  4811. {
  4812. $html = explode('<!-- new page -->',strtolower(ob_get_contents()));
  4813. $html = $html[count($html)-1];
  4814. echo '</TD></TR></TABLE>';
  4815. $br = (substr_count($html,'<br>')) + (substr_count($html,'</p>')) + (substr_count($html,'</tr>')) + (substr_count($html,'</h1>')) + (substr_count($html,'</h2>')) + (substr_count($html,'</h3>')) + (substr_count($html,'</h4>')) + (substr_count($html,'</h5>'));
  4816. if($br%2!=0)
  4817. {
  4818. $br++;
  4819. echo '<BR>';
  4820. }
  4821. }
  4822. else
  4823. echo '</TD></TR></TABLE>';
  4824. }
  4825. // END MISC ---
  4826. // WIDTH = 100%
  4827. echo '<TABLE width=98% border=0 cellspacing=0 cellpadding=0><TR>';
  4828. // SEARCH BOX & MORE HEADERS
  4829. if($where_message || ($singular && $plural) || (!isset($_REQUEST['_openSIS_PDF']) && $options['search']))
  4830. {
  4831. echo '<TD align=center>';
  4832. echo '<TABLE cellpadding=1 width=100% border=0 class=\"grid\">';
  4833. echo "<TR><TD align=left valign=middle>";
  4834. if($singular && $plural && $options['count'])
  4835. {
  4836. if($display_count > 1)
  4837. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>$display_count $plural were found.</b></td></tr></table>";
  4838. elseif($display_count==1)
  4839. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>1 $singular was found.</b></td></tr></table>";
  4840. #if($where_message)
  4841. # echo '<br>'.$where_message;
  4842. }
  4843. if($options['save'] && !isset($_REQUEST['_openSIS_PDF']) && $result_count > 0)
  4844. //echo str_replace("Modules.php", "for_export.php", $PHP_tmp_SELF);
  4845. echo "<table cellpadding=0 cellspacing=0 class=download align=left ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&LO_save=1&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0 alt=\"Download\" title=\"Download\"></a></td></tr></table>";
  4846. //echo "<br><br><table class=download ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0></a></td><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true >Download</A></td></tr></table>";
  4847. echo '</TD>';
  4848. $colspan = 1;
  4849. if(!isset($_REQUEST['_openSIS_PDF']) && $options['search'])
  4850. {
  4851. $tmp_REQUEST = $_REQUEST;
  4852. unset($tmp_REQUEST['LO_search']);
  4853. unset($tmp_REQUEST['page']);
  4854. echo '<TD height="50" align=right valign=middle style="white-space:nowrap;">&nbsp;&nbsp;';
  4855. echo "<INPUT type=text class='cell_medium' id=LO_search name=LO_search value='".(($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')?$_REQUEST['LO_search']:'Search\' style=\'color:BBBBBB\''),"' onfocus='if(this.value==\"Search\") this.value=\"\"; this.style.color=\"000000\";' onblur='if(this.value==\"\") {this.value=\"Search\"; this.style.color=\"BBBBBB\";}' onkeypress='if(event.keyCode==13){document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+this.value; return false;} '>&nbsp;&nbsp;<INPUT type=button class='btn_go' value=Go onclick='document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+document.getElementById(\"LO_search\").value;'></TD>";
  4856. $colspan++;
  4857. }
  4858. echo "</TR>";
  4859. echo '<TR style="height:0;"><TD width=100% align=center colspan='.$colspan.'><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV></TD></TR></TABLE>';
  4860. }
  4861. else
  4862. echo '<TD width=100% align=right><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV>';
  4863. // END SEARCH BOX ----
  4864. echo '</TD></TR><TR><TD>';
  4865. // SHADOW
  4866. if(!isset($_REQUEST['_openSIS_PDF']))
  4867. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  4868. echo "<TABLE cellpadding=6 width=96% cellspacing=1 class=\"grid\" align=center>";
  4869. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  4870. echo '<THEAD>';
  4871. if(!isset($_REQUEST['_openSIS_PDF']))
  4872. echo '<TR>';
  4873. $i =1;
  4874. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  4875. {
  4876. //THIS LINE IS FOR COLUMN HEADING
  4877. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV></TD>";
  4878. $i++;
  4879. }
  4880. if($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))
  4881. {
  4882. foreach($column_names as $key=>$value)
  4883. {
  4884. if($_REQUEST['LO_sort'] == $key)
  4885. $direction = -1 * $_REQUEST['LO_direction'];
  4886. else
  4887. $direction = 1;
  4888. //THIS LINE IS FOR COLUMN HEADING
  4889. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV>";
  4890. echo "<A ";
  4891. if($options['sort'])
  4892. echo "HREF=$PHP_tmp_SELF&page=$_REQUEST[page]&LO_sort=$key&LO_direction=$direction&LO_search=".urlencode($_REQUEST['LO_search']);
  4893. echo " class=column_heading><b>$value</b></A>";
  4894. if($i==1)
  4895. echo "<DIV id=LOy0 style='position: relative;'></DIV>";
  4896. echo "</TD>";
  4897. $i++;
  4898. }
  4899. //echo '<TD width=0><DIV id=LO'.$i.'></DIV></TD>';
  4900. echo "</TR>";
  4901. }
  4902. $color = 'class=even';
  4903. //style="height: 300px; overflow: auto; padding-right: 16px;"
  4904. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  4905. echo '</THEAD><TBODY>';
  4906. // mab - enable add link as first or last
  4907. if($result_count!=0 && $link['add']['first'] && ($stop-$start)>=$link['add']['first'])
  4908. {
  4909. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  4910. // $cols++;
  4911. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  4912. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  4913. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  4914. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  4915. elseif($link['add']['html'] && $cols)
  4916. {
  4917. echo "<TR $color>";
  4918. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  4919. echo "<TD class=even align=left>".$link['add']['html']['remove']."</TD>";
  4920. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  4921. echo "<TD class=even align=left>".button('add')."</TD>";
  4922. foreach($column_names as $key=>$value)
  4923. {
  4924. echo "<TD class=even align=left >".$link['add']['html'][$key]."</TD>";
  4925. }
  4926. echo "</TR>";
  4927. $count++;
  4928. }
  4929. }
  4930. for($i=$start;$i<=$stop;$i++)
  4931. {
  4932. $item = $result[$i];
  4933. if(isset($_REQUEST['_openSIS_PDF']) && $options['print'] && count($item))
  4934. {
  4935. foreach($item as $key=>$value)
  4936. {
  4937. $value = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$value);
  4938. $value = eregi_replace('<SELECT.*</SELECT\>','',$value);
  4939. if(strpos($value,'LO_field')===false)
  4940. $item[$key] = str_replace(' ','&nbsp;',ereg_replace("<div onclick='[^']+'>",'',$value));
  4941. else
  4942. $item[$key] = ereg_replace("<div onclick='[^']+'>",'',$value);
  4943. }
  4944. }
  4945. if($item['row_color'])
  4946. $color = $item['row_color'];
  4947. elseif($color=='class=even')
  4948. $color = $side_color;
  4949. else
  4950. $color = 'class=even';
  4951. //$color = '#EDF3FE';
  4952. if(isset($_REQUEST['_openSIS_PDF']) && $count%$repeat_headers==0)
  4953. {
  4954. if($count!=0)
  4955. {
  4956. echo '</TABLE><TABLE cellpadding=6 width=820 class=\"grid\">';
  4957. echo '<!-- NEW PAGE -->';
  4958. }
  4959. echo "<TR>";
  4960. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  4961. echo "<TD class=grid></TD>";
  4962. if($cols)
  4963. {
  4964. foreach($column_names as $key=>$value)
  4965. {
  4966. echo "<TD class=grid >" . str_replace(' ','&nbsp;',$value) . "</TD>";
  4967. }
  4968. }
  4969. echo "</TR>";
  4970. }
  4971. if($count==0)
  4972. $count = $br;
  4973. echo "<TR $color>";
  4974. $count++;
  4975. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  4976. if(1==1)
  4977. {
  4978. $button_title = $link['remove']['title'];
  4979. //if(!$button_title)
  4980. //$button_title = 'Remove';
  4981. $button_link = $link['remove']['link'];
  4982. if(count($link['remove']['variables']))
  4983. {
  4984. foreach($link['remove']['variables'] as $var=>$val)
  4985. $button_link .= "&$var=" . urlencode($item[$val]);
  4986. }
  4987. echo "<TD $color>" . button_missing_atn('remove',$button_title,$button_link) . "</TD>";
  4988. }
  4989. if($cols)
  4990. {
  4991. foreach($column_names as $key=>$value)
  4992. {
  4993. if($link[$key] && !isset($_REQUEST['_openSIS_PDF']))
  4994. {
  4995. echo "<TD $color >";
  4996. if($key=='FULL_NAME')
  4997. echo '<DIV id=LOy'.($count-$br).' style="height: 100%; min-height: 100%; position: relative;">';
  4998. if($link[$key]['js']===true)
  4999. {
  5000. echo "<A HREF=# onclick='window.open(\"{$link[$key][link]}";
  5001. if(count($link[$key]['variables']))
  5002. {
  5003. foreach($link[$key]['variables'] as $var=>$val)
  5004. echo "&$var=".urlencode($item[$val]);
  5005. }
  5006. echo "\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'";
  5007. if($link[$key]['extra'])
  5008. echo ' '.$link[$key]['extra'];
  5009. echo ">";
  5010. }
  5011. else
  5012. {
  5013. echo "<A HREF={$link[$key][link]}";
  5014. if(count($link[$key]['variables']))
  5015. {
  5016. foreach($link[$key]['variables'] as $var=>$val)
  5017. echo "&$var=".urlencode($item[$val]);
  5018. }
  5019. if($link[$key]['extra'])
  5020. echo ' '.$link[$key]['extra'];
  5021. echo " onclick='grabA(this); return false;'>";
  5022. }
  5023. if($color==Preferences('HIGHLIGHT'))
  5024. echo '';
  5025. else
  5026. echo '<b>';
  5027. echo $item[$key];
  5028. echo '</b>';
  5029. if(!$item[$key])
  5030. echo '***';
  5031. echo "</A>";
  5032. if($key=='FULL_NAME')
  5033. echo '</DIV>';
  5034. echo "</TD>";
  5035. }
  5036. else
  5037. {
  5038. echo "<TD $color >";
  5039. if($key=='FULL_NAME')
  5040. echo '<DIV id=LOy'.($count-$br).' style="position: relative;">';
  5041. if($color==Preferences('HIGHLIGHT'))
  5042. echo '';
  5043. echo $item[$key];
  5044. if(!$item[$key])
  5045. echo '&nbsp;';
  5046. if($key=='FULL_NAME')
  5047. echo '<DIV>';
  5048. echo "</TD>";
  5049. }
  5050. }
  5051. }
  5052. echo "</TR>";
  5053. }
  5054. if($result_count!=0 && (!$link['add']['first'] || $link['add']['first'] && ($stop-$start)<$link['add']['first']))
  5055. {
  5056. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  5057. // $cols++;
  5058. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  5059. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  5060. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  5061. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  5062. elseif($link['add']['html'] && $cols)
  5063. {
  5064. if($count%2)
  5065. $color = 'class=even';
  5066. else
  5067. $color = $side_color;
  5068. echo "<TR $color>";
  5069. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  5070. echo "<TD class=even align=left>".$link['add']['html']['remove']."</TD>";
  5071. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  5072. echo "<TD class=even align=left class=grid_button>".button('add')."</TD>";
  5073. foreach($column_names as $key=>$value)
  5074. {
  5075. echo "<TD class=even align=left valign=top>".$link['add']['html'][$key]."</TD>";
  5076. }
  5077. echo "</TR>";
  5078. }
  5079. }
  5080. if($result_count!=0)
  5081. {
  5082. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  5083. echo '</TBODY>';
  5084. echo "</TABLE>";
  5085. // SHADOW
  5086. if(!isset($_REQUEST['_openSIS_PDF']))
  5087. echo '</TD ></TR></TABLE>';
  5088. echo "</TD ></TR>";
  5089. echo "</TABLE>";
  5090. if($options['center'])
  5091. echo '';
  5092. }
  5093. // END PRINT THE LIST ---
  5094. }
  5095. if($result_count==0)
  5096. {
  5097. // mab - problem with table closing if not opened above - do same conditional?
  5098. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  5099. #echo '<td>'; //edited for Search in parents (user>> associate student with parents)
  5100. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  5101. echo '<table width=120px cellspacing=8 cellpadding=6 ><tr><TD align=left class=lone_add >' . button('add',$link['add']['title'],$link['add']['link']) . '</td></tr></table>';
  5102. elseif(($link['add']['html'] || $link['add']['span']) && count($column_names) && !isset($_REQUEST['_openSIS_PDF']))
  5103. {
  5104. $color = $side_color;
  5105. if($options['center'])
  5106. #echo '<CENTER>';
  5107. // WIDTH=100%
  5108. //echo "<TABLE cellpadding=1 bgcolor=#f8f8f9 width=100%><TR><TD>";
  5109. // SHADOW
  5110. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  5111. if($link['add']['html'])
  5112. {
  5113. /*Here also change the colour for left corner*/
  5114. echo "<TABLE cellpadding=6 cellspacing=1 width=96% class=\"grid\"><TR><TD class=subtabs></TD>";
  5115. foreach($column_names as $key=>$value)
  5116. {
  5117. //Here to change the ListOutput Header Colour
  5118. echo "<TD class=subtabs><A><b>" . str_replace(' ','&nbsp;',$value) . "</b></A></TD>";
  5119. }
  5120. echo "</TR>";
  5121. echo "<TR class=odd>";
  5122. if($link['add']['html']['remove'])
  5123. echo "<TD >".$link['add']['html']['remove']."</TD>";
  5124. else
  5125. echo "<TD>".button('add')."</TD>";
  5126. foreach($column_names as $key=>$value)
  5127. {
  5128. echo "<TD >".$link['add']['html'][$key]."</TD>";
  5129. }
  5130. echo "</TR>";
  5131. echo "</TABLE>";
  5132. }
  5133. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  5134. echo "<TABLE><TR><TD align=center>".button('add').$link['add']['span']."</TD></TR></TABLE>";
  5135. // SHADOW
  5136. //echo '</TD></TR></TABLE>';
  5137. echo "</TD></TR></TABLE>";
  5138. if($options['center'])
  5139. echo '</CENTER>';
  5140. }
  5141. }
  5142. if($result_count!=0)
  5143. {
  5144. if($options['yscroll'])
  5145. {
  5146. echo '<div id="LOy_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  5147. echo '<TABLE cellpadding=6 id=LOy_table>';
  5148. $i = 1;
  5149. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  5150. {
  5151. $color = $side_color;
  5152. foreach($result as $item)
  5153. {
  5154. echo "<TR><TD $color id=LO_row$i>";
  5155. if($color==Preferences('HIGHLIGHT'))
  5156. echo '';
  5157. echo $item['FULL_NAME'];
  5158. if(!$item['FULL_NAME'])
  5159. echo '&nbsp;';
  5160. if($color==Preferences('HIGHLIGHT'))
  5161. echo '';
  5162. echo "</TD></TR>";
  5163. $i++;
  5164. if($item['row_color'])
  5165. $color = $item['row_color'];
  5166. elseif($color=='class=even')
  5167. $color = $side_color;
  5168. else
  5169. $color = 'class=even';
  5170. }
  5171. }
  5172. echo '</TABLE>';
  5173. echo '</div>';
  5174. }
  5175. echo '<div id="LOx_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  5176. echo '<TABLE cellpadding=6 id=LOx_table><TR>';
  5177. $i = 1;
  5178. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  5179. {
  5180. echo "<TD class=grid id=LO_col$i></TD>";
  5181. $i++;
  5182. }
  5183. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  5184. {
  5185. foreach($column_names as $key=>$value)
  5186. {
  5187. echo '<TD class=grid id=LO_col'.$i.'><A class=column_heading><b>'.str_replace('controller','',$value).'</b></A></TD>';
  5188. $i++;
  5189. }
  5190. }
  5191. echo '</TR></TABLE>';
  5192. echo '</div>';
  5193. }
  5194. }
  5195. }
  5196. #### ------------------------------- List Output For Missing Attn. End ---------------------------------------- ###
  5197. #### ------------------------------- List Output For Missing Attn. in Teacher portal -------------------------- ###
  5198. function ListOutput_missing_attn_teach_port($result,$column_names,$singular='',$plural='',$link=false,$group=false,$options=false)
  5199. {
  5200. if(!isset($options['save']))
  5201. $options['save'] = true;
  5202. if(!isset($options['print']))
  5203. $options['print'] = true;
  5204. if(!isset($options['search']))
  5205. $options['search'] = true;
  5206. if(!isset($options['center']))
  5207. $options['center'] = true;
  5208. if(!isset($options['count']))
  5209. $options['count'] = true;
  5210. if(!isset($options['sort']))
  5211. $options['sort'] = true;
  5212. //if(!$link)
  5213. //$link = array();
  5214. /*if(!isset($options['add']))
  5215. {
  5216. if(!AllowEdit() || $_REQUEST['_openSIS_PDF'])
  5217. {
  5218. if($link)
  5219. {
  5220. unset($link['add']);
  5221. unset($link['remove']);
  5222. }
  5223. }
  5224. }*/
  5225. // PREPARE LINKS ---
  5226. $result_count = $display_count = count($result);
  5227. $num_displayed = 150;
  5228. $extra = "page=$_REQUEST[page]&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search']);
  5229. $tmp_REQUEST = $_REQUEST;
  5230. unset($tmp_REQUEST['page']);
  5231. unset($tmp_REQUEST['LO_sort']);
  5232. unset($tmp_REQUEST['LO_direction']);
  5233. unset($tmp_REQUEST['LO_search']);
  5234. unset($tmp_REQUEST['remove_prompt']);
  5235. unset($tmp_REQUEST['remove_name']);
  5236. unset($tmp_REQUEST['LO_save']);
  5237. unset($tmp_REQUEST['PHPSESSID']);
  5238. $PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);
  5239. // END PREPARE LINKS ---
  5240. // UN-GROUPING
  5241. $group_count = count($group);
  5242. if(!is_array($group))
  5243. $group_count = false;
  5244. //$side_color = Preferences('COLOR');
  5245. $side_color = 'class=odd';
  5246. if($group_count && $result_count)
  5247. {
  5248. $color = 'class=even';
  5249. $group_result = $result;
  5250. unset($result);
  5251. $result[0] = '';
  5252. foreach($group_result as $item1)
  5253. {
  5254. if($group_count==1)
  5255. {
  5256. if($color=='class=even')
  5257. $color = $side_color;
  5258. else
  5259. $color = 'class=even';
  5260. }
  5261. foreach($item1 as $item2)
  5262. {
  5263. if($group_count==1)
  5264. {
  5265. $i++;
  5266. if(count($group[0]) && $i!=1)
  5267. {
  5268. foreach($group[0] as $column)
  5269. $item2[$column] = str_replace('<!-- <!--','<!--','<!-- '.str_replace('-->','--><!--',$item2[$column])).' -->';
  5270. }
  5271. $item2['row_color'] = $color;
  5272. $result[] = $item2;
  5273. }
  5274. else
  5275. {
  5276. if($group_count==2)
  5277. {
  5278. if($color=='class=even')
  5279. $color = $side_color;
  5280. else
  5281. $color = 'class=even';
  5282. }
  5283. foreach($item2 as $item3)
  5284. {
  5285. if($group_count==2)
  5286. {
  5287. $i++;
  5288. if(count($group[0]) && $i!=1)
  5289. {
  5290. foreach($group[0] as $column)
  5291. $item3[$column] = '<!-- '.$item3[$column].' -->';
  5292. }
  5293. if(count($group[1]) && $i!=1)
  5294. {
  5295. foreach($group[1] as $column)
  5296. $item3[$column] = '<!-- '.$item3[$column].' -->';
  5297. }
  5298. $item3['row_color'] = $color;
  5299. $result[] = $item3;
  5300. }
  5301. else
  5302. {
  5303. if($group_count==3)
  5304. {
  5305. if($color=='class=even')
  5306. $color = $side_color;
  5307. else
  5308. $color = 'class=even';
  5309. }
  5310. foreach($item3 as $item4)
  5311. {
  5312. if($group_count==3)
  5313. {
  5314. $i++;
  5315. if(count($group[2]) && $i!=1)
  5316. {
  5317. foreach($group[2] as $column)
  5318. unset($item4[$column]);
  5319. }
  5320. $item4['row_color'] = $color;
  5321. $result[] = $item4;
  5322. }
  5323. }
  5324. }
  5325. }
  5326. }
  5327. }
  5328. $i = 0;
  5329. }
  5330. unset($result[0]);
  5331. $result_count = count($result);
  5332. unset($_REQUEST['LO_sort']);
  5333. }
  5334. // END UN-GROUPING
  5335. $_LIST['output'] = true;
  5336. // PRINT HEADINGS, PREPARE PDF, AND SORT THE LIST ---
  5337. if($_LIST['output']!=false)
  5338. {
  5339. if($result_count != 0)
  5340. {
  5341. $count = 0;
  5342. $remove = count($link['remove']['variables']);
  5343. $cols = count($column_names);
  5344. // HANDLE SEARCHES ---
  5345. if($result_count && $_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')
  5346. {
  5347. $_REQUEST['LO_search'] = $search_term = str_replace('\\\"','"',$_REQUEST['LO_search']);
  5348. $_REQUEST['LO_search'] = $search_term = ereg_replace('[^a-zA-Z0-9 _"]*','',strtolower($search_term));
  5349. if(substr($search_term,0,0)!='"' && substr($search_term,-1)!='"')
  5350. {
  5351. $search_term = ereg_replace('"','',$search_term);
  5352. while($space_pos = strpos($search_term,' '))
  5353. {
  5354. $terms[strtolower(substr($search_term,0,$space_pos))] = 1;
  5355. $search_term = substr($search_term,($space_pos+1));
  5356. }
  5357. $terms[trim($search_term)] = 1;
  5358. }
  5359. else
  5360. {
  5361. $search_term = ereg_replace('"','',$search_term);
  5362. $terms[trim($search_term)] = 1;
  5363. }
  5364. unset($terms['of']); unset($terms['the']); unset($terms['a']); unset($terms['an']); unset($terms['in']);
  5365. foreach($result as $key=>$value)
  5366. {
  5367. $values[$key] = 0;
  5368. foreach($value as $name=>$val)
  5369. {
  5370. $val = ereg_replace('[^a-zA-Z0-9 _]+','',strtolower($val));
  5371. if(strtolower($_REQUEST['LO_search'])==$val)
  5372. $values[$key] += 25;
  5373. foreach($terms as $term=>$one)
  5374. {
  5375. if(ereg($term,$val))
  5376. $values[$key] += 3;
  5377. }
  5378. }
  5379. if($values[$key]==0)
  5380. {
  5381. unset($values[$key]);
  5382. unset($result[$key]);
  5383. $result_count--;
  5384. $display_count--;
  5385. }
  5386. }
  5387. if($result_count)
  5388. {
  5389. array_multisort($values,SORT_DESC,$result);
  5390. $result = ReindexResults($result);
  5391. $values = ReindexResults($values);
  5392. $last_value = 1;
  5393. $scale = (100/$values[$last_value]);
  5394. for($i=$last_value;$i<=$result_count;$i++)
  5395. $result[$i]['RELEVANCE'] = '<!--' . ((int) ($values[$i]*$scale)) . '--><IMG SRC="assets/pixel_grey.gif" width=' . ((int) ($values[$i]*$scale)) . ' height=10>';
  5396. }
  5397. $column_names['RELEVANCE'] = "Relevance";
  5398. if(is_array($group) && count($group))
  5399. {
  5400. $options['count'] == false;
  5401. $display_zero = true;
  5402. }
  5403. }
  5404. // END SEARCHES ---
  5405. if($_REQUEST['LO_sort'])
  5406. {
  5407. foreach($result as $sort)
  5408. {
  5409. if(substr($sort[$_REQUEST['LO_sort']],0,4)!='<!--')
  5410. $sort_array[] = $sort[$_REQUEST['LO_sort']];
  5411. else
  5412. $sort_array[] = substr($sort[$_REQUEST['LO_sort']],4,strpos($sort[$_REQUEST['LO_sort']],'-->')-5);
  5413. }
  5414. if($_REQUEST['LO_direction']==-1)
  5415. $dir = SORT_DESC;
  5416. else
  5417. $dir = SORT_ASC;
  5418. if($result_count>1)
  5419. {
  5420. if(is_int($sort_array[1]) || is_double($sort_array[1]))
  5421. array_multisort($sort_array,$dir,SORT_NUMERIC,$result);
  5422. else
  5423. array_multisort($sort_array,$dir,$result);
  5424. for($i=$result_count-1;$i>=0;$i--)
  5425. $result[$i+1] = $result[$i];
  5426. unset($result[0]);
  5427. }
  5428. }
  5429. }
  5430. // HANDLE SAVING THE LIST ---
  5431. if($_REQUEST['LO_save']=='1')
  5432. {
  5433. if(!$options['save_delimiter'] && Preferences('DELIMITER')=='CSV')
  5434. $options['save_delimiter'] = 'comma';
  5435. switch($options['save_delimiter'])
  5436. {
  5437. case 'comma':
  5438. $extension = 'csv';
  5439. break;
  5440. case 'xml':
  5441. $extension = 'xml';
  5442. break;
  5443. default:
  5444. $extension = 'xls';
  5445. break;
  5446. }
  5447. ob_end_clean();
  5448. if($options['save_delimiter']!='xml')
  5449. {
  5450. foreach($column_names as $key=>$value)
  5451. $output .= str_replace('&nbsp;',' ',eregi_replace('<BR>',' ',ereg_replace('<!--.*-->','',$value))) . ($options['save_delimiter']=='comma'?',':"\t");
  5452. $output .= "\n";
  5453. }
  5454. foreach($result as $item)
  5455. {
  5456. foreach($column_names as $key=>$value)
  5457. {
  5458. if($options['save_delimiter']=='comma' && !$options['save_quotes'])
  5459. $item[$key] = str_replace(',',';',$item[$key]);
  5460. $item[$key] = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$item[$key]);
  5461. $item[$key] = eregi_replace('<SELECT.*</SELECT\>','',$item[$key]);
  5462. $output .= ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='xml'?'<'.str_replace(' ','',$value).'>':'') . ereg_replace('<[^>]+>','',ereg_replace("<div onclick='[^']+'>",'',ereg_replace(' +',' ',ereg_replace('&[^;]+;','',str_replace('<BR>&middot;',' : ',str_replace('&nbsp;',' ',$item[$key])))))) . ($options['save_delimiter']=='xml'?'</'.str_replace(' ','',$value).'>'."\n":'') . ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='comma'?',':"\t");
  5463. }
  5464. $output .= "\n";
  5465. }
  5466. header("Cache-Control: public");
  5467. header("Pragma: ");
  5468. header("Content-Type: application/$extension");
  5469. header("Content-Disposition: inline; filename=\"".ProgramTitle().".$extension\"\n");
  5470. if($options['save_eval'])
  5471. eval($options['save_eval']);
  5472. echo $output;
  5473. exit();
  5474. }
  5475. // END SAVING THE LIST ---
  5476. if($options['center'])
  5477. #echo '<CENTER>';
  5478. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  5479. {
  5480. #echo "<TABLE border=0 cellspacing=3 cellpadding=6>" ;
  5481. if(isset($_REQUEST['_openSIS_PDF']))
  5482. #echo " width=98%";
  5483. echo " <TR><TD align=center>";
  5484. }
  5485. if($options['count'] || $display_zero)
  5486. {
  5487. if(($result_count==0 || $display_count==0) && $plural)
  5488. echo "<div style=text-align:left><table cellpadding=5 cellspacing=5 class=alert_box ><tr><td class=alert></td><td class=alert_msg ><b>No $plural were found.</b></td></tr><tr><td colspan=2 class=clear></td></tr></table></div>";
  5489. elseif($result_count==0 || $display_count==0)
  5490. echo '<div style=text-align:left><table cellpadding=5 cellspacing=5 class=alert_box ><tr><td class=alert></td><td class=alert_msg ><b>None were found.</b></td></tr><tr><td colspan=2 class=clear></td></tr></table></div>';
  5491. }
  5492. if($result_count != 0 || ($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search'))
  5493. {
  5494. if(!isset($_REQUEST['_openSIS_PDF']))
  5495. {
  5496. if(!$_REQUEST['page'])
  5497. $_REQUEST['page'] = 1;
  5498. if(!$_REQUEST['LO_direction'])
  5499. $_REQUEST['LO_direction'] = 1;
  5500. $start = ($_REQUEST['page'] - 1) * $num_displayed + 1;
  5501. $stop = $start + ($num_displayed-1);
  5502. if($stop > $result_count)
  5503. $stop = $result_count;
  5504. if($result_count > $num_displayed)
  5505. {
  5506. echo '<br>';
  5507. echo $where_message = "<strtong>Displaying $start through $stop</strong>";
  5508. echo "<div style=text-align:right;margin-top:-15px;padding-right:29px;><strong>Go to Page ";
  5509. if(ceil($result_count/$num_displayed) <= 10)
  5510. {
  5511. for($i=1;$i<=ceil($result_count/$num_displayed);$i++)
  5512. {
  5513. if($i!=$_REQUEST['page'])
  5514. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  5515. else
  5516. $pages .= "$i, ";
  5517. }
  5518. $pages = substr($pages,0,-2) . "<BR>";
  5519. }
  5520. else
  5521. {
  5522. for($i=1;$i<=7;$i++)
  5523. {
  5524. if($i!=$_REQUEST['page'])
  5525. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  5526. else
  5527. $pages .= "$i, ";
  5528. }
  5529. $pages = substr($pages,0,-2) . " ... ";
  5530. for($i=ceil($result_count/$num_displayed)-2;$i<=ceil($result_count/$num_displayed);$i++)
  5531. {
  5532. if($i!=$_REQUEST['page'])
  5533. $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=$i>$i</A>, ";
  5534. else
  5535. $pages .= "$i, ";
  5536. }
  5537. $pages = substr($pages,0,-2) . " &nbsp;<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search'])."&page=" . ($_REQUEST['page'] +1) . ">Next Page</A><BR>";
  5538. }
  5539. echo $pages;
  5540. #echo '</TD></TR></TABLE>';
  5541. echo '</div>';
  5542. echo '<BR>';
  5543. }
  5544. }
  5545. else
  5546. {
  5547. $start = 1;
  5548. $stop = $result_count;
  5549. if($cols>8 || $_REQUEST['expanded_view'])
  5550. {
  5551. $_SESSION['orientation'] = 'landscape';
  5552. $repeat_headers = 16;
  5553. }
  5554. else
  5555. $repeat_headers = 27;
  5556. if($options['print'])
  5557. {
  5558. $html = explode('<!-- new page -->',strtolower(ob_get_contents()));
  5559. $html = $html[count($html)-1];
  5560. echo '</TD></TR></TABLE>';
  5561. $br = (substr_count($html,'<br>')) + (substr_count($html,'</p>')) + (substr_count($html,'</tr>')) + (substr_count($html,'</h1>')) + (substr_count($html,'</h2>')) + (substr_count($html,'</h3>')) + (substr_count($html,'</h4>')) + (substr_count($html,'</h5>'));
  5562. if($br%2!=0)
  5563. {
  5564. $br++;
  5565. echo '<BR>';
  5566. }
  5567. }
  5568. else
  5569. echo '</TD></TR></TABLE>';
  5570. }
  5571. // END MISC ---
  5572. // WIDTH = 100%
  5573. echo '<TABLE width=98% border=0 cellspacing=0 cellpadding=0><TR>';
  5574. // SEARCH BOX & MORE HEADERS
  5575. if($where_message || ($singular && $plural) || (!isset($_REQUEST['_openSIS_PDF']) && $options['search']))
  5576. {
  5577. echo '<TD align=center>';
  5578. echo '<TABLE cellpadding=1 width=100% border=0 class=\"grid\">';
  5579. echo "<TR><TD align=left valign=middle>";
  5580. if($singular && $plural && $options['count'])
  5581. {
  5582. if($display_count > 1)
  5583. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>$display_count $plural were found.</b></td></tr></table>";
  5584. elseif($display_count==1)
  5585. echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>1 $singular was found.</b></td></tr></table>";
  5586. #if($where_message)
  5587. # echo '<br>'.$where_message;
  5588. }
  5589. if($options['save'] && !isset($_REQUEST['_openSIS_PDF']) && $result_count > 0)
  5590. //echo str_replace("Modules.php", "for_export.php", $PHP_tmp_SELF);
  5591. echo "<table cellpadding=0 cellspacing=0 class=download align=left ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&LO_save=1&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0 alt=\"Download\" title=\"Download\"></a></td></tr></table>";
  5592. //echo "<br><br><table class=download ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0></a></td><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true >Download</A></td></tr></table>";
  5593. echo '</TD>';
  5594. $colspan = 1;
  5595. if(!isset($_REQUEST['_openSIS_PDF']) && $options['search'])
  5596. {
  5597. $tmp_REQUEST = $_REQUEST;
  5598. unset($tmp_REQUEST['LO_search']);
  5599. unset($tmp_REQUEST['page']);
  5600. echo '<TD height="50" align=right valign=middle style="white-space:nowrap;">&nbsp;&nbsp;';
  5601. echo "<INPUT type=text class='cell_medium' id=LO_search name=LO_search value='".(($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')?$_REQUEST['LO_search']:'Search\' style=\'color:BBBBBB\''),"' onfocus='if(this.value==\"Search\") this.value=\"\"; this.style.color=\"000000\";' onblur='if(this.value==\"\") {this.value=\"Search\"; this.style.color=\"BBBBBB\";}' onkeypress='if(event.keyCode==13){document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+this.value; return false;} '>&nbsp;&nbsp;<INPUT type=button class='btn_go' value=Go onclick='document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+document.getElementById(\"LO_search\").value;'></TD>";
  5602. $colspan++;
  5603. }
  5604. echo "</TR>";
  5605. echo '<TR style="height:0;"><TD width=100% align=center colspan='.$colspan.'><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV></TD></TR></TABLE>';
  5606. }
  5607. else
  5608. echo '<TD width=100% align=right><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_openSIS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV>';
  5609. // END SEARCH BOX ----
  5610. echo '</TD></TR><TR><TD>';
  5611. // SHADOW
  5612. if(!isset($_REQUEST['_openSIS_PDF']))
  5613. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  5614. echo "<TABLE cellpadding=6 width=96% cellspacing=1 class=\"grid\" align=center>";
  5615. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  5616. echo '<THEAD>';
  5617. if(!isset($_REQUEST['_openSIS_PDF']))
  5618. echo '<TR>';
  5619. $i =1;
  5620. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  5621. {
  5622. //THIS LINE IS FOR COLUMN HEADING
  5623. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV></TD>";
  5624. $i++;
  5625. }
  5626. if($result_count!=0 && $cols && !isset($_REQUEST['_openSIS_PDF']))
  5627. {
  5628. foreach($column_names as $key=>$value)
  5629. {
  5630. if($_REQUEST['LO_sort'] == $key)
  5631. $direction = -1 * $_REQUEST['LO_direction'];
  5632. else
  5633. $direction = 1;
  5634. //THIS LINE IS FOR COLUMN HEADING
  5635. echo "<TD class=subtabs><DIV id=LOx$i style='position: relative;'></DIV>";
  5636. echo "<A ";
  5637. if($options['sort'])
  5638. echo "HREF=$PHP_tmp_SELF&page=$_REQUEST[page]&LO_sort=$key&LO_direction=$direction&LO_search=".urlencode($_REQUEST['LO_search']);
  5639. echo " class=column_heading><b>$value</b></A>";
  5640. if($i==1)
  5641. echo "<DIV id=LOy0 style='position: relative;'></DIV>";
  5642. echo "</TD>";
  5643. $i++;
  5644. }
  5645. //echo '<TD width=0><DIV id=LO'.$i.'></DIV></TD>';
  5646. echo "</TR>";
  5647. }
  5648. $color = 'class=even';
  5649. //style="height: 300px; overflow: auto; padding-right: 16px;"
  5650. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  5651. echo '</THEAD><TBODY>';
  5652. // mab - enable add link as first or last
  5653. if($result_count!=0 && $link['add']['first'] && ($stop-$start)>=$link['add']['first'])
  5654. {
  5655. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  5656. // $cols++;
  5657. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  5658. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  5659. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  5660. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  5661. elseif($link['add']['html'] && $cols)
  5662. {
  5663. echo "<TR $color>";
  5664. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  5665. echo "<TD class=even align=left>".$link['add']['html']['remove']."</TD>";
  5666. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  5667. echo "<TD class=even align=left>".button('add')."</TD>";
  5668. foreach($column_names as $key=>$value)
  5669. {
  5670. echo "<TD class=even align=left >".$link['add']['html'][$key]."</TD>";
  5671. }
  5672. echo "</TR>";
  5673. $count++;
  5674. }
  5675. }
  5676. for($i=$start;$i<=$stop;$i++)
  5677. {
  5678. $item = $result[$i];
  5679. if(isset($_REQUEST['_openSIS_PDF']) && $options['print'] && count($item))
  5680. {
  5681. foreach($item as $key=>$value)
  5682. {
  5683. $value = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$value);
  5684. $value = eregi_replace('<SELECT.*</SELECT\>','',$value);
  5685. if(strpos($value,'LO_field')===false)
  5686. $item[$key] = str_replace(' ','&nbsp;',ereg_replace("<div onclick='[^']+'>",'',$value));
  5687. else
  5688. $item[$key] = ereg_replace("<div onclick='[^']+'>",'',$value);
  5689. }
  5690. }
  5691. if($item['row_color'])
  5692. $color = $item['row_color'];
  5693. elseif($color=='class=even')
  5694. $color = $side_color;
  5695. else
  5696. $color = 'class=even';
  5697. //$color = '#EDF3FE';
  5698. if(isset($_REQUEST['_openSIS_PDF']) && $count%$repeat_headers==0)
  5699. {
  5700. if($count!=0)
  5701. {
  5702. echo '</TABLE><TABLE cellpadding=6 width=820 class=\"grid\">';
  5703. echo '<!-- NEW PAGE -->';
  5704. }
  5705. echo "<TR>";
  5706. if($remove && !isset($_REQUEST['_openSIS_PDF']))
  5707. echo "<TD class=grid></TD>";
  5708. if($cols)
  5709. {
  5710. foreach($column_names as $key=>$value)
  5711. {
  5712. echo "<TD class=grid >" . str_replace(' ','&nbsp;',$value) . "</TD>";
  5713. }
  5714. }
  5715. echo "</TR>";
  5716. }
  5717. if($count==0)
  5718. $count = $br;
  5719. echo "<TR $color>";
  5720. $count++;
  5721. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  5722. if(1==1)
  5723. {
  5724. $button_title = $link['remove']['title'];
  5725. //if(!$button_title)
  5726. //$button_title = 'Remove';
  5727. $button_link = $link['remove']['link'];
  5728. if(count($link['remove']['variables']))
  5729. {
  5730. foreach($link['remove']['variables'] as $var=>$val)
  5731. $button_link .= "&$var=" . urlencode($item[$val]);
  5732. if($_SESSION['take_mssn_attn'] && $var=='cp_id'){
  5733. $cur_cp_id=$item[$val];
  5734. }
  5735. }
  5736. echo "<TD $color>" . button_missing_atn('remove',$button_title,$button_link,$cur_cp_id) . "</TD>";
  5737. }
  5738. if($cols)
  5739. {
  5740. foreach($column_names as $key=>$value)
  5741. {
  5742. if($link[$key] && !isset($_REQUEST['_openSIS_PDF']))
  5743. {
  5744. echo "<TD $color >";
  5745. if($key=='FULL_NAME')
  5746. echo '<DIV id=LOy'.($count-$br).' style="height: 100%; min-height: 100%; position: relative;">';
  5747. if($link[$key]['js']===true)
  5748. {
  5749. echo "<A HREF=# onclick='window.open(\"{$link[$key][link]}";
  5750. if(count($link[$key]['variables']))
  5751. {
  5752. foreach($link[$key]['variables'] as $var=>$val)
  5753. echo "&$var=".urlencode($item[$val]);
  5754. }
  5755. echo "\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'";
  5756. if($link[$key]['extra'])
  5757. echo ' '.$link[$key]['extra'];
  5758. echo ">";
  5759. }
  5760. else
  5761. {
  5762. echo "<A HREF={$link[$key][link]}";
  5763. if(count($link[$key]['variables']))
  5764. {
  5765. foreach($link[$key]['variables'] as $var=>$val)
  5766. echo "&$var=".urlencode($item[$val]);
  5767. }
  5768. if($link[$key]['extra'])
  5769. echo ' '.$link[$key]['extra'];
  5770. echo " onclick='grabA(this); return false;'>";
  5771. }
  5772. if($color==Preferences('HIGHLIGHT'))
  5773. echo '';
  5774. else
  5775. echo '<b>';
  5776. echo $item[$key];
  5777. echo '</b>';
  5778. if(!$item[$key])
  5779. echo '***';
  5780. echo "</A>";
  5781. if($key=='FULL_NAME')
  5782. echo '</DIV>';
  5783. echo "</TD>";
  5784. }
  5785. else
  5786. {
  5787. echo "<TD $color >";
  5788. if($key=='FULL_NAME')
  5789. echo '<DIV id=LOy'.($count-$br).' style="position: relative;">';
  5790. if($color==Preferences('HIGHLIGHT'))
  5791. echo '';
  5792. echo $item[$key];
  5793. if(!$item[$key])
  5794. echo '&nbsp;';
  5795. if($key=='FULL_NAME')
  5796. echo '<DIV>';
  5797. echo "</TD>";
  5798. }
  5799. }
  5800. }
  5801. echo "</TR>";
  5802. }
  5803. if($result_count!=0 && (!$link['add']['first'] || $link['add']['first'] && ($stop-$start)<$link['add']['first']))
  5804. {
  5805. //if($remove && !isset($_REQUEST['_openSIS_PDF']))
  5806. // $cols++;
  5807. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  5808. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
  5809. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  5810. echo "<TR><TD colspan=".($remove?$cols+1:$cols)." align=left class=even>".button('add').$link['add']['span']."</TD></TR>";
  5811. elseif($link['add']['html'] && $cols)
  5812. {
  5813. if($count%2)
  5814. $color = 'class=even';
  5815. else
  5816. $color = $side_color;
  5817. echo "<TR $color>";
  5818. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove'])
  5819. echo "<TD class=even align=left>".$link['add']['html']['remove']."</TD>";
  5820. elseif($remove && !isset($_REQUEST['_openSIS_PDF']))
  5821. echo "<TD class=even align=left class=grid_button>".button('add')."</TD>";
  5822. foreach($column_names as $key=>$value)
  5823. {
  5824. echo "<TD class=even align=left valign=top>".$link['add']['html'][$key]."</TD>";
  5825. }
  5826. echo "</TR>";
  5827. }
  5828. }
  5829. if($result_count!=0)
  5830. {
  5831. if(!isset($_REQUEST['_openSIS_PDF']) && ($stop-$start)>10)
  5832. echo '</TBODY>';
  5833. echo "</TABLE>";
  5834. // SHADOW
  5835. if(!isset($_REQUEST['_openSIS_PDF']))
  5836. echo '</TD ></TR></TABLE>';
  5837. echo "</TD ></TR>";
  5838. echo "</TABLE>";
  5839. if($options['center'])
  5840. echo '';
  5841. }
  5842. // END PRINT THE LIST ---
  5843. }
  5844. if($result_count==0)
  5845. {
  5846. // mab - problem with table closing if not opened above - do same conditional?
  5847. if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
  5848. #echo '<td>'; //edited for Search in parents (user>> associate student with parents)
  5849. if($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF']))
  5850. echo '<table width=120px cellspacing=8 cellpadding=6 ><tr><TD align=left class=lone_add >' . button('add',$link['add']['title'],$link['add']['link']) . '</td></tr></table>';
  5851. elseif(($link['add']['html'] || $link['add']['span']) && count($column_names) && !isset($_REQUEST['_openSIS_PDF']))
  5852. {
  5853. $color = $side_color;
  5854. if($options['center'])
  5855. #echo '<CENTER>';
  5856. // WIDTH=100%
  5857. //echo "<TABLE cellpadding=1 bgcolor=#f8f8f9 width=100%><TR><TD>";
  5858. // SHADOW
  5859. echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
  5860. if($link['add']['html'])
  5861. {
  5862. /*Here also change the colour for left corner*/
  5863. echo "<TABLE cellpadding=6 cellspacing=1 width=96% class=\"grid\"><TR><TD class=subtabs></TD>";
  5864. foreach($column_names as $key=>$value)
  5865. {
  5866. //Here to change the ListOutput Header Colour
  5867. echo "<TD class=subtabs><A><b>" . str_replace(' ','&nbsp;',$value) . "</b></A></TD>";
  5868. }
  5869. echo "</TR>";
  5870. echo "<TR class=odd>";
  5871. if($link['add']['html']['remove'])
  5872. echo "<TD >".$link['add']['html']['remove']."</TD>";
  5873. else
  5874. echo "<TD>".button('add')."</TD>";
  5875. foreach($column_names as $key=>$value)
  5876. {
  5877. echo "<TD >".$link['add']['html'][$key]."</TD>";
  5878. }
  5879. echo "</TR>";
  5880. echo "</TABLE>";
  5881. }
  5882. elseif($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF']))
  5883. echo "<TABLE><TR><TD align=center>".button('add').$link['add']['span']."</TD></TR></TABLE>";
  5884. // SHADOW
  5885. //echo '</TD></TR></TABLE>';
  5886. echo "</TD></TR></TABLE>";
  5887. if($options['center'])
  5888. echo '</CENTER>';
  5889. }
  5890. }
  5891. if($result_count!=0)
  5892. {
  5893. if($options['yscroll'])
  5894. {
  5895. echo '<div id="LOy_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  5896. echo '<TABLE cellpadding=6 id=LOy_table>';
  5897. $i = 1;
  5898. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  5899. {
  5900. $color = $side_color;
  5901. foreach($result as $item)
  5902. {
  5903. echo "<TR><TD $color id=LO_row$i>";
  5904. if($color==Preferences('HIGHLIGHT'))
  5905. echo '';
  5906. echo $item['FULL_NAME'];
  5907. if(!$item['FULL_NAME'])
  5908. echo '&nbsp;';
  5909. if($color==Preferences('HIGHLIGHT'))
  5910. echo '';
  5911. echo "</TD></TR>";
  5912. $i++;
  5913. if($item['row_color'])
  5914. $color = $item['row_color'];
  5915. elseif($color=='class=even')
  5916. $color = $side_color;
  5917. else
  5918. $color = 'class=even';
  5919. }
  5920. }
  5921. echo '</TABLE>';
  5922. echo '</div>';
  5923. }
  5924. echo '<div id="LOx_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
  5925. echo '<TABLE cellpadding=6 id=LOx_table><TR>';
  5926. $i = 1;
  5927. if($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count!=0)
  5928. {
  5929. echo "<TD class=grid id=LO_col$i></TD>";
  5930. $i++;
  5931. }
  5932. if($cols && !isset($_REQUEST['_openSIS_PDF']))
  5933. {
  5934. foreach($column_names as $key=>$value)
  5935. {
  5936. echo '<TD class=grid id=LO_col'.$i.'><A class=column_heading><b>'.str_replace('controller','',$value).'</b></A></TD>';
  5937. $i++;
  5938. }
  5939. }
  5940. echo '</TR></TABLE>';
  5941. echo '</div>';
  5942. }
  5943. }
  5944. }
  5945. #### ------------------------ List Output For Missing Attn. in Teacher portal End ------------------------------ ###
  5946. ?>