function add($document)
 {
     if (!$this->newFile) {
         throw new LogicException('Missing file');
     }
     $this->db->transaction_begin();
     $document['name'] = $this->newFile->getOriginalName();
     $receipt = parent::add($document);
     $filePath = $this->generate_filename($receipt['id'], $document['name']);
     $this->newFile->save($filePath);
     // make sure that uploaded images are "web friendly"
     // automatically resize pictures that are too big
     if ($this->db->transaction_commit()) {
         return $receipt;
     }
     throw new UnexpectedValueException('Transaction failed.');
 }
 function add($document)
 {
     if (!$this->newFile) {
         throw new LogicException('Missing file');
     }
     $this->db->transaction_begin();
     $document['name'] = $this->newFile->getOriginalName();
     $receipt = parent::add($document);
     $filePath = $this->generate_filename($receipt['id'], $document['name']);
     $this->newFile->save($filePath);
     // make sure that uploaded images are "web friendly"
     // automatically resize pictures that are too big
     if (preg_match('/(jpg|jpeg|gif|bmp|png)$/i', $this->newFile->getOriginalName())) {
         $config = CreateObject('phpgwapi.config', 'booking');
         $config->read();
         $image_maxwidth = isset($config->config_data['image_maxwidth']) && $config->config_data['image_maxwidth'] ? $config->config_data['image_maxwidth'] : 300;
         $image_maxheight = isset($config->config_data['image_maxheight']) && $config->config_data['image_maxheight'] ? $config->config_data['image_maxheight'] : 300;
         $thumb = new Imagick($filePath);
         $thumb->resizeImage($image_maxwidth, $image_maxheight, Imagick::FILTER_LANCZOS, 1, true);
         $thumb->writeImage($filePath);
         $thumb->clear();
         $thumb->destroy();
     }
     if ($this->db->transaction_commit()) {
         return $receipt;
     }
     throw new UnexpectedValueException('Transaction failed.');
 }
 function add($entry)
 {
     $export_reservations =& $this->get_completed_reservations_for($entry);
     if (!$export_reservations) {
         throw new LogicException('Nothing to export');
     }
     $entry['from_'] = $export_reservations[0]['to_'];
     $entry['to_'] = $export_reservations[count($export_reservations) - 1]['to_'];
     $entry['total_cost'] = $this->calculate_total_cost($export_reservations);
     $entry['total_items'] = count(array_filter($export_reservations, array($this, 'not_free')));
     $this->db->transaction_begin();
     $receipt = parent::add($entry);
     $entry['id'] = $receipt['id'];
     $this->update_completed_reservations_exported_state($entry, $export_reservations);
     if (!$this->db->transaction_commit()) {
         throw new UnexpectedValueException('Transaction failed.');
     }
     return $receipt;
 }
Пример #4
0
 function add($entity)
 {
     return parent::add($this->trim_contacts($entity));
 }
 function add($entry)
 {
     $entry['object_type'] = $this->get_object_type();
     return parent::add($entry);
 }