How to use init method of out class

Best Atoum code snippet using out.init

_creativeTable.php

Source:_creativeTable.php Github

copy

Full Screen

...9 var $sort; // selected column 1a_2d_t_t (data gathering)10 var $page; // selected page (for the sql query)11 var $id; // id of the table12 var $class; // class of the table13 var $form_init; // true, false show or not to show the form14 var $form_url; // form url15 var $header; // text for the header i.e. 'ID,Movie Title,Any Text,...'16 var $width; // ''; '15,100,200,50'17 var $search_init; // false, true, ttftt18 var $search_html; // html with search configuration19 var $multiple_search_init; // hide, true, false, ttftt, ttftt hide20 var $items_per_page_init; // false; 10,20,50,100; ($i+1)*1021 var $items_per_page_all; // text for the show all option: All; false; #TOTAL_ITEMS#22 var $items_per_page_url; // index.php or javascript: myFunc();23 var $sort_init; // true, false ttftt24 var $sort_order; // 'adt';'ad';'da';'dat'; (ascending, descending, true)25 var $sort_url; // index.php or javascript: myFunc();26 var $extra_cols; // array containing the the information about extra columns array(array(col,header,width,html),array(...),...)27 var $odd_even; // true, false28 var $no_results; // false; html for the no results29 var $actions; // array containing the value and the text of the select box array(array($value,$text),...)30 var $actions_url; // text function when the select box of actions is changed31 var $pager; // external html pager32 var $total_items; // total items (got from sql query)33 var $sql_fields; // sql fields (got from sql query)34 var $out; // output of the table35 function table($params){36 global $tpl, $wpdb;37 // Default Values38 $this->sql_query = isset($params['sql_query']) ? $params['sql_query'] : '';39 $this->data = isset($params['data']) ? $params['data'] : '';40 $this->search = isset($params['search']) ? $params['search'] : '';41 $this->multiple_search = isset($params['multiple_search']) ? $params['multiple_search'] : '';42 $this->items_per_page = isset($params['items_per_page']) ? $params['items_per_page'] : '';43 $this->sort = isset($params['sort']) ? $params['sort'] : false;44 $this->page = isset($params['page']) ? $params['page'] : 1;45 $this->id = isset($params['id']) ? $params['id'] : 'ct';46 $this->class = isset($params['class']) ? $params['class'] : '';47 $this->form_init = isset($params['form_init']) ? $params['form_init'] : true;48 $this->form_url = isset($params['form_url']) ? $params['form_url'] : '';49 $this->header = isset($params['header']) ? $params['header'] : false;50 $this->width = isset($params['width']) ? $params['width'] : '';51 $this->search_init = isset($params['search_init']) ? $params['search_init'] : true;52 $this->search_html = isset($params['search_html']) ? $params['search_html'] : '<span id="#ID#_search_value">Search...</span> <div id="#ID#_loader"></div>';53 $this->multiple_search_init = isset($params['multiple_search_init']) ? $params['multiple_search_init'] : true;54 $this->items_per_page_init = isset($params['items_per_page_init']) ? $params['items_per_page_init'] : '10*$i';55 $this->items_per_page_all = isset($params['items_per_page_all']) ? (($params['items_per_page_all']!='' or $params['items_per_page_all']===false) ? $params['items_per_page_all'] : '#TOTAL_ITEMS#') : '#TOTAL_ITEMS#';56 $this->items_per_page_url = isset($params['items_per_page_url']) ? $params['items_per_page_url'] : 'ctItemsPerPage(\'#ID#\')';57 $this->sort_init = isset($params['sort_init']) ? $params['sort_init'] : true;58 $this->sort_order = isset($params['sort_order']) ? $params['sort_order'] : 'adt';59 $this->sort_url = isset($params['sort_url']) ? $params['sort_url'] : 'ctSort(\'#ID#\',\'#COLUMN_ID#\')';60 $this->extra_cols = isset($params['extra_cols']) ? $params['extra_cols'] : array();61 $this->odd_even = isset($params['odd_even']) ? $params['odd_even'] : true;62 $this->no_results = isset($params['no_results']) ? $params['no_results'] : 'No results found.';63 $this->actions = isset($params['actions']) ? $params['actions'] : array();64 $this->actions_url = isset($params['actions_url']) ? $params['actions_url'] : 'ctActions(\'#ID#\')';65 $this->pager = isset($params['pager']) ? $params['pager'] : '';66 $this->total_items = isset($params['total_items']) ? $params['total_items'] : 0;67 $this->sql_fields = '';68 $this->out = '';69 if($this->sql_query!='')70 $this->init_data();71 }72 // Gets the data from the database and makes somes necessary initializations73 function init_data(){74 75 global $wpdb;76 // default value of items per page77 if($this->items_per_page==''){78 // formula $i*10; pow(10,$i)79 if(strpos($this->items_per_page_init,'$')!==false){80 $i=1;81 eval('$items_per_page='.$this->items_per_page_init.';');82 }else{83 $items_per_page=explode(',',$this->items_per_page_init);84 $items_per_page=$items_per_page[0];85 }86 $this->items_per_page=$items_per_page;87 }88 // adds the new extra columns to the data89 for($i=0; $i<count($this->extra_cols); $i++)90 91 $this->add_col($this->extra_cols[$i][0],$this->extra_cols[$i][1],$this->extra_cols[$i][2],$this->extra_cols[$i][3],'init');92 $bd_fields=substr($this->sql_query,7,stripos($this->sql_query,' FROM ')-7);93 $this->sql_fields=explode(',',$bd_fields);94 // gets the data from the DB95 $result = mysql_query($this->get_sql());96 if($result) {97 while ($row = mysql_fetch_array($result, MYSQL_NUM))98 $this->data[]=$row;99 mysql_free_result($result);100 }101 102 // total of items103 $result=mysql_query(str_replace($bd_fields,'count('.$this->sql_fields[0].')',$this->get_sql_select()).$this->get_sql_where(),$wpdb->dbh);104 105 $this->total_items=mysql_fetch_row($result);106 $this->total_items=$this->total_items[0];107 mysql_free_result($result);108 // adds the new extra columns to the data109 for($i=0; $i<count($this->extra_cols); $i++)110 $this->add_col($this->extra_cols[$i][0],$this->extra_cols[$i][1],$this->extra_cols[$i][2],$this->extra_cols[$i][3],'data');111 }112 // Adds a new row i.e. $ct->add_row(array(69,69,'ola',69),3);113 function add_row($arr_html,$row){114 array_splice($this->data, $row-1, 0, array($arr_html));115 }116 // Adds a new column i.e. $ct->add_col(1,'Check','<input type="checkbox" name="check" />','50');117 function add_col($col,$header,$width,$html,$op='init_data'){118 if($op=='init_data')119 $this->extra_cols[]=array($col,$header,$width,$html);120 if(strpos($op,'init')!==false){121 // adds the new header122 $arr_header=explode(',',$this->header);123 if($col>count($arr_header)+1)124 $col=count($arr_header)+1;125 array_splice($arr_header, $col-1, 0, $header);126 $this->header=implode(',',$arr_header);127 // adds the new column width128 $arr_width=explode(',',$this->width);129 array_splice($arr_width, $col-1, 0, $width);130 $this->width=implode(',',$arr_width);131 // rearrange the sort string132 if($this->sort_init===true){133 $this->sort_init=str_repeat('t',count($arr_header));134 $this->sort_init[$col-1]='f';135 }else if($this->sort_init!==true and $this->sort_init!==false){136 $this->sort_init=substr_replace($this->sort_init,'f',$col-1,0);137 }138 // rearrange the search_init string139 if($this->search_init===true){140 $this->search_init=str_repeat('t',count($arr_header));141 $this->search_init[$col-1]='f';142 }elseif($this->search_init!==true and $this->search_init!==false){143 $this->search_init=substr_replace($this->search_init,'f',$col-1,0);144 }145 // rearrange the multiple_search_init string146 if($this->multiple_search_init===true){147 $this->multiple_search_init=str_repeat('t',count($arr_header));148 $this->multiple_search_init[$col-1]='f';149 }else if($this->multiple_search_init=='hide'){150 $this->multiple_search_init=str_repeat('t',count($arr_header));151 $this->multiple_search_init[$col-1]='f';152 $this->multiple_search_init.='hide';153 }else if($this->multiple_search_init!==true and $this->multiple_search_init!==false){154 $this->multiple_search_init=substr_replace($this->multiple_search_init,'f',$col-1,0);155 }156 }157 if(strpos($op,'data')!==false){158 // add the new column in all rows159 if($this->total_items>0){160 for($i=0; $i<count($this->data); $i++){161 array_splice($this->data[$i], $col-1, 0, array($html));162 }163 }164 }165 }166 // Rearrange the sort string167 function init_sort(){168 $out='';169 if($this->sort===true or $this->sort==''){170 for($i=0; $i<count($this->data[0]); $i++){171 $out.=($out ? '_' : '').'t';172 }173 $this->sort=$out;174 }175 }176 // Gets final composed sql query177 function get_sql(){178 return $this->get_sql_select().$this->get_sql_where().$this->get_sql_order().$this->get_sql_limit();179 }180 // Gets the sql query corresponding to selecting fields and tables parameters181 function get_sql_select(){182 if(stripos($this->sql_query,' WHERE ')!==false)183 $select_str=substr($this->sql_query,0,stripos($this->sql_query,' WHERE '));184 else185 $select_str=$this->sql_query;186 return $select_str;187 }188 // Gets the sql query corresponding to conditions parameters189 function get_sql_where(){190 $where_str='';191 $multiple_search_str='';192 if(stripos($this->sql_query,' WHERE ')!==false){193 if(stripos($this->sql_query,' ORDER BY ')!==false)194 $where_str_ini='('.substr($this->sql_query,stripos($this->sql_query,' WHERE ')+7,stripos($this->sql_query,' ORDER BY ')-stripos($this->sql_query,' WHERE ')-7).')';195 elseif(stripos($this->sql_query,' LIMIT ')!==false)196 $where_str_ini='('.substr($this->sql_query,stripos($this->sql_query,' WHERE ')+7,stripos($this->sql_query,' LIMIT ')-stripos($this->sql_query,' WHERE ')-7).')';197 else198 $where_str_ini='('.substr($this->sql_query,stripos($this->sql_query,' WHERE ')+7).')';199 }else{200 $where_str_ini='';201 }202 // adds the extra columns in consideration203 $arr_sql_fields=$this->sql_fields;204 for($i=0; $i<count($this->extra_cols); $i++)205 array_splice($arr_sql_fields, $this->extra_cols[$i][0]-1, 0, '');206 for($i=0; $i<count($arr_sql_fields); $i++){207 if(empty($this->multiple_search[$i]))208 $this->multiple_search[$i]='';209 if($this->search!='' and $this->search_init[$i]!='f')210 $where_str.=(($i==0 and $where_str_ini) ? ' AND ' : '').($where_str ? ' OR ' : '(').$arr_sql_fields[$i]." LIKE '%".$this->search."%'";211 if(count($this->multiple_search)>0 and $this->multiple_search[$i]!='' and $this->multiple_search_init[$i]!='f')212 $multiple_search_str.=(($where_str_ini or $where_str or $multiple_search_str) ? ' AND ' : '').$arr_sql_fields[$i]." LIKE '%".$this->multiple_search[$i]."%'";213 }214 if($where_str!='')215 $where_str.=')';216 return (($where_str_ini or $where_str or $multiple_search_str) ? ' WHERE ' : '').$where_str_ini.$where_str.$multiple_search_str;217 }218 // Gets the sql query corresponding to order parameters219 function get_sql_order(){220 if(stripos($this->sql_query,' ORDER BY ')!==false){221 if(stripos($this->sql_query,' LIMIT ')!==false)222 $order_str_ini=substr($this->sql_query,stripos($this->sql_query,' ORDER BY '),stripos($this->sql_query,' LIMIT ')-stripos($this->sql_query,' ORDER BY '));223 else224 $order_str_ini=substr($this->sql_query,stripos($this->sql_query,' ORDER BY '));225 }else{226 $order_str_ini='';227 }228 $order_str='';229 $arr_new_cols=array();230 // adds the extra columns in consideration231 $arr_sql_fields=$this->sql_fields;232 for($i=0; $i<count($this->extra_cols); $i++){233 array_splice($arr_sql_fields, $this->extra_cols[$i][0]-1, 0, '');234 $arr_new_cols[]=$this->extra_cols[$i][0];235 }236 $arr_sort=explode('_',$this->sort);237 asort($arr_sort);238 foreach($arr_sort as $key => $value){239 if(!in_array($key+1,$arr_new_cols)){240 if(substr($arr_sort[$key],-1)=='a')241 $order_str.=(($order_str_ini or $order_str) ? ', ' : ' ORDER BY ').$arr_sql_fields[$key].' ASC';242 if(substr($arr_sort[$key],-1)=='d')243 $order_str.=(($order_str_ini or $order_str) ? ', ' : ' ORDER BY ').$arr_sql_fields[$key].' DESC';244 }245 }246 return $order_str_ini.$order_str;247 }248 // Gets the sql query corresponding to limit parameters249 function get_sql_limit(){250 $limit_str='';251 if($this->items_per_page!='all' and $this->items_per_page!='')252 $limit_str=' LIMIT '.($this->page-1)*$this->items_per_page.','.$this->items_per_page;253 return $limit_str;254 }255 // Analises the url passed, if it has the tag #COLUMN_ID# it substitues for the true value of the page,256 // otherwise puts ?pag=1 or &pag=1 in the end of url257 function get_url($column){258 if(strpos($this->sort_url,'#COLUMN_ID#')!==false){259 return str_replace('#COLUMN_ID#',$column,$this->sort_url);260 }else{261 return $this->sort_url.(strpos($this->sort_url,'?')!==false ? '&' : '?').'sort='.$this->sort;262 }263 }264 // Change some specific tags to their corresponding value265 function change_tags($str){266 $str=str_replace('#ID#',$this->id,$str);267 $str=str_replace('#PAGE#',$this->page,$str);268 $str=str_replace('#ITEMS_PER_PAGE#',$this->items_per_page,$str);269 $str=str_replace('#TOTAL_ITEMS#',$this->total_items,$str);270 return $str;271 }272 // Change the column tags for their value #COL1#, #COL2#, ...273 function change_tag_col($str,$arr_cols){274 preg_match_all('/#COL(\d+)#/i', $str, $matches, PREG_SET_ORDER);275 for($i=0; $i<count($matches); $i++){276 $str=str_replace($matches[$i][0], addslashes($arr_cols[$matches[$i][1]-1]), $str);277 }278 return $str;279 }280 // Draw the form281 function draw_form(){282 $out='';283 if($this->form_init)284 $out='<form id="'.$this->id.'_form" name="'.$this->id.'_form" method="get" action="'.$this->form_url.'">285 <input type="hidden" id="'.$this->id.'_items_per_page" name="'.$this->id.'_items_per_page" value="'.$this->items_per_page.'" />286 <input type="hidden" id="'.$this->id.'_sort" name="'.$this->id.'_sort" value="'.$this->sort.'" />287 <input type="hidden" id="'.$this->id.'_page" name="'.$this->id.'_page" value="'.$this->page.'" />';288 return $out;289 }290 // Draw the search component291 function draw_search(){292 $out='';293 if($this->search_init)294 $out.='<input type="text" id="'.$this->id.'_search" name="'.$this->id.'_search" value="'.$this->search.'" onfocus="ctSearchFocus(\''.$this->id.'\');" onblur="ctSearchBlur(\''.$this->id.'\');" onkeypress="ctSearchKeypress(\''.$this->id.'\');" onkeyup="ctSearch(\''.$this->id.'\');" />'.$this->change_tags($this->search_html);295 return $out;296 }297 // Draw the items_per_page component298 function draw_items_per_page(){299 $out='';300 if($this->items_per_page_init!==false and $this->total_items>0){301 $out='<select id="'.$this->id.'_items_per_page_change" name="'.$this->id.'_items_per_page_change" onchange="'.$this->change_tags($this->items_per_page_url).'">';302 // formula $i*10; pow(10,$i)303 if(strpos($this->items_per_page_init,'$')!==false){304 $i=1;305 eval('$value='.$this->items_per_page_init.';');306 while ($value<$this->total_items) {307 $out.='<option value="'.$value.'"'.($value==$this->items_per_page ? ' selected="selected"' : '').'>'.$value.'</option>';308 $i++;309 eval('$value='.$this->items_per_page_init.';');310 }311 }else{312 $i=0;313 $arr_items_per_page=explode(',',$this->items_per_page_init);314 while ($i<count($arr_items_per_page) and $arr_items_per_page[$i]<$this->total_items) {315 $out.='<option value="'.$arr_items_per_page[$i].'"'.($arr_items_per_page[$i]==$this->items_per_page ? ' selected="selected"' : '').'>'.$arr_items_per_page[$i].'</option>';316 $i++;317 }318 }319 if($this->items_per_page_all!='')320 $out.='<option value="all"'.('all'==$this->items_per_page ? ' selected="selected"' : '').'>'.$this->change_tags($this->items_per_page_all).'</option>';321 $out.='</select>';322 }323 return $out;324 }325 // Draw the header of the table326 function draw_header(){327 $out_multiple_search='';328 $arr_width=explode(',',$this->width);329 $out='<thead><tr id="'.$this->id.'_sort">';330 $arr_sort=explode('_',$this->sort);331 $arr_header=explode(',',$this->header);332 $column=1;333 for($i=0; $i<count($arr_header);$i++){334 if($this->sort_init!==false and $this->sort_init[$i]!='f'){335 336 if(!isset($arr_sort[$i])){ $arr_sort[$i]= ""; }337 338 $out.='<th'.(($this->width!='' and $arr_width[$i]>0) ? ' ' : '').' 339 onclick="'.$this->change_tags($this->get_url($i+1)).'">340 <span'.($arr_sort[$i]=='f' ? ' class="no_sort' : ' class="sort').(substr($arr_sort[$i],-1)=='a' ? '_asc' : (substr($arr_sort[$i],-1)=='d' ? '_desc' : '')).'">341 </span>342 '.$arr_header[$i].'</th>';343 344 }else{345 $out.='<th'.(($this->width!='' and $arr_width[$i]>0) ? ' ' : '').'><span></span>'.$arr_header[$i].'</th>';346 }347 if($this->multiple_search_init===true or $this->multiple_search_init=='hide' or (strpos($this->multiple_search_init,'hide')!==false and $this->multiple_search_init[$i]=='t') or $this->multiple_search_init[$i]=='t')348 $out_multiple_search.='<th><input type="text" id="'.$this->id.'_multiple_search'.($i+1).'" name="'.$this->id.'_multiple_search[]'.'" value="'.$this->multiple_search[$i].'" onkeyup="ctMultiSearch(\''.$this->id.'\');" /></a></th>';349 else350 $out_multiple_search.='<th></th>';351 }352 $out.='</tr>';353 if($this->multiple_search_init===true or strpos($this->multiple_search_init,'hide')!==false or strpos($this->multiple_search_init,'t')!==false)354 $out.='<tr id="'.$this->id.'_multiple_search"'.(($this->multiple_search_init!==true and strpos($this->multiple_search_init,'hide')!==false) ? ' style="display: none;"' : '').'>'.$out_multiple_search.'</tr>';355 $out.'</thead>';356 return $out;357 }358 // Draw the body of the table359 function draw_body(){360 361 global $PPT;362 363 $out='';364 if($this->total_items>0){365 $arr_width=explode(',',$this->width);366 367 for($i=0; $i<count($this->data);$i++){$c=0;368 $out.='<tr'.($this->odd_even ? ($i%2==0 ? ' class="odd"' : ' class="even"') : '').'>';369 foreach($this->data[$i] as $key => $value){370 371 $arr_header=explode(',',$this->header);372 373 if($arr_header[$c] == "ORDER ID"){374 375 $out.='<td'.(($i==0 and $this->width!='' and $arr_width[$key]>0) ? ' width="'.$arr_width[$key].'"' : '').'>376 377 <a href="javascript:void(0);" onclick="document.getElementById(\'delo\').value =\''.str_replace('#ROW#',$i+1,$this->change_tag_col($this->change_tags($value),$this->data[$i])).'\';document.DeleteOrder.submit();" title="delete order"><img src="../wp-content/themes/'.strtolower(constant('PREMIUMPRESS_SYSTEM')).'/PPT/img/premiumpress/led-ico/cross.png" align="middle"></a>378 379 <a href="../wp-content/themes/'.strtolower(constant('PREMIUMPRESS_SYSTEM')).'/admin/_invoice.php?id='.str_replace('#ROW#',$i+1,$this->change_tag_col($this->change_tags($value),$this->data[$i])).'" target="_blank" title="view invoice"><img src="../wp-content/themes/'.strtolower(constant('PREMIUMPRESS_SYSTEM')).'/PPT/img/premiumpress/led-ico/page.png" align="middle"></a>380 381 <a href="admin.php?page=orders&id='.str_replace('#ROW#',$i+1,$this->change_tag_col($this->change_tags($value),$this->data[$i])).'" title="edit order"><img src="../wp-content/themes/'.strtolower(constant('PREMIUMPRESS_SYSTEM')).'/images/admin/icon-edit.gif" align="middle"> '.str_replace('#ROW#',$i+1,$this->change_tag_col($this->change_tags($value),$this->data[$i])).'</a></td>';382 383 }elseif($arr_header[$c] == "TOTAL"){384 385 $out.='<td'.(($i==0 and $this->width!='' and $arr_width[$key]>0) ? ' width="'.$arr_width[$key].'"' : '').'>'.number_format(str_replace('#ROW#',$i+1,$this->change_tag_col($this->change_tags($value),$this->data[$i])),2).'</td>';386 387 388 }elseif($arr_header[$c] == "STATUS"){389 390 switch(str_replace('#ROW#',$i+1,$this->change_tag_col($this->change_tags($value),$this->data[$i]))){391 392 case "0": { $O1 = "Awaiting Payment"; $O2 = "#0c95ff"; } break;393 case "3": { $O1 = "Paid & Completed "; $O2 = "green"; } break; 394 case "5": { $O1 = "Payment Received"; $O2 = "green"; } break; 395 case "6": { $O1 = "Payment Failed"; $O2 = "red"; } break;396 case "7": { $O1 = "Payment Pending"; $O2 = "orange"; } break; 397 case "8": { $O1 = "Payment Refunded"; $O2 = "black"; } break; 398 399 }400 401 $out.='<td'.(($i==0 and $this->width!='' and $arr_width[$key]>0) ? ' width="'.$arr_width[$key].'"' : '').' style="background-color:'.$O2.'"><span style="color:white;">'.$O1.'</span></td>';402 403 }else{404 405 406 $out.='<td'.(($i==0 and $this->width!='' and $arr_width[$key]>0) ? ' width="'.$arr_width[$key].'"' : '').'>'.str_replace('#ROW#',$i+1,$this->change_tag_col($this->change_tags($value),$this->data[$i])).'</td>';407 408 }409 $c++; 410 }411 $out.='</tr>'; 412 }413 }else{414 $arr_header=explode(',',$this->header);415 if($this->no_results!==false)416 $out.='<tr id="'.$this->id.'_no_results"><td colspan="'.count($arr_header).'">'.$this->no_results.'</td></tr>';417 }418 return $out;419 }420 // Draw the actions component421 function draw_actions(){422 $out='';423 if(count($this->actions)>0){424 $out='<select id="'.$this->id.'_actions" name="'.$this->id.'_actions" onchange="'.$this->change_tags($this->actions_url).'">';425 for($i=0; $i<count($this->actions); $i++){426 $out.='<option value="'.$this->actions[$i][0].'">'.$this->actions[$i][1].'</option>';427 }428 $out.='</select>';429 }430 return $out;431 }432 // Draw the pager component433 function draw_pager(){434 return $this->pager;435 }436 // Draw the necessary javascript block437 function draw_javascript_block(){438 // sort order439 $out_sort_order='var arr_sort_order= new Array();';440 for($i=0; $i<strlen($this->sort_order); $i++){441 if($i==strlen($this->sort_order)-1)442 $out_sort_order.='arr_sort_order["'.$this->sort_order[$i].'"]="'.$this->sort_order[0].'";';443 else444 $out_sort_order.='arr_sort_order["'.$this->sort_order[$i].'"]="'.$this->sort_order[$i+1].'";';445 }446 if(strpos($this->sort_order,'t')===false)447 $out_sort_order.='arr_sort_order["t"]="";';448 $out_sort_order.='arr_sort_order["first"]="'.$this->sort_order[0].'";';449 $out='<script type="text/javascript">'.$out_sort_order.'var extra_cols ='.json_encode($this->extra_cols).';';450 if($this->search=='')451 $out.='jQuery(document).ready(function(){ jQuery("#'.$this->id.'_search_value").css("opacity","1"); });';452 $out.='</script>';453 return $out;454 }455 // Displays the output456 function display($op=''){457 $out='';458 // Builds the all structure of the table459 $this->init_sort();460 if($op=='' or strpos($op,'form')!==false)461 $out.=$this->draw_form();462 if($op=='' or strpos($op,'search')!==false or strpos($op,'items_per_page')!==false){463 $out.='<div id="'.$this->id.'_top_container">';464 if(($op=='' or strpos($op,'search')!==false))465 $out.='<div id="'.$this->id.'_search_container">'.$this->draw_search().'</div>';466 if(($op=='' or strpos($op,'items_per_page')!==false))467 $out.='<div id="'.$this->id.'_items_per_page_container">'.$this->draw_items_per_page().'</div>';468 $out.='</div>';469 }470 if($op=='' or strpos($op,'table')!==false){471 $out.='<table id="'.$this->id.'"'.($this->class!='' ? ' class="'.$this->class.'"' : '').'>';472 if($this->header!==false)473 $out.=$this->draw_header();474 $out.='<tbody>'.$this->draw_body().'</tbody>';475 $out.='</table>';476 }477 if($op=='' or strpos($op,'actions')!==false or strpos($op,'pager')!==false){478 $out.='<div id="'.$this->id.'_bottom_container">';479 if(($op=='' or strpos($op,'actions')!==false) and count($this->actions)>0)480 $out.='<div id="'.$this->id.'_actions_container">'.$this->draw_actions().'</div>';481 if(($op=='' or strpos($op,'pager')!==false) and $this->pager!='')482 $out.='<div id="'.$this->id.'_pager_container">'.$this->draw_pager().'</div>';483 $out.='</div>';484 }485 if(($op=='' or strpos($op,'form')!==false) and $this->form_init)486 $out.='</form>';487 $out.=$this->draw_javascript_block();488 $this->out=$out;489 return $out;490 }491}492class CreativePager{493 var $id;494 var $class;495 var $selected_page;496 var $total_items;497 var $items_per_page;498 var $total_pages;499 var $nav_pages;500 var $url;501 var $first;502 var $last;503 var $out;504 function pager($params){505 global $tpl;506 // Default Values507 $this->id = isset($params['id']) ? $params['id'] : 'pager';508 $this->class = isset($params['class']) ? $params['class'] : '';509 $this->selected_page = isset($params['selected_page']) ? ($params['selected_page']>0 ? $params['selected_page'] : 1) : 1;510 $this->total_items = isset($params['total_items']) ? $params['total_items'] : '';511 $this->items_per_page = isset($params['items_per_page']) ? ($params['items_per_page']>0 ? $params['items_per_page'] : 10) : 10;512 $this->total_pages = isset($params['total_pages']) ? $params['total_pages'] : ceil($this->total_items/$this->items_per_page);513 $this->nav_pages = isset($params['nav_pages']) ? (($params['nav_pages']!==true and $params['nav_pages']>0 or $params['nav_pages']===false) ? $params['nav_pages'] : 9) : 9;514 $this->url = isset($params['url']) ? $params['url'] : '';515 $this->first = true;516 $this->last = true;517 // Builds the all structure of the pager (info1 + pager + info2)518 $out='<span id="'.$this->id.'_info1">'.'Total: '.$this->total_items.'</span>';519 if($this->total_pages>1){520 $out.='<ul id="'.$this->id.'"'.($this->class!='' ? ' class="'.$this->class.'"' : '').'>';521 $out.=$this->draw_type();522 $out.='</ul>';523 }524 $out.='<span id="'.$this->id.'_info2">'.'Page: '.$this->selected_page.' of '.$this->total_pages.'</span>';525 $this->out=$out;526 }527 // Analises the url passed, if it has the tag #NUM_PAGE# it substitues for the true value of the page,528 // otherwise puts ?pag=1 or &pag=1 in the end of url529 function get_url($page){530 if(strpos($this->url,'#NUM_PAGE#')!==false){531 return str_replace('#NUM_PAGE#',$page,$this->url);532 }else{533 return $this->url.(strpos($this->url,'?')!==false ? '&' : '?').'page='.$page;534 }535 }536 // Button first537 function draw_first(){538 $out='';539 if($this->first){540 $out='<li id="'.$this->id.'_first"><a href="'.$this->get_url(1).'">?First</a></li>';541 $out.='<li id="'.$this->id.'_pos_first">...</li>';542 }543 return $out;544 }545 // Button last546 function draw_last(){547 $out='';548 if($this->last){549 $out='<li id="'.$this->id.'_pre_last">...</li>';550 $out.='<li id="'.$this->id.'_last"><a href="'.$this->get_url($this->total_pages).'">Last </a></li>';551 }552 return $out;553 }554 // Builds the pager555 function draw_type(){556 $out='';557 if($this->nav_pages){558 if($this->selected_page>1) $out='<li id="'.$this->id.'_prev"><a href="'.$this->get_url($this->selected_page-1).'"></a></li>';559 $out.=$this->type_centered();560 if($this->selected_page<$this->total_pages) $out.='<li id="'.$this->id.'_next"><a href="'.$this->get_url($this->selected_page+1).'"></a></li>';561 }562 return $this->draw_first().$out.$this->draw_last();563 }564 // Centered type - the selected page allways stays in the center565 function type_centered(){566 $out='';567 if($this->selected_page<=ceil(($this->nav_pages+1)/2)){568 $min=1;569 $max=$this->nav_pages;570 $this->first=false;571 }elseif($this->selected_page>$this->total_pages-floor(($this->nav_pages+1)/2)){572 $min=$this->total_pages-$this->nav_pages+1;573 $max=$this->total_pages;574 $this->last=false;575 }else{576 $min=$this->selected_page-ceil(($this->nav_pages-1)/2);577 $max=$min+$this->nav_pages-1;578 }579 if($this->total_pages<=$this->nav_pages)580 $this->last=false;581 if($min<1) $min=1;582 if($max>$this->total_pages) $max=$this->total_pages;583 for($i=$min; $i<=$max; $i++)584 $out.='<li><a href="'.$this->get_url($i).'" '.($i==$this->selected_page ? 'class="selected"' : '').'>'.$i.'</a></li>';585 return $out;586 }587 // Display the output588 function display(){589 return $this->out;590 }591}592function getCreativePagerLite($page,$total_items,$items_per_page){593 594 $cp=new CreativePager();595 // Data Gathering596 $params['selected_page'] = $page;597 $params['total_items'] = $total_items;598 $params['items_per_page'] = $items_per_page=='all' ? $total_items : $items_per_page;599 $params['url'] = 'javascript: ctPager(\'ct\',\'#NUM_PAGE#\');';600 // Layout Configurations601 $params['id'] = 'ct_pager';602 $params['type'] = 'centered';603 $params['nav_pages'] = 5;604 $cp->pager($params);605 $out_pager=$cp->display();606 return $out_pager;607}608// function to check if an array as any value - for the real example and complex example609function filled_array($arr){610 for($i=0; $i<count($arr); $i++){611 if($arr[$i]!='')612 return true;613 }614 return false;615}616function TablePageMeta(){617?>618<style>619#ct_top_container{ width:100%; height: 33px; }620#ct_search_container{ float: right; margin-top: 5px; margin-right: 0px; position: relative; margin-right:-5px; }621#ct_search_container a:link, #ct_search_container a:visited{ color: #555555; text-decoration: none;}622#ct_search_container a:hover, #ct_search_container a:active { color: #333333; text-decoration: none;}623#ct_search{ color: #555555; width:250px; height:35px; border: 1px solid #aaaaaa; padding:10px; -webkit-border-radius: 0px; border-radius: 0px; margin:2px; margin-left:-5px; border:1px solid #ddd; }624 625#ct_search_value{ position: absolute; top: 13px; left: 15px; opacity:0; filter:alpha(opacity=0); z-index: 300; text-transform:uppercase; color:#999999; }626#ct_advanced_search{ position: absolute; top: 3px; left: 210px; z-index: 300;}627#ct_loader{ width: 16px; height: 16px; margin-left: 5px; float: right; margin-top:-27px; }628/* ITEMS_PER_PAGE */629#ct_items_per_page_container{ float: left; margin-top: 7px; margin-left: 15px;}630/* TABLE */631#ct { border-collapse:collapse; margin-top: 0px; clear: both; border:0px; width:800px; margin-left:20px; margin-top:20px; }632#ct th{ color: #555555; font-weight: normal; text-align: left; text-decoration: none; border-top:1px solid #d3d3d3; border-left:1px solid #d3d3d3; padding:3px 0px 3px 8px; margin: 0px; cursor: pointer;}633#ct th span{ display: block; float: right; width: 21px; height: 9px; margin-top: 5px; }634#ct th span.sort{ background: url(../wp-content/themes/<?php echo strtolower(constant('PREMIUMPRESS_SYSTEM')); ?>/images/admin/sort_black.gif) no-repeat right center;}635#ct th span.sort_asc{ background: url(../wp-content/themes/<?php echo strtolower(constant('PREMIUMPRESS_SYSTEM')); ?>/images/admin/sort_asc_black.gif) no-repeat right center;}636#ct th span.sort_desc{ background: url(../wp-content/themes/<?php echo strtolower(constant('PREMIUMPRESS_SYSTEM')); ?>/images/admin/sort_desc_black.gif) no-repeat right center;}637#ct_multiple_search th{ padding:0px; }638#ct_multiple_search th input{ width: 95%; padding: 0px; height: 20px; border: 0px; -webkit-border-radius: 0px; border-radius: 0px; margin:2px; margin-left:5px; border:1px solid #ddd; }639#ct td{ color: 555555; border:1px solid #d3d3d3; padding:5px 8px;}640#ct .odd, #ct_no_results{ background-color: #EEFFEE;}641#ct .even{ background-color: #DDFFDD;} 642/* BOTTOM CONTAINER : ACTIONS + PAGER */643#ct_bottom_container{ width:100%; height: 33px; }644/* ACTIONS */645#ct_actions_container{ margin-top: 20px; float: left;}646/* PAGER */647#ct_pager{ list-style: none; float: right; margin-top: 17px; margin-right: 15px; margin-bottom:10px;}648#ct_pager li{ display: inline;}649#ct_pager li a{ display: inline; color: #555555; font-size: 12px; text-decoration: none; padding: 5px 6px; background: #ededed; border: 1px solid #D3D3D3;margin-right:3px}650#ct_pager li a:hover{ background: #ededed;color: #333333;}651#ct_pager li a.selected{ background: #ededed; color: #555555; font-weight: bold;}652#ct_pager_info1{ font-size: 9px; height: 20px; margin: 5px 0px 10px 0px; padding: 0px 10px 0px 10px; float: left;}653#ct_pager_info2{ display: none;}654#ct_pager_pos_first{ color: #000000; font-size: 12px; margin-right: 3px; padding: 5px;}655#ct_pager_pre_last{ color: #000000; font-size: 12px; margin-right: 3px; padding: 5px;}656 657</style>658<script>659 660var timeout=0; // time to begin search after keypressed (miliseconds)661// ***************************************************662// Global vars663var typingTimeout;664var multiple_sort=0;665function ctSearchFocus(table_id){666 if(jQuery('#'+table_id+'_search').val()=='')667 jQuery('#'+table_id+'_search_value').animate({opacity: 0.25}, 300);668}669function ctSearchBlur(table_id){670 if(jQuery('#'+table_id+'_search').val()=='')671 jQuery('#'+table_id+'_search_value').animate({opacity: 1}, 300);672}673function ctSearchKeypress(table_id){674 if(jQuery('#'+table_id+'_search').val()=='')675 jQuery('#'+table_id+'_search_value').animate({opacity: 0}, 10);676}677function ctSearch(table_id){678 if(jQuery('#'+table_id+'_search').val()=='')679 jQuery('#'+table_id+'_search_value').animate({opacity: 0.25}, 300);680 window.clearInterval(typingTimeout);681 typingTimeout = window.setTimeout(function() { ctSubmitForm(table_id,'',1,'items_per_page,body,pager') },timeout);682}683function ctMultiSearch(table_id){684 window.clearInterval(typingTimeout);685 typingTimeout = window.setTimeout(function() { ctSubmitForm(table_id,'',1,'items_per_page,body,pager') },timeout);686}687function ctShowAdvancedSearch(table_id){688 jQuery('#'+table_id+'_multiple_search').toggle();689}690function ctItemsPerPage(table_id){691 jQuery('#'+table_id+'_items_per_page').val(jQuery('#'+table_id+'_items_per_page_change').val());692 ctSubmitForm(table_id,'',1,'body,pager');693}694function ctSort(table_id,sort_column){695 var sort_num;696 var sort_order;697 var max_num=1;698 var str_sort='';699 var sort_aux='';700 var arr_sort_aux='';701 var arr_sort_order_txt= new Array();702 arr_sort_order_txt["a"]="_asc";703 arr_sort_order_txt["d"]="_desc";704 arr_sort_order_txt["t"]="";705 sort_aux=jQuery('#'+table_id+'_sort').val();706 arr_sort_aux=sort_aux.split('_');707 if(multiple_sort==1){708 for(i=0; i<arr_sort_aux.length; i++){709 sort_num=arr_sort_aux[i].substring(0,arr_sort_aux[i].length-1);710 if(sort_num>max_num)711 max_num=sort_num;712 }713 for(i=0; i<arr_sort_aux.length; i++){714 sort_num=arr_sort_aux[i].substring(0,arr_sort_aux[i].length-1);715 sort_order=arr_sort_aux[i].substring(arr_sort_aux[i].length-1);716 if(sort_column==i+1){717 jQuery('#'+table_id+'_sort th span:eq('+(sort_column-1)+')').removeClass().addClass('sort'+arr_sort_order_txt[(arr_sort_order[sort_order]=='' ? arr_sort_order["first"] : arr_sort_order[sort_order])]);718 str_sort+=(str_sort!='' ? '_' : '')+(arr_sort_order[sort_order]=='t' ? '' : (sort_num!='' ? sort_num : parseInt(max_num)+1))+(arr_sort_order[sort_order]=='' ? arr_sort_order["first"] : arr_sort_order[sort_order]);719 }else{720 str_sort+=(str_sort!='' ? '_' : '')+(sort_order=='f' ? 'f' : sort_num+sort_order);721 }722 }723 jQuery('#'+table_id+'_sort').val(str_sort);724 ctSubmitForm(table_id,str_sort,1,'body');725 }else{726 for(i=0; i<arr_sort_aux.length; i++){727 sort_num=arr_sort_aux[i].substring(0,arr_sort_aux[i].length-1);728 sort_order=arr_sort_aux[i].substring(arr_sort_aux[i].length-1);729 if(sort_column==i+1){730 jQuery('#'+table_id+'_sort th span:eq('+(sort_column-1)+')').removeClass().addClass('sort'+arr_sort_order_txt[(arr_sort_order[sort_order]=='' ? arr_sort_order["first"] : arr_sort_order[sort_order])]);731 str_sort+=(str_sort!='' ? '_' : '')+(arr_sort_order[sort_order]=='t' ? '' : 1)+(arr_sort_order[sort_order]=='' ? arr_sort_order["first"] : arr_sort_order[sort_order]);732 }else{733 jQuery('#'+table_id+'_sort th span:eq('+i+')').filter("'.sort, .sort_asc, .sort_desc").removeClass('sort_asc sort_desc').addClass('sort');734 str_sort+=(str_sort!='' ? '_' : '')+(sort_order=='f' ? 'f' : 't');735 }736 }737 jQuery('#'+table_id+'_sort').val(str_sort);738 ctSubmitForm(table_id,str_sort,1,'body');739 }740}741function ctActions(table_id){742 return true;743}744function ctPager(table_id,page){745 ctSubmitForm(table_id,'',page,'body,pager');746}747// reload_option = 'items_per_page'; 'body'; 'pager'; 'items_per_page,body'; 'items_per_page,body,pager'; ...748function ctSubmitForm(table_id,sort,page,reload_option){749 // starts the loading gif750 jQuery('#'+table_id+'_loader').css("backgroundImage", "url(images/loading.gif)");751 var multiple_search_str='';752 jQuery('#'+table_id+'_multiple_search th').each(function(index) {753 multiple_search_str+=(multiple_search_str=='' ? '' : ',')+'"'+(jQuery('#'+table_id+'_multiple_search'+(index+1)).val()==undefined ? '' : jQuery('#'+table_id+'_multiple_search'+(index+1)).val())+'"';754 });755 var multiple_search=JSON.parse('['+multiple_search_str+']');756 // body refresh757 jQuery.ajax({758 type: "POST",759 url: "../wp-content/themes/<?php echo strtolower(constant('PREMIUMPRESS_SYSTEM')); ?>/admin/_ad_orders.php?ajaxcall=1&op="+reload_option,760 data: {761 "id" : table_id,762 "items_per_page" : jQuery('#'+table_id+'_items_per_page').val(),763 "sort" : sort,764 "page" : page,765 "search" : jQuery('#'+table_id+'_search').val(),766 "multiple_search" : multiple_search,767 "extra_cols" : extra_cols,768 "search_init" : jQuery('#'+table_id+'_search_init').val()769 },770 dataType: 'json',771 success: function(out){772 if(reload_option.indexOf('items_per_page')!=-1)773 jQuery('#'+table_id+'_items_per_page_container').html(out.items_per_page);774 if(reload_option.indexOf('body')!=-1){775 jQuery('#'+table_id+' tbody').html(out.body);776 }777 if(reload_option.indexOf('pager')!=-1)778 jQuery('#'+table_id+'_pager_container').html(out.pager);779 jQuery('#info').html(out.info);780 // stops the loading gif781 jQuery('#'+table_id+'_loader').css("backgroundImage", "");782 }...

