forked from zygtech/goldwater
-
Notifications
You must be signed in to change notification settings - Fork 3
/
quote.php
executable file
·128 lines (124 loc) · 4.57 KB
/
quote.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
<?php
/*
* quote.php
*
* Copyright 2018 Krzysztof Hrybacz <krzysztof@zygtech.pl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
?>
<?php
require_once('config.php');
session_start();
if ($_SESSION['login']!='') {
$link = mysqli_connect($sql, $sqluser, $sqlpass, $sqldb);
mysqli_set_charset($link,'utf8');
if ($_GET['id']!='') {
$result = mysqli_query($link,'SELECT * FROM `quotes` WHERE id=' . $_GET['id'] . ';');
$quote = mysqli_fetch_array($result);
}
?>
<html>
<head>
<title>Quote Edit</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Titillium+Web%3A400%2C300%2C900%7CPT+Sans%3A00&subset=latin" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="limit.js"></script>
<style>
td { width: 50% !important; }
</style>
<script>
function phone(sel)
{
$("#phone").load('phone.php?id='+sel.value.replace(/ /g,"%20"));
}
</script>
</head>
<body>
<div class="container">
<img class="right" src="logo.png" />
<h1> Welcome: <?php echo $_SESSION['login']; ?> <span class="logout">(<a href="index.php?logout=true">log out</a>)</span></h1>
</div>
<div class="ribbon"><div class="container">
<h2> QUOTE EDIT </h2>
</div></div>
<div class="main"><div class="container">
<form action="quoteedit.php" method="POST">
<input type="hidden" name="id" value="<?php echo $quote['id']; ?>" />
<table>
<tr><td>Quote ID:<br /><div class="field"><?php if ($quote['id']!='') echo 'QTE' . sprintf('%04d',$quote['id']); ?> </div></td>
<td>Date of creation:<br /><div class="field"><?php if ($quote['creation']!='') echo $quote['creation']; else echo date('Y-m-d'); ?> </div></td></tr>
<?php
$result = mysqli_query($link,'SELECT * FROM `clients` WHERE id=' . $quote['client'] . ';');
$client = mysqli_fetch_array($result);
$result = mysqli_query($link,'SELECT * FROM `clients` ORDER BY company,fullname;;');
?>
<tr><td>Company/full name:<br />
<input type="text" name="clientname" list="clients" onchange="phone(this);" value="<?php
if ($client['company']!='')
echo $client['company'];
else
echo $client['fullname'];
?>">
<datalist id="clients">
<?php
while ($client = mysqli_fetch_array($result)) {
if ($client['company']!='')
echo '<option>' . $client['company'] . '</option>';
else
echo '<option>' . $client['fullname'] . '</option>';
}
?>
</datalist></td>
<?php
$result = mysqli_query($link,'SELECT * FROM `clients` WHERE id=' . $quote['client'] . ';');
$client = mysqli_fetch_array($result);
?>
<td>Client mobile:<br /><div id="phone" class="field"><?php if ($client['mobile']!='') echo $client['mobile']; ?> </div></td></tr>
</table><br />
Quote short description:<br />
<input type="text" name="name" value="<?php echo $quote['name']; ?>" maxlength="50" /><br /><br />
Description:
<textarea class="desc" name="description" onkeyup="limitTextarea(this,20,100)"><?php echo $quote['description']; ?></textarea>
<br /><br />
<table>
<tr><td></td><td>Created by:<br /><div class="field"><?php if ($quote['added']!='') {
$result = mysqli_query($link,'SELECT * FROM `users` WHERE name="' . $quote['added'] . '";');
$user = mysqli_fetch_array($result);
echo $quote['added'] . ' - ' . $user['mail'];
}
else {
$result = mysqli_query($link,'SELECT * FROM `users` WHERE name="' . $_SESSION['login'] . '";');
$user = mysqli_fetch_array($result);
echo $_SESSION['login'] . ' - ' . $user['mail'];
}
?> </div></td></tr>
</table><br /><br />
<input type="submit" value="Save" /><br /><br />
</form>
</div></div>
<div class="ribbon"><div class="container">
<?php require_once('menu.php'); ?>
</div></div>
</body>
</html>
<?php
}
?>