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