$tmp1 = $this->db->fetch_assoc($this->db->query("SELECT grant_total FROM erp_order WHERE order_id = {$module_id}"));
$full_amount = $tmp1["grant_total"];
$bill_amount = $full_amount / 2;
$total_arr = $this->db->fetch_assoc($this->db->query("SELECT SUM( amount ) total FROM `payments` WHERE for_module_name = 'order' AND for_module_id = '{$module_id}' AND refund='no'"));
$already_payed = $total_arr["total"];
// $return["javascript"] = "alert('ba: $bill_amount|ap: $already_payed');";
//$return["javascript"] = "alert('" . $this->db->num_rows($result) . "| $already_payed | $bill_amount" . "');";
if ($this->db->num_rows($result) == 0 && $already_payed < $bill_amount) {
    $return["stop"] = "YES";
    $bill = $bill_amount - $already_payed;
    $contacts = $this->get_contact_by_module($module_id, $module_name);
    $credit_cards = $secure->get_creditcards("contacts", $contacts[0]);
    $tmp1 = $this->db->fetch_assoc($this->db->query("SELECT ccid FROM erp_order WHERE order_id = {$module_id}"));
    $ccid = $tmp1["ccid"];
    if (array_key_exists($ccid, $credit_cards) == false && $ccid != '0') {
        $cc2 = $secure->get_creditcard($ccid);
        $credit_cards[$ccid] = $cc2[$ccid];
    }
    $ccoptions = '<option value="">--SELECT ONE--</option>';
    foreach ($credit_cards as $num => $card) {
        if ($num = $ccid) {
            $select = " SELECTED ";
        } else {
            $select = '';
        }
        $ccoptions .= "<option {$select} value='" . $card["ccid"] . "' >" . $card["name"] . " - " . $card["type"] . " " . $card["expiration"] . "</option>";
    }
    ob_start();
    ?>
<div id='payment_parrent_div' style='position: fixed;right: 0px;bottom:0px; width: 50%;height: 50%;' >
<div style='z-index: 21;position: relative;left: -200px;top: -150px;width: 400px; height: 300px;background: white;border-top-left-radius: 20px;border-top-right-radius: 20px;' >