<?php

/* 
 * Author       : Jai K
 * Purpose      : The add page for Prasadam Billing
 * Created On   : 2016-08-12 12:19    
 */
?>
<aside class="right-side">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color"><a href="<?php echo get_bill_list_url(); ?>" class="list-btn"><i class="fa fa-list" title="Go to Listing"></i></a><?php echo $title; ?> - Add</h1>
            <div class="breadcrumb_container"><?php echo breadcrumb_links();?></div>
        </div>
    </section>
    <section class="content">
        <div class="row" id="main-content">
            <div class="col-xs-12">
                <form action="<?php echo $form_action;?>" method="post"  enctype="multipart/form-data" method="post" >    
                    <input type="hidden" name="token" value="<?php echo $token; ?>" />    
                    <input type="hidden" name="hidden_id" value="<?php echo $id; ?>" /> 
                    <input type="hidden" name="hidden_edit_id" value="" />                    
                    <div class="box box-danger">
                        <div class="box-body">
                            <?php if( !empty( $success ) || !empty( $error ) ) : ?>
                                <div class="alert alert-<?php echo !empty( $success ) ? 'success' : 'danger'; ?> alert-dismissable">
                                    <i class="fa fa-thumbs-o-<?php echo !empty( $success ) ? 'up' : 'down'; ?>"></i>
                                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                                    <h4><?php echo !empty( $success ) ? $success : $error; ?></h4>
                                </div>
                            <?php endif; ?>
                            
                            <ul class="error_container"></ul>
                            <div class="col-xs-12">
                                <div class="col-md-6">
                                    <div class="form-group float-clear">
                                        <label>Receipt No</label>
                                        <input type="text" class="form-control readonly" name="rec_no" placeholder="Auto Generated" readonly />
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="form-group float-clear" style="text-align: right;">
                                        <button class="btn btn-success dialog-btn" data-target="#booked-dialog" id="bkd-btn"><i class="fa fa-book"></i> Booked Details</button>
                                    </div>
                                </div>
                            </div>    
                                    
                            <div class="col-xs-12 blck err-target-wrapper">
                                <div class="sub-title err-target"><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Prasadam Details</h4><i class="ctrl opener opened fa fa-chevron-up" style="float: right; margin-top: -25px;"></i></div>
                                <div class="blck-content col-xs-12">
                                    <div class="col-md-6">   
                                        <div class="form-group">
                                            <label>Type<span class="required">*</span></label>
                                            <div class="input-group" style="width: 66%;">
                                                <select name="fn_type" class="form-control select2 req">
                                                    <option value="">-- Select Type --</option>
                                                    <?php 
                                                        foreach( $fn_types as $k => $fn_type ) :
                                                            ?>
                                                                <option value="<?php echo $fn_type['id']; ?>" data-amt="<?php echo $fn_type['amount']; ?>" data-prefix="<?php echo $fn_type['prefix']; ?>" data-isdeity="<?php echo $fn_type['is_deity']; ?>"><?php echo $fn_type['name']; ?></option>
                                                            <?php
                                                        endforeach;
                                                    ?>
                                                </select>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Date</label>
                                            <div class="input-group">
                                                <input type="text" class="form-control date-picker" name="fn_date" placeholder="dd/mm/yyyy" value="<?php echo date("d-m-Y"); ?>" />
                                                <div class="input-group-addon"><i class="fa fa-calendar"></i></div>
                                            </div>
                                        </div>

                                        <div class="form-group float-clear">
                                            <label>Name 1<span class="required">*</span></label>
                                            <input type="text" class="form-control req name" name="dev_name_1" placeholder="Name 01" />
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Name 2</label>
                                            <input type="text" class="form-control name" name="dev_name_2" placeholder="Name 02" />
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>Star 1</label>
                                            <div class="input-group">
                                                <select name="star_1" class="form-control select2 star">
                                                    <option value="">-- Select Star 1 --</option>
                                                    <?php 
                                                        foreach( $stars as $k => $star ) :
                                                            ?>
                                                                <option value="<?php echo $star['id']; ?>"><?php echo $star['name'] . ' / ' . $star['tamil_name']; ?></option>
                                                            <?php
                                                        endforeach;
                                                    ?>
                                                </select>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Contact No</label>
                                            <div class="input-group">
                                                <input type="text" class="form-control contact-no num-pad" name="contact_no" placeholder="Contact No" />
                                                <div class="input-group-addon"><i class="fa fa-phone"></i></div>
                                            </div>
                                        </div>
                                        
                                        <!--<div class="form-group float-clear">
                                            <label>Address 1</label>
                                            <textarea class="form-control address" name="address_1"></textarea>
                                        </div>-->
                                        
                                    </div>

                                    <div class="col-md-6">                                    
                                        <div class="form-group">
                                            <label>Period<span class="required">*</span></label>
                                            <div class="input-group" style="width: 66%;">
                                                <select name="fn_period" class="form-control select2 req">
                                                    <option value="1">Morning</option>
                                                    <option value="2">Evening</option>
                                                </select>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Name 1 (T)</label>
                                            <div class="input-group">
                                                <input type="text" class="form-control multi tamil-name input-tamil" name="tamil_name_1" placeholder="jkpH;bgah;" onclick="set_tamil_keypad(this);" />
                                                <div class="input-group-addon"><i class="fa fa-keyboard-o"></i></div>
                                            </div>
                                            
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Name 2 (T)</label>
                                            <div class="input-group">
                                                <input type="text" class="form-control multi tamil-name input-tamil" name="tamil_name_2" placeholder="jkpH;bgah;" onclick="set_tamil_keypad(this);" />
                                                <div class="input-group-addon"><i class="fa fa-keyboard-o"></i></div>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label>Star 2</label>
                                            <div class="input-group">
                                                <select name="star_2" class="form-control select2 star">
                                                    <option value="">-- Select Star 2 --</option>
                                                    <?php 
                                                        foreach( $stars as $k => $star ) :
                                                            ?>
                                                                <option value="<?php echo $star['id']; ?>"><?php echo $star['name'] . ' / ' . $star['tamil_name'] ; ?></option>
                                                            <?php
                                                        endforeach;
                                                    ?>
                                                </select>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Email ID</label>
                                            <div class="input-group">
                                                <input type="text" class="form-control email" name="email" placeholder="Email Address" />
                                                <div class="input-group-addon"><i class="fa fa-envelope"></i></div>
                                            </div>
                                        </div>
                                        
                                        <!--<div class="form-group float-clear">
                                            <label>Address 2</label>
                                            <textarea class="form-control" name="address_2"></textarea>
                                        </div>-->
                                        
                                    </div>
                                    
                                </div> <!-- blck-content -->    
                            </div> <!-- blck -->
                            
                            <div class="col-xs-12 blck err-target-wrapper innr-table">
                                <div class="sub-title err-target" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Add Items</h4><i class="ctrl opener fa fa-chevron-down" style="float: right; margin-top: -25px;"></i></div>
                                <div class="blck-content col-xs-12" style="display: none;">
                                    <div class="col-xs-12">                                    
                                        <div class="col-md-3"> 
                                            <label>Deity</label>
                                        </div>
                                        
                                        <div class="col-md-3"> 
                                            <label>Prasadam<span class="required">*</span></label>
                                        </div>
                                        
                                        <div class="col-md-1"> 
                                            <label>Quantity<span class="required">*</span></label>
                                        </div>
                                        
                                        <div class="col-md-2"> 
                                            <label>Price<span class="required">*</span></label>
                                        </div>
                                        <div class="col-md-2"> 
                                            <label>Sub Total</label>
                                        </div>
                                        <div class="col-md-1"> 
                                            <label>&nbsp;</label>
                                        </div>
                                    </div>    
                                    
                                    <div class="col-xs-12 row-details">    
                                        <div class="col-md-3">
                                            <select name="pr_deity[]" class="form-control select2 pr-deity" onchange="get_deity_name(this);">
                                                <option value="">-- Select Deity --</option>
                                                <?php 
                                                    foreach( $gods as $k => $god ) :
                                                    ?>
                                                        <option value="<?php echo $god['id']; ?>" ><?php echo $god['name']; ?></option>
                                                    <?php
                                                    endforeach;
                                                ?>
                                            </select>
                                            
                                        </div>

                                        <div class="col-md-3">
                                            <select name="pr_prasadam[]" class="form-control select2 req pr-prasadam" onchange="get_prasadam_name(this);">
                                                <option value="">-- Select Prasadam --</option>
                                                <?php 
                                                    foreach( $prasadams as $k => $prasadam ) :
                                                    ?>
                                                        <option value="<?php echo $prasadam['id']; ?>" ><?php echo $prasadam['name']; ?></option>
                                                    <?php
                                                    endforeach;
                                                ?>
                                            </select>
                                        </div>
                                            

                                        <div class="col-md-1">                                    
                                            <input type="text" class="form-control low-width req pr-qty amount num-pad" name="pr_qty[]" placeholder="0" value="" style="min-width: 60px;"/>
                                        </div>
                                        
                                        <div class="col-md-2">                                    
                                            <input type="text" class="form-control req pr-price amount num-pad" name="pr_price[]" placeholder="0.00" style="text-align: right;"/>
                                        </div>
                                        
                                        <div class="col-md-2">                                    
                                            <input type="text" class="form-control readonly stotal" name="pr_stotal[]" placeholder="0.00" style="text-align: right;" readonly />
                                        </div>

                                        <div class="col-md-1 ctrls">                                    
                                            <i class="fa fa-plus-circle add-btn"></i>
                                        </div>    
                                    </div> <!-- col-xs-12 -->
                                    
                                </div> <!-- blck-content -->

                                
                            </div> <!-- blck -->
                            
                            <div class="col-xs-12 blck err-target-wrapper">
                                <div class="sub-title err-target" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Amount</h4><i class="ctrl opener fa fa-chevron-down" style="float: right; margin-top: -25px;"></i></div>
                                <div class="blck-content col-xs-12" style="display: none;">
                                    <div class="col-md-6">     
                                        <div class="form-group float-clear">
                                            <label>Amount</label>
                                            <input type="text" class="form-control amount num-pad readonly" name="amount" placeholder="0.00" readonly/>
                                        </div>
                                        
                                    </div>

                                    <div class="col-md-6">                                    
                                        <div class="form-group float-clear">
                                            <label>Description</label>
                                            <textarea class="form-control" name="desc"></textarea>
                                        </div>
                                        
                                    </div>
                                    
                                </div> <!-- blck-content -->    
                            </div> <!-- blck -->
                            

                            
                            
                        </div>
                        
                        
                        <div class="box-footer form-actions float-clear" style="text-align: right; padding-right: 30px;">
                            <button class="btn btn-primary" type="reset"><i class="fa fa-trash"></i> Clear</button>
                            <button type="submit" class="btn btn-success payment-btn" name="book-now" value="book-now" ><i class="fa fa-thumb-tack"></i> Book Now</button>
                            <button type="button" class="btn btn-danger" id="payment-btn" disabled><i class="fa fa-credit-card"></i> Payment</button>
                            
                        </div>
                    </div><!-- /.box -->
                    
                    <!-- Payment types Modal -->
                    <div class="modal fade" id="ptypes-dialog" role="dialog">
                        <div class="modal-dialog">
                            <!-- Modal content-->
                            <div class="modal-content">
                                    <div class="modal-header" style="background-color: #337AB7;">
                                        <h4 class="modal-title" style="color: #FFF;">Payment Details</h4>
                                    </div>
                                    <div class="modal-body col-xs-12">
                                        <div class="err-blck" style="margin-top: -20px;"></div>
                                        <div class="row" id="pay-amounts-box">

                                            <div class="col-md-6">                                    
                                                <div class="form-group float-clear">
                                                    <label>Amount To Pay</label>
                                                    <input type="text" class="form-control readonly" name="pay_amount" placeholder="0.00" readonly/>
                                                </div>
                                            </div>

                                            <div class="col-md-6">                                    
                                                <div class="form-group float-clear">
                                                    <label>Now Paying</label>
                                                    <input type="text" class="form-control readonly" name="paid_amount" placeholder="0.00" value="" readonly/>
                                                </div>
                                            </div>

                                        </div> 
                                        
                                        <div class="row" id="cheque-box" style="display: none;">
    
                                            <div class="col-xs-4">                                    
                                                <div class="form-group float-clear">
                                                    <label>Bank Name</label>
                                                    <input type="text" class="form-control input"  name="chq_bnk_name" placeholder="Bank Name" value=""/>
                                                </div>
                                            </div>
                    
                                            <div class="col-xs-4">                                    
                                                <div class="form-group float-clear">
                                                    <label>No</label>
                                                    <input type="text" class="form-control input"  name="chq_no" placeholder="No" value=""/>
                                                </div>
                                            </div>
                                            
                                            <div class="col-xs-4">                                    
                                                <div class="form-group float-clear">
                                                    <label>Date</label>
                                                    <input type="text" class="form-control input date-picker"  name="chq_date" placeholder="dd/mm/YYYY" value="<?php echo date('d-m-Y');?>"/>
                                                </div>
                                            </div>
                    
                                        </div>
                                        
                                        <div style="margin-top: 10px; border-top: 1px dotted #1ba; padding: 20px 0px;">
                                            <div class="row">
                                                <?php
                                                    $step = 4;
                                                    foreach( $ptypes as $k => $ptype ) :

                                                        echo '<div class="col-md-'. floor( 12 / $step ) .'">';
                                                        ?>
                                                            <div class="form-group float-clear blck-content ptype-box" id="ptype-box-<?php echo $ptype['slug']; ?>" style="margin: 10px 10px;">
                                                                <div class="pay-box">
                                                                    <?php if( !empty( $ptype['img_url'] ) && file_exists( DIR_PAY_TYPE . $ptype['img_url'] ) ) : ?><div id="pay-preview"><img src="<?php echo BASE_URL . DIR_PAY_TYPE . $ptype['img_url']; ?>" /></div><?php endif; ?>
                                                                    <label><?php echo $ptype['name']; ?></label>
                                                                </div>
                                                                <input type="text" class="input pay-type amount num-pad" data-id="<?php echo $ptype['id']; ?>" name="pay_type[<?php echo $ptype['id']; ?>]" value="" />
                                                            </div>
                                                        <?php
                                                        echo '</div>';

                                                        if( ($k+1) % $step == 0 ) :
                                                            echo '</div><div class="row">';
                                                        endif;

                                                    endforeach;
                                                ?>
                                            </div>
                                        </div>
                                        

                                    </div>

                                    <div class="modal-footer" style="padding-right: 30px;">
                                        <button type="button" class="btn btn-primary cancel_popup" id="sbmt-cancel-btn" data-dismiss="modal"><i class="fa fa-chevron-left"></i> Go Back</button>
                                        <button type="submit" id="sbmt-btn" class="btn btn-danger" name="submit" value="Submit"><i class="fa fa-floppy-o"></i> Submit</button>
                                        
                                    </div>
                                

                            </div>   <!-- Modal Content -->     
                        </div> 
                    </div> <!-- Payment Types Dialog -->
                    
                    
                    
                </form>
            </div><!-- /.col-xs-12 -->
        </div><!-- /.row -->
        
        <!-- Start Modal -->
        <div class="modal fade" id="booked-dialog" role="dialog">
            <div class="modal-dialog" style="width: 90%;">
                <!-- Modal content-->
                <div class="modal-content">

                    <div class="modal-header" style="background-color: #337AB7;">
                        <button type="button" class="close cancel_popup" data-dismiss="modal" style="color: #FFF;">x</button>
                        <h4 class="modal-title" style="color: #FFF;">Booked Details</h4>
                    </div>
                    <div class="modal-body col-xs-12" style="margin-bottom: 30px; border-bottom: 1px dotted #1ba;">
                    
                        
                        <form name="m">
                                                                 
                                <div class="col-xs-3">
                                    <label>Start Date</label>
                                    <input type="text" class="form-control bk_from_date" name="bk_from_date" placeholder="dd/mm/yyyy" value="" />
                                </div>

                                <div class="col-xs-3">
                                    <label>End Date</label>
                                    <input type="text" class="form-control bk_to_date" name="bk_to_date" placeholder="dd/mm/yyyy" value="" />
                                </div>  
                                  
                                <div class="col-xs-2">
                                    <label>Period</label>
                                    <div class="input-group">
                                        <select name="bk_period" class="form-control select2">
                                            <option value="">-- Select Period --</option>
                                            <option value="1">Morning</option>
                                            <option value="2">Evening</option>
                                        </select>
                                    </div>
                                </div>
                            
                                <div class="col-xs-4" style="text-align: right; padding: 25px 0px; margin-left: -35px; z-index: 99;">
                                    <button type="button" class="btn btn-primary reset-btn"><i class="fa fa-times"></i> Reset</button>
                                    <button type="button" class="btn btn-danger filter-btn"><i class="fa fa-filter"></i> Filter</button>
                                    <button type="button" class="btn btn-primary cancel_popup" data-dismiss="modal"><i class="fa fa-ban"></i> Cancel</button>

                                </div>
                        </form>

                    </div>

                    <div class="modal-footer" style="padding-right: 30px;">
                        
                    </div>


                </div>   <!-- Modal Content -->     
            </div> 
        </div> <!-- Booked Dialog -->
              
    <!-- End Modal -->
    </section><!-- /.content -->
</aside>
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/billing/prasadam.js'?>"></script>

