This repository was archived by the owner on Feb 24, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoadd.php
More file actions
159 lines (150 loc) · 6.14 KB
/
oadd.php
File metadata and controls
159 lines (150 loc) · 6.14 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php include 'inc/header.inc'; ?>
<title>add order</title>
</head>
<?php require_once 'query.php'; ?>
<body>
<?php include 'inc/navbar.inc'; ?>
<br>
<!-- reset -->
<form>
<input type="submit" value="reset">
</form>
<!-- search -->
<form>
<input type="text" name="kw" placeholder="ابحث بالرقم">
<input type="submit">
</form>
<br><br>
<!-- new customer -->
<?php
if (@$_GET['ppp'] == 'ac1') {
echo '<P style="color:red"><b>خطأ الرقم موجود مسبقا</b></P>';
}
if (array_key_exists("addc", $_GET)) {
echo '<form>';
echo '<div>الاسم<input type="text" name="name" placeholder="name" value=""></div>';
echo '<div>العنوان<input type="text" name="address" placeholder="address" value=""></div>';
echo '<div>المحافظة<input type="text" name="providence" placeholder="providence" value=""></div>';
echo '<div>الرقم<input type="number" name="phone1" placeholder="phone1" value="" min="0" requireds></div>';
echo '<div>رقم2<input type="number" name="phone2" placeholder="phone2" value="" min="0"></div>';
echo '<div><button name="save" id="b0"><b> حفظ </b></button></div>';
echo '</form>';
}
if (array_key_exists('save', $_GET)) {
if (customerByPhone($_GET['phone1'])) {
header('Location: oadd.php?ppp=ac1');
} else {
insertCustomers($_GET['name'], $_GET['address'], $_GET['providence'], $_GET['phone1'], $_GET['phone2']);
header('Location: oadd.php');
}
} ?>
<!-- customers list of #5 -->
<table>
<tr>
<th>
<form><button name="addc" id="addc" value="1">عميل جديد</button></form>
</th>
<th>الرقم</th>
<th>رقم2</th>
<th>العنوان</th>
</tr>
<?php
$i = 0;
if (array_key_exists("kw", $_GET)) {
$snum = strtr($_GET['kw'], array('۰' => '0', '۱' => '1', '۲' => '2', '۳' => '3', '۴' => '4', '۵' => '5', '۶' => '6', '۷' => '7', '۸' => '8', '۹' => '9', '٠' => '0', '١' => '1', '٢' => '2', '٣' => '3', '٤' => '4', '٥' => '5', '٦' => '6', '٧' => '7', '٨' => '8', '٩' => '9'));
$cp = customerByPhone($snum);
foreach ($cp as $k => $v) {
$i++; ?>
<tr>
<td>
<form><button name="idbc" value="<?php echo $cp[$k]['id']; ?>">اختر</button></form>
</td>
<td><?php echo $cp[$k]['phone']; ?></td>
<td><?php echo $cp[$k]['phone2']; ?></td>
<td><?php echo $cp[$k]['caddress']; ?></td>
</tr>
<?php
}
} else {
$x = 0;
$cp = fetchCustomersL(0, 5);
foreach ($cp as $k => $v) { ?>
<tr>
<td>
<form><button name="idbc" value="<?php echo $cp[$k]['id']; ?>">اختر</button></form>
</td>
<td><?php echo $cp[$k]['phone']; ?></td>
<td><?php echo $cp[$k]['phone2']; ?></td>
<td><?php echo $cp[$k]['caddress']; ?></td>
</tr>
<?php
}
$x++;
} ?>
</table>
<!-- order and items -->
<?php if (array_key_exists("idbc", $_GET)) { ?>
//items
<form>
<table>
<tr>
<th>المنتج</th>
<th>العدد</th>
</tr>
<?php
$px = 0;
$pr = fetchActiveProducts();
while ($px < 5) {
$px++; ?>
<tr>
<td><select name="product<?php echo $px; ?>" id="product<?php echo $px; ?>">
<?php foreach ($pr as $k => $v) { ?>
<option value="<?php echo $pr[$k]['product_name']; ?>"><?php echo $pr[$k]['product_name']; ?></option>
<?php } ?>
</select></td>
<td><input type="number" name="quant<?php echo $px; ?>" min="0" value=""></td>
</tr>
<?php
} ?>
</table>
<br><br>
//order
<?php echo $_GET['idbc']; ?>
<td> <?php echo customerById($_GET['idbc'])[0]['phone']; ?></td>
<td> <?php echo customerById($_GET['idbc'])[0]['phone2']; ?></td>
<td> <?php echo customerById($_GET['idbc'])[0]['caddress']; ?></td>
</tr>
</div>
<input type="hidden" name="idbc" value="<?php echo $_GET["idbc"]; ?>">
<div>الخصم<input type="text" name="discount" placeholder="الخصم" value=""></div>
<div><?php echo date("Y-m-d", time()) ?></div>
<div>المجموع javascript</div>
<div>notes<input type="text" name="notes" placeholder="ملاحضات" value=""></div>
<div>
<button name="b0" id="b0"><b> حفظ </b></button>
</div>
</form>
<?php
} ?>
<?php if (array_key_exists('b0', $_GET)) {
if ($_GET['quant1'] != '') {
insertOrder($_GET['idbc'], $_GET['discount'], $_GET['notes']);
$id = maxoid();
insertItems($id, productByName($_GET['product1'])['id'], $_GET['quant1']);
if ($_GET['quant2'] != '') {
insertItems($id, productByName($_GET['product2'])['id'], $_GET['quant2']);
};
if ($_GET['quant3'] != '') {
insertItems($id, productByName($_GET['product3'])['id'], $_GET['quant3']);
};
if ($_GET['quant4'] != '') {
insertItems($id, productByName($_GET['product4'])['id'], $_GET['quant4']);
};
if ($_GET['quant5'] != '') {
insertItems($id, productByName($_GET['product5'])['id'], $_GET['quant5']);
};
};
header('Location: orders.php');
} ?>
</body>
</html>