|
| 1 | +<?php |
| 2 | + |
| 3 | +require_once '../includes/ajax_header.php'; |
| 4 | + |
| 5 | +$quote_id = intval($_GET['id']); |
| 6 | + |
| 7 | +$sql = mysqli_query($mysqli, "SELECT * FROM quotes LEFT JOIN clients ON quote_client_id = client_id WHERE quote_id = $quote_id LIMIT 1"); |
| 8 | + |
| 9 | +$row = mysqli_fetch_array($sql); |
| 10 | +$quote_id = intval($row['quote_id']); |
| 11 | +$quote_prefix = nullable_htmlentities($row['quote_prefix']); |
| 12 | +$quote_number = intval($row['quote_number']); |
| 13 | +$quote_scope = nullable_htmlentities($row['quote_scope']); |
| 14 | +$quote_date = nullable_htmlentities($row['quote_date']); |
| 15 | +$quote_expire = nullable_htmlentities($row['quote_expire']); |
| 16 | +$quote_discount = floatval($row['quote_discount_amount']); |
| 17 | +$quote_created_at = nullable_htmlentities($row['quote_created_at']); |
| 18 | +$quote_category_id = intval($row['quote_category_id']); |
| 19 | +$client_name = nullable_htmlentities($row['client_name']); |
| 20 | + |
| 21 | +// Generate the HTML form content using output buffering. |
| 22 | +ob_start(); |
| 23 | +?> |
| 24 | + |
| 25 | +<div class="modal-header"> |
| 26 | + <h5 class="modal-title text-white"><i class="fas fa-fw fa-comment-dollar mr-2"></i>Editing quote: <span class="text-bold"><?php echo "$quote_prefix$quote_number"; ?></span> - <span class="text"><?php echo $client_name; ?></span></h5> |
| 27 | + <button type="button" class="close text-white" data-dismiss="modal"> |
| 28 | + <span>×</span> |
| 29 | + </button> |
| 30 | +</div> |
| 31 | +<form action="post.php" method="post" autocomplete="off"> |
| 32 | + <input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>"> |
| 33 | + |
| 34 | + <div class="modal-body bg-white"> |
| 35 | + |
| 36 | + <div class="form-group"> |
| 37 | + <label>Quote Date</label> |
| 38 | + <div class="input-group"> |
| 39 | + <div class="input-group-prepend"> |
| 40 | + <span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span> |
| 41 | + </div> |
| 42 | + <input type="date" class="form-control" name="date" max="2999-12-31" value="<?php echo $quote_date; ?>" required> |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + |
| 46 | + <div class="form-group"> |
| 47 | + <label>Expire <strong class="text-danger">*</strong></label> |
| 48 | + <div class="input-group"> |
| 49 | + <div class="input-group-prepend"> |
| 50 | + <span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span> |
| 51 | + </div> |
| 52 | + <input type="date" class="form-control" name="expire" max="2999-12-31" value="<?php echo $quote_expire; ?>" required> |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + |
| 56 | + <div class="form-group"> |
| 57 | + <label>Income Category</label> |
| 58 | + <div class="input-group"> |
| 59 | + <div class="input-group-prepend"> |
| 60 | + <span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span> |
| 61 | + </div> |
| 62 | + <select class="form-control select2" name="category" required> |
| 63 | + <?php |
| 64 | + |
| 65 | + $sql = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Income' AND (category_archived_at > '$quote_created_at' OR category_archived_at IS NULL) ORDER BY category_name ASC"); |
| 66 | + while ($row = mysqli_fetch_array($sql)) { |
| 67 | + $category_id = intval($row['category_id']); |
| 68 | + $category_name = nullable_htmlentities($row['category_name']); |
| 69 | + ?> |
| 70 | + <option <?php if ($quote_category_id == $category_id) { echo "selected"; } ?> value="<?php echo $category_id; ?>"><?php echo $category_name; ?></option> |
| 71 | + |
| 72 | + <?php } ?> |
| 73 | + |
| 74 | + </select> |
| 75 | + <div class="input-group-append"> |
| 76 | + <a class="btn btn-secondary" href="admin_category.php?category=Income" target="_blank"><i class="fas fa-fw fa-plus"></i></a> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + |
| 81 | + |
| 82 | + <div class='form-group'> |
| 83 | + <label>Discount Amount</label> |
| 84 | + <div class='input-group'> |
| 85 | + <div class='input-group-prepend'> |
| 86 | + <span class='input-group-text'><i class='fa fa-fw fa-dollar-sign'></i></span> |
| 87 | + </div> |
| 88 | + <input type='text' class='form-control' inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name='quote_discount' placeholder='0.00' value="<?php echo number_format($quote_discount, 2, '.', ''); ?>"> |
| 89 | + </div> |
| 90 | + </div> |
| 91 | + |
| 92 | + <div class="form-group"> |
| 93 | + <label>Scope</label> |
| 94 | + <div class="input-group"> |
| 95 | + <div class="input-group-prepend"> |
| 96 | + <span class="input-group-text"><i class="fa fa-fw fa-comment"></i></span> |
| 97 | + </div> |
| 98 | + <input type="text" class="form-control" name="scope" placeholder="Quick description" value="<?php echo $quote_scope; ?>" maxlength="255"> |
| 99 | + </div> |
| 100 | + </div> |
| 101 | + |
| 102 | + </div> |
| 103 | + <div class="modal-footer bg-white"> |
| 104 | + <button type="submit" name="edit_quote" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button> |
| 105 | + <button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button> |
| 106 | + </div> |
| 107 | +</form> |
| 108 | + |
| 109 | +<?php |
| 110 | + |
| 111 | +require_once "../includes/ajax_footer.php"; |
0 commit comments