Professional Documents
Culture Documents
View Source Print?
View Source Print?
net/forums/topic/388790-approval-system/
view source
print?
001 <?php
002 include_once("init.php");
003
004 ?>
005 <!DOCTYPE html>
006
007 <html lang="en">
008 <head>
009 <meta charset="utf-8">
010 <title>Ajouter Achat</title>
011
012 <!-- Stylesheets -->
013
014 <link rel="stylesheet" href="css/style.css">
015 <link rel="stylesheet" href="js/date_pic/date_input.css">
016 <link rel="stylesheet" href="lib/auto/css/jquery.autocomplete.css">
017
018 <!-- Optimize for mobile devices -->
019 <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
020
021 <!-- jQuery & JS files -->
022 <?php include_once("tpl/common_js.php"); ?>
023 <script src="js/script.js"></script>
024 <script src="js/date_pic/jquery.date_input.js"></script>
025 <script src="lib/auto/js/jquery.autocomplete.js "></script>
026
027 <script type="text/javascript">
028 $(function () {
029 document.getElementById('bill_no').focus();
030 $("#supplier").autocomplete("supplier1.php", {
031 width: 160,
032 autoFill: true,
033 selectFirst: true
034 });
035 $("#item").autocomplete("stock_purchse.php", {
036 width: 160,
037 autoFill: true,
038 mustMatch: true,
039 selectFirst: true
040 });
041 $("#item").blur(function () {
042 document.getElementById('total').value = document.getElementById('cost').value * document.getElementById('quty').value
043 });
044 $("#item").blur(function () {
045
046
047 $.post('check_item_details.php', {stock_name1: $(this).val()},
048 function (data) {
049 $("#cost").val(data.cost);
050 $("#sell").val(data.sell);
051 $("#stock").val(data.stock);
052 $('#guid').val(data.guid);
053 if (data.cost != undefined)
054 $("#0").focus();
055
056
057 }, 'json');
058
059
060 });
061 $("#quty").blur(function () {
062 if (document.getElementById('item').value == "") {
063 document.getElementById('item').focus();
064 }
065 });
066 $("#supplier").blur(function () {
067
068
069 $.post('check_supplier_details.php', {stock_name1: $(this).val()},
070 function (data) {
071
072 $("#address").val(data.address);
073 $("#contact1").val(data.contact1);
074
075 if (data.address != undefined)
076 $("#0").focus();
077
078 }, 'json');
079
080
081 });
082 $('#test1').jdPicker();
083 $('#test2').jdPicker();
084
085
086 var hauteur = 0;
087 $('.code').each(function () {
088 if ($(this).height() > hauteur) hauteur = $(this).height();
089 });
090
091 $('.code').each(function () {
092 $(this).height(hauteur);
093 });
094 });
095
096 </script>
097 <script>
098 /*$.validator.setDefaults({
099 submitHandler: function() { alert("submitted!"); }
100 });*/
101 $(document).ready(function () {
102 if (document.getElementById('item') === "") {
103 document.getElementById('item').focus();
104 }
105 // validate signup form on keyup and submit
106 $("#form1").validate({
107 rules: {
108 bill_no: {
109 required: true,
110 minlength: 3,
111 maxlength: 200
112 },
113 stockid: {
114 required: true
115 },
1 of 6 1/27/2022, 3:30 AM
Firefox https://www.dreamincode.net/forums/topic/388790-approval-system/
116 grand_total: {
117 required: true
118 },
119 payment: {
120 required: true
121 },
122 supplier: {
123 required: true,
124 }
125 },
126 messages: {
127 supplier: {
128 required: "SVP entrez le fournisseur"
129 },
130 stockid: {
131 required: "SVP entrer Stock ID"
132 },
133 grand_total: {
134 required: "Ajouter les articles de stock"
135 },
136 payment: {
137 required: "Saisir le paiement"
138 },
139 bill_no: {
140 required: "SVP entrer le N° de facture",
141 minlength: "Le numero de facture doit comporter au moins 3 caracteres"
142 }
143 }
144 });
145
146 });
147 function numbersonly(e) {
148 var unicode = e.charCode ? e.charCode : e.keyCode
149 if (unicode != 8 && unicode != 46 && unicode != 37 && unicode != 27 && unicode != 38 && unicode != 39 && unicode != 40 && unicode != 9) { //if the key isn't the backspace key (which we should allow)
150 if (unicode < 48 || unicode > 57)
151 return false
152 }
153 }
154
155
156 </script>
157 <script type="text/javascript">
158 function remove_row(o) {
159 var p = o.parentNode.parentNode;
160 p.parentNode.removeChild(p);
161 }
162 function add_values() {
163 if (unique_check()) {
164
165 if (document.getElementById('edit_guid').value == "") {
166 if (document.getElementById('item').value != "" && document.getElementById('quty').value != "" && document.getElementById('cost').value != "" && document.getElementById('total').value != "") {
167 code = document.getElementById('item').value;
168
169 quty = document.getElementById('quty').value;
170 cost = document.getElementById('cost').value;
171 sell = document.getElementById('sell').value;
172 disc = document.getElementById('stock').value;
173 total = document.getElementById('total').value;
174 item = document.getElementById('guid').value;
175 main_total = document.getElementById('posnic_total').value;
176
$('<tr id=' + item + '><td><input type=hidden value=' + item + ' id=' + item + 'id ><input type=text name="stock_name[]" id=' + item + 'st style="width: 150px" class="round my_with" ></td>
<td><input type=text name=quty[] readonly="readonly" value=' + quty + ' id=' + item + 'q class="round my_with" style="text-align:right;" ></td><td><input type=text name=cost[] readonly="readonly" value=' + cost + ' id=' +
item + 'c class="round my_with" style="text-align:right;"></td><td><input type=text name=sell[] readonly="readonly" value=' + sell + ' id=' + item + 's class="round my_with" style="text-align:right;" ></td><td><input
177 type=text name=stock[] readonly="readonly" value=' + disc + ' id=' + item + 'p class="round my_with" style="text-align:right;" ></td><td><input type=text name=jibi[] readonly="readonly" value=' + total + ' id=' + item +
'to class="round my_with" style="width: 120px;margin-left:20px;text-align:right;" ><input type=hidden name=total[] id=' + item + 'my_tot value=' + main_total + '> </td><td><input type=button value="" id=' + item + '
style="width:30px;border:none;height:30px;background:url(images/edit_new.png)" class="round" onclick="edit_stock_details(this.id)" ></td><td><input type=button value="" id=' + item + ' style="width:30px;border:none;
height:30px;background:url(images/close_new.png)" class="round" onclick= $(this).closest("tr").remove() ></td></tr>').fadeIn("slow").appendTo('#item_copy_final');
178 document.getElementById('quty').value = "";
179 document.getElementById('cost').value = "";
180 document.getElementById('sell').value = "";
181 document.getElementById('stock').value = "";
182 document.getElementById('total').value = "";
183 document.getElementById('item').value = "";
184 document.getElementById('guid').value = "";
185 if (document.getElementById('grand_total').value == "") {
186 document.getElementById('grand_total').value = main_total;
187 } else {
188 document.getElementById('grand_total').value = parseFloat(document.getElementById('grand_total').value) + parseFloat(main_total);
189 }
190 document.getElementById('main_grand_total').value = parseFloat(document.getElementById('grand_total').value);
191 document.getElementById(item + 'st').value = code;
192 document.getElementById(item + 'to').value = total;
193 document.getElementById('item').focus();
194
195 } else {
196 alert('SVP selectionner un article');
197 }
198 } else {
199 id = document.getElementById('edit_guid').value;
200 document.getElementById(id + 'st').value = document.getElementById('item').value;
201 document.getElementById(id + 'q').value = document.getElementById('quty').value;
202 document.getElementById(id + 'c').value = document.getElementById('cost').value;
203 document.getElementById(id + 's').value = document.getElementById('sell').value;
204 document.getElementById(id + 'p').value = document.getElementById('stock').value;
document.getElementById('grand_total').value = parseFloat(document.getElementById('grand_total').value) + parseFloat(document.getElementById('posnic_total').value) -
205
parseFloat(document.getElementById(id + 'my_tot').value);
206 document.getElementById('main_grand_total').value = parseFloat(document.getElementById('grand_total').value);
207 document.getElementById(id + 'to').value = document.getElementById('total').value;
208 document.getElementById(id + 'id').value = id;
209
210 document.getElementById(id + 'my_tot').value = document.getElementById('posnic_total').value
211 document.getElementById('quty').value = "";
212 document.getElementById('cost').value = "";
213 document.getElementById('sell').value = "";
214 document.getElementById('stock').value = "";
215 document.getElementById('total').value = "";
216 document.getElementById('item').value = "";
217 document.getElementById('guid').value = "";
218 document.getElementById('edit_guid').value = "";
219 document.getElementById('item').focus();
220 }
221 }
222
223 }
224 function total_amount() {
225 balance_amount();
226
227 document.getElementById('total').value = document.getElementById('cost').value * document.getElementById('quty').value
228 document.getElementById('posnic_total').value = document.getElementById('total').value;
229 document.getElementById('total').value = parseFloat(document.getElementById('total').value);
2 of 6 1/27/2022, 3:30 AM
Firefox https://www.dreamincode.net/forums/topic/388790-approval-system/
3 of 6 1/27/2022, 3:30 AM
Firefox https://www.dreamincode.net/forums/topic/388790-approval-system/
344 <!-- Change this image to your own company's logo -->
345 <!-- The logo will automatically be resized to 30px height. --><a href="#" id="company-branding-small" class="fr"><img src="<?php if (isset($_SESSION['logo'])) {
346 echo "upload/" . $_SESSION['logo'];
347 } else {
348 echo "upload/posnic.png";
349 } ?>" alt="Point of Sale"/></a>
350
351 </div>
352 <!-- end full-width -->
353
354 </div>
355 <!-- end header -->
356
357
358 <!-- MAIN CONTENT -->
359 <div id="content">
360
361 <div class="page-full-width cf">
362
363
364 <div class="side-menu fl">
365
366 <h3>GESTION DES ACHATS</h3>
367 <ul>
368 <li><a href="add_purchase.php">Ajouter Achat</a></li>
369 <li><a href="view_purchase.php">Voir Achat </a></li>
370 <li><a href="view_purchase_validated.php">Voir Achat VALIDES </a></li>
371 </ul>
372
373 </div>
374
375 <!-- end side-menu -->
376 <div class="side-content fr">
377
378 <div class="content-module">
379
380 <div class="content-module-heading cf">
381
382 <h3 class="fl">Ajouter Achat</h3>
383 <span class="fr expand-collapse-text">Cliquer pour replier </span>
384 <span class="fr expand-collapse-text initial-expand">Cliquer pour deplier </span>
385
386 </div>
387 <!-- end content-module-heading -->
388
389 <div class="content-module-main cf">
390
391
392 <?php
393 //Gump is libarary for Validatoin
394 if (isset($_GET['msg'])) {
395 echo $_GET['msg'];
396 }
397 if (isset($_POST['supplier']) and isset($_POST['stock_name'])) {
398 $_POST = $gump->sanitize($_POST);
399 $gump->validation_rules(array(
400 'supplier' => 'required|max_len,100|min_len,3'
401
402
403 ));
404
405 $gump->filter_rules(array(
406 'supplier' => 'trim|sanitize_string|mysqli_escape'
407
408
409 ));
410
411 $validated_data = $gump->run($_POST);
412 $supplier = "";
413 $stockid = "";
414 $stock_name = "";
415 $cost = "";
416 $bill_no = "";
417
418
419 if ($validated_data === false) {
420 echo $gump->get_readable_errors(true);
421 } else {
422 $username = $_SESSION['username'];
423
424 $stockid = mysqli_real_escape_string($db->connection, $_POST['stockid']);
425
426 $bill_no = mysqli_real_escape_string($db->connection, $_POST['bill_no']);
427 $supplier = mysqli_real_escape_string($db->connection, $_POST['supplier']);
428 $address = mysqli_real_escape_string($db->connection, $_POST['address']);
429 $contact = mysqli_real_escape_string($db->connection, $_POST['contact']);
430 $stock_name = $_POST['stock_name'];
431
432 $count = $db->countOf("supplier_details", "supplier_name='$supplier'");
433 if ($count == 0) {
434 $db->query("insert into supplier_details(supplier_name,supplier_address,supplier_contact1) values('$supplier','$address','$contact')");
435 }
436 $quty = $_POST['quty'];
437 $date = date("d M Y h:i A");
438 $sell = $_POST['sell'];
439 $cost = $_POST['cost'];
440 $total = $_POST['total'];
441 $subtotal = $_POST['subtotal'];
442 $description = mysqli_real_escape_string($db->connection, $_POST['description']);
443 $due = mysqli_real_escape_string($db->connection, $_POST['duedate']);
444 $payment = mysqli_real_escape_string($db->connection, $_POST['payment']);
445 $balance = mysqli_real_escape_string($db->connection, $_POST['balance']);
446 $mode = mysqli_real_escape_string($db->connection, $_POST['mode']);
447
448 $autoid = $_POST['stockid'];
449 $autoid1 = $autoid;
450 $selected_date = $_POST['date'];
451 $selected_date = strtotime($selected_date);
452 $date = date('Y-m-d H:i:s', $selected_date);
453 for ($i = 0; $i < count($stock_name); $i++) {
4 of 6 1/27/2022, 3:30 AM
Firefox https://www.dreamincode.net/forums/topic/388790-approval-system/
5 of 6 1/27/2022, 3:30 AM
Firefox https://www.dreamincode.net/forums/topic/388790-approval-system/
6 of 6 1/27/2022, 3:30 AM