<?php if(!defined('ABSPATH')) exit; // Exit if accessed directly  ?>
<script>
var ajaxurl = "<?php echo esc_html(admin_url('admin-ajax.php')); ?>";
var pluginurl = "<?php
                    $urlparts = wp_parse_url(home_url());
                    $protocol = esc_html($urlparts['scheme']);
                    $domain = esc_html($urlparts['host']);
                    $myurl = $protocol . "://" . $domain . esc_html($_SERVER['REQUEST_URI']);
                    $myurl = str_replace("&amp;", "&", $myurl);
                    $myurl = remove_query_arg(array('action','id','pg','st','o','a','n','r','f','t','tid','status','min','max','c','rc'), $myurl);
                    if(substr($myurl, -1) === '/') {$myurl = substr($myurl, 0, -1);}
                    echo $myurl; ?>";
pluginurl = pluginurl.replace(/&amp;/g, '&');
var expenseszyx987_createExpense_nonce = "<?php echo wp_create_nonce('expenseszyx987_createExpense'); ?>";
function formSubmit(event) {
    event.preventDefault();
}
var myform;
jQuery(function() {
    jQuery('select#expensetypeid').val('-1');
    jQuery('h3#createexpense_header').focus();
    myform = document.getElementById('createexpense');
    myform.addEventListener('submit',formSubmit);
    jQuery("input#expenseisrecurring2").click(function(){
        jQuery("div.recurringdetails > div").show();
    });     
    jQuery("input#expenseisrecurring").click(function(){
        jQuery("div.recurringdetails > div").hide();
        jQuery("input#expenserecurringpaymentstartdate").val('');
        jQuery("input#expenserecurringpaymentenddate").val('');
        jQuery("select#expenserecurringpaymentfrequencyid").val('-1');
        jQuery("select#expenserecurringpaymentdayid").val('-1');
    });
    jQuery("select#expensetaxrateid").click(function(){
        if(jQuery(this).find(":selected").val() === '-1') {
            jQuery("div.expenseamountistaxinclusive > div").hide();
            jQuery("input#expenseamountincludetax").prop("checked", true);
        } else {
            jQuery("div.expenseamountistaxinclusive > div").show();
        }
    });
});
</script>
<style>
div#wpadminbar {
    display: none !important;
}
select, textarea, input {
    font-size: 2.25rem !important;
}
a.btn-lg {
    font-size: 2.25rem !important;
    border: 1px solid gray !important;
}
.bold, div.contentcontainer h3 {
    font-size: 2.25rem !important;
    font-weight: bold !important;
}
.xdsoft_datetimepicker .xdsoft_timepicker {
    width: 350px !important;
}
div.xdsoft_time {
    font-size: 2.25rem !important;
    font-weight: bold !important;
    padding: 5px 0px 5px 0px !important;
    height: 40px !important;
}
div.xdsoft_scrollbar {
    width: 35px !important;
}
div.xdsoft_scrollbar div.xdsoft_scroller {
    height: 50px !important;
}
span.w, li>a.w, .redtext {
    color: red !important;
}
span.m, li>a.m {
    color: orange !important;
}
span.b, li>a.b {
    color: black !important;
}
span.t, li>a.t {
    color: blue !important;
}
span.v, li>a.v {
    color: green !important;
}
span.h, li>a.h {
    color: purple !important;
}
span.o, li>a.o {
    color: cyan !important;
}
div.inline {
    display: inline-block;
}
.datepicker {
    padding: 0 0 0 0px;
}
.outer {
    display: table;
    position: absolute;
    height: 100%;
    width: 100%;
}
.middle {
    display: table-cell;
    vertical-align: middle;
}
.inner {
    margin-left: auto;
    margin-right: auto; 
    width: 10px;
}
.font24px {
    font-size:24px;
}
a.filled {
    background-color: #337ab7;
    border-color: #2e6da4;
}
/* The Close Button */
.closebutton {
    color: #fff;
    position: absolute;
    top: 10px;
    right: 25px;
    font-size: 35px;
    font-weight: bold;
    font-family: Verdana, sans-serif;
}
.closebutton:hover,
.closebutton:focus {
    color: #999;
    text-decoration: none;
    cursor: pointer;
}
.cursor {
    cursor: pointer
}
.expense_create_right_section {
    display: none;
}
div.recurringdetails > div {
    display: none;
}
div.expenseamountistaxinclusive > div{
    display: none;
}
</style>
<br/>
<h3 tabindex="0" id="createexpense_header">Create Expense:</h3>
<?php if($dragon_expense_submitform_Result !== '') { ?>
<div class="updated col-12" style="color:#842029;background-color:#f8d7da;padding-top:5px;padding-bottom:5px;"><p style="margin-top:5px !important;margin-bottom:5px !important;text-align:center;"><?php echo esc_html($dragon_expense_submitform_Result); ?></p></div>
<?php } ?>
<form id="createexpense" name="createexpense"  action="" method="POST" onsubmit="submitExpenseData('createexpense', 'submitcreateexpense');">
    <div class="container-fluid">
        <br/>
        <div class="row"><br/>
            <div  class="col-xs-12 col-md-12 bold" ><span tabindex="0">Expense Date* (For example, 2000-12-01, not 2000-12-1, not 12/1/2000, not 1/12/2000, not Jan 12, 2000):</span>
                <br/><input tabindex="0" aria-label="Expense Date" type="text" name="expensedate" id="expensedate" class="fromdate datepicker form-control bold" value="" />
            </div>
        </div>
        <br/>
        <div class="row"><br/>
            <div  class="col-xs-12 col-md-12 bold"><span tabindex="0">Expense Type*:</span>
            <select tabindex="0" aria-label="Expense Type" name="expensetypeid" id="expensetypeid" class="form-select form-select-lg">
                <option value="-1">Select one...</option>
                <?php
                if(!empty($expensetypes)){
                    foreach ($expensetypes as $type){
                            $temp1 = empty($type->list) ? array() : explode('|',$type->list);
                            $myassociatearray = [];
                            foreach($temp1 as $temp2) {
                                $temp3 = empty($temp2) ? array('','') : explode('_',$temp2,2);
                                $myassociatearray[$temp3[0]] = $temp3[1] . " [" . $type->typecategoryname . "]";
                            }

                        if (count($myassociatearray)){
                            foreach ($myassociatearray as $k => $v){
                               echo "<option value='" . esc_html($k) . "'>" . esc_html($v) . "</option>";
                            }
                        }
                    }
                }
                ?>
            </select>
            </div>
        </div>
        <br/>
        <div class="row"><br/>
            <div class="col-xs-12 col-md-12 bold" ><span tabindex="0">Amount*:</span>
            </div>
        </div>

        <div class="row">
            <div class="col-xs-4 col-md-4 bold" >
                <select tabindex="0" aria-label="Expense Currency Name" name="expensecurrencyid" id="expensecurrencyid" class="form-select form-select-lg">
                    <option value="-1">Select currency...</option>
                    <?php
                    if(!empty($currencies)){
                        foreach ($currencies as $currency){
                            echo "<option value='" . intval($currency->id) . "'>" . esc_html($currency->name) . "</option>";
                        }
                    }
                    ?>
                </select>
            </div>
            <div class="col-xs-8 col-md-8 bold" >
                <input tabindex="0" aria-label="Expense Amount" type="text" name="expenseamount" id="expenseamount" class="fromdate form-control bold" value="" />
            </div>
        </div>
        <br/>
        <div class="row"><br/>
            <div class="col-xs-12 col-md-12 bold" ><span tabindex="0">Tax Rate:</span>
            </div>
        </div>

        <div class="row">
            <div class="col-xs-12 col-md-12 bold" >
                <select tabindex="0" aria-label="Expense Tax Rate" name="expensetaxrateid" id="expensetaxrateid" class="form-select form-select-lg">
                    <option value="-1">Select rate...</option>
                    <?php
                    if(!empty($taxrates)){
                        foreach ($taxrates as $rate){
                            echo "<option value='$rate->id'>" . esc_html($rate->name) ." [" . (100 * $rate->rate) . "%]</option>";
                        }
                    }
                    ?>
                </select>
            </div>
        </div>

        <div class="expenseamountistaxinclusive row">
            <div class="col-xs-12 col-md-12 bold" ><br/><span tabindex="0">Amount is:</span>
            </div>
        </div>
        
        <div class="expenseamountistaxinclusive row">
            <div class="col-xs-4 col-md-4 bold" >
                <input tabindex="0" aria-label="Expense Amount Is Tax Inclusive" type="radio" id="expenseamountincludetax" name="expenseamountincludetax" value="1" checked="checked" >
                <label for="expenseamountincludetax">Tax Inclusive</label>
            </div>
            <div class="col-xs-4 col-md-4 bold" >
                <input tabindex="0" aria-label="Expense Amount Is Tax Exclusive" type="radio" id="expenseamountincludetax2" name="expenseamountincludetax" value="0">
                <label for="expenseamountincludetax2">Tax Exclusive</label>
            </div>
        </div>
        <br/>
        <div class="row"><br/>
            <div class="col-xs-12 col-md-12 bold" ><span tabindex="0">Reference #:</span>
                <input tabindex="0" aria-label="Expense Reference Number" type="text" name="expensereferencenumber" id="expensereferencenumber" class="fromdate form-control bold" value="" />
            </div>
        </div>
        <br/>
        <div class="row"><br/>
            <div class="col-xs-12 col-md-12 bold" ><span tabindex="0">Notes:</span>
                <textarea tabindex="0" aria-label="Expense Notes" name="expensenotes" id="expensenotes" class="form-control form-control-lg"  rows="3"></textarea>
            </div>
        </div>
        <br/>
        <div class="row"><br/>
            <div  class="col-xs-12 col-md-12 bold"><span tabindex="0">Customer Name:</span>
            <select tabindex="0" aria-label="Expense Customer Name" name="expensecustomerid" id="expensecustomerid" class="form-select form-select-lg">
                <option value="-1">Select one...</option>
                <?php
                if(!empty($customers)){
                    foreach ($customers as $customer){
                        echo "<option value='$customer->id'>" . esc_html($customer->name) . "</option>";
                    }
                }
                ?>
            </select>
            </div>
        </div>
        <br/>
        <div class="row"><br/>
            <div class="col-xs-12 col-md-12 bold" ><span tabindex="0">Expense Is Recurring?:</span>
            </div>
        </div>

        <div class="row">
            <div class="col-xs-4 col-md-4 bold" >
                <input tabindex="0" aria-label="Expense Is Recurring" type="radio" id="expenseisrecurring" name="expenseisrecurring" value="0" checked="checked">
                <label for="expenseisrecurring">No</label><br>
            </div>
            <div class="col-xs-4 col-md-4 bold" >
                <input tabindex="0" aria-label="Expense Is Recurring" type="radio" id="expenseisrecurring2" name="expenseisrecurring" value="1" >
                <label for="expenseisrecurring2">Yes</label><br>
            </div>
        </div>

        <div class="row recurringdetails">
            <div  class="col-xs-12 col-md-12 bold" ><br/><span tabindex="0">Recurring Payment Start Date (For example, 2000-12-01, not 2000-12-1, not 12/1/2000, not 1/12/2000, not Jan 12, 2000):</span>
                <br/><input tabindex="0" aria-label="Recurring Payment Start Date" type="text" name="expenserecurringpaymentstartdate" id="expenserecurringpaymentstartdate" class="fromdate datepicker form-control bold" value="" />
            </div>
        </div>

        <div class="row recurringdetails">
            <div  class="col-xs-12 col-md-12 bold" ><br/><span tabindex="0">Recurring Payment End Date (For example, 2000-12-01, not 2000-12-1, not 12/1/2000, not 1/12/2000, not Jan 12, 2000):</span>
                <br/><input tabindex="0" aria-label="Recurring Payment End Date" type="text" name="expenserecurringpaymentenddate" id="expenserecurringpaymentenddate" class="fromdate datepicker form-control bold" value="" />
            </div>
        </div>

        <div class="row recurringdetails">
            <div  class="col-xs-12 col-md-12 bold"><br/><span tabindex="0">Recurring Payment Frequency:</span>
            <select tabindex="0" aria-label="Recurring Payment Frequency" name="expenserecurringpaymentfrequencyid" id="expenserecurringpaymentfrequencyid" class="form-select form-select-lg">
                <option value="-1">Select one...</option>
                <?php
                if(!empty($expenserecurringpaymentfrequencies)){
                    foreach ($expenserecurringpaymentfrequencies as $frequency){
                        echo "<option value='$frequency->id'>" . esc_html($frequency->name) . "</option>";
                    }
                }
                ?>
            </select>
            </div>
        </div>

        <div class="row recurringdetails">
            <div  class="col-xs-12 col-md-12 bold"><br/><span tabindex="0">Recurring Payment Day (First day is 1, not 0):</span>
            <select tabindex="0" aria-label="Recurring Payment Day" name="expenserecurringpaymentdayid" id="expenserecurringpaymentdayid" class="form-select form-select-lg">
                <option value="-1">Select one...</option>
                <?php
                    for ($i=1;$i<=366;$i++){
                        echo "<option value='" . intval($i-1) . "'>" . intval($i) . "</option>";
                    }
                ?>
            </select>
            </div><br/>
        </div>
        <br/>
        <div class="row">
            <div class="col-xs-12 col-md-12">
                <input type="submit" id="submitcreateexpense" name="submit" class="btn btn-primary btn-lg bold" value="Submit" />
                <input type="button" name="reset" class="btn btn-default btn-lg bold" onclick="resetExpenseData();" value="Reset" style="background-color:grey;" />
                <br/><br/><a class="btn btn-default btn-lg bold" role="button" tabindex="0" aria-label="cancel" href="<?php
                    $urlparts = wp_parse_url(home_url());
                    $protocol = esc_html($urlparts['scheme']);
                    $domain = esc_html($urlparts['host']);
                    $myurl = $protocol . "://" . $domain . esc_html($_SERVER['REQUEST_URI']);
                    $myurl = str_replace("&amp;", "&", $myurl);
                    $myurl = remove_query_arg('action', $myurl);
                    if(substr($myurl, -1) === '/') {$myurl = substr($myurl, 0, -1);}
                    echo $myurl;?>" target="_self">CANCEL</a>
                <p id="compose-error"></p>
            </div>
        </div>

        <br/>
        <div class="row">
            <input type="hidden" name="expenseszyx987_hidden_security_createexpense" value="<?php echo esc_html(wp_create_nonce('expenseszyx987_createexpense')); ?>" />
        </div>
    </div>
</form>