Example #1
0
 /**
  * Sends receipt
  * @return bool 
  */
 public function mail()
 {
     $this->read();
     $invoice = new Invoice($this->invoice_id);
     // make e-mail template
     $template = new Template(Configuration::get('base_dir') . DS . 'templates' . DS . 'mail.php');
     $template->replaceFromPHPFile('content', Configuration::get('base_dir') . DS . 'templates' . DS . 'payment-mail.php', array('invoice' => $invoice->read(), 'payment' => $this->toClone()));
     // send e-mail
     $config = Configuration::getInstance();
     $header = "From: {$config['user']['name']} <{$config['user']['email']}>";
     return mail($invoice->client_email, "A payment was made", $template->toString(), $header);
 }
Example #2
0
<?php

chdir('..');
require 'libraries/start.php';
// setup
$message = '';
$config = array();
// save input
if (array_key_exists('config', $_POST) && $_POST['config']) {
    $config = Http::clean($_POST['config'], 'html');
    $errors = find_configuration_errors($config);
    // display errors, if any
    if ($errors) {
        foreach ($errors as $error) {
            $message .= "<p class='error'>{$error}</p>";
        }
    } else {
        Configuration::write($config);
        Configuration::reset();
    }
}
// get config
$config = Configuration::getInstance();
// templating
$t = new Template(Configuration::get('base_dir') . DS . 'templates' . DS . 'base.html');
$t->replace('base_url', Configuration::get('base_url'));
$t->replaceFromPHPFile('content', Configuration::get('base_dir') . DS . 'templates' . DS . 'configuration.html', array('c' => $config));
$t->replace('message', $message);
$t->display();
Example #3
0
<?php

// get base template
$t = new Template(realpath('./templates/base-install.html'));
// create error html
$message = '<p>To start off, please enter some configuration information</p>';
if ($this->getCurrentStep()->getErrors()) {
    $errors = Set::flatten($this->getCurrentStep()->getErrors());
    foreach ($errors as $error) {
        $message .= "<p class='error'>{$error}</p>";
    }
}
// replace
$t->replace('title', 'Install');
$t->replace('base_url', get_base_url('invoices'));
$config = $this->getCurrentStep()->getData();
$t->replaceFromPHPFile('content', realpath('./templates/configuration.html'), array('c' => @$_POST['config']));
$t->replace('message', $message);
// display
$t->display();
Example #4
0
require 'libraries/start.php';
// create app
$app = new App();
$app->setAllowedObjects('invoices', 'payments');
$app->setAllowedActions('create', 'edit', 'validate', 'view', 'publish');
// routing
try {
    $object = Routing::getToken('object');
} catch (Exception $e) {
    $object = 'home';
}
// show home page
if ($object == 'home') {
    $t = new Template('templates/base.html');
    $t->replace('base_url', Configuration::get('base_url'));
    $t->replaceFromFile('content', 'templates/home.html');
    $t->replaceFromPHPFile('invoice-list', 'templates/invoice-list.php');
    $t->display();
    exit;
}
// allowed input
if ($object == 'payments') {
    $app->setOutputFormat('PaymentHtml');
} elseif ($object == 'invoices') {
    $app->setOutputFormat('InvoiceHtml');
} else {
    $app->setOutputFormat('AppFormatHtml');
}
$app->setInputFormat('Html');
// execute
$app->execute();
Example #5
0
 /**
  * 
  * @param array $list 
  */
 protected function editToHtml($invoice)
 {
     // get template
     $template = new Template(Configuration::get('base_dir') . DS . 'templates' . DS . 'base.html');
     $template->replace('base_url', Configuration::get('base_url'));
     // make title
     $title = 'Edit Invoice [' . $invoice->id . ']';
     $template->replace('title', $title);
     $action = $this->getLink() . "/{$invoice->id}/update";
     $template->replaceFromPHPFile('content', Configuration::get('base_dir') . DS . 'templates' . DS . 'invoice-edit.php', array('action' => $action, 'invoice' => $invoice));
     // return
     return $template;
 }