<?php
// If it's going to need the database, then it's 
// probably smart to require it before we start.
//error_reporting(0);
require_once("initializer.php");

class OrderNotes extends DatabaseObject {
	
  protected static $table_name="OrderDishNotes";
 
  
  //we will populate this array of attribure dynamically
	//protected static $db_fields = array('id','Username','Privilege','First_Name','Last_Name','Password');
  
  protected static $db_fields;
  protected static $exclu_fields = array ("");

	// public  $id;
	// public $Username;
	// public $Privilege;
	// public $Last_Name;
  // public $First_Name;
  // public $Password;

  public function __construct($options=""){
    if ($options=="Blank") {
      $myFields = static::Get_Object_Fields ();
      foreach($myFields as $field) {
        $this->{$field} = "";
      }
    }

   // unset ($this->id);
    
  }

  //we may need to create an special function 
  ///that will change ItemType_id to id


  public static function saveOrderNote ($OrderDishInfo_id="",$OrderNote="") {
    $note = new self ("Blank");
        //  foreach(  $object as $attribute =>$value){
        //     if(property_exists($note,$attribute) && $attribute != "id" ) {
        //       $note->$attribute = $value;
        //     }  
        //      $note->OrderDishInfo_id =  $orderID  ;
        //      $note->ItemType_id =  $object->id;
        //  }

      $note->OrderDishInfo_id=$OrderDishInfo_id;
      $note->Notes=$OrderNote;
      //unset( $note->id);

      // error_log(print_r("inside note",true));

   // error_log(print_r($note,true));

   //check if this is appStoring

      $note->save();

    // error_log(print_r($object,true));

}


  public static function createProperty( $name, $value ){
     $this->{$name} = $value;
}

  public static function setGetField ($idf) {
    return self::$db_fields['id'] = $idf;
  }


  public static function GetNotes ($OrderDishInfo_id="") {

    $note = self::find_by_sql('SELECT * FROM `OrderDishNotes` WHERE `OrderDishInfo_id` = "'.$OrderDishInfo_id.'"',""  )  ;
   // error_log(print_r( $note->Notes ,true));
//    error_log(print_r( "see note above" ,true));

    return  $note[0]->Notes;
  }
	
	
  public function full_name() {
    if(isset($this->First_Name) && isset($this->Last_Name)) {
      return $this->First_Name . " " . $this->Last_Name;
    } else {
      return "";
    }
  }

  



}

?>