| Server IP : 192.169.170.185 / Your IP : 216.73.216.97 Web Server : Apache System : Linux p3plmcpnl495852.prod.phx3.secureserver.net 4.18.0-553.52.1.lve.el8.x86_64 #1 SMP Wed May 21 15:31:29 UTC 2025 x86_64 User : akhilnew ( 1712764) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/akhilnew/public_html/admin/ |
Upload File : |
<?php
function paymentmodes($payment_mode = null)
{
$modes = array('CASH', 'CHEQUE', 'DEMAND DRAFT', 'DEBIT CARD', 'CREDIT CARD', 'NET BANKING', 'IMPS', 'NEFT', 'PAYTM', 'PHONEPE', 'UPI', 'GOOGLE PAY', 'RTGS', 'AKINIK PAYMENT', 'MONEY ORDER', 'OTHER');
$html = '<option selected="selected" value="">Select payment mode</option>';
foreach ($modes as $mode) {
$html .= '<option value="' . $mode . '" ' . ($payment_mode === $mode ? 'selected' : '') . '>' . $mode . '</option>';
}
return $html;
}
function shippingmethods()
{
global $mysqli;
$html = '';
$stmt = $mysqli->prepare("SELECT shippingmethod FROM orders WHERE (shippingmethod != '' AND shippingmethod IS NOT NULL) GROUP BY shippingmethod ORDER BY shippingmethod ASC") or die($mysqli->error);
$stmt->execute();
$stmt->store_result();
$stmt->num_rows();
$stmt->bind_result($shippingmethod);
while ($stmt->fetch()) :
$html .= '<option value="' . $shippingmethod . '">' . $shippingmethod . '</option>';
endwhile;
$stmt->close();
return $html;
}
if ($opt1 && $opt1 === 'add') :
function customers()
{
global $mysqli;
$html = '';
$stmt = $mysqli->prepare("SELECT customerid, name, email, phone, address, city, state, country, pincode FROM customers WHERE (name != '' AND name IS NOT NULL AND status = 'enabled') ORDER BY name ASC") or die($mysqli->error);
$stmt->execute();
$stmt->store_result();
$stmt->num_rows();
$stmt->bind_result($id, $name, $email, $phone, $address, $city, $state, $country, $pincode);
while ($stmt->fetch()) :
$html .= '<option value="' . htmlspecialchars($id) . '"
data-name="' . htmlspecialchars($name) . '"
data-phone="' . htmlspecialchars($phone) . '"
data-address="' . htmlspecialchars($address) . '"
data-city="' . htmlspecialchars($city) . '"
data-state="' . htmlspecialchars($state) . '"
data-country="' . htmlspecialchars($country) . '"
data-pincode="' . htmlspecialchars($pincode) . '">' .
htmlspecialchars($name) . ' (' . htmlspecialchars($email) . ')
</option>';
endwhile;
$stmt->close();
return $html;
}
$customers = customers();
function product_list()
{
global $mysqli;
$html = '';
$stmt = $mysqli->prepare("SELECT productid, title, volume, price, royalty FROM products WHERE category = 'Book' ORDER BY title ASC, volume ASC") or die($mysqli->error);
$stmt->execute();
$stmt->store_result();
$stmt->num_rows();
$stmt->bind_result($productid, $title, $volume, $price, $royalty);
while ($stmt->fetch()) :
$html .= '<option value="' . $productid . '" data-price="' . (explode('.', $price)[0]) . '" data-royalty="' . ($royalty ?: '') . '">' . $title . ($volume ? ' (Volume - ' . $volume . ')' : '') . '</option>';
endwhile;
$stmt->close();
return $html;
}
$product_list = product_list();
$paymentmodes = paymentmodes();
echo <<<EOJ
<div class="head">
{$back}
<button type="submit" class="waves-effect btn-flat blue accent-3">submit</button>
</div>
<div class="body">
<div class="row">
<div class="col s12 m4 l4">
<label for="customerid">customer<b class="red-text right">*</b></label>
<select name="customerid" id="customerid" class="browser-default" onchange="fillCustomerDetails(this)">
<option value="" selected>Select Customer</option>
{$customers}
</select>
</div>
<div class="col s12 m4 l4">
<label for="shippingname">shipping name<b class="red-text right">*</b></label>
<input type="text" name="shippingname" id="shippingname" />
</div>
<div class="col s12 m4 l4">
<label for="shippingphone">shipping phone</label>
<input type="text" name="shippingphone" id="shippingphone" />
</div>
</div>
<div class="row">
<div class="col s12 m6 l6">
<label for="shippingaddress">shipping address</label>
<textarea rows="5" cols="5" name="shippingaddress" id="shippingaddress" class="materialize-textarea"></textarea>
</div>
<div class="col s12 m6 l6">
<label for="billingaddress">billing address</label>
<textarea rows="5" cols="5" name="billingaddress" id="billingaddress" class="materialize-textarea"></textarea>
</div>
</div>
<div id="copyableProduct">
<div class="row" style="display:flex;">
<div class="col">
<label for="productid">product<b class="red-text right">*</b></label>
<select name="productid[]" class="browser-default" onchange="$(this).closest('.row').find('.price').val($(this).children('option:selected').data('price')); $(this).parents('.row').find('.royalty').val($(this).children('option:selected').data('royalty'));">
<option value="" selected>Select Product</option>
{$product_list}
</select>
</div>
<div class="col">
<label for="price">price<b class="red-text right">*</b></label>
<input type="text" name="price[]" id="price" class="price" />
</div>
<div class="col">
<label for="discount">discount</label>
<input type="text" name="discount[]" id="discount" class="int" />
</div>
<div class="col">
<label for="quantity">quantity<b class="red-text right">*</b></label>
<input type="text" name="quantity[]" id="quantity" value="1" class="int" />
</div>
<div class="col">
<label for="royalty">royalty</label>
<input type="text" name="royalty[]" id="royalty" class="int royalty" />
</div>
<div class="col">
<button type="button" class="waves-effect btn-flat black-text right" style="width:85px;margin-top:16px" onclick="addMoreProduct()">add more</button>
</div>
</div>
</div>
<div class="moreproduct"></div>
</div>
<script>
function addMoreProduct(){
$('.moreproduct').append(copyableProduct.innerHTML).find('button').text('remove').attr('onclick', '$(this).closest(\'.row\').remove().find(\'input\').val(\'\')');
}
</script>
<br clear="all"><br clear="all">
<div class="body">
<div class="row">
<div class="col s12 m3 l3">
<label for="shippingcharge">shipping charge</label>
<input type="text" name="shippingcharge" id="shippingcharge" />
</div>
<div class="col s12 m3 l3">
<label for="payment_mode">payment mode</label>
<select name="payment_mode" id="payment_mode" class="browser-default">
{$paymentmodes}
</select>
</div>
<div class="col s12 m3 l3">
<label for="payment_date">payment date</label>
<input type="text" name="payment_date" id="payment_date" class="datepicker" />
</div>
<div class="col s12 m3 l3">
<label for="txn_number">txn number</label>
<input type="text" name="txn_number" id="txn_number" />
</div>
</div>
<div class="row">
<div class="col s12 m6 l4">
<label for="account_number">account number</label>
<input type="text" name="account_number" id="account_number" list="account_numbers" />
<datalist id="account_numbers">
<option value="ICICI-100405000489">ICICI-100405000489</option>
<option value="IDBI-0163102000020323">IDBI-0163102000020323</option>
</datalist>
</div>
<div class="col s12 m6 l8">
<label for="comment">comment</label>
<input type="text" name="comment" id="comment" />
</div>
</div>
<div class="row">
<div class="col s12 m4 l4">
<label for="gemcontractnumber">gem contract number</label>
<input type="text" name="gemcontractnumber" id="gemcontractnumber" />
</div>
<div class="col s12 m4 l4">
<label for="gemsellerid">gem seller id</label>
<input type="text" name="gemsellerid" id="gemsellerid" />
</div>
<div class="col s12 m4 l4">
<label class="chklab" style="margin-top:17px;"><input type="checkbox" name="gemorder" value="true" onchange="if(this.checked) { gemsellerid.value = '8GXR220005346594' } else { gemsellerid.value = '' }" />gem order</label>
</div>
</div>
</div>
EOJ;
?>
<script>
function fillCustomerDetails(selectElement) {
const dataset = selectElement.options[selectElement.selectedIndex]?.dataset ?? {};
const {name = '', phone = '', address = '', city = '', state = '', country = '', pincode = ''} = dataset;
const fullAddress = `${name}\r${address}, ${city}, ${state}, ${country}\rPin code - ${pincode}\rPhone - ${phone}`;
const shippingAddressElem = document.getElementById('shippingaddress');
const billingAddressElem = document.getElementById('billingaddress');
const shippingNameElem = document.getElementById('shippingname');
const shippingPhoneElem = document.getElementById('shippingphone');
shippingAddressElem.textContent = billingAddressElem.textContent = fullAddress;
if (name) shippingNameElem.value = name;
if (phone) shippingPhoneElem.value = phone;
}
</script>
<?php
elseif ($opt1 && $opt1 === 'edit' && $opt2) :
$stmt = $mysqli->prepare("SELECT ordernumber, orderdate, shippingcharge, shippingdate, shippingmethod, shippingcode, shippingname, shippingemail, shippingphone, shippingaddress, billingaddress, payment_mode, payment_date, txn_number, account_number, comment, gemcontractnumber, gemsellerid, gemorder FROM $table WHERE $firstcol = ? LIMIT 1") or die($mysqli->error);
$stmt->bind_param('i', $opt2);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($ordernumber, $orderdate, $shippingcharge, $shippingdate, $shippingmethod, $shippingcode, $shippingname, $shippingemail, $shippingphone, $shippingaddress, $billingaddress, $payment_mode, $payment_date, $txn_number, $account_number, $comment, $gemcontractnumber, $gemsellerid, $gemorder);
$stmt->fetch();
$stmt->close();
$shippingdate = $shippingdate ? date('m/d/Y', strtotime($shippingdate)) : '';
$shippingmethods = shippingmethods();
$paymentmodes = paymentmodes($payment_mode);
$payment_date = $payment_date ? date('m/d/Y', strtotime($payment_date)) : '';
$gemorderChecked = $gemorder === 'true' ? 'checked' : '';
echo <<<EOJ
<input type="hidden" name="dataid" value="{$opt2}" readonly />
<div class="head">
{$back}
<button type="submit" class="waves-effect btn-flat blue accent-3" onclick="sOPT('edit')">submit</button>
<button type="button" class="waves-effect btn-flat">order no. - {$ordernumber}</button>
<button type="button" class="waves-effect btn-flat">order date - {$fn->dateformat($orderdate)}</button>
<button type="submit" class="waves-effect btn-flat" onclick="sOPT('downloadinvoice')"><i class="material-icons left">download</i>invoice</button>
<button type="submit" class="waves-effect btn-flat" onclick="sOPT('downloadreceipt')"><i class="material-icons left">download</i>receipt</button>
<button type="submit" class="waves-effect btn-flat red white-text" onclick="sOPT('sendshippingdetails', 'Do you really want to send shipping details?')">send shipping details</button>
</div>
<div class="body">
<div class="row">
<div class="col s12 m4 l4">
<label for="shippingdate">shipping date</label>
<input type="text" name="shippingdate" value="{$shippingdate}" id="shippingdate" class="datepicker" />
</div>
<div class="col s12 m4 l4">
<label for="shippingmethod">shipping method</label>
<input type="text" name="shippingmethod" value="{$shippingmethod}" id="shippingmethod" list="shippingmethods" />
<datalist id="shippingmethods">{$shippingmethods}</datalist>
</div>
<div class="col s12 m4 l4">
<label for="shippingcode">shipping code</label>
<input type="text" name="shippingcode" value="{$shippingcode}" id="shippingcode" />
</div>
</div>
<div class="row">
<div class="col s12 m4 l4">
<label for="shippingname">shipping name<b class="red-text right">*</b></label>
<input type="text" name="shippingname" value="{$shippingname}" id="shippingname" />
</div>
<div class="col s12 m4 l4">
<label for="shippingemail">shipping email</label>
<input type="text" name="shippingemail" value="{$shippingemail}" id="shippingemail" />
</div>
<div class="col s12 m4 l4">
<label for="shippingphone">shipping phone</label>
<input type="text" name="shippingphone" value="{$shippingphone}" id="shippingphone" />
</div>
</div>
<div class="row">
<div class="col s12 m6 l6">
<label for="shippingaddress">shipping address</label>
<textarea rows="5" cols="5" name="shippingaddress" id="shippingaddress" class="materialize-textarea">{$shippingaddress}</textarea>
</div>
<div class="col s12 m6 l6">
<label for="billingaddress">billing address</label>
<textarea rows="5" cols="5" name="billingaddress" id="billingaddress" class="materialize-textarea">{$billingaddress}</textarea>
</div>
</div>
<div class="row">
<div class="col s12 m3 l3">
<label for="shippingcharge">shipping charge</label>
<input type="text" name="shippingcharge" id="shippingcharge" value="{$shippingcharge}" />
</div>
<div class="col s12 m3 l3">
<label for="payment_mode">payment mode</label>
<select name="payment_mode" id="payment_mode" class="browser-default">
{$paymentmodes}
</select>
</div>
<div class="col s12 m3 l3">
<label for="payment_date">payment date</label>
<input type="text" name="payment_date" value="{$payment_date}" id="payment_date" class="datepicker" />
</div>
<div class="col s12 m3 l3">
<label for="txn_number">txn number</label>
<input type="text" name="txn_number" value="{$txn_number}" id="txn_number" />
</div>
</div>
<div class="row">
<div class="col s12 m6 l4">
<label for="account_number">account number</label>
<input type="text" name="account_number" value="{$account_number}" id="account_number" list="account_numbers" />
<datalist id="account_numbers">
<option value="ICICI-100405000489">ICICI-100405000489</option>
<option value="IDBI-0163102000020323">IDBI-0163102000020323</option>
</datalist>
</div>
<div class="col s12 m6 l8">
<label for="comment">comment</label>
<input type="text" name="comment" value="{$comment}" id="comment" />
</div>
</div>
<div class="row">
<div class="col s12 m4 l4">
<label for="gemcontractnumber">gem contract number</label>
<input type="text" name="gemcontractnumber" value="{$gemcontractnumber}" id="gemcontractnumber" />
</div>
<div class="col s12 m4 l4">
<label for="gemsellerid">gem seller id</label>
<input type="text" name="gemsellerid" value="{$gemsellerid}" id="gemsellerid" />
</div>
<div class="col s12 m4 l4">
<label class="chklab" style="margin-top:17px;"><input type="checkbox" name="gemorder" value="true" {$gemorderChecked} />gem order</label>
</div>
</div>
</div>
EOJ;
function products($productid)
{
global $mysqli, $imageurl, $uploadpath;
$stmt = $mysqli->prepare("SELECT title, volume, image FROM products WHERE productid = ? LIMIT 1") or die($mysqli->error);
$stmt->bind_param('i', $productid);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($title, $volume, $image);
$stmt->fetch();
$stmt->close();
$image = ($image && file_exists($uploadpath . $image)) ? $image : 'product-ico.png';
return array('<img src="' . $imageurl . $image . '" width="70" style="float:none" />', $title . ($volume ? ' (Volume - ' . $volume . ')' : ''));
}
function product_list()
{
global $mysqli;
$html = '';
$stmt = $mysqli->prepare("SELECT productid, title, volume, price, royalty FROM products WHERE category = 'Book' ORDER BY title ASC, volume ASC") or die($mysqli->error);
$stmt->execute();
$stmt->store_result();
$stmt->num_rows();
$stmt->bind_result($productid, $title, $volume, $price, $royalty);
while ($stmt->fetch()) :
$html .= '<option value="' . $productid . '" data-price="' . (explode('.', $price)[0]) . '" data-royalty="' . ($royalty ?: '') . '">' . $title . ($volume ? ' (Volume - ' . $volume . ')' : '') . '</option>';
endwhile;
$stmt->close();
return $html;
}
$product_list = product_list();
?>
<div class="body" style="margin-top: 10px;">
<button type="submit" class="waves-effect btn-flat blue accent-3" style="margin-left: 12px;" onclick="sOPT('additems')">add items</button><br>
<div id="copyableProduct" style="float:left;width:100%;margin-top:15px;">
<div class="row" style="display:flex;">
<div class="col">
<label for="productid">product<b class="red-text right">*</b></label>
<select name="productid[]" class="browser-default" onchange="$(this).closest('.row').find('.price').val($(this).children('option:selected').data('price')); $(this).parents('.row').find('.royalty').val($(this).children('option:selected').data('royalty'));">
<option value="" selected>Select Product</option>
<?php echo $product_list; ?>
</select>
</div>
<div class="col">
<label for="price">price<b class="red-text right">*</b></label>
<input type="text" name="newprice[]" id="price" class="price" />
</div>
<div class="col">
<label for="discount">discount</label>
<input type="text" name="newdiscount[]" id="discount" class="int" />
</div>
<div class="col">
<label for="quantity">quantity<b class="red-text right">*</b></label>
<input type="text" name="newquantity[]" id="quantity" value="1" class="int" />
</div>
<div class="col">
<label for="royalty">royalty</label>
<input type="text" name="newroyalty[]" id="royalty" class="int royalty" />
</div>
<div class="col">
<button type="button" class="waves-effect btn-flat black-text right" style="width:85px;margin-top:16px" onclick="addMoreProduct()">add more</button>
</div>
</div>
</div>
<div class="moreproduct" style="float:left;width:100%;"></div>
</div>
<script>
function addMoreProduct(){
$('.moreproduct').append(copyableProduct.innerHTML).find('button').text('remove').attr('onclick', '$(this).closest(\'.row\').remove().find(\'input\').val(\'\')');
}
</script>
<div style="padding: 10px;float:left;width:100%;">
<button type="submit" class="waves-effect btn-flat h blue accent-3" onclick="sOPT('saveitems')">save items</button>
<button type="submit" class="waves-effect btn-flat h" onclick="sOPT('deleteorderitem', 'Do you really want to delete?')"><i class="material-icons">delete</i></button>
</div>
<table class="table" style="border-top:1px solid #e5e5e5">
<thead>
<tr>
<th class="xs center-align"><input type="checkbox" name="checkall" id="checkall" value="" /></th>
<th class="xs center-align">s. no.</th>
<th class="md center-align">item</th>
<th>title</th>
<th class="sm center-align">royalty</th>
<th class="sm right-align">price (₹)</th>
<th class="sm center-align">discount (%)</th>
<th class="sm center-align">quantity</th>
<th class="sm right-align">subtotal</th>
</tr>
</thead>
<tbody>
<?php
$total = 0;
$stmt = $mysqli->prepare("SELECT orderitemid, productid, price, discount, quantity, royalty, royaltyprice FROM order_items WHERE orderid = ? ORDER BY orderitemid DESC") or die($mysqli->error);
$stmt->bind_param('i', $opt2);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows() > 0) :
$stmt->bind_result($orderitemid, $productid, $price, $discount, $quantity, $royalty, $royaltyprice);
while ($stmt->fetch()) :
$snum = $snum + 1;
$product = products($productid);
$subtotal = $price * $quantity;
$discount = $discount ?: 0;
$discountedAmount = $subtotal - (($subtotal * $discount) / 100);
$total = $total + $discountedAmount;
$royaltyAmount = ($discountedAmount * $royalty) / 100;
?>
<tr>
<td class="center-align"><input type="checkbox" name="orderitemid[]" value="<?php echo $orderitemid; ?>" class="checkbox" /></td>
<td class="center-align"><?php echo $snum; ?></td>
<td class="center-align"><?php echo $product[0]; ?></td>
<td><?php echo $product[1]; ?></td>
<td class="center-align"><?php echo $royalty; ?>%</td>
<td class="center-align">
<input type="text" name="price[<?php echo $orderitemid; ?>]" value="<?php echo number_format($price, 0, '', ''); ?>" class="right-align" />
</td>
<td class="center-align">
<input type="text" name="discount[<?php echo $orderitemid; ?>]" value="<?php echo $discount; ?>" class="center-align" />
</td>
<td class="center-align">
<input type="text" name="quantity[<?php echo $orderitemid; ?>]" value="<?php echo $quantity; ?>" class="center-align" />
</td>
<td class="right-align">₹ <?php echo number_format($discountedAmount, 2); ?></td>
</tr>
<?php
endwhile;
?>
<tr>
<td class="right-align" colspan="8"><b>Total</b></td>
<td class="right-align"><b>₹ <?php echo number_format($total, 2); ?></b></td>
</tr>
<?php
if ($gemorder === 'true') :
$gemDiscount = ($total * 10) / 100;
?>
<tr>
<td class="right-align" colspan="8"><b>Discount (10%)</b></td>
<td class="right-align"><b>₹ <?php echo number_format($gemDiscount, 2); ?></b></td>
</tr>
<tr>
<td class="right-align" colspan="8"><b>Grand Total</b></td>
<td class="right-align"><b>₹ <?php echo number_format($total - $gemDiscount, 2); ?></b></td>
</tr>
<?php
endif;
endif;
$stmt->close();
?>
</tbody>
</table>
<?php
else :
function items($orderid)
{
global $mysqli;
$stmt = $mysqli->prepare("SELECT COUNT(*), SUM(price * quantity) FROM order_items WHERE orderid = ?") or die($mysqli->error);
$stmt->bind_param('i', $orderid);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($count_rows, $price);
$stmt->fetch();
$stmt->close();
return array('items' => $count_rows, 'price' => $price);
}
$keyword = "%$keyword%";
if ($opt1 === "search") :
$stmt = $mysqli->prepare("SELECT * FROM $table WHERE (ordernumber LIKE ? OR shippingcode LIKE ? OR shippingname LIKE ? OR shippingemail LIKE ? OR shippingphone LIKE ? OR shippingaddress LIKE ? OR txn_number LIKE ? OR gemcontractnumber LIKE ? OR gemsellerid LIKE ?)") or die($mysqli->error);
$stmt->bind_param('sssssssss', $keyword, $keyword, $keyword, $keyword, $keyword, $keyword, $keyword, $keyword, $keyword);
$stmt->execute();
$stmt->store_result();
$total_rows = $stmt->num_rows();
$stmt->close();
elseif ($opt1 === 'status') :
$stmt = $mysqli->prepare("SELECT * FROM $table WHERE orderstatus = ?") or die($mysqli->error);
$stmt->bind_param('s', $opt2);
$stmt->execute();
$stmt->store_result();
$total_rows = $stmt->num_rows();
$stmt->close();
elseif ($opt1 === 'searchbybookname') :
$bookname = "%$opt2%";
$stmt = $mysqli->prepare("SELECT orders.* FROM $table JOIN (order_items JOIN products ON products.productid = order_items.productid) ON order_items.orderid = orders.orderid WHERE products.title LIKE ?") or die($mysqli->error);
$stmt->bind_param('s', $bookname);
$stmt->execute();
$stmt->store_result();
$total_rows = $stmt->num_rows();
$stmt->close();
else :
$stmt = $mysqli->prepare("SELECT * FROM $table") or die($mysqli->error);
$stmt->execute();
$stmt->store_result();
$total_rows = $stmt->num_rows();
$stmt->close();
endif;
echo <<<EOJ
<div class="head">
<button type="button" class="waves-effect btn-flat green" onclick="cURL('add')">add order</button>
<button type="submit" class="waves-effect btn-flat red white-text h" onclick="sOPT('failed', 'Do you really want to mark as failed?')">failed</button>
<button type="submit" class="waves-effect btn-flat green h" onclick="sOPT('placed', 'Do you really want to mark as placed?')">placed</button>
<button type="submit" class="waves-effect btn-flat green h" onclick="sOPT('delivered', 'Do you really want to mark as delivered?')">delivered</button>
<button type="submit" class="waves-effect btn-flat green h" onclick="sOPT('dispatched', 'Do you really want to mark as dispatched?')">dispatched</button>
<button type="submit" class="waves-effect btn-flat h" onclick="sOPT('refund', 'Do you really want to mark as refund?')">refund</button>
<button type="submit" class="waves-effect btn-flat h" onclick="sOPT('invoice', 'Do you really want to mark as invoice?')">invoice</button>
<button type="submit" class="waves-effect btn-flat h" onclick="sOPT('gemorder', 'Do you really want to mark as gem order?')">gem order</button>
<button type="submit" class="waves-effect btn-flat h" onclick="sOPT('downloadaddress')">download address</button>
<button type="submit" class="waves-effect btn-flat h" onclick="sOPT('delete', 'Do you really want to delete?')"><i class="material-icons">delete</i></button>
{$pagination->get($total_rows,$page_number,$item_per_page)}
<select name="status" class="browser-default right" style="width:auto;border:1px solid #ddd;clear:none;margin-right:10px;" onchange="if (this.value) { location = '{$adminurl}u/orders/status/' + this.value; }">
<option value="" selected="selected">Select Status</option>
<option value="processing">Processing</option>
<option value="placed">Placed</option>
<option value="failed">Failed</option>
<option value="cancelled">Cancelled</option>
<option value="dispatched">Dispatched</option>
<option value="delivered">Delivered</option>
<option value="refund">Refund</option>
</select>
</div>
<div style="float:left;width:100%;padding:10px;">
<input type="text" id="bookNameKeyword" class="browser-default" placeholder="Enter book name" style="float:left;width:300px;height:36px;border:1px solid #999;padding:0 10px;" onkeypress="if (event.keyCode == 13) { if (this.value) { let key = this.value; location = '{$adminurl}u/orders/searchbybookname/' + key.replace(/ /gi, '+'); return false; } else { return false; } }" />
</div>
<table class="table">
<thead>
<tr>
<th nowrap class="xs center-align"><input type="checkbox" name="checkall" id="checkall" value="" /></th>
<th nowrap class="xs center-align">s. no.</th>
<th nowrap>order number</th>
<th>customer</th>
<th nowrap class="center-align">items</th>
<th nowrap class="right-align">amount</th>
<th>ship name</th>
<th>ship email</th>
<th>ship phone</th>
<th>ship code</th>
<th nowrap class="right-align">order date</th>
<th nowrap class="center-align">status</th>
</tr>
</thead>
<tbody>
EOJ;
if ($opt1 === 'search') :
$stmt = $mysqli->prepare("SELECT $firstcol, currency, customerid, ordernumber, orderdate, orderstatus,shippingcharge, shippingcode, shippingname, shippingemail, shippingphone, shippingaddress, payment_mode, payment_date, txn_number, gemorder FROM $table WHERE (ordernumber LIKE ? OR shippingcode LIKE ? OR shippingname LIKE ? OR shippingemail LIKE ? OR shippingphone LIKE ? OR shippingaddress LIKE ? OR txn_number LIKE ? OR gemcontractnumber LIKE ? OR gemsellerid LIKE ?) ORDER BY $firstcol DESC LIMIT $page_position, $item_per_page") or die($mysqli->error);
$stmt->bind_param('sssssssss', $keyword, $keyword, $keyword, $keyword, $keyword, $keyword, $keyword, $keyword, $keyword);
elseif ($opt1 === 'status') :
$stmt = $mysqli->prepare("SELECT $firstcol, currency, customerid, ordernumber, orderdate, orderstatus, shippingcharge, shippingcode, shippingname, shippingemail, shippingphone, shippingaddress, payment_mode, payment_date, txn_number, gemorder FROM $table WHERE orderstatus = ? ORDER BY $firstcol DESC LIMIT $page_position, $item_per_page") or die($mysqli->error);
$stmt->bind_param('s', $opt2);
elseif ($opt1 === 'searchbybookname') :
$stmt = $mysqli->prepare("SELECT orders.$firstcol, orders.currency, orders.customerid, orders.ordernumber, orders.orderdate, orders.orderstatus, orders.shippingcharge, orders.shippingcode, orders.shippingname, orders.shippingemail, orders.shippingphone, orders.shippingaddress, orders.payment_mode, orders.payment_date, orders.txn_number, orders.gemorder FROM $table JOIN (order_items JOIN products ON products.productid = order_items.productid) ON order_items.orderid = orders.orderid WHERE products.title LIKE ? ORDER BY orders.$firstcol DESC LIMIT $page_position, $item_per_page") or die($mysqli->error);
$stmt->bind_param('s', $bookname);
else :
$stmt = $mysqli->prepare("SELECT $firstcol, currency, customerid, ordernumber, orderdate, orderstatus, shippingcharge, shippingcode, shippingname, shippingemail, shippingphone, shippingaddress, payment_mode, payment_date, txn_number, gemorder FROM $table ORDER BY $firstcol DESC LIMIT $page_position, $item_per_page") or die($mysqli->error);
endif;
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows() > 0) :
$stmt->bind_result($id, $currency, $customerid, $ordernumber, $orderdate, $orderstatus, $shippingcharge, $shippingcode, $shippingname, $shippingemail, $shippingphone, $shippingaddress, $payment_mode, $payment_date, $txn_number, $gemorder);
while ($stmt->fetch()) :
$snum = ($page_number == 1) ? $snum + 1 : $page_position++ + 1;
$currency = $currency === 'USD' ? '$' : '₹';
$statuses = array('processing' => 'orange', 'placed' => 'green', 'dispatched' => 'green', 'delivered' => 'green', 'failed' => 'red');
$class = array_key_exists($orderstatus, $statuses) ? $statuses[$orderstatus] : 'grey';
$items = items($id);
$orderTotal = $items['price'] + $shippingcharge;
$gemorder = $gemorder === 'true' ? '<span style="font-size:10px;position:absolute;bottom:-1px;left:2px">GEM ORDER</span>' : '';
$paymentIcon = ($payment_mode && $payment_date && $txn_number) ? '<i class="material-icons" style="font-size:18px;position:absolute;top:-1px;left:-3px">star</i>' : '';
$shippingaddressIcon = $shippingaddress ? '<i class="material-icons" style="font-size:12px;position:absolute;top:-1px;left:-3px">location_on</i>' : '';
echo <<<EOJ
<tr>
<td nowrap class="center-align"><input type="checkbox" name="dataid[]" value="{$id}" class="checkbox" /></td>
<td nowrap class="center-align">{$paymentIcon}{$snum}</td>
<td nowrap>{$shippingaddressIcon}<button type="button" class="link blue-text text-accent-3" onclick="cURL('edit/{$id}')">{$ordernumber}</button>{$gemorder}</td>
<td>{$shippingname}</td>
<td nowrap class="center-align">{$items['items']}</td>
<td nowrap class="right-align">{$fn->amount($currency, $orderTotal)}</td>
<td>{$shippingname}</td>
<td>{$shippingemail}</td>
<td>{$shippingphone}</td>
<td>{$shippingcode}</td>
<td nowrap class="right-align">{$fn->dateformat($orderdate)}</td>
<td nowrap class="center-align"><span class="txnst {$class} white-text">{$orderstatus}</span></td>
</tr>
EOJ;
endwhile;
else :
echo '<tr><td colspan="12" class="center-align">' . $emptyrows . '</td></tr>';
endif;
$stmt->close();
echo '</tbody>';
echo '</table>';
endif;
?>