Advertisement
algore87

kundenstatus.php

Jan 10th, 2016
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.08 KB | None | 0 0
  1. <?php   // UTF-8 marker äöüÄÖÜ߀
  2. /**
  3.  * Class BlockTemplate for the exercises of the EWA lecture
  4.  * Demonstrates use of PHP including class and OO.
  5.  * Implements Zend coding standards.
  6.  * Generate documentation with Doxygen or phpdoc
  7.  *
  8.  * PHP Version 5
  9.  *
  10.  * @category File
  11.  * @package  Pizzaservice
  12.  * @author   Bernhard Kreling, <b.kreling@fbi.h-da.de>
  13.  * @author   Ralf Hahn, <ralf.hahn@h-da.de>
  14.  * @license  http://www.h-da.de  none
  15.  * @Release  1.2
  16.  * @link     http://www.fbi.h-da.de
  17.  */
  18.  
  19. /**
  20.  * This is a template for classes, which represent div-blocks
  21.  * within a web page. Instances of these classes are used as members
  22.  * of top level classes.
  23.  * The order of methods might correspond to the order of thinking
  24.  * during implementation.
  25.  
  26.  * @author   Bernhard Kreling, <b.kreling@fbi.h-da.de>
  27.  * @author   Ralf Hahn, <ralf.hahn@h-da.de>
  28. */
  29.  
  30. class Kundenstatus       // to do: change name of class
  31. {
  32.     // --- ATTRIBUTES ---
  33.  
  34.     /**
  35.      * Reference to the MySQLi-Database that is
  36.      * accessed by all operations of the class.
  37.      */
  38.     protected $_database = null;
  39.     protected $table = null;
  40.     protected $pizzaArray = [];
  41.     protected $pizzaIdArray = [];
  42.  
  43.    
  44.     // to do: declare reference variables for members
  45.     // representing substructures/blocks
  46.    
  47.     // --- OPERATIONS ---
  48.    
  49.     /**
  50.      * Gets the reference to the DB from the calling page template.
  51.      * Stores the connection in member $_database.
  52.      *
  53.      * @param $database $database is the reference to the DB to be used    
  54.      *
  55.      * @return none
  56.      */
  57.     public function __construct($database)
  58.     {
  59.         $this->_database = $database;
  60.         // to do: instantiate members representing substructures/block
  61.     }
  62.  
  63.     /**
  64.      * Fetch all data that is necessary for later output.
  65.      * Data is stored in an easily accessible way e.g. as associative array.
  66.      *
  67.      * @return none
  68.      */
  69.     protected function getViewData()
  70.     {
  71.         // to do: fetch data for this view from the database
  72.         /** Lade Einträge aus Datenbank nur bei gesetzter Session ID mit benutzer order_id */
  73.         if(isset($_COOKIE["SessionID"])) {
  74.             $order_id = $_COOKIE["SessionID"];
  75.             $this->table = $this->_database->query("SELECT * FROM `BestelltePizza` WHERE `fBestellungID` = {$order_id} AND `Status` < 4 ORDER BY `fBestellungID`, `Status` DESC, `fPizzaName`");
  76.             while (($row = $this->table->fetch_assoc()) != null) {
  77.                 $this->pizzaArray[] = $row;
  78.                 $this->pizzaIdArray[] = $row['PizzaID'];
  79.             }
  80.         }
  81.     }
  82.    
  83.     /**
  84.      * Generates an HTML block embraced by a div-tag with the submitted id.
  85.      * If the block contains other blocks, delegate the generation of their
  86.      * parts of the view to them.
  87.      *
  88.      * @param $id $id is the unique (!!) id to be used as id in the div-tag    
  89.      *
  90.      * @return none
  91.      */
  92.     public function generateView($id = "")
  93.     {
  94.         $this->getViewData();
  95.         if ($id) {
  96.             $id = "id=\"$id\"";
  97.         }
  98.         /* generate one pizza */
  99.         echo "<div $id>\n";
  100.  
  101.  
  102.         foreach ($this->pizzaArray as $row) {
  103.             $pizza = htmlspecialchars($row['fPizzaName']);
  104.             $status = $row['Status'];
  105.             $id = $row['PizzaID'];
  106.  
  107.             echo <<< EOT
  108.     <tr>
  109.         <td>{$pizza}</td>
  110. EOT;
  111.  
  112.             if ($status == 0)
  113.                 echo "<td><label><input type=\"radio\" checked disabled></label></td>";
  114.             else
  115.                 echo "<td><label><input type=\"radio\" disabled></label></td>";
  116.  
  117.             if ($status == 1)
  118.                 echo "<td><label><input type=\"radio\" checked disabled></label></td>";
  119.             else
  120.                 echo "<td><label><input type=\"radio\" disabled></label></td>";
  121.  
  122.             if ($status == 2)
  123.                 echo "<td><label><input type=\"radio\" checked disabled></label></td>";
  124.             else
  125.                 echo "<td><label><input type=\"radio\" disabled></label></td>";
  126.  
  127.             if ($status == 3)
  128.                 echo "<td><label><input type=\"radio\" checked disabled></label></td>";
  129.             else
  130.                 echo "<td><label><input type=\"radio\" disabled></label></td>";
  131.  
  132.  
  133.             echo <<< EOT
  134.     </tr>
  135. EOT;
  136.  
  137.         }
  138.  
  139.         echo "</div>\n";
  140.     }
  141.    
  142.     /**
  143.      * Processes the data that comes via GET or POST i.e. CGI.
  144.      * If this block is supposed to do something with submitted
  145.      * data do it here.
  146.      * If the block contains other blocks, delegate processing of the
  147.      * respective subsets of data to them.
  148.      *
  149.      * @return none
  150.      */
  151.     public function processReceivedData()
  152.     {
  153.         // to do: call processData() for all members
  154.     }
  155. }
  156. // Zend standard does not like closing php-tag!
  157. // PHP doesn't require the closing tag (it is assumed when the file ends).
  158. // Not specifying the closing ? >  helps to prevent accidents
  159. // like additional whitespace which will cause session
  160. // initialization to fail ("headers already sent").
  161. //? >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement