| 1: | <?php |
| 2: | |
| 3: | class PermisApp extends \Sphp\tools\BasicApp { |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | public $extra = array(); |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | protected $insertedid = 0; |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | protected $defWhere = ""; |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | protected $formid = "form2"; |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | protected $genFormFront = null; |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | protected $showallFront = null; |
| 38: | |
| 39: | |
| 40: | public function page_event_showallShow($param) { |
| 41: | $showall = $this->showallFront->getComponent('showall'); |
| 42: | $showall->fu_unsetRenderTag(); |
| 43: | $this->JSServer->addJSONComp($showall,'showall'); |
| 44: | $this->JSServer->addJSONBlock('html','pagebar',$showall->getPageBar()); |
| 45: | } |
| 46: | |
| 47: | public function page_event_showall_show($param) { |
| 48: | $showall = $this->showallFront->getComponent('showall'); |
| 49: | $showall->fu_unsetRenderTag(); |
| 50: | $this->JSServer->addJSONComp($showall, 'showall'); |
| 51: | $this->JSServer->addJSONBlock('html', 'pagebar', $showall->getPageBar()); |
| 52: | } |
| 53: | |
| 54: | public function page_new(){ |
| 55: | |
| 56: | $this->setFrontFile($this->showallFront); |
| 57: | } |
| 58: | |
| 59: | public function hasPermission($p){ |
| 60: | return $this->page->hasPermission($p); |
| 61: | } |
| 62: | |
| 63: | public function page_event_addnew($param) { |
| 64: | if($this->page->hasPermission("add")){ |
| 65: | $this->genFormFront->addMetaData("pageName", "Add " . $this->genFormFront->getMetaData('pageName')); |
| 66: | |
| 67: | $this->genFormFront->addMetaData("formButton", "Save"); |
| 68: | $this->setFrontFile($this->genFormFront); |
| 69: | } else { |
| 70: | $this->page_new(); |
| 71: | } |
| 72: | } |
| 73: | |
| 74: | |
| 75: | public function page_view() { |
| 76: | if($this->page->hasPermission("view") && $this->page->getEventParameter() != ""){ |
| 77: | $this->genFormFront->addMetaData("pageName", "Edit " . $this->genFormFront->getMetaData('pageName')); |
| 78: | |
| 79: | $this->genFormFront->addMetaData("formButton", "Update"); |
| 80: | $form2 = $this->genFormFront->getComponent($this->formid); |
| 81: | |
| 82: | $this->page->viewData($form2); |
| 83: | $this->setFrontFile($this->genFormFront); |
| 84: | }else{ |
| 85: | $this->page_new(); |
| 86: | } |
| 87: | } |
| 88: | |
| 89: | public function page_insert() { |
| 90: | global $cmpid; |
| 91: | if($this->page->hasPermission("add")){ |
| 92: | if($this->Client->isSession('sid')) setErr('App','Need to login'); |
| 93: | $this->extra[]['userid'] = $this->Client->session('sid'); |
| 94: | $this->extra[]['parentid'] = $this->Client->session('parentid'); |
| 95: | $this->extra[]['spcmpid'] = $cmpid; |
| 96: | $this->extra[]['submit_timestamp'] = time(); |
| 97: | $this->extra[]['update_timestamp'] = time(); |
| 98: | |
| 99: | |
| 100: | if (!getCheckErr()) { |
| 101: | $form2 = $this->genFormFront->getComponent($this->formid); |
| 102: | $this->insertedid = $this->page->insertData($form2,$this->extra); |
| 103: | if (!getCheckErr()) { |
| 104: | setMsg('App', 'Added Successfully'); |
| 105: | $this->setFrontFile($this->showallFront); |
| 106: | } else { |
| 107: | setErr('App', 'Can not add Data'); |
| 108: | $this->setFrontFile($this->genFormFront); |
| 109: | } |
| 110: | } else { |
| 111: | setErr('App', 'Can not add Data'); |
| 112: | $this->setFrontFile($this->genFormFront); |
| 113: | } |
| 114: | } else { |
| 115: | $this->page_new(); |
| 116: | } |
| 117: | } |
| 118: | |
| 119: | public function page_update() { |
| 120: | if($this->page->hasPermission("view")){ |
| 121: | if (!getCheckErr()) { |
| 122: | $form2 = $this->genFormFront->getComponent($this->formid); |
| 123: | $this->page->updateData($form2,$this->extra); |
| 124: | if (!getCheckErr()) { |
| 125: | setMsg('App', 'Update Successfully'); |
| 126: | $this->setFrontFile($this->showallFront); |
| 127: | } else { |
| 128: | setErr('App', 'Record can not update'); |
| 129: | $this->setFrontFile($this->genFormFront); |
| 130: | } |
| 131: | } else { |
| 132: | setErr('App', 'Record can not update'); |
| 133: | $this->setFrontFile($this->genFormFront); |
| 134: | } |
| 135: | } else { |
| 136: | $this->page_new(); |
| 137: | } |
| 138: | } |
| 139: | |
| 140: | public function page_delete() { |
| 141: | if($this->page->hasPermission("delete") && $this->page->getEventParameter() != ""){ |
| 142: | $this->page->deleteRec(); |
| 143: | if (!getCheckErr()) { |
| 144: | setMsg("App",'delete Successfully'); |
| 145: | $type = "danger"; |
| 146: | $showall = $this->showallFront->getComponent('showall'); |
| 147: | $showall->fu_unsetRenderTag(); |
| 148: | $this->JSServer->addJSONComp($showall,'showall'); |
| 149: | $this->JSServer->addJSONBlock('html','pagebar',$showall->getPageBar()); |
| 150: | $this->JSServer->addJSONJSBlock('setFormStatus("'.$msg.'", "'.$type.'"); readyFormAsNew("form2");'); |
| 151: | } else { |
| 152: | setErr('App', 'Record could not be deleted'); |
| 153: | $this->setFrontFile($this->showallFront); |
| 154: | } |
| 155: | } else { |
| 156: | $this->page_new(); |
| 157: | } |
| 158: | } |
| 159: | |
| 160: | |
| 161: | public function checkUserName($username) { |
| 162: | $check = false; |
| 163: | |
| 164: | if($this->dbEngine->isRecordExist("SELECT * FROM member WHERE username = '$username' ")) { |
| 165: | $check = true; |
| 166: | } |
| 167: | return $check; |
| 168: | } |
| 169: | |
| 170: | public function checkUserEmail($email) { |
| 171: | $check = false; |
| 172: | |
| 173: | if($this->dbEngine->isRecordExist("SELECT * FROM member WHERE email = '$email' ")) { |
| 174: | $check = true; |
| 175: | } |
| 176: | return $check; |
| 177: | } |
| 178: | } |
| 179: | |
| 180: | |