<?php
include("../../classes/manager.class.php");
$m = new Manager();
$customer = '';
if ($_REQUEST['id']) {
    $id = $_REQUEST['id'];
    $discount = $_REQUEST['discount'];
    if ($customer == 0) {
        $hide = 'style="display:none"';
    }
    $qry = ProductSetup::GetProductSetupById($id);
    if ($qry) {
        echo "<tr id='tr" . $id . "'>";
        echo '<td style="width: 30px; height: 30px; font-size: 12px; line-height: 15px; margin-top: 11px;" class="mini-stat-icon orange darken-2">';
        echo '<i id="trashing' . $id . '" style="cursor: pointer;font-size: 18px;margin-top: 7px;" class="mdi-action-delete"></i>';
        echo '</td>';
        echo '<td>';
        echo '<input class="form-control" style="width:100%!important;" type="text" readonly value="' . $qry->name . '">';
        echo '<input type="hidden" name="products[]" id="product" value="' . $qry->id . '">';
        echo '</td>';
        echo '<td>';
        echo '<input class="form-control" style="width:100%!important;" type="text" readonly value="' . $qry->barcode . '">';
        echo '</td>';
        echo '<td>';
        echo '<input class="form-control" style="width:100%!important;" type="text" readonly value="' . $qry->weight . ' ' . $qry->unit . '">';
        echo '</td>';
        echo '<td>';
        echo '<input required maxlength="10" onkeypress="return isDoubleNumberKey(event)" class="form-control" style="width:100%!important;" type="text" name="piece_carton[]" value="' . $qry->carton_pieces . '">';
        echo '</td>';
        echo '<td>';
        echo '<input style="width:100%!important;" required maxlength="10" onkeypress="return isDoubleNumberKey(event)" class="form-control" type="text" name="tpRate[]" value="' . $qry->tp_rate . '" id="tpRate">';
        echo '</td>';
        echo '<td>';
        echo '<input class="form-control" style="width:100%!important;" type="text" readonly value="' . $discount . '" id="discountProductsText">';
        echo '<input type="hidden" name="discountProducts[]" id="discountProducts" value="' . $discount . '">';
        echo '</td>';
        echo '<td id="subTotal">';
        $discountPrice = 0;
        $discountPrice = intval($qry->tp_rate) - (intval($qry->tp_rate) * ($discount / 100));
        echo $discountPrice;
        echo '</td>';
        //echo "</tr>";
    }
}

?>
<script>
    $('#trashing<?=$id?>').on('click', function () {
        $(this).parent('td').parent('tr').remove();
        Calculate();
    });
</script>
</tr>