Пример #1
0
 private function get_data($data)
 {
     // get id
     $this->receipt_id = $data['receipt_id'];
     //get the time of receipt
     $this->time = $data['time'];
     // get clients data
     if (is_null($data['clients'])) {
         $this->clients = null;
     } else {
         $this->clients = new Customer();
         $this->clients->get_data_from_array($data['clients']);
     }
     //get receiver data
     if (is_null($data['receiver'])) {
         $this->receiver = null;
     } else {
         $this->receiver = new Employee();
         $this->receiver->get_data_from_array($data['receiver']);
     }
     //get list of product
     $list_data_product = $data['list_product'];
     // for each value in data list product, push into the list product
     foreach ($list_data_product as $value) {
         //get the product factory to get the right product object type
         $product = ProductFactory::create_product($value);
         //add product to list_product
         $this->add($product);
     }
 }