Example #1
0
 public function delete()
 {
     $data = $this->model->getData();
     if ($this->model->hasSingleRecord) {
         $this->_delete($data["id"]);
     } else {
         $toBeDeleted = array();
         foreach ($data as $datum) {
             $toBeDeleted[] = $datum['id'];
         }
         $this->_delete($toBeDeleted);
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function render($viewName, Model $model, NotificationCenter $notificationCenter, $output = true)
 {
     Profile::start('Renderer', 'Generate HTML');
     $templateName = $viewName . '.' . static::$templateFileExtension;
     $dwoo = new Dwoo($this->compiledPath, $this->cachePath);
     $dwoo->getLoader()->addDirectory($this->functionsPath);
     Profile::start('Renderer', 'Create template file.');
     $template = new Dwoo_Template_File($templateName);
     $template->setIncludePath($this->getTemplatesPath());
     Profile::stop();
     Profile::start('Renderer', 'Render');
     $dwooData = new Dwoo_Data();
     $dwooData->setData($model->getData());
     $dwooData->assign('errorMessages', $notificationCenter->getErrors());
     $dwooData->assign('successMessages', $notificationCenter->getSuccesses());
     $this->setHeader('Content-type: text/html', $output);
     // I do never output directly from dwoo to have the possibility to show an error page if there was a render error.
     $result = $rendered = $dwoo->get($template, $dwooData, null, false);
     if ($output) {
         echo $result;
     }
     Profile::stop();
     Profile::stop();
     return $output ? null : $rendered;
 }
Example #3
0
 public function getData($raw = false)
 {
     $data = parent::getData();
     if (!$raw) {
         // Hide the password field
         unset($data['password']);
     }
     // Remove all integer indexed entries
     for ($i = 0; $i < count($data); $i++) {
         unset($data[$i]);
     }
     return $data;
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function render($viewName, Model $model, NotificationCenter $notificationCenter, $output = true)
 {
     Profile::start('Renderer', 'Generate JSON');
     if (strpos($viewName, 'errors/') === 0) {
         $data = array('error' => substr($viewName, strlen('errors/')));
     } else {
         $c = $model->getData(Model::PUBLISHABLE);
         $data = array('content' => count($c) === 0 ? null : $c);
     }
     if (count($notificationCenter->getErrors())) {
         $data['errorMessages'] = $notificationCenter->getErrors();
     }
     if (count($notificationCenter->getSuccesses())) {
         $data['successMessages'] = $notificationCenter->getSuccesses();
     }
     $json = json_encode($data);
     $this->setHeader('Content-type: application/json', $output);
     if ($output) {
         echo $json;
     }
     Profile::stop();
     return $output ? null : $json;
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function render($viewName, Model $model, NotificationCenter $notificationCenter, $output = true)
 {
     Profile::start('Renderer', 'Rendering HTML');
     $templateName = $viewName . '.' . static::$templateFileExtension;
     $loader = new Twig_Loader_Filesystem($this->templatesPath);
     $twig = new Twig_Environment($loader, array('cache' => $this->cachePath));
     foreach ($this->extensions as $extension) {
         $twig->addExtension($extension);
     }
     foreach ($this->globals as $name => $global) {
         $twig->addGlobal($name, $global);
     }
     $twig->addGlobal('notifications', $notificationCenter);
     //    $twig->addGlobal('controller', $);
     $this->setHeader('Content-type: text/html', $output);
     $result = $twig->render($templateName, $model->getData());
     if ($output) {
         echo $result;
     }
     Profile::stop();
     return $output ? null : $rendered;
 }
Example #6
0
<?php

session_start();
error_reporting(0);
ini_set('max_execution_time', 0);
//echo __FILE__;
$site_url = 'http://' . $_SERVER['HTTP_HOST'] . '/jobscraperv2/pdf/';
//$site_url = 'http://'.$_SERVER['HTTP_HOST'].'/jobscrapperv2/jobscrapperv2/pdf/';
$dir = dirname(__FILE__) . '/';
require_once $dir . 'db.php';
require_once $dir . 'model.php';
$model = new Model();
if ($_REQUEST['action'] == 'download_excel') {
    $data = $model->getData();
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=receipts.csv');
    header('Pragma: no-cache');
    $csv = "Ref ID,Name,Ref Date, Total \n";
    foreach ($data as $d) {
        $csv .= 5000 + $d['id'] . ',"' . $d['full_name'] . '",' . $d['ref_date'] . ',' . $d['total'] . "\n";
    }
    echo $csv;
    exit;
} else {
    if ($_REQUEST['action'] == 'logout') {
        session_destroy();
        header('location: index.php?action=login');
    } else {
        if ($_REQUEST['action'] == 'add_receipt') {
            require_once $dir . 'html/add_receipt.php';
Example #7
0
 public function getModelData()
 {
     return $this->model->getData();
 }