| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | include_once("{$libpath}/dev/QueryBuilder.php"); |
| 8: | |
| 9: | |
| 10: | class AutoApp extends \Sphp\tools\BasicApp { |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | protected $genFormFront = null; |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | protected $showallFront = null; |
| 21: | public $heading = "heading"; |
| 22: | public $footer = "set footer property of app, for logo image set logoimg"; |
| 23: | public $logoimg = "apps/helper/fronts/logo.png"; |
| 24: | public $phone = "6AA-AAA-AAAA"; |
| 25: | public $mobile = "AAA-AAA-AAAA"; |
| 26: | public $address = "address"; |
| 27: | public $city = "Mississauga"; |
| 28: | public $country = "Canada"; |
| 29: | |
| 30: | protected $insertedid = -1; |
| 31: | protected $formid = "form2"; |
| 32: | |
| 33: | public $extra = array(); |
| 34: | public $recID = ""; |
| 35: | public $recWhere = ""; |
| 36: | public $printstyle = "test"; |
| 37: | public $printstylefile = __DIR__ ."/fronts/style.css"; |
| 38: | |
| 39: | public function onstart() { |
| 40: | $this->logoimg = SphpBase::sphp_settings()->slib_res_path ."/apps/helper/fronts/logo.png"; |
| 41: | $this->showallFront->getComponent('showall')->fu_unsetRenderTag(); |
| 42: | $this->genFormFront->getComponent('btnDel')->fu_unsetRender(); |
| 43: | $this->showallFront->getComponent('showall')->fu_setPerPageRows(10); |
| 44: | SphpBase::sphp_api()->addProp('page_title',$this->heading); |
| 45: | } |
| 46: | |
| 47: | public function page_event_loadform($evtp) { |
| 48: | $this->showallFront->getComponent('showall')->fu_setRenderTag(); |
| 49: | |
| 50: | $this->JSServer->addJSONFront($this->showallFront, 'listFormHolder'); |
| 51: | |
| 52: | |
| 53: | } |
| 54: | |
| 55: | public function page_new() { |
| 56: | $this->showallFront->getComponent('showall')->fu_setRenderTag(); |
| 57: | |
| 58: | |
| 59: | $this->setFrontFile($this->showallFront); |
| 60: | } |
| 61: | |
| 62: | |
| 63: | public function page_event_test($param) { |
| 64: | $this->setFrontFile($this->showallFront); |
| 65: | } |
| 66: | |
| 67: | public function page_event_showall_show($param) { |
| 68: | $showall = $this->showallFront->getComponent('showall'); |
| 69: | $this->JSServer->addJSONComp($showall, 'showall'); |
| 70: | $this->JSServer->addJSONBlock('html', 'pagebar', $showall->getPageBar()); |
| 71: | } |
| 72: | |
| 73: | public function page_event_print($param) { |
| 74: | $this->printstyle = \SphpBase::sphp_api()->getDynamicContent($this->printstylefile); |
| 75: | $showall = $this->showallFront->getComponent('showall'); |
| 76: | require($this->phppath . '/classes/bundle/reports/html2pdf/Front2PDF.php'); |
| 77: | $showsingleFront = new Sphp\tools\FrontFileChild(__DIR__ ."/fronts/pdf_temp.front",false,null,$this->showallFront); |
| 78: | $showall->unsetAddButton(); |
| 79: | $showall->unsetDialog(); |
| 80: | $showall->unsetPageBar(); |
| 81: | |
| 82: | $pdf = new Front2PDF($showsingleFront); |
| 83: | $pdf->setDefaultFont('Arial'); |
| 84: | $pdf->render('sample.pdf', 'I'); |
| 85: | } |
| 86: | |
| 87: | public function page_event_usersrch($param) { |
| 88: | $showall = $this->showallFront->getComponent('showall'); |
| 89: | if (!getCheckErr()) { |
| 90: | if (!getCheckErr()) { |
| 91: | $this->JSServer->addJSONComp($showall, 'showall'); |
| 92: | |
| 93: | $this->JSServer->addJSONBlock('html', 'pagebar', $showall->getPageBar()); |
| 94: | } else { |
| 95: | setErr('app1', 'Can not Search Data'); |
| 96: | $this->sendError(); |
| 97: | } |
| 98: | } else { |
| 99: | setErr('app1', 'Can not Search Data'); |
| 100: | $this->sendError(); |
| 101: | } |
| 102: | } |
| 103: | |
| 104: | public function page_event_up($param) { |
| 105: | if ($this->Client->request('txtid') != "") { |
| 106: | $this->update(); |
| 107: | } else { |
| 108: | $this->insert(); |
| 109: | } |
| 110: | } |
| 111: | |
| 112: | public function page_event_rowclick($param) { |
| 113: | $this->Client->session("formType", "Edit"); |
| 114: | $this->page->viewData($this->genFormFront->getComponent($this->formid)); |
| 115: | $this->genFormFront->getComponent('btnDel')->fu_setRender(); |
| 116: | $this->JSServer->addJSONJSBlock('$( "#showall_dlg" ).dialog( "open" );'); |
| 117: | $this->JSServer->addJSONFront($this->genFormFront, 'showall_editor'); |
| 118: | |
| 119: | } |
| 120: | |
| 121: | public function page_event_showall_newa($param) { |
| 122: | $this->page_event_addform($param); |
| 123: | } |
| 124: | public function page_event_addform($param) { |
| 125: | if(isset($_SESSION['curtrec'])){ |
| 126: | unset($_SESSION['curtrec']); |
| 127: | } |
| 128: | $this->Client->session("formType", "Add"); |
| 129: | $this->JSServer->addJSONFront($this->genFormFront, 'showall_editor'); |
| 130: | } |
| 131: | |
| 132: | |
| 133: | public function page_event_crossclick($param) { |
| 134: | $this->page->viewData($this->genFormFront->getComponent($this->formid)); |
| 135: | $this->genFormFront->getComponent('btnDel')->fu_setRender(); |
| 136: | $extupdate = array(); |
| 137: | $extupdate["up"] = 12; |
| 138: | $extupdate["previd"] = $this->Client->request("previd"); |
| 139: | $extupdate["prevctrl"] = $this->Client->request("prevctrl"); |
| 140: | $this->Client->session("extupdate", $extupdate); |
| 141: | $this->JSServer->addJSONFront($this->genFormFront, 'showall_editor'); |
| 142: | } |
| 143: | |
| 144: | public function page_insert() { |
| 145: | global $cmpid; |
| 146: | $this->extra[]['spcmpid'] = $cmpid; |
| 147: | $blnsendList = $this->checkCrossCall(); |
| 148: | if (!getCheckErr()) { |
| 149: | $this->insertedid = $this->page->insertData($this->genFormFront->getComponent($this->formid),$this->extra); |
| 150: | if (!getCheckErr()) { |
| 151: | |
| 152: | |
| 153: | if ($blnsendList) { |
| 154: | $this->JSServer->addJSONComp($this->showallFront->getComponent('showall'), 'showall'); |
| 155: | } else { |
| 156: | $this->sendCrossCall(); |
| 157: | } |
| 158: | |
| 159: | $this->JSServer->addJSONBlock('jsp','proces','$( "#showall_dlg" ).dialog( "close" );'); |
| 160: | $this->sendSuccess('Data is inserted in Database'); |
| 161: | $this->sendError(); |
| 162: | } else { |
| 163: | setErr('app1', 'Can not add Data'); |
| 164: | $this->sendError(); |
| 165: | } |
| 166: | } else { |
| 167: | setErr('app1', 'Can not add Data'); |
| 168: | $this->sendError(); |
| 169: | } |
| 170: | } |
| 171: | |
| 172: | public function checkCrossCall() { |
| 173: | $extupdate = $this->Client->session("extupdate"); |
| 174: | if (isset($extupdate["up"]) && $extupdate["up"] == 12) { |
| 175: | $extupdate["up"] = 11; |
| 176: | $this->Client->session("extupdate", $extupdate); |
| 177: | return false; |
| 178: | } else { |
| 179: | return true; |
| 180: | } |
| 181: | } |
| 182: | |
| 183: | public function sendCrossCall() { |
| 184: | $extupdate = $this->Client->session("extupdate"); |
| 185: | $this->JSServer->addJSONJSBlock("getURL('" . getEventURL("rowclick", $extupdate['previd'], $extupdate["prevctrl"]) . "');"); |
| 186: | } |
| 187: | |
| 188: | public function page_update() { |
| 189: | $blnsendList = $this->checkCrossCall(); |
| 190: | if (!getCheckErr()) { |
| 191: | $this->page->updateData($this->genFormFront->getComponent($this->formid),$this->extra, $this->recID, $this->recWhere); |
| 192: | if (!getCheckErr()) { |
| 193: | if ($blnsendList) { |
| 194: | $this->JSServer->addJSONComp($this->showallFront->getComponent('showall'), 'showall'); |
| 195: | |
| 196: | } else { |
| 197: | $this->sendCrossCall(); |
| 198: | } |
| 199: | |
| 200: | $this->JSServer->addJSONBlock('jsp','proces','$( "#showall_dlg" ).dialog( "close" );'); |
| 201: | $this->sendSuccess('Record is updated'); |
| 202: | } else { |
| 203: | setErr('app1', 'Record can not update'); |
| 204: | $this->sendError(); |
| 205: | } |
| 206: | } else { |
| 207: | setErr('app1', 'Record can not update'); |
| 208: | $this->sendError(); |
| 209: | } |
| 210: | } |
| 211: | |
| 212: | public function page_delete() { |
| 213: | $blnsendList = $this->checkCrossCall(); |
| 214: | if (!getCheckErr()) { |
| 215: | $this->page->deleteRec(); |
| 216: | if ($blnsendList) { |
| 217: | $this->JSServer->addJSONComp($this->showallFront->getComponent('showall'), 'showall'); |
| 218: | $this->JSServer->addJSONFront($this->genFormFront, 'showall_editor'); |
| 219: | } else { |
| 220: | $this->sendCrossCall(); |
| 221: | } |
| 222: | |
| 223: | $this->JSServer->addJSONBlock('jsp','proces','$( "#showall_dlg" ).dialog( "close" );'); |
| 224: | $this->sendSuccess('Record is Deleted'); |
| 225: | } else { |
| 226: | setErr('app1', 'Record could not be deleted'); |
| 227: | $this->sendError(); |
| 228: | } |
| 229: | } |
| 230: | |
| 231: | public function sendSuccess($msg) { |
| 232: | $this->JSServer->addJSONBlock('html', 'sphpsuccessmsg', $msg); |
| 233: | $this->JSServer->addJSONJSBlock('runanierr("success");'); |
| 234: | } |
| 235: | |
| 236: | public function sendWarning($msg) { |
| 237: | $this->JSServer->addJSONBlock('html', 'sphpwarningmsg', $msg); |
| 238: | $this->JSServer->addJSONJSBlock('runanierr("warning");'); |
| 239: | } |
| 240: | |
| 241: | public function sendError($errorInner = "") { |
| 242: | $msg = traceMsg(true); |
| 243: | $err = traceError(true); |
| 244: | if ($errorInner == "") { |
| 245: | $erri = traceErrorInner(true); |
| 246: | if ($erri != "") { |
| 247: | $errorInner = "Something goes wrong!"; |
| 248: | } |
| 249: | } |
| 250: | if ($msg != "") { |
| 251: | $this->JSServer->addJSONBlock('html', 'sphpinfomsg', $msg); |
| 252: | $this->JSServer->addJSONJSBlock('runanierr("info");'); |
| 253: | } |
| 254: | if ($err != "" || $errorInner != "") { |
| 255: | $this->JSServer->addJSONBlock('html', 'sphperrormsg', $err . ' ' . $errorInner); |
| 256: | $this->JSServer->addJSONJSBlock('runanierr("error");'); |
| 257: | } |
| 258: | } |
| 259: | |
| 260: | public function sendInfo($msg) { |
| 261: | $msg1 = traceMsg(true); |
| 262: | $this->JSServer->addJSONBlock('html', 'sphpinfomsg', $msg . $msg1); |
| 263: | $this->JSServer->addJSONJSBlock('runanierr("info");'); |
| 264: | } |
| 265: | |
| 266: | public function page_event_efillstate($param) { |
| 267: | $this->Client->session('country', $this->Client->request('country')); |
| 268: | $this->JSServer->addJSONComp($this->genFormFront->getComponent('state'), 'edit_state_box'); |
| 269: | $this->JSServer->addJSONComp($this->genFormFront->getComponent('city'), 'edit_city_box'); |
| 270: | } |
| 271: | |
| 272: | public function page_event_efillcity($param) { |
| 273: | $this->Client->session('country', $this->Client->request('country')); |
| 274: | $this->Client->session('state', $this->Client->request('state')); |
| 275: | $this->JSServer->addJSONComp($this->genFormFront->getComponent('city'), 'edit_city_box'); |
| 276: | } |
| 277: | |
| 278: | |
| 279: | public function page_event_efillstates($param) { |
| 280: | $this->JSServer->addJSONComp($this->showallFront->getComponent('searchby_state'), 'edit_state_boxs'); |
| 281: | $this->JSServer->addJSONComp($this->showallFront->getComponent('searchby_city'), 'edit_city_boxs'); |
| 282: | } |
| 283: | |
| 284: | public function page_event_efillcitys($param) { |
| 285: | $this->JSServer->addJSONComp($this->showallFront->getComponent('searchby_city'), 'edit_city_boxs'); |
| 286: | } |
| 287: | |
| 288: | } |
| 289: | |