/** * Run the update. */ public function run() { $target_name = (string) $this->module->target; $update_name = $this->normalized_id; $log_prefix = "[{$update_name} {$target_name}] "; $update_reflection = new \ReflectionClass($this); $this->before(); foreach ($update_reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method_reflection) { $method_name = $method_reflection->name; if (strpos($method_name, 'update_') !== 0) { continue; } try { $this->{$method_name}(); echo $log_prefix . \ICanBoogie\titleize(substr($method_name, 7)) . "\n"; } catch (AssertionFailed $e) { continue; } catch (\Exception $e) { echo $log_prefix . "{$method_name} raised the following exception:\n\n " . $e . "\n\n"; } } echo $log_prefix . "Done\n"; }
public function generateInvoice($id) { $modelDevice = new Device($this->db); $device = $modelDevice->findById($id); if ($device === null) { $this->flash->error('Unable to generate invoice!'); return $this->redirect('/devices/view/' . $id); } $modelCustomer = new Customer($this->db); $customer = $modelCustomer->findById($device['customer_id']); if ($customer === null) { $this->flash->error('Unable to generate invoice!'); return $this->redirect('/devices/view/' . $id); } $modelPart = new Part($this->db); $parts = $modelPart->findAllByDeviceId($device['id']); if ($parts === null) { $this->flash->error('Unable to generate invoice!'); return $this->redirect('/devices/view/' . $id); } $infoShop = [$customer['shop'], $customer['shop_periods']]; $infoAddress = [\ICanBoogie\titleize($customer['address']), strtoupper($customer['state']) . ' ' . \ICanBoogie\titleize($customer['zip'])]; $infoStaff = []; if (strlen(trim($customer['room_number'])) > 0) { $infoStaff[] = 'Room #' . $customer['room_number']; } if (strlen(trim($customer['phone_ext'])) > 0) { $infoStaff[] = 'Ext.' . $customer['phone_ext']; } $this->set('now', date('n/j/Y', time())); $this->set('parts', $parts); $this->set('device', $device); $this->set('customer', $customer); $this->set('infoShop', implode(', ', array_filter(array_map('trim', $infoShop), 'strlen'))); $this->set('infoStaff', implode(', ', array_filter(array_map('trim', $infoStaff), 'strlen'))); $this->set('infoAddress', implode(', ', array_filter(array_map('trim', $infoAddress), 'strlen'))); }
public function view($name) { if ($this->shouldLockIfNoPermission('data.view')) { return; } $filename = $this->reportsFolder . DS . 'generated-' . $name . '.txt'; if (is_file($filename)) { if (preg_match('#^(([0-9]+)([a-zA-Z-]*))$#', $name, $matches)) { $item = ['time' => date('F d, Y - g:i A', $matches[2]), 'title' => \ICanBoogie\titleize($matches[3]), 'name' => $matches[1]]; $this->set('item', $item); $this->set('reportData', file_get_contents($filename)); return; } } $this->flash->error('The report was not found!'); return $this->redirect('/reports'); }