} else {
            display_warning(" Your Current Account Balance is lower than the payout!.");
        }
        echo '</tr>';
        end_table();
    } else {
        display_warning(" Paid Already!.");
    }
    div_end();
}
end_form();
if (get_post('RefreshInquiry')) {
    $Ajax->activate('gross_salary');
    $Ajax->activate('leave_days');
    $Ajax->activate('monthly_loan');
    $Ajax->activate('totals_tbl');
}
if (get_post('pay_salary')) {
    global $Refs;
    $pay_slip_id = add_payslip($_POST['year'], $_POST['month'], $_POST['empl_id'], $_POST['basic'], $_POST['da'], $_POST['hra'], $_POST['convey_allow'], $_POST['edu_other_allow'], $_POST['pf'], $_POST['lop_amount'], $_POST['tds'], $_POST['total_ded'], $_POST['total_net'], $_POST['date_of_pay']);
    add_gl_trans(99, $pay_slip_id, $_POST['date_of_pay'], 5410, 0, 0, 'employee Salary #' . $_POST['empl_id'], $_POST['total_net']);
    add_gl_trans(99, $pay_slip_id, $_POST['date_of_pay'], 1060, 0, 0, 'employee Salary #' . $_POST['empl_id'], -$_POST['total_net']);
    $trans_no = kv_get_next_trans_no(99) + 1;
    $ref = get_next_reference(99);
    $total_net_pay = -$_POST['total_net'];
    add_bank_trans(99, $trans_no, 1, $ref, $_POST['date_of_pay'], $total_net_pay, 99, $_POST['empl_id']);
    $Refs->save(99, $trans_no, $ref);
    kv_save_next_trans_no($trans_no);
    display_notification(' The Employee Payslip is added #' . $pay_slip_id);
}
end_page();
    }
    if (date_diff2(sql2date($wo_details["released_date"]), $_POST['date_'], "d") > 0) {
        display_error(_("The additional cost date cannot be before the release date of the work order."));
        set_focus('date_');
        return false;
    }
    return true;
}
//--------------------------------------------------------------------------------------------------
if (isset($_POST['process']) && can_process() == true) {
    $date = $_POST['date_'];
    begin_transaction();
    add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['cr_acc'], 0, 0, $date . ": " . $wo_cost_types[$_POST['PaymentType']], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType']);
    $is_bank_to = is_bank_account($_POST['cr_acc']);
    if ($is_bank_to) {
        add_bank_trans(ST_WORKORDER, $_POST['selected_id'], $is_bank_to, "", $_POST['date_'], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType'], get_company_currency(), "Cannot insert a destination bank transaction");
    }
    add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['db_acc'], $_POST['dim1'], $_POST['dim2'], $date . ": " . $wo_cost_types[$_POST['PaymentType']], input_num('costs'), PT_WORKORDER, $_POST['PaymentType']);
    //Chaitanya : Apply the costs to manfuctured stock item as adjustement
    $wo = get_work_order($_POST['selected_id']);
    if ($_POST['PaymentType'] == 0) {
        add_labour_cost($wo['stock_id'], 0, $_POST['date_'], input_num('costs'), true);
    } else {
        add_overhead_cost($wo['stock_id'], 0, $_POST['date_'], input_num('costs'), true);
    }
    commit_transaction();
    meta_forward($_SERVER['PHP_SELF'], "AddedID=" . $_POST['selected_id']);
}
//-------------------------------------------------------------------------------------
display_wo_details($_POST['selected_id']);
//-------------------------------------------------------------------------------------