Ejemplo n.º 1
0
 public function testDeletePayment()
 {
     $payment = getPaymentInstance('deletePayment');
     $bmapper = new PaymentMapper(self::$pdo);
     $bmapper->insert($payment);
     $bmapper->delete($payment);
     $allPayments = $bmapper->findAll()->fetchAll();
     $this->assertEmpty($allPayments);
 }
Ejemplo n.º 2
0
    $data['amount'] = filter_var($post_data['amount'], FILTER_SANITIZE_STRING);
    $mapper = new PaymentMapper($this->db);
    $payment = $mapper->getPaymentById($data['id']);
    $payment->setDate($data['date']);
    $payment->setUnits($data['amount']);
    $mapper->save($payment);
    $response = $response->withRedirect("/index.php/payments");
    return $response;
});
// Delete payment
$app->get('/payment/{id}/delete', function ($request, $response, $args) {
    $id = (int) $args['id'];
    $mapper = new PaymentMapper($this->db);
    $payment = $mapper->getPaymentById($id);
    $this->logger->info("Deleting payment" . $id);
    $mapper->delete($payment);
    $response = $response->withRedirect("/index.php/payments");
    return $response;
});
/*Produce a report on the top three selling products of the Company (in terms of
total value of sales) during the past 12 months. List (among other details) the
name of the item, number of orders placed, number of items sold. */
/**********************QUERY ROUTES**********************/
// Products
$app->get('/products/query', function ($request, $response, $args) {
    $this->logger->info("products query");
    $mapper = new ProductQueryMapper($this->db);
    $products = $mapper->processQuery();
    return $this->renderer->render($response, 'queries/query_products.phtml', [$args, "products" => $products]);
});
/*