Bebera hari yg lalu saya membuat CRM, dan saya menggunakan AuraCMS
dari
situlah timbul ide saya untuk mempercantik pagingajaxnya auraCMS
oke
langung saja ke modifikasinya:
1. Edit CSS dan
tambahkan CSS berikut :
.table {
border:1px solid #ccc;
width: 20px;
height: 20px;
text-align: center;
font-family: verdana;
padding:.3em .7em;
margin:0 .38em 0 0;
color: #00c;
}
.table:hover {
border: 1px solid blue;
text-align: center;
padding:.3em .7em;
margin:0 .38em 0 0;
font-family: verdana;
border:1px solid #83bc46;
background:#f0f7e8;
}
.active {
border:1px solid #83bc46;
text-align: center;
padding:.3em .7em;
margin:0 .38em 0 0;
color: #00c;
font-weight: bold;
background:#f0f7e8;
}
#uh:link{
color: #CC6600;
text-decoration: none;
}
#uh:hover{
color: #FF6600;
text-decoration: none;
background-color: #FFF;
}
2. Edit fungsi.php, ganti function getPagingajax sbb:
function getPagingajax($jumlah, $pg, $stg)
if (!isset ($pg,$stg)){
$pg = 1;
$stg = 1;
}
$qs = '';
$arr = explode("&",$_SERVER["QUERY_STRING"]);
if (is_array($arr)) {
for ($i=0;$i
if (!is_int(strpos($arr[$i],"pg=")) && !is_int(strpos($arr[$i],"stg=")) && !is_int(strpos($arr[$i],"offset=")) && !is_int(strpos($arr[$i],"math.rand=")) && trim($arr[$i]) != "") {
$qs .= $arr[$i]."&";
}
}
}
if ($this->rowperpage<$jumlah) {
$allpage = ceil($jumlah/$this->rowperpage);
$allstg = ceil($allpage/$this->pageperstg);
$minpage = (($stg-1)*$this->pageperstg)+1;
$maxpage = $stg*$this->pageperstg;
if ($maxpage>$allpage) $maxpage = $allpage;
if ($allpage>1) {
if (($pg-1) == 1){
$newoffset = 0;
} else {
$newoffset = (($pg-2)*$this->rowperpage);
}
$rtn = array ();
/*
if ($stg>1) {
$rtn[] = array('link'=>"".$qs."pg=".($minpage-1)."&stg=".($stg-1). "&offset=". $newoffset,'title'=>'«««');
}
*/
if ($pg>1) {
if ($pg==$minpage) {
if (($pg-1) == 1){
$newoffset = 0;
} else {
$newoffset = (($pg-2)*$this->rowperpage);
}
$prevy ="Prev";
$rtn[] = array ('link'=>"".$qs."pg=".($pg-1)."&stg=".($stg-1). "&offset=".$newoffset,'judul'=>'Prev','title'=>$prevy);
} else {
if (($pg-1) == 1){
$newoffset = 0;
} else {
$newoffset = (($pg-2)*$this->rowperpage);
}
$prevu ="Prev";
$rtn[] = array('link'=>"".$qs."pg=".($pg-1)."&stg=$stg&offset=".$newoffset,'judul'=>'Prev','title'=>$prevu);
}
}
for ($i=$minpage;$i<=$maxpage;$i++) {
if ($i==$pg) {
$ioto ="$i ";
$rtn[] = array('link'=>'','title'=>$ioto);
} else {
if ($i==1) {
$newoffset = 0;
}else {
$newoffset = ($i-1)*$this->rowperpage;
}
$inya ="$i";
$rtn[] = array('link'=>"".$qs."pg=$i&stg=$stg&offset=$newoffset",'judul'=>$i,'title'=>$inya);
}
}
if ($pg<=$maxpage) {
if ($pg==$maxpage && $stg<$allstg) {
$nexty ="Next";
$rtn[] = array('link'=>"".$qs."pg=".($pg+1)."&stg=".($stg+1)."&offset=".(($pg)*$this->rowperpage),'judul'=>'Next','title'=>$nexty);
} elseif ($pg<$maxpage) {
$nextu ="Next";
$rtn[] = array('link'=>"".$qs."pg=".($pg+1)."&stg=$stg&offset=" .(($pg)*$this->rowperpage),'judul'=>'Next','title'=>$nextu);
}
}
/*
if ($stg<$allstg) {
$rtn[] = array('link'=>"".$qs."pg=".($maxpage+1)."&stg=".($stg+1)."&offset=".(($maxpage)*$this->rowperpage),'title'=>'»»»');
}
*/
return $rtn;
}
}
}
3. Edit file yg menggunakan pagingajax dimulai dari foreach menjadi:
foreach ($pagging as $k=>$v){
if ($v['link'] == ""){
$ddl .= $v['title'].' ';
}else {
$ddl .= ''.$v['title'].' ';
}
}
Selamat Menggunakan :D