Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.25 KB | None | 0 0
  1. class View
  2. {
  3.     public function listar_registros( $query, AbstractAction $action, $paginacao='' )
  4.     {
  5.         $ctrl = getGet('ctrl');
  6.         $ac = getGet('ac');
  7.  
  8.         $order = getGet('order')!='DESC' ? 'DESC' : 'ASC';
  9.  
  10.                    
  11.         $html = '<h2>Bem vindo, <b>'.getSession('nome').'</b></h2>';   
  12.         $html .= '<a href="?ctrl='.$ctrl.'&ac=new" class="additem">Adicionar '.ucfirst( $ctrl ).'</a>';
  13.         $html .= '<table id="lista">';
  14.         $html .= '
  15.             <thead>
  16.                 <tr>
  17.                     <th><input class="check-all" type="checkbox" /></th>
  18.                     <th><a href="?ctrl='.$ctrl.'&ac='.$ac.'&by=id&order='.$order.'">ID</a></th>
  19.                     <th><a href="?ctrl='.$ctrl.'&ac='.$ac.'&by=label&order='.$order.'">Nome</a></th>';
  20.        
  21.         $bool_ths = method_exists( $action, 'ths' );
  22.        
  23.         if( $bool_ths ) $html .= $action->ths();
  24.        
  25.         $html .= '<th>Opções</th>
  26.                 </tr>
  27.             </thead>
  28.             <tfoot>
  29.                 <tr>
  30.                     <td colspan="6">
  31.                         <div class="bulk-actions align-left">
  32.                             <select name="dropdown">
  33.                                 <option value="option1">Escolha uma ação...</option>
  34.                                 <option value="option3">Deletar</option>
  35.                             </select>
  36.                             <a class="button" href="#">Aplicar as selecionadas</a>
  37.                         </div>                     
  38.                         '.$paginacao.'
  39.                     </td>
  40.                 </tr>
  41.             </tfoot>
  42.             <tbody>';
  43.        
  44.         if( $query && $query->num_rows )
  45.         {
  46.             $i=1;
  47.             while( $dados = $query->fetch_object() )
  48.             {
  49.                 $class = $i%2==0 ? ' class="alt-row"' : '';
  50.                
  51.                 $html .= '<tr'.$class.'>
  52.                     <td><input type="checkbox" name="id[]" value="'.$dados->id.'" /></td>
  53.                     <td><a href="?ctrl='.$ctrl.'&ac=view&id='.$dados->id.'">'.$dados->id.'</a></td>
  54.                     <td class="nome"><a href="?ctrl='.$ctrl.'&ac=view&id='.$dados->id.'">'.$dados->label.'</a></td>';
  55.                    
  56.                 if( $bool_ths ) $html .= $action->tds( $dados );
  57.                
  58.                 $html .=
  59.                     <td>
  60.                         <!-- Icons -->
  61.                          <a href="?ctrl='.$ctrl.'&ac=view&id='.$dados->id.'" title="Editar"><img src="resources/images/icons/pencil.png" alt="Edit" /></a>
  62.                          <a href="?ctrl='.$ctrl.'&ac=del&id='.$dados->id.'" title="Deletar"><img src="resources/images/icons/cross.png" alt="Delete" /></a>
  63.                     </td>
  64.                 </tr>';
  65.    
  66.                 $i++;
  67.             }
  68.         }
  69.         else
  70.             $html .=  '<tr><td></td><td colspan="3" class="nome">Nenhum cadastro</td></tr>';
  71.            
  72.         $html .= '</tbody></table>';
  73.         echo $html;
  74.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement