Ejemplo n.º 1
0
 public function formatItems($items, $format, $parameters = null)
 {
     $formattedItems = array();
     foreach ($items as $item) {
         $itemMapper = new ItemMapper($item['uid_owner']);
         $formattedItem = $itemMapper->findById($item['item_source']);
         $formattedItems[] = $formattedItem;
     }
     return $formattedItems;
 }
Ejemplo n.º 2
0
 /**
  * Gets a inventory
  *
  * @return [InventoryEntity]  List of items
  */
 public function getItems()
 {
     $sql = "SELECT * FROM Inventory";
     $stmt = $this->db->query($sql);
     $results = [];
     while ($row = $stmt->fetch()) {
         $inv_item = new InventoryEntity($row);
         $item_mapper = new ItemMapper($this->db);
         $item = $item_mapper->getItemById($inv_item->getId());
         $inv_item->setItem($item);
         $results[] = $inv_item;
     }
     return $results;
 }
Ejemplo n.º 3
0
 /**
  * Returns an singleton instance of this class
  * @return
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new ItemMapper();
     }
     return self::$instance;
 }
Ejemplo n.º 4
0
 function items($items = null)
 {
     if (is_null($items)) {
         //getting items
         if (isset($this->items)) {
             return $this->items;
         } else {
             $this->items = ItemMapper::instance()->find_all_by_sql('feed_id = ' . $this->id());
             return $this->items;
         }
     } else {
         //setting items
         $this->items = $items;
     }
 }
Ejemplo n.º 5
0
echo "  ({$i->parent->item_id}) {$i->parent->item_name}\n";
// one-to-many
$rm = new ResourceMapper($conf['adapter']);
$r = $rm->findOne(1);
echo "Resource ({$r->resource_id}) {$r->resource_name} has " . count($r->availabilities) . " availabilities:\n";
foreach ($r->availabilities as $ra) {
    echo '  (' . $ra->availability_id . ') ' . $ra->resource->resource_name . " on " . strftime('%x %X', $ra->availability_date) . " (" . $ra->availability_hours . " hours)\n";
}
// many-to-one
$ram = new ResourceAvailabilityMapper($conf['adapter']);
$ra = $ram->findOne(1);
echo "Resource Availability ({$ra->availability_id}) " . strftime('%x %X', $ra->availability_date) . " has resource:\n";
echo "  ({$ra->resource->resource_id}) {$ra->resource->resource_name}\n";
// many-to-many
echo "Listing all Items and their Resources:\n\n";
$im = new ItemMapper($conf['adapter']);
foreach ($im->find() as $i) {
    if (count($i->resources)) {
        echo " (" . $i->item_id . ") " . $i->item_name . " has resources:\n";
        foreach ($i->resources as $r) {
            echo '  (' . $r->resource_id . ') ' . $r->resource_name . "\n";
        }
    }
}
echo "\n\nListing all Resources and their Items:\n\n";
$rm = new ResourceMapper($conf['adapter']);
foreach ($rm->find() as $r) {
    if (count($r->items)) {
        echo " (" . $r->resource_id . ") " . $r->resource_name . " has items:\n";
        foreach ($r->items as $i) {
            echo '  (' . $i->item_id . ') ' . $i->item_name . "\n";
Ejemplo n.º 6
0
<?php

/**
 * @package Rdo
 */
require_once './Clotho.php';
$im = new ItemMapper($conf['adapter']);
$dm = new DependencyMapper($conf['adapter']);
$cm = new CalendarMapper($conf['adapter']);
$rm = new ResourceMapper($conf['adapter']);
$ram = new ResourceAvailabilityMapper($conf['adapter']);
$item = $im->create(array('item_name' => 'Test Item', 'item_parent' => 0));
echo get_class($item) . "\n";
$item = $im->create(array('item_name' => 'Test Item 2', 'item_parent' => 0));
echo get_class($item) . "\n";
$item = $im->create(array('item_name' => 'Child Item', 'item_parent' => 1));
echo get_class($item) . "\n";
$dep = $dm->create(array('dependency_type' => 'S', 'dependency_lhs_item' => 1, 'dependency_rhs_item' => 2));
echo get_class($dep) . "\n";
$cal = $cm->create(array('calendar_name' => 'Test Calendar', 'calendar_hoursinday' => 8, 'calendar_hoursinweek' => 40, 'calendar_type' => 'weekly', 'calendar_data' => ''));
echo get_class($cal) . "\n";
$res = $rm->create(array('resource_type' => 'M', 'resource_name' => 'Test Resource', 'resource_base_calendar' => 1));
echo get_class($res) . "\n";
$resavail = $ram->create(array('resource_id' => 1, 'availability_date' => 1121404095, 'availability_hours' => 2));
echo get_class($resavail) . "\n";
Ejemplo n.º 7
0
    $requisitante = Utils::findById($sessao->getVar('id'), 'usuarios', 'id_usuario');
}
if (array_key_exists('save', $_POST)) {
    $dados = array('nome_requisitante' => array('Requisitante'), 'nome_responsavel' => array('Responsável'), 'dt_inicial_emprestimo' => array('Data', 'tipo' => 'data'));
    $validacao = ValidaFormulario($dados);
    if ($validacao === true) {
        $emp = new Emp();
        $emp->setRequisitanteId($sessao->getVar('id'));
        $emp->setUsuarioId($sessao->getVar('usuario')->id_usuario);
        EmpMapper::map($emp, $_POST);
        $date_inicial = Utils::conv_data_to_us($_POST['dt_inicial_emprestimo']) . ' ' . date('H:m:s');
        $emp->setDtInicialEmprestimo($date_inicial);
        if ($sessao->getVar('mat') != null) {
            foreach ($sessao->getVar('mat') as $item) {
                $itemObject = new Item();
                ItemMapper::map($itemObject, $item);
                $emp->addItens($itemObject);
            }
            EmpMapper::insert($emp);
            $sessao->removeVar('mat');
            Flash::addFlash('Empréstimo salvo com sucesso');
            //header('location:index.php?modulo=usuarios&page=visualizar');
        } else {
            Flash::addFlash('Por favor adicione um item.');
        }
    } else {
        Flash::addFlash($validacao);
    }
}
if (array_key_exists('add-mat', $_GET)) {
    $dados = array('item' => array('Item'), 'item_qtd' => array('Qtd', 'tipo' => 'inteiro'));
Ejemplo n.º 8
0
 function mapper()
 {
     return ItemMapper::instance();
 }
Ejemplo n.º 9
0
 public function deleteById($id)
 {
     if ($id == null) {
         return false;
     }
     $stmt = \OCP\DB::prepare('DELETE FROM ' . self::tableName . ' WHERE id = ? AND user_id = ?');
     $result = $stmt->execute(array($id, $this->userid));
     $itemMapper = new ItemMapper();
     //TODO: handle the value that the execute returns
     $itemMapper->deleteAll($id);
     return true;
 }
Ejemplo n.º 10
0
 /**
  * Initializes DB mappers
  *
  * @param object $config
  * @param object $args
  * @return
  */
 function __construct($config, $args)
 {
     $this->config = $config;
     $this->args = $args;
     $this->mapper = ItemMapper::getInstance();
 }
Ejemplo n.º 11
0
<?php

include 'header.php';
$item = ItemMapper::instance()->find($_GET['id']);
?>

<?php 
$feed_helper = new FeedHelper();
?>

<?php 
echo $feed_helper->link($item->feed());
?>

<h2><?php 
echo $item->title();
?>
</h2>

<?php 
echo $item->body();
include 'footer.php';
Ejemplo n.º 12
0
});
// Delete Employee
$app->get('/employee/{id}/delete', function ($request, $response, $args) {
    $id = (int) $args['id'];
    $mapper = new EmployeeMapper($this->db);
    $employee = $mapper->getEmployeeById($id);
    $this->logger->info("Deleting employee " . $employee->getName());
    $mapper->delete($employee);
    $response = $response->withRedirect("/index.php/employees");
    return $response;
});
/**********************ITEMS**********************/
// Items
$app->get('/items', function ($request, $response, $args) {
    $this->logger->info("Items page");
    $item_mapper = new ItemMapper($this->db);
    $items = $item_mapper->getItems();
    return $this->renderer->render($response, 'item/items.phtml', [$args, "items" => $items]);
});
// New Item
$app->get('/item/new', function ($request, $response, $args) {
    $this->logger->info("Creating new item");
    $mapper = new ColorMapper($this->db);
    $colors = $mapper->getColors();
    return $this->renderer->render($response, 'item/item.phtml', [$args, "colors" => $colors]);
});
// New Item POST
$app->post('/item/new', function ($request, $response) {
    $post_data = $request->getParsedBody();
    $data = [];
    $data['Name'] = filter_var($post_data['name'], FILTER_SANITIZE_STRING);