-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgerir_encomendas.php
140 lines (93 loc) · 4.01 KB
/
gerir_encomendas.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
include("includes/body.php");
top();
menu();
pesquisa();
logged();
if((isset($_SESSION['user_id'])) && ($_SESSION['user_id'] == 'admin'))
{menu_admin();
if(!isset($_GET['p']))
{header("location:index.php?erro=9");
exit(); }
//paginacao
$produtos_pagina=10;
$pagina = $_GET['p'];
if (!$pagina) {
$pagina = 1;
}
$primeiro = ($pagina*$produtos_pagina) - $produtos_pagina;
if((isset($_GET['erro'])) && ($_GET['erro'] == 'eid'))
echo "<span style='left:410px;top:395px;position:absolute;'><font size='3' color='#CC0000'>Ocorreu um erro ao processar este operação. Por favor, tente novamente.</font></span>";
$res=mysql_query("select * from encomendas inner join clientes on encomenda_cliente_id=cliente_id order by encomenda_data limit $primeiro, $produtos_pagina") or die (mysql_error());
$num=mysql_affected_rows();
?><div style="left:400px; top:320px; position:absolute;"><img src="imagens/g_enc.jpg" border="0" /></div><div style="left:280px; top:510px; position:absolute;">
<table cellpadding="3" align="center" border="1" style="border-collapse:collapse; border-color:#333;">
<?php
if($num>0)
{
?>
<tr>
<td class="tableheaders">ID</td>
<td class="tableheaders" width="100">Nome do cliente</td>
<td width="200" class="tableheaders">Morada do cliente</td>
<td class="tableheaders">Data</td>
<td class="tableheaders">Estado</td>
<td class="tableheaders">Pagamento</td>
<td > </td>
</tr>
<?php for($i=0;$i<$num;$i++)
{
?>
<tr>
<td><?php echo mysql_result($res,$i,"encomenda_id");?></td>
<td ><?php echo mysql_result($res,$i,"cliente_nome");?></td>
<td ><?php echo mysql_result($res,$i,"cliente_morada")." ".mysql_result($res,$i,"cliente_cp")." ".mysql_result($res,$i,"cliente_localidade");?></td>
<td><?php echo mysql_result($res,$i,"encomenda_data");?></td>
<td><?php echo mysql_result($res,$i,"encomenda_estado");?></td>
<td ><?php if(mysql_result($res,$i,"encomenda_mod_paga")=="ce") echo "Contra-entrega";elseif(mysql_result($res,$i,"encomenda_mod_paga")=="tb") echo "Transf. bancária";?></td>
<td align="center"><input type="button" title="Clique aqui para eliminar a encomenda" value="Eliminar" onclick="if(con('encomenda') == true)
document.location.href='exe_eliminar_encomenda.php?id=<?php echo mysql_result($res,$i,"encomenda_id");?>';" /></td>
</tr>
<?php } ?>
<?php } else {
echo "<tr><td width='200'>Sem encomendas</td></tr>";}
?> </table>
<?php $tot=mysql_query("select count(*) from encomendas") or die (mysql_error());
list($total_p) = mysql_fetch_array($tot);
$total_pag = $total_p/$produtos_pagina;
$prev = $pagina - 1;
$next = $pagina + 1;
//anterior
if ($pagina > 1) {
$prev_l = "<a href=\"$_SERVER[PHP_SELF]?p=$prev\">Anterior</a>";
} else {
$prev_l = "Anterior";
}
//seguinte
if ($total_pag > $pagina) {
$next_l = "<a href=\"$_SERVER[PHP_SELF]?p=$next\">Seguinte</a>";
} else {
$next_l = "Seguinte";
}
$total_pag = ceil($total_pag);
$painel = "";
for ($x=1; $x<=$total_pag; $x++) {
if ($x==$pagina) {
$painel .= " [$x] ";
} else {
$painel .= " <a href=\"$_SERVER[PHP_SELF]?p=$x\">[$x]</a>";
}
}
echo "<div> </div><div align='center'>$prev_l | $painel | $next_l</div>";
?>
</div><?php
}
else
header("location:index.php?erro=5");
?>
<div align="center" id="foot"><div id="txtfoot">
Copyright © 2010 Todos os direitos reservados. Gonçalo Cardeira.</div>
</div>
</div>
</body>
</html>