PageRenderTime 69ms CodeModel.GetById 32ms 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

Large files files are truncated, but you can click here to view the full file

  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]['variab…

Large files files are truncated, but you can click here to view the full file