Full Screen

Full Screen

visitorsController.php

Source:visitorsController.php Github

copy

Full Screen

1<?php2namespace App\Http\Controllers;3class visitorsController extends Controller {4 var $data = array();5 var $panelInit ;6 public function __construct(){7 if(app('request')->header('Authorization') != "" || \Input::has('token')){8 $this->middleware('jwt.auth');9 }else{10 $this->middleware('authApplication');11 }12 $this->panelInit = new \DashboardInit();13 $this->data['panelInit'] = $this->panelInit;14 $this->data['users'] = $this->panelInit->getAuthUser();15 if(!isset($this->data['users']->id)){16 return \Redirect::to('/');17 }18 }19 public function listAll($page = 1,$search = ""){20 if(!$this->panelInit->can( array("visitors.list","visitors.View","visitors.add_vis","visitors.edit_vis","visitors.del_vis","visitors.Download","visitors.Export") )){21 exit;22 }23 $toReturn = array();24 $toReturn["visitors"] = \visitors::orderby('id','DESC');25 if($search != ""){26 $toReturn["visitors"] = $toReturn["visitors"]->where(function($query) use ($search){27 $query->where("pass_id","like","%".$search."%")->orWhere("fullName","like","%".$search."%")->orWhere("phoneNo","like","%".$search."%")->orWhere("email","like","%".$search."%")->orWhere("std_relation","like","%".$search."%")->orWhere("purpose","like","%".$search."%")->orWhere("visit_notes","like","%".$search."%");28 });29 }30 $toReturn["totalItems"] = $toReturn["visitors"]->count();31 $toReturn["visitors"] = $toReturn["visitors"]->select('id','pass_id','fullName','phoneNo','email','id_pass_id','usr_type','comp_name','student','to_meet','purpose','check_in','check_out')->take('20')->skip(20* ($page - 1) )->get()->toArray();32 33 foreach ($toReturn["visitors"] as $key => $value) {34 $toReturn["visitors"][$key]["student"] = json_decode($toReturn["visitors"][$key]["student"]);35 if(!is_array($toReturn["visitors"][$key]["student"])){36 $toReturn["visitors"][$key]["student"] = array();37 }38 $toReturn["visitors"][$key]["to_meet"] = json_decode($toReturn["visitors"][$key]["to_meet"]);39 if(!is_array($toReturn["visitors"][$key]["to_meet"])){40 $toReturn["visitors"][$key]["to_meet"] = array();41 }42 $toReturn["visitors"][$key]["check_in"] = json_decode($toReturn["visitors"][$key]["check_in"]);43 $toReturn["visitors"][$key]["check_out"] = json_decode($toReturn["visitors"][$key]["check_out"]);44 }45 if($page == 1){ 46 $toReturn["wel_office"] = array();47 $wel_office = \wel_office::where('av_for','LIKE','%visit_purpose%')->select('id','cat_title')->get();48 foreach ($wel_office as $key => $value) {49 $toReturn['wel_office'][ $value->id ] = $value->cat_title;50 }51 }52 return $toReturn;53 }54 public function search($keyword,$page = 1){55 return $this->listAll($page,$keyword);56 }57 public function create(){58 if(!$this->panelInit->can( "visitors.add_vis" )){59 exit;60 }61 $visitors = new \visitors();62 if(\Input::has('id')){63 $visitors->id = \Input::get('id');64 }65 $visitors->pass_id = \Input::get('pass_id');66 $visitors->fullName = \Input::get('fullName');67 if(\Input::has('phoneNo')){68 $visitors->phoneNo = \Input::get('phoneNo');69 }70 if(\Input::has('email')){71 $visitors->email = \Input::get('email');72 }73 $visitors->id_pass_id = \Input::get('id_pass_id');74 if(\Input::has('no_pers')){75 $visitors->no_pers = \Input::get('no_pers');76 }77 $visitors->usr_type = \Input::get('usr_type');78 if(\Input::has('student_ser')){79 $visitors->student = \Input::get('student_ser');80 }81 if(\Input::has('std_relation')){82 $visitors->std_relation = \Input::get('std_relation');83 }84 if(\Input::has('comp_name')){85 $visitors->comp_name = \Input::get('comp_name');86 }87 if(\Input::has('to_meet_ser')){88 $visitors->to_meet = \Input::get('to_meet_ser');89 }90 $visitors->purpose = \Input::get('purpose'); 91 if(\Input::has('check_in')){92 93 $check_in = \Input::get('check_in');94 if(!is_array($check_in)){95 $check_in = json_decode($check_in,true);96 }97 $check_in["ts"] = $this->panelInit->date_to_unix($check_in["date"]) + ( $check_in["hour"] * 60 * 60 ) + ( $check_in["min"] * 60 );98 if($check_in["ampm"] == "pm"){99 $check_in["ts"] += (12 * 60 * 60);100 }101 $visitors->check_in = json_encode($check_in);102 }103 if(\Input::has('check_out')){104 105 $check_out = \Input::get('check_out');106 if(!is_array($check_out)){107 $check_out = json_decode($check_out,true);108 }109 if(count($check_out) == 4 && $check_out["date"] != "" && $check_out["hour"] != "" && $check_out["min"] != "" && $check_out["ampm"] != ""){110 $check_out["ts"] = $this->panelInit->date_to_unix($check_out["date"]) + ( $check_out["hour"] * 60 * 60 ) + ( $check_out["min"] * 60 );111 if($check_out["ampm"] == "pm"){112 $check_out["ts"] += (12 * 60 * 60);113 }114 $visitors->check_out = json_encode($check_out);115 }116 }117 118 if (\Input::hasFile('docs')) {119 $fileInstance = \Input::file('docs');120 if(!$this->panelInit->validate_upload($fileInstance)){121 return $this->panelInit->apiOutput(false,$this->panelInit->language['add_vis'],"Sorry, This File Type Is Not Permitted For Security Reasons ");122 }123 $newFileName = uniqid().".".$fileInstance->getClientOriginalExtension();124 $fileInstance->move('uploads/visitors/',$newFileName);125 $visitors->docs = $newFileName;126 }127 if(\Input::has('visit_notes')){128 $visitors->visit_notes = \Input::get('visit_notes');129 }130 $visitors->save();131 return $this->panelInit->apiOutput(true,$this->panelInit->language['add_vis'],$this->panelInit->language['vis_added']);132 }133 public function fetch($id){134 if(!$this->panelInit->can( "visitors.edit_vis" )){135 exit;136 }137 $visitors = \visitors::select('id','pass_id','fullName','phoneNo','email','id_pass_id','no_pers','usr_type','student','std_relation','comp_name','to_meet','purpose','check_in','check_out','docs','visit_notes')->where('id',$id)->first()->toArray();138 $visitors['student'] = json_decode($visitors['student'],true);139 $visitors['to_meet'] = json_decode($visitors['to_meet'],true);140 if(!is_array($visitors['to_meet'])){141 $visitors['to_meet'] = array();142 }143 $visitors['check_in'] = json_decode($visitors['check_in']);144 $visitors['check_out'] = json_decode($visitors['check_out']);145 146 return $visitors;147 }148 public function view($id){149 if(!$this->panelInit->can( "visitors.View" )){150 exit;151 }152 $visitors = \visitors::where('id',$id)->select('id','pass_id','fullName','phoneNo','email','id_pass_id','no_pers','usr_type','student','std_relation','comp_name','to_meet','purpose','check_in','check_out','docs','visit_notes')->first()->toArray();153 $visitors['student'] = json_decode($visitors['student'],true);154 $visitors['to_meet'] = json_decode($visitors['to_meet'],true);155 $visitors['check_in'] = json_decode($visitors['check_in']);156 $visitors['check_out'] = json_decode($visitors['check_out']);157 158 return $visitors;159 }160 public function edit($id){161 if(!$this->panelInit->can( "visitors.edit_vis" )){162 exit;163 }164 $visitors = \visitors::find($id);165 if(\Input::has('id')){166 $visitors->id = \Input::get('id');167 }168 $visitors->pass_id = \Input::get('pass_id');169 $visitors->fullName = \Input::get('fullName');170 if(\Input::has('phoneNo')){171 $visitors->phoneNo = \Input::get('phoneNo');172 }173 if(\Input::has('email')){174 $visitors->email = \Input::get('email');175 }176 $visitors->id_pass_id = \Input::get('id_pass_id');177 if(\Input::has('id_pass_id')){178 $visitors->no_pers = \Input::get('no_pers');179 }180 $visitors->usr_type = \Input::get('usr_type');181 if(\Input::has('student_ser')){182 $visitors->student = \Input::get('student_ser');183 }184 if(\Input::has('std_relation')){185 $visitors->std_relation = \Input::get('std_relation');186 }187 if(\Input::has('comp_name')){188 $visitors->comp_name = \Input::get('comp_name');189 }190 if(\Input::has('to_meet_ser')){191 $visitors->to_meet = \Input::get('to_meet_ser');192 }193 $visitors->purpose = \Input::get('purpose'); 194 if(\Input::has('check_in')){195 196 $check_in = \Input::get('check_in');197 if(!is_array($check_in)){198 $check_in = json_decode($check_in,true);199 }200 $check_in["ts"] = $this->panelInit->date_to_unix($check_in["date"]) + ( $check_in["hour"] * 60 * 60 ) + ( $check_in["min"] * 60 );201 if($check_in["ampm"] == "pm"){202 $check_in["ts"] += (12 * 60 * 60);203 }204 $visitors->check_in = json_encode($check_in);205 }206 if(\Input::has('check_out')){207 208 $check_out = \Input::get('check_out');209 if(!is_array($check_out)){210 $check_out = json_decode($check_out,true);211 }212 if(is_array($check_out) && count($check_out) == 4 && $check_out["date"] != "" && $check_out["hour"] != "" && $check_out["min"] != "" && $check_out["ampm"] != ""){213 $check_out["ts"] = $this->panelInit->date_to_unix($check_out["date"]) + ( $check_out["hour"] * 60 * 60 ) + ( $check_out["min"] * 60 );214 if($check_out["ampm"] == "pm"){215 $check_out["ts"] += (12 * 60 * 60);216 }217 $visitors->check_out = json_encode($check_out);218 }219 }220 221 if (\Input::hasFile('docs')) {222 $fileInstance = \Input::file('docs');223 if(!$this->panelInit->validate_upload($fileInstance)){224 return $this->panelInit->apiOutput(false,$this->panelInit->language['edit_vis'],"Sorry, This File Type Is Not Permitted For Security Reasons ");225 }226 if($visitors->docs != ""){227 @unlink("uploads/visitors/".$visitors->docs);228 }229 $newFileName = uniqid().".".$fileInstance->getClientOriginalExtension();230 $fileInstance->move('uploads/visitors/',$newFileName);231 $visitors->docs = $newFileName;232 }233 if(\Input::has('visit_notes')){234 $visitors->visit_notes = \Input::get('visit_notes');235 }236 $visitors->save();237 return $this->panelInit->apiOutput(true,$this->panelInit->language['edit_vis'],$this->panelInit->language['vis_mod']);238 }239 240 public function delete($id){241 if(!$this->panelInit->can( "visitors.del_vis" )){242 exit;243 }244 if ( $postDelete = \visitors::where('id', $id)->first() ){245 if($postDelete->docs != ""){ @unlink('uploads/visitors/'.$postDelete->docs); }246 247 $postDelete->delete();248 return $this->panelInit->apiOutput(true,$this->panelInit->language['del_vis'],$this->panelInit->language['vis_deleted']);249 }else{250 return $this->panelInit->apiOutput(true,$this->panelInit->language['del_vis'],$this->panelInit->language['vis_not_exist']);251 }252 }253 public function download($id){254 if(!$this->panelInit->can( "visitors.Download" )){255 exit;256 }257 $toReturn = \visitors::where('id',$id)->select("id","docs","pass_id")->first();258 if(file_exists("uploads/visitors/".$toReturn->docs)){259 $fileName = preg_replace('/[^a-zA-Z0-9-_\.]/','',$toReturn->pass_id). "." .pathinfo($toReturn->docs, PATHINFO_EXTENSION);260 header("Content-Type: application/force-download");261 header("Content-Disposition: attachment; filename=" . $fileName);262 echo file_get_contents("uploads/visitors/".$toReturn->docs);263 }else{264 echo "<br/><br/><br/><br/><br/><center>File not exist, Please contact site administrator to reupload it again.</center>";265 }266 exit;267 }268 public function checkout($id){269 if(!$this->panelInit->can( "visitors.edit_vis" )){270 exit;271 }272 $visitors = \visitors::find($id);273 if(\Input::has('check_out')){274 275 $check_out = \Input::get('check_out');276 if(!is_array($check_out)){277 $check_out = json_decode($check_out,true);278 }279 if(count($check_out) == 4 && $check_out["date"] != "" && $check_out["hour"] != "" && $check_out["min"] != "" && $check_out["ampm"] != ""){280 $check_out["ts"] = $this->panelInit->date_to_unix($check_out["date"]) + ( $check_out["hour"] * 60 * 60 ) + ( $check_out["min"] * 60 );281 if($check_out["ampm"] == "pm"){282 $check_out["ts"] += (12 * 60 * 60);283 }284 $visitors->check_out = json_encode($check_out);285 }286 }287 $visitors->save();288 return $this->panelInit->apiOutput(true,$this->panelInit->language['edit_vis'],$this->panelInit->language['vis_mod']);289 }290 public function export($type){291 if(!$this->panelInit->can( "visitors.Export" )){292 exit;293 }294 $wel_office = array();295 $wel_office_tmp = \wel_office::where('av_for','LIKE','%visit_purpose%')->select('id','cat_title')->get();296 foreach ($wel_office_tmp as $key => $value) {297 $wel_office[ $value->id ] = $value->cat_title;298 }299 $header = array ($this->panelInit->language["pass_id"],$this->panelInit->language["visitor"],$this->panelInit->language["id_pass"],$this->panelInit->language["no_pers"],$this->panelInit->language["usr_typ"],$this->panelInit->language["to_meet"],$this->panelInit->language["purpose"],$this->panelInit->language["chkin"],$this->panelInit->language["chkout"],$this->panelInit->language["Notes"]);300 $data = array();301 $visitors = \visitors::select('pass_id','fullName','phoneNo','email','id_pass_id','no_pers','usr_type','student','comp_name','to_meet','purpose','check_in','check_out','visit_notes')->get()->toArray();302 foreach ($visitors as $value) {303 $student = json_decode($value['student'],true);304 $value['student'] = "";305 if(is_array($student)){306 foreach ($student as $key_ => $value_) {307 $value['student'] .= $value_['user'].PHP_EOL;308 }309 }310 $to_meet = json_decode($value['to_meet'],true);311 $value['to_meet'] = "";312 if(is_array($to_meet)){313 foreach ($to_meet as $key_ => $value_) {314 $value['to_meet'] .= $value_['user'].PHP_EOL;315 }316 }317 $check_in = json_decode($value['check_in'],true);318 $value['check_in'] = "";319 if(is_array($check_in) AND isset($check_in['date']) ){320 $value['check_in'] = $check_in['date']." ".$check_in['hour'].":".$check_in['min']." ".$check_in['ampm'];321 }322 $check_out = json_decode($value['check_out'],true);323 $value['check_out'] = "";324 if(is_array($check_out) AND isset($check_out['date']) ){325 $value['check_out'] = $check_out['date']." ".$check_out['hour'].":".$check_out['min']." ".$check_out['ampm'];326 }327 $data[] = array ($value['pass_id'],$value['fullName'].PHP_EOL.$value['phoneNo'].PHP_EOL.$value['email'],$value['id_pass_id'],$value['no_pers'],$value['usr_type'] .PHP_EOL.($value['usr_type'] == 'parent'?$value['student']:$value['comp_name']),$value['to_meet'],(isset($wel_office[$value['purpose']])?$wel_office[$value['purpose']]:""),$value['check_in'],$value['check_out'],$value['visit_notes']);328 }329 330 if($type == "excel"){331 $xls_data = array();332 $xls_data[] = $header;333 foreach($data as $value){334 $xls_data[] = $value;335 }336 \Excel::create("visitors-Sheet", function($excel) use($xls_data) {337 // Set the title338 $excel->setTitle($this->panelInit->language["visitors"]);339 // Chain the setters340 $excel->setCreator("OraSchool")->setCompany("SolutionsBricks");341 $excel->sheet($this->panelInit->language["visitors"], function($sheet) use($xls_data) {342 $sheet->freezeFirstRow();343 $sheet->getStyle('A1')->getAlignment()->setWrapText(true);344 $sheet->fromArray($xls_data);345 });346 })->download("xls");347 }348 if($type == "pdf"){349 $doc_details = array(350 "title" => $this->panelInit->language["visitors"],351 "author" => $this->data["panelInit"]->settingsArray["siteTitle"],352 "topMarginValue" => 10,353 "orientation" => "L"354 );355 if( $this->panelInit->isRTL == "1" ){356 $doc_details["is_rtl"] = true;357 }358 $pdfbuilder = new \PdfBuilder($doc_details);359 $content = "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\"><thead><tr>";360 foreach ($header as $value) {361 $content .="<th style='width:15%;border: solid 1px #000000; padding:2px;'>".$value."</th>";362 }363 364 $content .="</tr></thead><tbody>";365 foreach($data as $row)366 {367 $content .= "<tr>";368 foreach($row as $col){369 $content .="<td>".$col."</td>";370 }371 $content .= "</tr>";372 }373 $content .= "</tbody></table>";374 $pdfbuilder->table($content, array("border" => "0","align"=>"") );375 $pdfbuilder->output("visitors.pdf");376 }377 }378 public function searchUser($keyword){379 if(!$this->panelInit->can( array("visitors.edit_vis","visitors.add_vis") )){380 exit;381 }382 $users_list = \User::where(function($query) use ($keyword){383 $query->where("fullName","like","%".$keyword."%")->orWhere("username","like","%".$keyword."%")->orWhere("email","like","%".$keyword."%");384 })->get();385 $retArray = array();386 foreach ($users_list as $user) {387 $retArray[$user->id] = array("id"=>$user->id,"name"=>$user->fullName,"email"=>$user->email);388 }389 return $retArray;390 }391}...

Full Screen

Full Screen

SAttendanceController.php

Source:SAttendanceController.php Github

copy

Full Screen

1<?php2namespace App\Http\Controllers;3class SAttendanceController extends Controller {4 var $data = array();5 var $panelInit ;6 var $layout = 'dashboard';7 public function __construct(){8 if(app('request')->header('Authorization') != "" || \Input::has('token')){9 $this->middleware('jwt.auth');10 }else{11 $this->middleware('authApplication');12 }13 $this->panelInit = new \DashboardInit();14 $this->data['panelInit'] = $this->panelInit;15 $this->data['breadcrumb']['Settings'] = \URL::to('/dashboard/languages');16 $this->data['users'] = $this->panelInit->getAuthUser();17 if(!isset($this->data['users']->id)){18 return \Redirect::to('/');19 }20 }21 public function listAttendance(){22 if(!$this->panelInit->can( array("staffAttendance.takeAttendance","staffAttendance.attReport") )){23 exit;24 }25 $toReturn = array();26 $toReturn['teachers'] = array();27 $studentArray = \User::whereIn('role',array('teacher','employee'));28 if($this->data['panelInit']->settingsArray['teachersSort'] != ""){29 $studentArray = $studentArray->orderByRaw($this->data['panelInit']->settingsArray['teachersSort']);30 }31 $studentArray = $studentArray->get();32 $attendanceList = array();33 $vacationList = array();34 $attendanceArray = \attendance::where('date',$this->panelInit->date_to_unix(\Input::get('attendanceDay')))->get();35 foreach ($attendanceArray as $sAttendance) {36 $attendanceList[$sAttendance->studentId]['attendance'] = $sAttendance->status;37 $attendanceList[$sAttendance->studentId]['attNotes'] = $sAttendance->attNotes;38 $attendanceList[$sAttendance->studentId]['in_time'] = $sAttendance->in_time;39 $attendanceList[$sAttendance->studentId]['out_time'] = $sAttendance->out_time;40 if($this->data['panelInit']->settingsArray['sAttendanceInOut'] == 1 && \Input::has('InOut')){41 if(\Input::get('InOut') == "in" && $sAttendance->in_time != ""){42 $check_in = explode(":", $sAttendance->in_time);43 $check_in[1] = explode(" ", $check_in[1]);44 $attendanceList[$sAttendance->studentId]['check_in']['hour'] = $check_in[0];45 $attendanceList[$sAttendance->studentId]['check_in']['min'] = $check_in[1][0];46 $attendanceList[$sAttendance->studentId]['check_in']['ampm'] = $check_in[1][1];47 }48 if(\Input::get('InOut') == "out" && $sAttendance->out_time != ""){49 $check_out = explode(":", $sAttendance->out_time);50 $check_out[1] = explode(" ", $check_out[1]);51 $attendanceList[$sAttendance->studentId]['check_out']['hour'] = $check_out[0];52 $attendanceList[$sAttendance->studentId]['check_out']['min'] = $check_out[1][0];53 $attendanceList[$sAttendance->studentId]['check_out']['ampm'] = $check_out[1][1];54 }55 }56 }57 $vacationArray = \vacation::where('vacDate',$this->panelInit->date_to_unix(\Input::get('attendanceDay')))->where('acYear',$this->panelInit->selectAcYear)->whereIn('role',array('teacher','employee'))->get();58 foreach ($vacationArray as $vacation) {59 $vacationList[$vacation->userid] = $vacation->acceptedVacation;60 }61 $i = 0;62 foreach ($studentArray as $stOne) {63 $toReturn['teachers'][$i] = array('name'=>$stOne->fullName,'id'=>$stOne->id,'attendance'=>'');64 if(isset($attendanceList[$stOne->id])){65 $toReturn['teachers'][$i]['attendance'] = $attendanceList[$stOne->id]['attendance'];66 $toReturn['teachers'][$i]['attNotes'] = $attendanceList[$stOne->id]['attNotes'];67 if($this->data['panelInit']->settingsArray['sAttendanceInOut'] == 1){68 if(isset($attendanceList[$stOne->id]['check_in'])){69 $toReturn['teachers'][$i]['check_in'] = $attendanceList[$stOne->id]['check_in'];70 }71 if(isset($attendanceList[$stOne->id]['check_out'])){72 $toReturn['teachers'][$i]['check_out'] = $attendanceList[$stOne->id]['check_out'];73 }74 }75 }else{76 if($this->data['panelInit']->settingsArray['sAttendanceInOut'] == 1){77 $toReturn['teachers'][$i]['no_in_time'] = true;78 }79 }80 if(isset($vacationList[$stOne->id])){81 $toReturn['teachers'][$i]['vacation'] = true;82 $toReturn['teachers'][$i]['vacationStat'] = $vacationList[$stOne->id];83 }84 $i ++;85 }86 if($this->data['panelInit']->settingsArray['sAttendanceInOut'] == 1){87 $toReturn['InOut'] = \Input::get('InOut');88 }89 return json_encode($toReturn);90 }91 public function saveAttendance(){92 if(!$this->panelInit->can( array("staffAttendance.takeAttendance") )){93 exit;94 }95 96 $attendanceList = array();97 $attendanceArray = \attendance::where('date',$this->panelInit->date_to_unix(\Input::get('attendanceDay')))->get();98 foreach ($attendanceArray as $stAttendance) {99 $attendanceList[$stAttendance->studentId] = $stAttendance->status;100 }101 $vacationArray = array();102 $vacationList = \vacation::where('vacDate',$this->panelInit->date_to_unix(\Input::get('attendanceDay')))->where('acYear',$this->panelInit->selectAcYear)->whereIn('role',array('teacher','employee'))->get();103 foreach ($vacationList as $vacation) {104 $vacationArray[$vacation->userid] = $vacation->id;105 }106 $teachers_list = array();107 $attendance_list = array();108 $stAttendance = \Input::get('stAttendance');109 foreach($stAttendance as $key => $value){110 if(isset($value['attendance']) AND strlen($value['attendance']) > 0){111 $teachers_list[] = $value['id'];112 $attendance_list[$value['id']] = $value['attendance'];113 if(!isset($attendanceList[$value['id']])){114 $attendanceN = new \attendance();115 $attendanceN->classId = 0;116 $attendanceN->date = $this->panelInit->date_to_unix(\Input::get('attendanceDay'));117 $attendanceN->studentId = $value['id'];118 $attendanceN->status = $value['attendance'];119 $attendanceN->subjectId = 0;120 if(isset($value['attNotes'])){121 $attendanceN->attNotes = $value['attNotes'];122 }123 if($this->data['panelInit']->settingsArray['sAttendanceInOut'] == 1 && \Input::has('InOut') && \Input::get('InOut') == "in" && isset($value['check_in']) && count($value['check_in']) == 3){124 $attendanceN->in_time = $value['check_in']['hour'].":".$value['check_in']['min']." ".$value['check_in']['ampm'];125 }126 if($this->data['panelInit']->settingsArray['sAttendanceInOut'] == 1 && \Input::has('InOut') && \Input::get('InOut') == "out" && isset($value['check_out']) && count($value['check_out']) == 3){127 $attendanceN->out_time = $value['check_out']['hour'].":".$value['check_out']['min']." ".$value['check_out']['ampm'];128 }129 $attendanceN->save();130 }else{131 $attendanceN = \attendance::where('studentId',$value['id'])->where('date',$this->panelInit->date_to_unix(\Input::get('attendanceDay')))->first();132 $attendanceN->status = $value['attendance'];133 $attendanceN->subjectId = 0;134 if(isset($value['attNotes'])){135 $attendanceN->attNotes = $value['attNotes'];136 }137 if($this->data['panelInit']->settingsArray['sAttendanceInOut'] == 1 && \Input::has('InOut') && \Input::get('InOut') == "in" && isset($value['check_in']) && count($value['check_in']) == 3){138 $attendanceN->in_time = $value['check_in']['hour'].":".$value['check_in']['min']." ".$value['check_in']['ampm'];139 }140 if($this->data['panelInit']->settingsArray['sAttendanceInOut'] == 1 && \Input::has('InOut') && \Input::get('InOut') == "out" && isset($value['check_out']) && count($value['check_out']) == 3){141 $attendanceN->out_time = $value['check_out']['hour'].":".$value['check_out']['min']." ".$value['check_out']['ampm'];142 }143 $attendanceN->save();144 }145 }146 }147 //Send Push Notifications148 $tokens_list = array();149 $user_list = \User::whereIn('role',array('teacher','employee'))->whereIn('id',$teachers_list)->select('id','firebase_token')->get();150 151 foreach ($user_list as $value) {152 if($value['firebase_token'] != ""){153 $tokens_list[ $value['id'] ] = $value['firebase_token']; 154 }155 }156 $absentStatus = array();157 $absentStatus[0] = $this->panelInit->language['Absent'];158 $absentStatus[1] = $this->panelInit->language['Present'];159 $absentStatus[2] = $this->panelInit->language['Late'];160 $absentStatus[3] = $this->panelInit->language['LateExecuse'];161 if(count($tokens_list) > 0){162 foreach ($tokens_list as $key => $value) {163 if(isset($absentStatus[ $attendance_list[$key] ])){164 $this->panelInit->send_push_notification($value,$this->panelInit->language['yrAttIs']." : ".$absentStatus[ $attendance_list[$key] ]." - ".$this->panelInit->language['Date']." :".\Input::get('attendanceDay'),$this->panelInit->language['staffAttendance']); 165 }166 }167 }168 return $this->panelInit->apiOutput(true,"Attendance",$this->panelInit->language['attendanceSaved'] );169 }170 public function reportAttendance(){171 if(!$this->panelInit->can( array("staffAttendance.attReport") )){172 exit;173 }174 175 $toReturn = array();176 //Prepare users list177 $toReturn['employees'] = array();178 $student_ids = array();179 $studentArray = \User::whereIn('role',array('teacher','employee'))->where('activated','1');180 if($this->data['panelInit']->settingsArray['teachersSort'] != ""){181 $studentArray = $studentArray->orderByRaw($this->data['panelInit']->settingsArray['teachersSort']);182 }183 $studentArray = $studentArray->get();184 foreach ($studentArray as $key => $value) {185 $toReturn['employees'][$value->id] = array("id"=>$value->id,"fullName"=>$value->fullName,"precentage"=>array("0"=>0,"1"=>0,"2"=>0,"3"=>0),"attendance"=>array(),"vacation"=>array());186 $student_ids[] = $value->id;187 }188 $toReturn['date_range'] = $this->panelInit->date_ranges(\Input::get('attendanceDayFrom'),\Input::get('attendanceDayTo'));189 //Prepare attendance List190 $attendanceN = \attendance::where('date','>=',$this->panelInit->date_to_unix(\Input::get('attendanceDayFrom')))->where('date','<=',$this->panelInit->date_to_unix(\Input::get('attendanceDayTo')))->whereIn('studentId',$student_ids)->get();191 foreach ($attendanceN as $key => $value) {192 if(isset($toReturn['employees'][$value->studentId])){193 if(!isset($toReturn['employees'][$value->studentId]['attendance'][$value->date])){194 $toReturn['employees'][$value->studentId]['attendance'][$value->date] = array();195 }196 $toReturn['employees'][$value->studentId]['attendance'][$value->date]['status'] = $value->status;197 $toReturn['employees'][$value->studentId]['attendance'][$value->date]['attNotes'] = $value->attNotes;198 if($this->data['panelInit']->settingsArray['sAttendanceInOut'] == 1){199 if($value->in_time != ""){200 $toReturn['employees'][$value->studentId]['attendance'][$value->date]['in_time'] = $value->in_time; 201 }202 if($value->out_time != ""){203 $toReturn['employees'][$value->studentId]['attendance'][$value->date]['out_time'] = $value->out_time; 204 }205 }206 }207 }208 if(count($student_ids) > 0){209 $vacationArray = \vacation::where('vacDate','>=',$this->panelInit->date_to_unix(\Input::get('attendanceDayFrom')))->where('vacDate','<=',$this->panelInit->date_to_unix(\Input::get('attendanceDayTo')))->whereIn('userid',$student_ids)->get();210 foreach ($vacationArray as $key => $value) {211 if(isset($toReturn['employees'][$value->userid])){212 $toReturn['employees'][$value->userid]['vacation'][$value->vacDate] = $value->acceptedVacation;213 }214 }215 }216 217 foreach ($toReturn['employees'] as $key => $value) {218 $total = 0;219 $attendance_perc = array("0"=>0,"1"=>0,"2"=>0,"3"=>0);220 foreach ($toReturn['employees'][$key]['attendance'] as $key_ => $value_) {221 if(!isset($attendance_perc[$value_['status']])){222 $attendance_perc[$value_['status']] = 0;223 }224 $attendance_perc[$value_['status']]++;225 $total ++;226 }227 if($total == 0){228 continue;229 }230 $toReturn['employees'][$key]['precentage'][0] = round(($attendance_perc[0] / $total)*100,1);231 $toReturn['employees'][$key]['precentage'][1] = round(($attendance_perc[1] / $total)*100,1);232 $toReturn['employees'][$key]['precentage'][2] = round(($attendance_perc[2] / $total)*100,1);233 $toReturn['employees'][$key]['precentage'][3] = round(($attendance_perc[3] / $total)*100,1);234 }235 return $toReturn;236 }237}...

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1$obj = new out;2$obj->init();3$obj = new out;4$obj->init();5$obj = new out;6$obj->init();7$obj = new out;8$obj->init();9$obj = new out;10$obj->init();11$obj = new out;12$obj->init();13$obj = new out;14$obj->init();15$obj = new out;16$obj->init();17$obj = new out;18$obj->init();19$obj = new out;20$obj->init();21$obj = new out;22$obj->init();23$obj = new out;24$obj->init();25$obj = new out;26$obj->init();27$obj = new out;28$obj->init();29$obj = new out;30$obj->init();31$obj = new out;32$obj->init();33$obj = new out;34$obj->init();35$obj = new out;36$obj->init();37$obj = new out;38$obj->init();

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1$test = new Test();2$test->init();3$test = new Test();4$test->init();5$test = new Test();6$test->init();7$test = new Test();8$test->init();9$test = new Test();10$test->init();11$test = new Test();12$test->init();13$test = new Test();14$test->init();15$test = new Test();16$test->init();17$test = new Test();18$test->init();19$test = new Test();20$test->init();21$test = new Test();22$test->init();23$test = new Test();24$test->init();25$test = new Test();26$test->init();27$test = new Test();28$test->init();29$test = new Test();30$test->init();31$test = new Test();32$test->init();33$test = new Test();34$test->init();35$test = new Test();36$test->init();

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1$obj = new Myclass;2$obj->init();3$obj = new Myclass;4$obj->init();5$obj = new Myclass;6$obj->init();7$obj = new Myclass;8$obj->init();9$obj = new Myclass;10$obj->init();11$obj = new Myclass;12$obj->init();13$obj = new Myclass;14$obj->init();15$obj = new Myclass;16$obj->init();17$obj = new Myclass;18$obj->init();19$obj = new Myclass;20$obj->init();21$obj = new Myclass;22$obj->init();23$obj = new Myclass;24$obj->init();25$obj = new Myclass;26$obj->init();27$obj = new Myclass;28$obj->init();29$obj = new Myclass;30$obj->init();31$obj = new Myclass;32$obj->init();33$obj = new Myclass;34$obj->init();35$obj = new Myclass;36$obj->init();37$obj = new Myclass;38$obj->init();

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1$foo = new foo();2$foo->init();3$foo = new foo();4$foo->init();5$foo = new foo();6$foo->init();7$foo = new foo();8$foo->init();9$foo = new foo();10$foo->init();11$foo = new foo();12$foo->init();13$foo = new foo();14$foo->init();15$foo = new foo();16$foo->init();17$foo = new foo();18$foo->init();19$foo = new foo();20$foo->init();21$foo = new foo();22$foo->init();23$foo = new foo();24$foo->init();25$foo = new foo();26$foo->init();27$foo = new foo();28$foo->init();29$foo = new foo();30$foo->init();31$foo = new foo();32$foo->init();33$foo = new foo();34$foo->init();35$foo = new foo();36$foo->init();

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1$obj = new out();2$obj->init();3$obj->display();4$obj = new out();5$obj->init();6$obj->display();7$obj = new out();8$obj->init();9$obj->display();10$obj = new out();11$obj->init();12$obj->display();13$obj = new out();14$obj->init();15$obj->display();16$obj = new out();17$obj->init();18$obj->display();19$obj = new out();20$obj->init();21$obj->display();22$obj = new out();23$obj->init();24$obj->display();25$obj = new out();26$obj->init();27$obj->display();28$obj = new out();29$obj->init();30$obj->display();31$obj = new out();32$obj->init();33$obj->display();34$obj = new out();35$obj->init();36$obj->display();37$obj = new out();38$obj->init();39$obj->display();40$obj = new out();41$obj->init();42$obj->display();43$obj = new out();44$obj->init();45$obj->display();46$obj = new out();47$obj->init();48$obj->display();49$obj = new out();50$obj->init();51$obj->display();

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1$myobj = new myclass();2$myobj->init();3$myobj = new myclass();4$myobj->init();5include "myclass.php";6$myobj = new myclass();7$myobj->init();8{9 function init()10 {11 echo "I am init method";12 }13}14include "myclass.php";15$myobj = new myclass();16$myobj->init();17include "myclass.php";18$myobj = new myclass();19$myobj->init();

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1$test = new Test();2$test->init();3$test->printHello();4$test = new Test();5$test->init();6$test->printHello();7$test = new Test();8$test->init();9$test->printHello();10$test = new Test();11$test->init();12$test->printHello();13$test = new Test();14$test->init();15$test->printHello();16$test = new Test();17$test->init();18$test->printHello();

Full Screen

Full Screen

init

Using AI Code Generation

copy

Full Screen

1$ob = new out();2$ob->init();3$ob = new out();4$ob->init();5include('out.php');6$ob = new out();7$ob->init();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in out

Trigger init code on LambdaTest Cloud Grid

Execute automation tests with init on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful