$SPR = new SPR( $DBH ); $orderby = ( isset( $_GET['orderby'] ) ) ? htmlspecialchars( $_GET['orderby'] ) : "date_started" ; $direction = ( isset( $_GET['direction'] ) ) ? htmlspecialchars( $_GET['direction'] ) : "DESC" ; $max_rec = ( isset( $_GET['max_rec'] ) ) ? htmlspecialchars( $_GET['max_rec'] ) : 10 ; // forms $options=array("date_started" => "Date Started", "manager_id"=>"Started By", "status"=>"Status"); $form_dropdown_orderby = form_select('orderby', $options, $orderby); $options=array("ASC" => "ASC", "DESC"=>"DESC"); $form_dropdown_direction = form_select('direction', $options, $direction); $options=array("10"=>"10", "20"=>"20", "30"=>"30", "40"=>"40"); $form_dropdown_num = form_select('max_rec', $options, $max_rec); $TPL->assign_vars(array( "ORDERBY" => $form_dropdown_orderby, "DIRECTION" => $form_dropdown_direction, "MAXREC" => $form_dropdown_num )); // pagination $offset = ( isset( $_GET['offset'] ) ) ? preg_replace( "/\D/","",$_GET['offset'] ) : 1 ; $total_recs = $SPR->get_total_spr_records(); $url = "index.php?program=spr&action=view_all&orderby=$orderby&direction=$direction&max_rec=$max_rec"; paginate( $offset, $total_recs, $max_rec, $url); if( $sprs = $SPR->get_all( $offset-1, $max_rec, $orderby, $direction ) ) { foreach( $sprs as $spr) { $TPL->assign_block_vars("SPR", array( "DATE_STARTED" => date("m/d/Y h:i:s a", $spr['date_started']), "REALNAME" => $spr['realname'], "ID" => $spr['id'], "MGR_ID" => $spr['manager_id'], "STATUS" => $SPR_CONFIG['status'][$spr['status']] )); } }