| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: |
|
| 7: |
|
| 8: |
|
| 9: | class Grid2 extends Control{
|
| 10: | public $pageNo = -1;
|
| 11: | public $totalPages = 1;
|
| 12: | public $perPageRows = 10;
|
| 13: | public $sql = '';
|
| 14: | public $pageCountSQL = '';
|
| 15: | public $result;
|
| 16: | public $row;
|
| 17: | public $linkno = 10;
|
| 18: | public $extraData = '';
|
| 19: | public $strFormat = '';
|
| 20: | public $fieldNames = '';
|
| 21: | public $headNames = '';
|
| 22: | public $colwidths = '';
|
| 23: | public $where = '';
|
| 24: | public $whereDef = '';
|
| 25: | public $ordersortby = '';
|
| 26: | public $app = '';
|
| 27: | public $blnEdit = false;
|
| 28: | public $blnDelete = false;
|
| 29: | public $cacheTime = 0;
|
| 30: | public $eventName = 'show';
|
| 31: | public $editeventName = 'view';
|
| 32: | public $deleventName = 'delete';
|
| 33: | private $evtp='';
|
| 34: | private $ctrl='';
|
| 35: | private $extra= 'page=';
|
| 36: | private $baseName='';
|
| 37: | private $sesID=false;
|
| 38: | private $blnajax = false;
|
| 39: | private $blndlg = true;
|
| 40: | private $blnadd = true;
|
| 41: | private $ajax = null;
|
| 42: | private $cachefile = '';
|
| 43: | private $cachekey = 'id';
|
| 44: | private $cachesave = false;
|
| 45: | private $header = '';
|
| 46: | private $footer = '';
|
| 47: | public $buttonnext = '';
|
| 48: | public $buttonprev = '';
|
| 49: | public $links = '';
|
| 50: | private $sortby = false;
|
| 51: | private $blnpagebar = true;
|
| 52: |
|
| 53: | public function __construct($name='',$fieldName='',$tableName='') {
|
| 54: | global $page,$ctrl,$tblName;
|
| 55: | if(SphpBase::page()->isSesSecure){
|
| 56: | $this->sesID = true;
|
| 57: | }
|
| 58: | $this->init($name,'','');
|
| 59: | $this->extra = $name . 'page=';
|
| 60: | if(isset($_REQUEST[$name . 'page'])){
|
| 61: | $_SESSION[$name.'p'] = $_REQUEST[$name . 'page'];
|
| 62: | $_SESSION[$name.'pc'] = $ctrl->ctrl;
|
| 63: | }else{
|
| 64: | $_REQUEST[$name . 'page'] = 1;
|
| 65: | if(isset($_SESSION[$name.'pc']) && $_SESSION[$name.'pc'] == $ctrl->ctrl){
|
| 66: | $_REQUEST[$name . 'page'] = $_SESSION[$name.'p'];
|
| 67: | }
|
| 68: | }
|
| 69: | $this->pageNo = $_REQUEST[$name . 'page'] - 1;
|
| 70: | if($tableName==''){
|
| 71: | $this->dtable = $tblName;
|
| 72: | }else{
|
| 73: | $this->dtable = $tableName;
|
| 74: | }
|
| 75: | $this->setHTMLName('');
|
| 76: | }
|
| 77: |
|
| 78: | public function getEventURL($eventName, $evtp='', $ControllerName='', $extra='', $newBasePath='', $blnSesID=false){
|
| 79: | $this->eventName = $eventName;
|
| 80: | $this->evtp=$evtp;
|
| 81: | $this->ctrl=$ControllerName;
|
| 82: | if($extra!=''){
|
| 83: | $this->extra=$extra.'&'. $this->name .'page=';
|
| 84: | }
|
| 85: | $this->baseName=$newBasePath;
|
| 86: | $this->sesID=$blnSesID;
|
| 87: | }
|
| 88: |
|
| 89: | public function setMsgName($val) { $this->msgName = $val;}
|
| 90: | public function setSQL($sql){
|
| 91: | $this->sql = $sql;
|
| 92: | }
|
| 93: | public function setPageCountSQL($sql){
|
| 94: | $this->pageCountSQL = $sql;
|
| 95: | }
|
| 96: | public function setPerPageRows($val){
|
| 97: | $this->perPageRows = intval($val);
|
| 98: | }
|
| 99: | public function setExtraData($val){
|
| 100: | $this->extraData = $val;
|
| 101: | }
|
| 102: | public function setPageNo($val){
|
| 103: | $this->pageNo = $val - 1;
|
| 104: | }
|
| 105: | public function getPageNo(){
|
| 106: | return $this->pageNo + 1;
|
| 107: | }
|
| 108: | public function setLinkNo($val){
|
| 109: | $this->linkno = $val;
|
| 110: | }
|
| 111: | public function setCacheFile($val){
|
| 112: | $this->cachefile = $val;
|
| 113: | }
|
| 114: | public function setCacheSave(){
|
| 115: | $this->cachesave = true;
|
| 116: | }
|
| 117: | public function setCacheKey($val){
|
| 118: | $this->cachekey = $val;
|
| 119: | }
|
| 120: | public function setCacheTime($val){
|
| 121: | $this->cacheTime = intval($val);
|
| 122: | }
|
| 123: | public function setFieldNames($val){
|
| 124: | $this->fieldNames = $val;
|
| 125: | }
|
| 126: | public function setHeaderNames($val){
|
| 127: | $this->headNames = $val;
|
| 128: | }
|
| 129: | public function setColWidths($val){
|
| 130: | $this->colwidths = $val;
|
| 131: | }
|
| 132: | public function setWhere($val){
|
| 133: | $this->where = $val;
|
| 134: | }
|
| 135: | public function setWhereDef($val){
|
| 136: | $this->whereDef = $val;
|
| 137: | }
|
| 138: | public function setApp($val){
|
| 139: | $this->app = $val;
|
| 140: | }
|
| 141: | public function setSortBy() {
|
| 142: | $this->sortby = true;
|
| 143: | }
|
| 144: | public function setAjax(){
|
| 145: | $this->blnajax = true;
|
| 146: | $this->ajax = new Ajaxsenddata($this->name."ajax1");
|
| 147: | $this->ajax->oncompcreate(array());
|
| 148: | $this->eventName = $this->name ."_show";
|
| 149: | $this->editeventName = $this->name ."_view";
|
| 150: | $this->deleventName = $this->name ."_delete";
|
| 151: | }
|
| 152: | public function setEdit(){
|
| 153: | $this->blnEdit = true;
|
| 154: | }
|
| 155: | public function setDelete(){
|
| 156: | $this->blnDelete = true;
|
| 157: | }
|
| 158: | public function getPageBar(){
|
| 159: | return $this->links;
|
| 160: | }
|
| 161: | public function getButtonNext(){
|
| 162: | return $this->buttonnext;
|
| 163: | }
|
| 164: | public function getButtonPrev(){
|
| 165: | return $this->buttonprev;
|
| 166: | }
|
| 167: | public function setHeader($val){
|
| 168: | $this->header = $val;
|
| 169: | }
|
| 170: | public function setFooter($val){
|
| 171: | $this->footer = $val;
|
| 172: | }
|
| 173: | public function unsetDialog(){
|
| 174: | $this->blndlg = false;
|
| 175: | }
|
| 176: | public function unsetAddButton(){
|
| 177: | $this->blnadd = false;
|
| 178: | }
|
| 179: | public function unsetPageBar(){
|
| 180: | $this->blnpagebar = false;
|
| 181: | }
|
| 182: |
|
| 183: |
|
| 184: | public function executeSQL(){
|
| 185: | global $libpath;
|
| 186: | $HTMLParser = new \Sphp\tools\HTMLParser();
|
| 187: | $stro = "";
|
| 188: |
|
| 189: | $mysql->connect();
|
| 190: | $row = true;
|
| 191: | if ($row){
|
| 192: |
|
| 193: | $totalRows = $this->perPageRows + 8;
|
| 194: | $this->totalPages = 2;
|
| 195: | if($this->pageNo < 0){
|
| 196: | $this->pageNo = 0;
|
| 197: | }
|
| 198: | else if($this->pageNo + 1 > $this->totalPages){
|
| 199: | $this->pageNo = $this->totalPages - 1 ;
|
| 200: | }
|
| 201: |
|
| 202: | $startat = $this->pageNo * $this->perPageRows;
|
| 203: | if($startat<0){$startat=0;}
|
| 204: | $this->result = $mysql->executeQuery($this->sql." LIMIT $startat,$this->perPageRows");
|
| 205: | $stro = '';
|
| 206: | if ($this->result){
|
| 207: | if($this->fieldNames!='' && $this->strFormat=='' && $this->content_section==null){
|
| 208: | $stro = '<table class="pagtable">';
|
| 209: | if($this->headNames==''){
|
| 210: | $this->headNames = $this->fieldNames;
|
| 211: | }
|
| 212: | $arr = explode(',',$this->headNames);
|
| 213: | $fieldcount = count($arr);
|
| 214: | $lenw = -1;
|
| 215: | $startw = 0;
|
| 216: | $w = '';
|
| 217: | if($this->colwidths!=''){
|
| 218: | $arrw = explode(',',$this->colwidths);
|
| 219: | $lenw = count($arrw)-1;
|
| 220: | $startw = 0;
|
| 221: | }
|
| 222: | $stro .= "<tr class=\"paghead\">";
|
| 223: | foreach($arr as $key=>$val){
|
| 224: | if($lenw>=$startw){
|
| 225: | $w = ' width="'.$arrw[$startw].'"';
|
| 226: | $startw += 1;
|
| 227: | }else{
|
| 228: | $w = '';
|
| 229: | }
|
| 230: | $stro .= "<th$w>$val</th>";
|
| 231: | }
|
| 232: | if($this->blnEdit){
|
| 233: | $stro .= "<th width=\"10\">Edit</th>";
|
| 234: | }
|
| 235: | if($this->blnDelete){
|
| 236: | $stro .= "<th width=\"10\">Delete</th>";
|
| 237: | }
|
| 238: | $stro .= "</tr>";
|
| 239: | $blnf = true;
|
| 240: | while($row = mysqli_fetch_assoc($this->result)){
|
| 241: | $arr = explode(',',$this->fieldNames);
|
| 242: | if($blnf){
|
| 243: | $stro .= "<tr class=\"pagrow1\">";
|
| 244: | $blnf = false;
|
| 245: | }else{
|
| 246: | $stro .= "<tr class=\"pagrow2\">";
|
| 247: | $blnf = true;
|
| 248: | }
|
| 249: | $startw = 0;
|
| 250: | for($C=0; $C < $fieldcount; $C++){
|
| 251: | $val =$arr[$C];
|
| 252: | if($lenw>=$startw){
|
| 253: | $w = ' style="width: '.$arrw[$startw].';"';
|
| 254: | $startw += 1;
|
| 255: | }else{
|
| 256: | $w = '';
|
| 257: | }
|
| 258: | $stro .= "<td$w>".$row[$val]."</td>";
|
| 259: | }
|
| 260: | if($this->blnEdit){
|
| 261: | $stro .= "<td width=\"25\"><a href=\"#\" onclick=\"pagiedit_$this->name('". getEventURL($this->editeventName,$row['id'],$this->app,$this->extraData,'',true)."');\" title=\"Click to Edit This Record\"><img src=\"{$this->myrespath}/res/editBTN.gif\" border=\"0\" /></a></td>";
|
| 262: | }
|
| 263: | if($this->blnDelete){
|
| 264: | $stro .= "<td width=\"25\"><a href=\"#\" onClick=\"confirmDel_$this->name('".getEventURL($this->deleventName,$row['id'],$this->app,$this->extraData,'',true)."')\" title=\"Click to Delete This Record\"><img src=\"{$this->myrespath}/res/del.jpg\" border=\"0\" /></a></td>";
|
| 265: | }
|
| 266: |
|
| 267: | $stro .= "</tr>";
|
| 268: | }
|
| 269: | $stro .= "</table>";
|
| 270: | if($this->blnpagebar){
|
| 271: | $stro .= $this->getPaging();
|
| 272: | }
|
| 273: | }else if($this->strFormat!=''){
|
| 274: |
|
| 275: | while($this->row = mysqli_fetch_assoc($this->result)){
|
| 276: | $stro .= $this->getEval($this->strFormat);
|
| 277: | }
|
| 278: |
|
| 279: | if($this->blnpagebar){
|
| 280: | $strom = $this->getPaging();
|
| 281: | }
|
| 282: | }
|
| 283: |
|
| 284: | }
|
| 285: | }
|
| 286: |
|
| 287: |
|
| 288: | return $stro;
|
| 289: |
|
| 290: | }
|
| 291: | private function getEval($strcode){
|
| 292: | extract($GLOBALS);
|
| 293: | ob_start();
|
| 294: | eval("?>" . $strcode . "<?php ");
|
| 295: | $this_string = ob_get_contents();
|
| 296: | ob_end_clean();
|
| 297: | return $this_string;
|
| 298: | }
|
| 299: | private function getPaging(){
|
| 300: | $lynx = "";
|
| 301: | $del = "";
|
| 302: | $linkNo = $this->linkno;
|
| 303: | $startPage = $this->getPageNo()- $linkNo;
|
| 304: | $endPage = $this->getPageNo()+$linkNo;
|
| 305: | if($startPage<1){
|
| 306: | $startPage = 1;
|
| 307: | }
|
| 308: | if($endPage>$this->totalPages){
|
| 309: | $endPage = $this->totalPages;
|
| 310: | }
|
| 311: | $strstart = "<div class=\"pfloat-left\">";
|
| 312: | for ($k=$startPage; $k<=$endPage; $k++) {
|
| 313: | if ($k != $_REQUEST[$this->name . 'page']) {
|
| 314: | if($this->blnajax){
|
| 315: | $lynx .= $strstart. "<a href=\"#\" onclick=\"getURL('". getEventURL($this->eventName,$this->evtp,$this->ctrl,$this->extra.$k,$this->baseName,$this->sesID)."'); return false;\">".($k)."</a></div>";
|
| 316: | }else{
|
| 317: | $lynx .= $strstart."<a href=\"". getEventURL($this->eventName,$this->evtp,$this->ctrl,$this->extra.$k,$this->baseName,$this->sesID)."\">".($k)."</a></div>";
|
| 318: | }
|
| 319: | } else {
|
| 320: | $lynx .= $strstart.($k)."</div>";
|
| 321: | }
|
| 322: | }
|
| 323: | $startPage2 = $this->getPageNo();
|
| 324: | $blnEndP = false;
|
| 325: | $blnStartP = false;
|
| 326: | if($startPage2>1){
|
| 327: | $prev = $startPage2 - 1;
|
| 328: | }else{
|
| 329: | $prev = 1;
|
| 330: | $blnStartP = true;
|
| 331: | }
|
| 332: | if($startPage2 >= $this->totalPages){
|
| 333: | $next = $this->totalPages;
|
| 334: | $blnEndP = true;
|
| 335: | }else{
|
| 336: | $next = $startPage2 + 1;
|
| 337: | }
|
| 338: | $edt = '';
|
| 339: | |
| 340: | |
| 341: | |
| 342: | |
| 343: | |
| 344: | |
| 345: | |
| 346: | |
| 347: |
|
| 348: | if($blnStartP){
|
| 349: | $strlinkP = "";
|
| 350: | }else{
|
| 351: | if($this->blnajax){
|
| 352: | $strlinkP = "<a class=\"pagprev\" href=\"#\" onclick=\"getURL('". getEventURL($this->eventName,$this->evtp,$this->ctrl,$this->extra.$prev,$this->baseName,$this->sesID)."');return false;\">Prev</a> ";
|
| 353: | }else{
|
| 354: | $strlinkP = "<a class=\"pagprev\" href=\"". getEventURL($this->eventName,$this->evtp,$this->ctrl,$this->extra.$prev,$this->baseName,$this->sesID)."\">Prev</a> ";
|
| 355: | }
|
| 356: | }
|
| 357: | if($blnEndP){
|
| 358: | $strlinkN = "";
|
| 359: | }else{
|
| 360: | if($this->blnajax){
|
| 361: | $strlinkN = "<a class=\"pagnext\" href=\"#\" onclick=\"getURL('".getEventURL($this->eventName,$this->evtp,$this->ctrl,$this->extra.$next,$this->baseName,$this->sesID)."');return false;\">Next</a>";
|
| 362: | }else{
|
| 363: | $strlinkN = "<a class=\"pagnext\" href=\"".getEventURL($this->eventName,$this->evtp,$this->ctrl,$this->extra.$next,$this->baseName,$this->sesID)."\">Next</a>";
|
| 364: | }
|
| 365: | }
|
| 366: |
|
| 367: | if($blnStartP && $blnEndP){
|
| 368: | $strout = '';
|
| 369: | }else{
|
| 370: | $strlink = $strlinkP . $strlinkN ;
|
| 371: | $this->buttonnext = $strlinkN;
|
| 372: | $this->buttonprev = $strlinkP;
|
| 373: | $this->links = $lynx;
|
| 374: | if($strlink!=''){
|
| 375: | $strout = '<div class="pagbar"><div class="pagnums"> '.$lynx.'</div>
|
| 376: | <div class="pagprevnext">'.
|
| 377: | $strlink .$edt.$del.'
|
| 378: | </div></div>
|
| 379: | <div style="clear:both"></div>';
|
| 380: | }
|
| 381: | }
|
| 382: | return $strout;
|
| 383: | }
|
| 384: |
|
| 385: | public function oncreate($element){
|
| 386: | $this->strFormat = $element->innertext;
|
| 387: | $element->innertext = '';
|
| 388: | }
|
| 389: | public function onaftercreate(){
|
| 390: | $this->handleEvent();
|
| 391: | }
|
| 392: | public function handleEvent(){
|
| 393: | global $page,$Client,$JSServer,$showall;
|
| 394: | if(SphpBase::page()->getEvent()== $this->name . "_sortby"){
|
| 395: | $this->unsetRenderTag();
|
| 396: | if($Client->request('dir')=='1'){
|
| 397: | $this->ordersortby = "ORDER BY ". $Client->request('sortby'). " DESC";
|
| 398: | }else{
|
| 399: | $this->ordersortby = "ORDER BY ". $Client->request('sortby') . " ASC";
|
| 400: | }
|
| 401: | $JSServer->addJSONComp($this, $this->name);
|
| 402: | }
|
| 403: | }
|
| 404: |
|
| 405: | public function startAJAX(){
|
| 406: | global $jquerypath,$JSClient,$JSServer;
|
| 407: | $opendlg = "";
|
| 408: | if($this->blndlg){
|
| 409: | addHeaderJSFunctionCode('ready',$this->name,'
|
| 410: | $("#'.$this->name.'_dlg").dialog({
|
| 411: | autoOpen: false,
|
| 412: | width: "auto",
|
| 413: | height: "400",
|
| 414: | show: {
|
| 415: | effect: "blind",
|
| 416: | duration: 1000
|
| 417: | },
|
| 418: | hide: {
|
| 419: | effect: "explode",
|
| 420: | duration: 1000
|
| 421: | },
|
| 422: | position: [10,10],
|
| 423: | title: "Grid Editor Form"
|
| 424: | });
|
| 425: | ');
|
| 426: | addHeaderCSS('dragdrop', '
|
| 427: | .dragdrop
|
| 428: | {
|
| 429: | position: relative;
|
| 430: | cursor: auto;
|
| 431: | }
|
| 432: | ');
|
| 433: | $opendlg = "$(\"#{$this->name}_dlg\").dialog(\"open\");";
|
| 434: | }
|
| 435: |
|
| 436: | if($this->blnajax){
|
| 437: | $jsAjax = "true";
|
| 438: | }else{
|
| 439: | $jsAjax = "false";
|
| 440: | }
|
| 441: | addHeaderJSCode($this->name,"
|
| 442: | function confirmDel_$this->name(link){
|
| 443: | confirmDel(link,$jsAjax);
|
| 444: | }
|
| 445: | function pagiedit_$this->name(link){
|
| 446: | $opendlg
|
| 447: | pagiedit(link,$jsAjax);
|
| 448: | }
|
| 449: | function paginew_$this->name(link){
|
| 450: | $opendlg
|
| 451: | pagiedit(link,$jsAjax);
|
| 452: | }
|
| 453: | ");
|
| 454: | addHeaderJSCode('pagi',"
|
| 455: | function confirmDel(link,jsajax){
|
| 456: | var ans = confirm('Are You Sure to Delete This Record !') ;
|
| 457: | if(ans){
|
| 458: | if(jsajax){
|
| 459: | getURL(link);
|
| 460: | }else{
|
| 461: | window.location = link ;
|
| 462: | }
|
| 463: | }
|
| 464: | }
|
| 465: | function pagiedit(link,jsajax) {
|
| 466: | if(jsajax){
|
| 467: | getURL(link);
|
| 468: | }else{
|
| 469: | window.location = link ;
|
| 470: | }
|
| 471: | return false;
|
| 472: | }
|
| 473: | function paginew(link,jsajax){
|
| 474: | if(jsajax){
|
| 475: | getURL(link);
|
| 476: | }else{
|
| 477: | window.location = link ;
|
| 478: | }
|
| 479: | }
|
| 480: | ");
|
| 481: |
|
| 482: | if($this->blnadd){
|
| 483: | $ptag = '<div id="'.$this->name.'_dlg" class="dragdrop">
|
| 484: | <div id="'.$this->name.'_editor" style="width:100%;height:100%;"></div>
|
| 485: | </div><div id="'.$this->name.'_toolbar">';
|
| 486: | }else{
|
| 487: | $ptag = '<div id="'.$this->name.'_toolbar">';
|
| 488: | }
|
| 489: | if($this->blnadd){
|
| 490: | $ptag .= '<input type="button" value="Add" onclick="paginew_'.$this->name.'(\''.getEventURL($this->name.'_newa','','','','',true).'\');" />';
|
| 491: | }
|
| 492: | $divt = "$ptag</div><div id=\"{$this->name}_list\">";
|
| 493: | $this->setPreTag($divt.$this->getPreTag());
|
| 494: | $this->setPostTag('</div>'.$this->getPostTag());
|
| 495: |
|
| 496: | }
|
| 497: |
|
| 498: |
|
| 499: | public function onjsrender(){
|
| 500: | global $jquerypath,$JSClient,$JSServer;
|
| 501: | $opendlg = "";
|
| 502: | if(!$JSServer->ajaxrender){
|
| 503: | if($this->blnajax){
|
| 504: | $this->eventName = $this->name."_show";
|
| 505: | $this->editeventName = $this->name."_view";
|
| 506: | $this->deleventName = $this->name."_delete";
|
| 507: | $this->startAJAX();
|
| 508: | }else{
|
| 509: | $jsAjax = "false";
|
| 510: | addHeaderJSCode($this->name,"
|
| 511: | function confirmDel_$this->name(link){
|
| 512: | confirmDel(link,$jsAjax);
|
| 513: | }
|
| 514: | var {$this->name}_setg = {
|
| 515: | sortby: '',
|
| 516: | dir: 1
|
| 517: | };
|
| 518: | function getSortBy(obj,field,link){
|
| 519: | data = {};
|
| 520: | var setg = {$this->name}_setg ;
|
| 521: | var span1 = $(obj).children('span:first');
|
| 522: | if(setg.sortby!=field){
|
| 523: | setg.sortby = field;
|
| 524: | setg.dir = 1;
|
| 525: | $('.glyphicon-upload').addClass('glyphicon-download');
|
| 526: | $('.glyphicon-upload').removeClass('glyphicon-upload');
|
| 527: | span1.removeClass('glyphicon-download');
|
| 528: | span1.addClass('glyphicon-upload');
|
| 529: | }else if(setg.sortby==field){
|
| 530: | if(setg.dir == 1){
|
| 531: | setg.dir = 0;
|
| 532: | $('.glyphicon-upload').addClass('glyphicon-download');
|
| 533: | $('.glyphicon-upload').removeClass('glyphicon-upload');
|
| 534: | }else{
|
| 535: | setg.dir = 1;
|
| 536: | $('.glyphicon-upload').addClass('glyphicon-download');
|
| 537: | $('.glyphicon-upload').removeClass('glyphicon-upload');
|
| 538: | span1.removeClass('glyphicon-download');
|
| 539: | span1.addClass('glyphicon-upload');
|
| 540: | }
|
| 541: | }
|
| 542: | data['sortby'] = field;
|
| 543: | data['dir'] = setg.dir;
|
| 544: | {$this->name}_setg = setg;
|
| 545: |
|
| 546: | getURL(link,data);
|
| 547: | return false;
|
| 548: | }
|
| 549: | function pagiedit_$this->name(link){
|
| 550: | $opendlg
|
| 551: | pagiedit(link,$jsAjax);
|
| 552: | }
|
| 553: | function paginew_$this->name(link){
|
| 554: | $opendlg
|
| 555: | pagiedit(link,$jsAjax);
|
| 556: | }
|
| 557: | ");
|
| 558: | addHeaderJSCode('pagi',"
|
| 559: | function confirmDel(link,jsajax){
|
| 560: | var ans = confirm('Are You Sure to Delete This Record !') ;
|
| 561: | if(ans){
|
| 562: | if(jsajax){
|
| 563: | getURL(link);
|
| 564: | }else{
|
| 565: | window.location = link ;
|
| 566: | }
|
| 567: | }
|
| 568: | }
|
| 569: | function pagiedit(link,jsajax) {
|
| 570: | if(jsajax){
|
| 571: | getURL(link);
|
| 572: | }else{
|
| 573: | window.location = link ;
|
| 574: | }
|
| 575: | return false;
|
| 576: | }
|
| 577: | function paginew(link,jsajax){
|
| 578: | if(jsajax){
|
| 579: | getURL(link);
|
| 580: | }else{
|
| 581: | window.location = link ;
|
| 582: | }
|
| 583: | }
|
| 584: | ");
|
| 585: | }
|
| 586: | }
|
| 587: | }
|
| 588: |
|
| 589: | public function onprerender(){
|
| 590: | global $Client,$ctrl;
|
| 591: |
|
| 592: | $spt = explode(',', $this->dtable);
|
| 593: | if(count($spt)>0){
|
| 594: | $idf = $spt[0].".id";
|
| 595: | }else{
|
| 596: | $idf = "id";
|
| 597: | }
|
| 598: | $storesql = $Client->session($this->name .'store');
|
| 599: | if(!is_array($storesql)) $storesql = array();
|
| 600: | if(isset($storesql['lastapp']) && $storesql['lastapp'] == $ctrl->ctrl){
|
| 601: | if($this->ordersortby==""){
|
| 602: | $this->ordersortby = $storesql['sortby'];
|
| 603: | }
|
| 604: | if($this->where==""){
|
| 605: | if($storesql['whereby']!=""){
|
| 606: | $this->where = $storesql['whereby'];
|
| 607: | }else{
|
| 608: | $this->where = $this->whereDef;
|
| 609: | }
|
| 610: | }
|
| 611: | }
|
| 612: | if(strpos($this->where,"WHERE")===false){
|
| 613: | $this->where = $this->whereDef;
|
| 614: | }
|
| 615: | if($this->pageCountSQL==''){
|
| 616: | $this->pageCountSQL = "SELECT count($idf) FROM ".$this->dtable." ".$this->where;
|
| 617: | }
|
| 618: | if($this->sql==''){
|
| 619: | $this->sql = "SELECT $idf,$this->fieldNames FROM ".$this->dtable." ".$this->where. " " . $this->ordersortby;
|
| 620: | }
|
| 621: | $storesql['lastsql'] = $this->sql;
|
| 622: | $storesql['lastpagecountsql'] = $this->pageCountSQL;
|
| 623: | $storesql['lastapp'] = $ctrl->ctrl;
|
| 624: | $storesql['sortby'] = $this->ordersortby;
|
| 625: | $storesql['whereby'] = $this->where;
|
| 626: | $Client->session($this->name .'store',$storesql);
|
| 627: |
|
| 628: | $this->setAttribute("class", 'pag');
|
| 629: | if($this->content_section===null){
|
| 630: | $this->setInnerHTMLApp($this->header. $this->executeSQL() . $this->footer);
|
| 631: | }else{
|
| 632: | $str = $this->executeSQL();
|
| 633: | }
|
| 634: |
|
| 635: |
|
| 636: |
|
| 637: |
|
| 638: | }
|
| 639: |
|
| 640: |
|
| 641: | public function onchildevent($event,$obj) {
|
| 642: | if($event=="oncreate" && $obj->type=='content'){
|
| 643: |
|
| 644: |
|
| 645: |
|
| 646: | }
|
| 647: | }
|
| 648: |
|
| 649: | }
|
| 650: |
|
| 651: | |