Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esercizio 3 del 02-03-16 #2

Open
wants to merge 1 commit into
base: 15_cart_archive
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions libs/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,21 @@ function salvaOrdine($prodotti, $utente) {
function getListaOrdini() {
$db = creaConnessionePDO();

$query = "SELECT ordini.id, ordini.data, clienti.nome, clienti.cognome, COUNT(ordini_dettagli.id) as num_prodotti, ordini.totale
FROM ordini, clienti, ordini_dettagli
$query = "SELECT ordini.id, ordini.data, clienti.nome, clienti.cognome, COUNT(ordini_dettagli.id) as num_prodotti, ordini.totale, spedizione.stato
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sarebbe stato comodo avere una migrazione per tracciare i cambiamenti allo schema del database

FROM ordini, clienti, ordini_dettagli, spedizione
WHERE ordini.id = ordini_dettagli.ordine_id
AND ordini.cliente_id = clienti.id
AND spedizione.id = ordini.stato_spedizione
GROUP BY ordini.id";

return $db->query($query);
}


function recuperaOrdine($id) {
$db = creaConnessionePDO();

$stmt = $db->prepare('SELECT * FROM ordini, clienti WHERE ordini.cliente_id = clienti.id AND ordini.id = :id');
$stmt = $db->prepare('SELECT * FROM ordini, clienti, spedizione WHERE ordini.cliente_id = clienti.id AND ordini.id = :id AND spedizione.id = ordini.stato_spedizione');

$codice = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);

Expand Down
2 changes: 2 additions & 0 deletions ordini.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<th>Cliente</th>
<th>Num. prodotti</th>
<th>Totale</th>
<th>Stato spedizione</th>
<th></th>
</tr>
</thead>
Expand All @@ -46,6 +47,7 @@
<td><?=$ordine["nome"] . ' ' . $ordine["cognome"]?></td>
<td><?=$ordine["num_prodotti"]?></td>
<td><?=$ordine["totale"] / 100?> &euro;</td>
<td><?=$ordine["stato"]?></td>
<td><a href="scheda_ordine.php?id=<?=$ordine["id"]?>" class="btn btn-link">dettaglio</a></td>
</tr>
<?php } ?>
Expand Down
9 changes: 9 additions & 0 deletions scheda_ordine.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
<dt>Totale</dt>
<dd><?=$ordine["totale"] / 100?> &euro;</dd>
</dl>
<dl class="dl-horizontal">
<dt>Spedizione</dt>
<dd><?=$ordine["stato"]?></dd>
</dl>
<dl class="dl-horizontal">
<dt>Cambia lo stato</dt>
<dd><button>In consegna</button></dd>
<dd><button>Consegnato</button></dd>
</dl>
<dl class="dl-horizontal">
<dt>Note</dt>
<dd><?=$ordine["note"]?></dd>
Expand Down
11 changes: 11 additions & 0 deletions src/Model/Archivio.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quando facciamo i commit, stiamo attenti ad includere solo i file che riguardano la funzionalità su cui stiamo lavorando. Questo file per esempio non centra

namespace MvLabs\Chocosite\Model;

interface archivio
{
public function recupera($id = null);

public function salva(\StdClass $object);

}
?>