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