Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('db.inc.php');
- ini_set("zlib.output_compression", "On");
- ini_set("zlib.outut_compression_level",6);
- // rows qty
- $sql = 'SELECT id FROM repair';
- try{
- $s = $pdo->prepare($sql);
- $s->execute();
- $size = $s->rowCount();
- }catch(PDOException $e){}
- if(!isset($_REQUEST['e'])){
- $_REQUEST['e'] = $size;
- }
- // masks
- $structure['repair'] = 'id:stamp:author:custid:status:content:id01:id02:id03:id04:ptype:brand:model';
- /*
- view.php?q=repair&s=0&e=5
- */
- // output initialization
- $output = '';
- // prepare mask var
- $mask = preg_split('@:@',$structure['repair']);
- // context
- $output .= '<h3>existing repair</h3>';
- $output .= '<div class="well well-small">';
- $output .= '<table class="table table-bordered">';
- $output .= '<thead>';
- $output .= '<tr>';
- for($i = 0; $i < count($mask); $i++){
- switch($mask[$i]){
- case 'id':
- $output .= '<th><i class="icon-tasks"></i> action(s)</th>';
- break;
- case 'stamp':
- $output .= '<th><i class="icon-calendar"></i> start on</th>';
- break;
- case 'author':
- $output .= '<th><i class="icon-user"></i> taken by</th>';
- break;
- case 'custid':
- $output .= '<th><i class="icon-user"></i> customer</th>';
- break;
- case 'status':
- $output .= '<th><i class="icon-tag"></i> status</th>';
- break;
- case 'content':
- $output .= '<th>job description</th>';
- break;
- case 'ptype':
- $output .= '<th>type</th>';
- break;
- default:
- $output .= '<th>'.$mask[$i].'</th>';
- break;
- }
- }
- $output .= '</tr>';
- $output .= '</thead>';
- $output .= '<tbody>';
- try{
- $sql = 'SELECT * FROM repair LIMIT '.$_REQUEST['s'].','.$_REQUEST['e'];
- // $sql = 'SELECT * FROM repair LIMIT :start,:end';
- $s = $pdo->prepare($sql);
- $s->execute();
- if($s->rowCount() > 0){
- while($row = $s->fetch()){
- $data[] = array(
- 'id' => $row['id'],
- 'stamp' => $row['stamp'],
- 'author' => $row['author'],
- 'custid' => $row['custid'],
- 'status' => $row['status'],
- 'content' => $row['content'],
- 'id01' => $row['id01'],
- 'id02' => $row['id02'],
- 'id03' => $row['id03'],
- 'id04' => $row['id04'],
- 'ptype' => $row['ptype'],
- 'brand' => $row['brand'],
- 'model' => $row['model']
- );
- }
- }
- }catch(PDOException $e){}
- if($size > 0){
- for($i = 0; $i < count($data); $i++){
- $output .= '<tr>';
- for($e = 0; $e < count($mask); $e++){
- switch($mask[$e]){
- case 'id':
- $output .= '<td>';
- $output .= '<form action="api.php" method="post">';
- $output .= '<input type="hidden" name="repairid" value="'.$data[$i][$mask[$e]].'">';
- $output .= '<select name="q" class="span8">';
- $output .= '<option value="edit-repair">edit</option>';
- $output .= '<option value="select-repair">select</option>';
- $output .= '<option value="delete-repair">delete</option>';
- $output .= '<option value="view-log">view log</option>';
- $output .= '<option value="archive-repair">archive</option>';
- $output .= '<option value="waiting-status-repair">status:waiting</option>';
- $output .= '<option value="order-status-repair">status:order</option>';
- $output .= '<option value="done-status-repair">status:done</option>';
- $output .= '<option value="called-status-repair">status:called</option>';
- $output .= '</select>';
- $output .= '<button type="submit" class="btn">go</button>';
- $output .= '</form>';
- $output .= '</td>';
- break;
- case 'custid':
- $output .= '<td>';
- /*
- sorting detail regarding the specific client
- */
- $sql = 'SELECT * FROM customer WHERE id = :id LIMIT 1';
- try{
- $s = $pdo->prepare($sql);
- $s->bindValue(':id',$data[$i][$mask[$e]]);
- $s->execute();
- if($s->rowCount() > 0){
- while($row = $s->fetch()){
- $cust = array(
- 'id' => $row['id'],
- 'stamp' => $row['stamp'],
- 'fname' => $row['fname'],
- 'lname' => $row['lname'],
- 'phoneHome' => $row['phoneHome'],
- 'phoneCell' => $row['phoneCell'],
- 'phoneWork' => $row['phoneWork'],
- 'phoneWorkExt' => $row['phoneWorkExt'],
- 'org' => $row['organization']
- );
- }
- }
- }catch(PDOException $e){}
- if(count($cust) > 0){
- $output .= $cust['fname'].' '.$cust['lname'].'<br/>';
- $output .= '<u>phone(s)</u><br/>';
- if($cust['phoneHome'] != '' && !(ctype_space($cust['phoneHome']))){
- $output .= 'home: '.$cust['phoneHome'].'<br/>';
- }
- if($cust['phoneCell'] != '' && !(ctype_space($cust['phoneCell']))){
- $output .= 'cell: '.$cust['phoneCell'].'<br/>';
- }
- if($cust['phoneWork'] != '' && !(ctype_space($cust['phoneWork']))){
- $output .= 'work: '.$cust['phoneWork'].'Ext: '.$cust['phoneWorkExt'].'<br/>';
- }
- if($cust['org'] != '' && !(ctype_space($cust['org']))){
- $output .= 'org: '.$cust['org'];
- }
- }else{
- $output .= 'This client no more exists.';
- }
- $output .= '</td>';
- break;
- case 'ptype':
- $output .= '<td>';
- switch($data[$i][$mask[$e]]){
- case 'laptop':
- $output .= '<td><i class="icon-laptop icon-3x"></i><br/><b>laptop</b></td>';
- break;
- case 'desktop':
- $output .= '<td><i class="icon-desktop icon-3x"></i><br/><b>desktop</b></td>';
- break;
- case 'tabletpc':
- $output .= '<td><i class="icon-tablet icon-3x"></i><br/><b>tablet pc</b></td>';
- break;
- case 'cellphone':
- $output .= '<td><i class="icon-mobile-phone icon-3x"></i><br/><b>cellphone</b></td>';
- break;
- case 'other':
- $output .= '<td><i class="icon-gamepad icon-3x"></i><br/><b>other</b></td>';
- break;
- }
- $output .= '</td>';
- break;
- case 'content':
- $output .= '<td>';
- $output .= wordwrap($data[$i][$mask[$e]],40,'<br/>');
- $output .= '</td>';
- break;
- case 'status':
- $output .= '<td>';
- switch($data[$i][$mask[$e]]){
- case 0:
- $output .= '<span class="status-not-started">not started</span>';
- break;
- case 1:
- $output .= '<span class="status-started">started</span>';
- break;
- case 7:
- $output .= '<span class="status-waiting">waiting</span>';
- break;
- case 8:
- $output .= '<span class="status-order">order</span>';
- break;
- case 9:
- $output .= '<span class="status-done">done</span>';
- break;
- case 10:
- $output .= '<span class="status-called">called</span>';
- break;
- default:
- $output .= $data[$i][$mask[$e]];
- break;
- }
- $output .= '</td>';
- break;
- default:
- $output .= '<td>'.$data[$i][$mask[$e]].'</td>';
- break;
- }
- }
- $output .= '</tr>';
- }
- }else{
- $output .= '<tr>';
- for($f = 0; $f < $data; $f++){
- $output .= '<td>no data</td>';
- }
- $output .= '</tr>';
- }
- $output .= '</tbody>';
- $output .= '</table>';
- $output .= '</div>';
- echo $output;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment