<?php
include VIEWPATH . 'admin/header.php';

$first_name = isset($donation_data['first_name']) ? escape_data($donation_data['first_name']) : set_value('first_name');
$last_name = isset($donation_data['last_name']) ? escape_data($donation_data['last_name']) : set_value('last_name');
$city = isset($donation_data['city']) ? escape_data($donation_data['city']) : set_value('city');
$amount = isset($donation_data['amount']) ? $donation_data['amount'] : set_value('amount');
$email = isset($donation_data['email']) ? escape_data($donation_data['email']) : set_value('email');
$phone = isset($donation_data['phone']) ? escape_data($donation_data['phone']) : set_value('phone');
$category_id = isset($donation_data['category_id']) ? $donation_data['category_id'] : set_value('category_id');
$type = isset($donation_data['type']) ? $donation_data['type'] : "CA";
$id = isset($donation_data['id']) ? (int) $donation_data['id'] : (int) set_value('id');
$cheque_no = isset($donation_data['cheque_no']) ? (int) $donation_data['cheque_no'] : (int) set_value('cheque_no');

?>
<div class="container-fluid  content-area">
    <div class="section">
        <div class="page-header">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="<?php echo base_url('admin/dashboard'); ?>"><i class="fa fa-home mr-1"></i> <?php echo dt_translate('dashboard'); ?></a></li>
                <li class="breadcrumb-item active" aria-current="page"><a href="<?php echo base_url('admin/donation'); ?>"><?php echo dt_translate('manage') . " " . dt_translate('donation') ?></a></li>
            </ol>
        </div>
        <div class="row">
            <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12">
                <?php $this->load->view('message'); ?>
                <?php
                $attributes = array('id' => 'Save_Form', 'name' => 'Save_Form', 'method' => "post");
                echo form_open('admin/save-donation', $attributes);
                ?>
                <div class="card">
                    <div class="card-header">
                        <?php echo ($id > 0) ? dt_translate('update') : dt_translate('add'); ?> <?php echo dt_translate('donation'); ?>
                    </div>
                    <div class="card-body">
                        <input type="hidden" id="id" name="id" value="<?php echo isset($id) ? $id : 0; ?>"/>
                        <div class="row">
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label for="title"><?php echo dt_translate('department') ?><small class="required">*</small></label>
                                    <select tabindex="1" autofocus required="" id="category_id" name="category_id" class="form-control">
                                        <option value=""><?php echo dt_translate('select')." ".dt_translate('department'); ?></option>
                                        <?php foreach ($app_donation_category as $value): ?>
                                            <option value="<?php echo $value['id']; ?>"  <?php echo ($value['id']==$category_id)?"selected='selected'" :"";?> ><?php echo $value['title']; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                    <?php echo form_error('category_id'); ?>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label for="title"><?php echo dt_translate('first_name') ?><small class="required">*</small></label>
                                    <div>
                                        <input type="text" tabindex="2" required="" autocomplete="off" value="<?php echo isset($first_name) ? $first_name : ""; ?>" class="form-control" id="first_name" name="first_name" placeholder="<?php echo dt_translate('first_name') ?>">
                                        <?php echo form_error('first_name'); ?>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label for="title"><?php echo dt_translate('last_name') ?><small class="required">*</small></label>
                                    <div>
                                        <input type="text" tabindex="3" required="" autocomplete="off" value="<?php echo isset($last_name) ? $last_name : ""; ?>" class="form-control" id="last_name" name="last_name" placeholder="<?php echo dt_translate('last_name') ?>">
                                        <?php echo form_error('last_name'); ?>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label for="title"><?php echo dt_translate('email') ?><small class="required">*</small></label>
                                    <div>
                                        <input type="email" tabindex="4" required="" autocomplete="off" value="<?php echo isset($email) ? $email : ""; ?>" class="form-control" id="email" name="email" placeholder="<?php echo dt_translate('email') ?>">
                                        <?php echo form_error('email'); ?>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-3">
                                <div class="form-group">
                                    <label for="title"><?php echo dt_translate('phone') ?></label>
                                    <div>
                                        <input type="text" tabindex="5" maxlength="18" minlength="10"  autocomplete="off" value="<?php echo isset($phone) ? $phone : ""; ?>" class="form-control" id="phone" name="phone" placeholder="<?php echo dt_translate('phone') ?>">
                                        <?php echo form_error('phone'); ?>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-3">
                                <div class="form-group">
                                    <label for="title"><?php echo dt_translate('city') ?><small class="required">*</small></label>
                                    <div>
                                        <input type="text" tabindex="6" required="" autocomplete="off" value="<?php echo isset($city) ? $city : ""; ?>" class="form-control" id="city" name="city" placeholder="<?php echo dt_translate('city') ?>">
                                        <?php echo form_error('city'); ?>
                                    </div>
                                </div>
                            </div>



                            <div class="col-md-3">
                                <div class="form-group">
                                    <label for="title"><?php echo dt_translate('amount') ?><small class="required">*</small></label>
                                    <div>
                                        <input type="number" min="1" tabindex="7" required="" autocomplete="off" value="<?php echo isset($amount) ? $amount : ""; ?>" class="form-control" id="amount" name="amount" placeholder="<?php echo dt_translate('amount') ?>">
                                        <?php echo form_error('amount'); ?>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <?php
                                    $cash_active=$cheque_active="";
                                    if($type=='cash'){
                                        $cash_active="checked";
                                    }elseif($type=="cheque"){
                                        $cheque_active="checked";
                                    }else{
                                        $cash_active="checked";
                                    }
                                    ?>
                                    <br/>

                                    <?php if(isset($type) && ($type=="paypal" || $type=="stripe" || $type=="razorpay" || $type=="paystack" || $type=="flutterwave")): ?>
                                        <?php
                                        $payment_type="";
                                        if($type=="paypal"){
                                            $payment_type="PayPal";
                                        }else if($type=="stripe"){
                                            $payment_type="Stripe";
                                        }else if($type=="razorpay"){
                                            $payment_type="Razorpay";
                                        }else if($type=="paystack"){
                                            $payment_type="Paystack";
                                        }else if($type=="flutterwave"){
                                            $payment_type="Flutterwave";
                                        }
                                        ?>
                                        <div class="custom-control custom-radio custom-control-inline">
                                            <input class="custom-control-input" type="radio" id="other_pay" checked  class="form-check-input" value="<?php echo $type; ?>" name="type">
                                            <label class="custom-control-label"  for='other_pay'><?php echo $payment_type; ?></label>
                                        </div>
                                    <?php else: ?>
                                        <div class="custom-control custom-radio custom-control-inline">
                                            <input class="custom-control-input" id="cash_active" type="radio" <?php echo $cash_active ?> onclick="toggle_payment_type('cash')" class="form-check-input" value="cash" name="type">
                                            <label class="custom-control-label" for='cash_active'><?php echo dt_translate('cash'); ?></label>
                                        </div>

                                        <div class="custom-control custom-radio custom-control-inline">
                                            <input class="custom-control-input" id="cheque_type" type="radio" <?php echo $cheque_active ?>  onclick="toggle_payment_type('cheque')" class="form-check-input" value="cheque" name="type">
                                            <label class="custom-control-label"  for='cheque_type'><?php echo dt_translate('cheque'); ?></label>
                                        </div>
                                    <?php endif;?>

                                </div>
                            </div>
                            <div class="col-md-3 <?php echo ($type!="CQ")?'d-none':''; ?>" id="cheq_div">
                                <div class="form-group">
                                    <label for="title"><?php echo dt_translate('cheque')." ".dt_translate('number'); ?><small class="required">*</small></label>
                                    <div>
                                        <input type="number" minlength="4" tabindex="8"  autocomplete="off" value="<?php echo isset($cheque_no) ? $cheque_no : ""; ?>" class="form-control" id="cheque_no" name="cheque_no" placeholder="<?php echo dt_translate('cheque')." ".dt_translate('number') ?>">
                                        <?php echo form_error('cheque_no'); ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-md-12">
                                <a tabindex="10" href="<?php echo base_url('admin/donation'); ?>" class="btn btn-warning"><?php echo dt_translate('cancel') ?></a>
                                <button tabindex="9" type="submit" class="btn btn-primary" name="Save" value="Save">
                                    <span class="spinner-border spinner-border-sm d-none" role="status" aria-hidden="true"></span>
                                    <?php echo dt_translate('save') ?>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>
<?php
include VIEWPATH . 'admin/footer.php';
?>

