/*
$SQL: SQL statements
$pagedir: Paging Click to jump Address
$page Current Page
Total $count Data
$pagesize show the number of bars per page
*/
Function page ($sql, $pagedir, $page = 1, $count, $pagesize = 10) {
$pagecode = ";
$page = Intval ($page);
$count = Intval ($count);
if (! $count) return ';
$pagecount = Ceil ($count/$pagesize);
if ($page < 1) $page = 1;
if ($page > $pagecount) $page = $pagecount;
$pageStart = $pagesize * ($page-1) + 1;
$pageEnd = $pagesize * $page;
if ($pageEnd > $count) {$pageEnd = $count;}
$pagecode = "<a href=\" $pagedir &page=1\ "></a>";
if ($page = = 1 | | empty ($page)) {
$pagecode = "<button type=\" button\ "id=\" popupviewstartbutton\ "title=\" start\ "class=\" button\ "disabled=\" \ " >
<span align=\ "absmiddle\" border=\ "0\" class=\ "spr_60e88c7c4bc21ade9c3010b6abcdc0fd\" title=\ "Start\" ></ Span>
</button><button type=\ "button\" id=\ "popupviewprevbutton\" class=\ "button\" disabled=\ "\" Title=\ " Previous\ ">
<span align=\ "absmiddle\" border=\ "0\" class=\ "spr_85ff471105a04f2dd1f76dd22206dd14\" title=\ "Previous\" > </span>
</button> ";
} else {
$pagecode = "<button type=\" button\ "id=\" popupviewstartbutton\ "title=\" start\ "class=\" button\ "onclick=\" Location.href= ' {$pagedir}&page=1 ' \ ' >
<span align=\ "absmiddle\" border=\ "0\" class=\ "spr_e6223c471f8cf9df579462569fa9306c\" title=\ "Start\" ></ Span>
</button> ";
if ($page > 1) $PreviousPage = $page-1; else $PreviousPage = 1;
$pagecode. = "<a href=\" $pagedir &page= $PreviousPage \ "></a>";
$pagecode. = "<button type=\" button\ "id=\" popupviewprevbutton\ "title=\" previous\ "class=\" button\ "onclick=\" Location.href= ' {$pagedir}&page={$PreviousPage} ' \ ' >
<span align=\ "absmiddle\" border=\ "0\" class=\ "spr_a6fa65259296aaa5b94ded054464cf68\" title=\ "Previous\" > </span></button> ";
}
$pagecode. = "<span class=\" pagenumbers\ "> ($pageStart-$pageEnd of $count) </span>";
if ($page < $pagecount) $NextPage = $page + 1; else $NextPage = $pagecount;
if ($pagecount = = $page) {
$pagecode. = "<span class=\" pagenumbers\ "> ($pageStart-$pageEnd of $count) </span>";
$pagecode. = "<button type=\" button\ "id=\" popupviewnextbutton\ "class=\" button\ "title=\" next\ "disabled=\" \ ">
<span align=\ "absmiddle\" border=\ "0\" class=\ "spr_9c82366f2d3d35c243dd91706811b036\" title=\ "Next\" ></ Span>
</button>
<button type=\ "button\" id=\ "popupviewendbutton\" class=\ "button\" disabled=\ "\" title=\ "End\" >
<span align=\ "absmiddle\" border=\ "0\" class=\ "spr_17b56a3610caf7a7ad1aa7da7a984801\" title=\ "End\" ></ Span>
</button> ";
} else {
$pagecode. = "<span class=\" pagenumbers\ "> ($pageStart-$pageEnd of {$pageEnd}+) </span>";
$pagecode. = "<button type=\" button\ "id=\" popupviewnextbutton\ "title=\" next\ "class=\" button\ "onclick=\" Location.href= ' {$pagedir}&page={$NextPage} ' \ ' >
<span align=\ "absmiddle\" border=\ "0\" class=\ "spr_8770145eda4b0bf4f79175b595174ae2\" title=\ "Next\" ></ Span>
</button>
<button type=\ "button\" id=\ "popupviewendbutton\" title=\ "end\" class=\ "button\" onclick=\ "location.href=" {$ pagedir}&page={$pagecount} ' \ ' >
<span align=\ "absmiddle\" border=\ "0\" class=\ "spr_60d1e91e479a5648f0ca1a59e0f39c61\" title=\ "End\" ></ Span>
</button> ";
$pagecode. = "<a href=\" $pagedir &page= $NextPage \ "></a>";
$pagecode. = "<a href=\" $pagedir &page= $pagecount \ "></a> ";
}
$result = Array ();
$sql = str_replace (Array (' {#pageStart #} ', ' {#pageEnd #} '), Array ($pageStart, $pageEnd), $sql);
$result = $this->oracle->getarray ($sql);
Return Array (' pagecode ' = $pagecode, ' result ' = $result, ' PageCount ' + $pagecount);
}
The invocation example is as follows:
$count = $this->oracle->getone ("SELECT count (1) from (
SELECT DISTINCT c.id from ACCOUNTS A
Left JOIN accounts_cstm B on (a.id = B.id_c)
Left JOIN CASES C on (c.account_id = a.id)
Left JOIN cases_cstm CS on (c.id = Cs.id_c)
WHERE a.deleted = 0 and c.deleted =0 and B.mg_insertdate_c < To_date (' {$this->existing_date} ', ' {$this->time_for Mat} ')
and B.mg_supplier_status_c = ' NON MSC '
and CS. Mg_case_origin_c = ' eform_portal ' $whereSQL) tt ");
$SQL = "Select DISTINCT c.id, C.name NAME, A.name supplier_name, C.status, CS. Mg_case_subjtype_c Case_subject_type, To_char (c.date_entered, ' DD. Mm. YYYY HH24:MI:SS ') create_date,
To_char (CS. Mg_case_due_date_c, ' DD. Mm. YYYY ') Due_date,
(SELECT NAME from TEAMS WHERE DELETED = 0 and ID =c.team_id) Team_name
From ACCOUNTS A
Left JOIN accounts_cstm B on (a.id = B.id_c)
Left JOIN CASES C on (c.account_id = a.id)
Left JOIN cases_cstm CS on (c.id = Cs.id_c)
WHERE a.deleted = 0 and c.deleted =0 and B.mg_insertdate_c < To_date (' {$this->existing_date} ', ' {$this->time_for Mat} ')
and B.mg_supplier_status_c = ' NON MSC '
and CS. Mg_case_origin_c = ' eform_portal ' $whereSQL ";
$newSQL = "SELECT * from" (select Aa.*, RowNum rn from ($SQL) AA where rownum <= {#pageEnd #}) where RN >= {#pageSta rt#} ";
$pagedir = "funnel_list.php?action=non_msc_cases_list¶=". $para;
$result = $this->pages ($newSQL, $pagedir, $_request[' page '), $count, 20);
PHP using the Oracle paging method