<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class inviteinevent extends MY_Controller{
	function __construct(){
        parent::__construct();
        $this->load->model('inviteinevent_model', '', TRUE); 
        $this->load->model('category_model', '', TRUE);   
        $this->load->model('contact_model', '', TRUE); 
        $this->load->model('event_model', '', TRUE); 
        $this->load->model('route_model', '', TRUE);  
    }
    function index(){
        //echo phpinfo();
        $event = $this->event_model->allevent_details();
        
        $html ='';
        foreach ($event as $eventkey => $eventvalue) {
            $eventid= $eventvalue['id'];
            $invitinglist = $this->inviteinevent_model->get_inviting_list($eventid);
            $html .='<tr>';
                $html .='<td>'.ucwords(strtolower($eventvalue['name'])).'</td>';
                $html .='<td>'.intval($invitinglist['tadult']).'</td>';
                $html .='<td>'.intval($invitinglist['tchild']).'</td>';
                $html .='<td>'.intval($invitinglist['ftotal']).'</td>';
                $html .='<td>';
                    $html .='<a href="'.$this->data['base_url'].'inviteinevent/eventwiseview/'.$eventid.'">';
                        $html .='<span class="btn btn-primary">
                            <i class="fa fa-eye"></i> View</span>';
                    $html .='</a> ';
                    $html .='<a href="'.$this->data['base_url'].'report/invite_report/'.$eventid.'/ExportinPDF" target="_blank">';
                        $html .='<span class="btn btn-danger">
                            <i class="fa fa-file-pdf-o"></i> Export in PDF</span>';
                    $html .='</a> ';
                    $html .='<a href="'.$this->data['base_url'].'report/invite_report/'.$eventid.'/ExportinExcel" target="_blank">';
                        $html .='<span class="btn btn-success">
                            <i class="fa fa-file-excel-o"></i> Export in Excel</span>';
                    $html .='</a> ';
                    $html .='<a href="'.$this->data['base_url'].'report/invite_report/'.$eventid.'/StickerView" target="_blank">';
                        $html .='<span class="btn btn-info">
                            <i class="fa fa-print"></i> Sticker View</span>';
                    $html .='</a>';

                $html .='</td>';
            $html .='</tr>'; 
        }
        $this->smarty->assign('eventwise',$html);
        $this->smarty->assign('evenininvite',$event);
        $this->data['message'] = $this->session->flashdata('message');
        $this->data['breadcrumb']='New inviteinevent';
        $this->data['tpl_name']= "inviteinevent.tpl";
        $this->smarty->assign('data', $this->data);
        $this->smarty->view('template.tpl');  
    }
    function eventwiseview(){
        $eventid = $this->uri->segment(3);
        
        $html ='';
        $eventwiseview = $this->inviteinevent_model->eventwiseview($eventid);
        //$eventwiseview = $this->unique_multidim_array($eventwiseview,'address');
        $grandtotal='0';
        $totaladult='0';
        $totalchild='0';
        foreach ($eventwiseview as $ekey => $eventvalue) {
            $grandtotal =($grandtotal+intval($eventvalue['total']));
            $totaladult =($totaladult+intval($eventvalue['adult']));
            $totalchild =($totalchild+intval($eventvalue['child']));
            $html .='<tr>';
                $html .='<td>'.ucwords(strtolower($eventvalue['name'])).'<br>'.ucwords(strtolower(nl2br($eventvalue['address']))).'</td>';
                $html .='<td>'.ucwords(strtolower($eventvalue['mobile'])).'</td>';
                $html .='<td>'.ucwords(strtolower($eventvalue['city'])).'</td>';
                $html .='<td>';
                 if($eventvalue['categoryid']!=''){
                    
                    $category_details = $this->contact_model->get_category($eventvalue['categoryid']);
                    foreach ($category_details as $cdkey => $cdvalue) {
                        $html .=strtoupper($cdvalue['name'])."<br>";
                    }
                   
                }
                $html .='</td>';
                $html .='<td><input style="width:50px" type="number" name="adult'.$eventvalue['id'].'" id="adult'.$eventvalue['id'].'" value="'.($eventvalue['adult']).'"</td>';
                $html .='<td><input style="width:50px" type="number" name="child'.$eventvalue['id'].'" id="child'.$eventvalue['id'].'" value="'.($eventvalue['child']).'"</td>';
                $html .='<td>'.($eventvalue['total']).'</td>';
                $html .='<td> By '.ucwords(strtolower($eventvalue['vehicle'])).'</td>';
                $html .='<td> '.ucwords(strtolower($eventvalue['room'])).'</td>';
                if($eventvalue['roomdate']!='0000-00-00'){
                    $html .='<td> '.date('d-m-Y',strtotime($eventvalue['roomdate'])).'</td>';
                }else{
                    $html .='<td></td>';
                }
                $html .='<td>';
                    $html .='<span class="btn btn-primary" onclick="updateinviteinevent('.$eventvalue['id'].')">Update</span>';
                    $html .='<br><span class="btn btn-danger" style="margin-top: 5px;" onclick="deleteinviteinevent('.$eventvalue["id"].')">Delete</span>
                    </a>';
                $html .='</td>';
            $html .='</tr>';
        }
        $totalsection .='<table class="table">
                           <tr>';
            $totalsection .='<td colspan="4" align="right" ><h5><b>Total :</b></h5> </td>';
            $totalsection .='<td><h5><b>Adult<br>'.$totaladult.'</b></h5></td>';
            $totalsection .='<td><h5><b>Child<br>'.$totalchild.'</b></h5></td>';
            $totalsection .='<td><h5><b>Total<br>'.$grandtotal.'</b></h5></td>';
            $totalsection .='<td><a href="'.$this->data['base_url'].'inviteinevent/invite/"><button class="btn btn-small btn-success pull-right">ADD NEW INVITE</button></a></td>';
        $totalsection .='</tr></table>';
        $event_details = $this->event_model->single_event_details($eventid); 
        $this->smarty->assign('evenininvite',$html);
        $this->smarty->assign('totalsection',$totalsection);
        $this->data['message'] = $this->session->flashdata('message');
        $this->data['breadcrumb']=strtoupper($event_details['name']);
        $this->data['tpl_name']= "eventwiseview.tpl";
        $this->smarty->assign('data', $this->data);
        $this->smarty->view('template.tpl');  
    }
    function create(){
        if($this->input->post()){ 
            $contact_id = $this->input->post('contact_id');
            if(count($contact_id)>0){
                foreach ($contact_id as $key => $contactvalue) {
                    $contactid = $contactvalue;
                    $event = $this->input->post('event'.$contactvalue);
                    $finalevent = implode(',',$event);
                    if(!empty($event) and $event[0]==0){
                        $eventval =array();
                        $all_event_id = $this->event_model->get_all_event_id();
                        foreach ($all_event_id as $eventkey => $eventvalue) {
                            $eventval[] = $eventvalue['id'];
                        }
                        $finalevent = implode(',',$eventval);
                    }
                    $adult = $this->input->post('adult'.$contactvalue);
                    $child = $this->input->post('child'.$contactvalue);
                    $totalmember = ($adult+$child);
                    $vehicle = $this->input->post('vehicle'.$contactvalue);
                    $room = $this->input->post('room'.$contactvalue);
                    $roomdate = $this->input->post('roomdate'.$contactvalue);
                    $route = $this->input->post('route'.$contactvalue);
                    if($contactid!='' and $finalevent!='' and $totalmember!='0'){
                        $data['contactid']=$contactid;
                        $data['event']=$finalevent;
                        $data['adult']=$adult;
                        $data['child']=$child;
                        $data['total']=$totalmember;
                        $data['vehicle']=$vehicle;
                        $data['room']=$room;
                        $data['roomdate']=$roomdate;
                        $data['route']=$route;
                        $data['status']='1';
                        $data['is_delete']='0';
                        $data['create_datetime']=date('Y-m-d h:i:s');
                        $data['created_ip']=$_SERVER['REMOTE_ADDR'];
                        $inviteineventdata = $this->inviteinevent_model->addinviteinevent($data);
                    }
                }
            }
            $this->session->set_flashdata('message',"Invite In Event Added Successfully.");
            redirect($this->data['base_url'] . 'inviteinevent/');
            
        }else{
            $event_details = $this->event_model->allevent_details();   
            $route_details = $this->route_model->allroute_details();   
            $html='<div class="panel-group accordion">';
            $totalcontact=0;
            $contact = $this->contact_model->allcontact_details_withgroupby();
            $totalcontact = (count($contact));
            //echo $totalcontact;exit;
            $html .='<div class="panel panel-primary">';
                   
                    $html .='<div class="panel-heading" style="background:#7d9748;">';
                            $html .='<h4 class="panel-title">';
                                $html .='<a href="#accOneColOneall" style="color:#ffffff;font-weight:bold;">GENERAL (A-Z) CONTACT</a>';
                            $html .='</h4>';
                            $html .='<ul class="panel-controls  pull-right">
                                <h4><strong style="color:#ffffff;font-weight:bold;">TOTAL : '.$totalcontact.'</strong></h4>
                            </ul>';
                    $html .='</div>';
                    $html .='<div class="panel-body" id="accOneColOneall">';
                        $html .='<table border="1" class="table datatable">';
                            $html .='<thead>';
                                $html .='<tr>';
                                    $html .='<th>All</th>';
                                    $html .='<th>Name &<br> City</th>';
                                    $html .='<th>Category</th>';
                                    $html .='<th>Event</th>';
                                    $html .='<th>Adult</th>';
                                    $html .='<th>Child</th>';
                                    $html .='<th>Vehicle</th>';
                                    $html .='<th>Room</th>';
                                    $html .='<th>Room Date</th>';
                                    $html .='<th>Route</th>';
                                $html .='</tr>';
                            $html .='</thead>';
                            
                            foreach ($contact as $contactkey => $contactvalue) {
                                $quniqid=$contactvalue['id'];
                                $html .='<tr id="row'.$contactvalue['id'].'">';
                                    $html .='<td id="ch" ><input type="checkbox" class="catchd'.$contactvalue['categoryid'].'"  name="contact_id[]" id="checkid" value="'.$contactvalue['id'].'" />
                                    </td>';
                                        $html .='<td id="name">'.ucwords(strtolower($contactvalue['name'])).'<br>'.ucwords(strtolower(nl2br($contactvalue['address']))).'<br>'.ucwords(strtolower($contactvalue['city'])).'</td>';
                                        if($contactvalue['name']!='' and $contactvalue['categoryid']!=''){
                                            $html .='<td>';
                                            $duplicat_details = $this->contact_model->duplicat_details($contactvalue['name'],'',$contactvalue['address']);
                                            foreach ($duplicat_details as $dkey => $dvalue) {
                                                $html .=ucwords(strtoupper($dvalue['catname'])).'<br>';
                                            }
                                            $html .='</td>';
                                        }else{
                                            $html .='<td>'.$contactvalue['catname'].'</td>';
                                        }
                                        $html .='<td id="event">';
                                                $html .='<select multiple class="form-control select" name="event'.$quniqid.'[]">';
                                                $html .='<option value="0">All</option>';
                                                foreach ($event_details as $eventkey => $eventvalue) {
                                                    $html .='<option value="'.$eventvalue['id'].'">'.ucwords(strtolower($eventvalue['name'])).'</option>';
                                                }
                                                $html .='</select></td>';
                                            $html .='<td><input  class="form-control" type="number" id="adult'.$quniqid.'" name="adult'.$quniqid.'" maxlength="5"></td>';
                                            $html .='<td><input  class="form-control" type="number" id="child'.$quniqid.'" name="child'.$quniqid.'" maxlength="5"></td>';
                                            $html .='<td id="vhical">';
                                                $html .='<select class="form-control"  style="width:60px" name="vehicle'.$quniqid.'" id="vehicle'.$quniqid.'">';
                                                $html .='<option value="NA">
                                                        N/A</option>';
                                                    $html .='<option value="bus">
                                                        Bus</option>';
                                                    $html .='<option value="car">Car</option>';
                                                $html .='</select>';
                                            $html .='</td>';
                                            $html .='<td><input  class="form-control" style="width:70px;" type="text" id="room'.$quniqid.'" name="room'.$quniqid.'" maxlength="55"></td>';
                                            $html .='<td><input  class="form-control datepicker" style="width:87px;" type="text" id="roomdate'.$quniqid.'" name="roomdate'.$quniqid.'"></td>';
                                            $html .='<td id="route">';
                                                $html .='<select  class="form-control" style="width:70px;" name="route'.$quniqid.'" id="route'.$quniqid.'" >';
                                                foreach ($route_details as $routekey => $routevalue) {
                                                    $html .='<option value="'.$routevalue['id'].'">'.ucwords(strtolower($routevalue['name'])).'</option>';
                                                }
                                                $html .='</select>';
                                            $html .='</td>';
                                $html .='</tr>';
                                $quniqid++;
                                   
                            }
                           
                        $html .='</table>';     
                    $html .='</div>';
            $html .='</div>';
            
            $html .='</div>'; 
            $this->data['contect'] = $html;
            $this->data['message'] = $this->session->flashdata('message');
            $this->data['breadcrumb']='New inviteinevent';
            $this->data['tpl_name']= "inviteinevent_create.tpl";
            $this->smarty->assign('data', $this->data);
            $this->smarty->view('template.tpl'); 
            // $event = $this->input->post('event');
            // $this->data['contact'] = $this->contact_model->allcontact_details();
            // $contactall = $this->contact_model->allcontact_details_withgroupby();
            // $category = $this->category_model->allcategory_details();
            // $event_details = $this->event_model->allevent_details();   
            // $html='<div class="panel-group accordion">';
            // $totalcontact=0;
            // foreach ($category as $catkey => $catval) {
            //     if($catkey==0){
            //         $active = 'panel-body-open'; 
            //     }else{ 
            //         $active='';
            //     }
            //     $contact = $this->contact_model->contact_details($catval['id']);
            //     $totalcontact = ($totalcontact+count($contact));
               
            //     $html .='<div class="panel panel-primary">';
            //         $html .='<div class="panel-heading">';
            //             $html .='<h4 class="panel-title">';
            //                 $html .='<a href="#accOneColOne'.$catval['id'].'">'.strtoupper($catval['name']).'</a>';
            //             $html .='</h4>';
            //             $html .='<ul class="panel-controls  pull-right">
            //                         <h4><strong>Total : '.count($contact).'</strong></h4>
            //                     </ul>';
            //         $html .='</div>                                ';
            //         $html .='<div class="panel-body '.$active.'" id="accOneColOne'.$catval['id'].'">';
                    
            //             $html .='<table border="1" class="table datatable">';
            //                 $html .='<thead>';
            //                     $html .='<tr>';
            //                         $html .='<th><input type="checkbox" class="check'.$catval['id'].'" id="checkAll" name="check_all[]" value="'.$catval['id'].'" onclick="checkAll('.$catval['id'].')">All</th>';
            //                         $html .='<th>Name</th>';
            //                         $html .='<th>City</th>';
            //                         $html .='<th>Category</th>';
            //                         $html .='<th>Event</th>';
            //                         $html .='<th>Adult</th>';
            //                         $html .='<th>Child</th>';
            //                     $html .='</tr>';
            //                 $html .='</thead>';
            //                     $quniqid = 1;
            //                     foreach ($contact as $contactkey => $contactvalue) {
            //                         $html .='<tr id="row'.$contactvalue['id'].'">';
            //                                 $html .='<td id="ch" ><input type="checkbox" class="catchd'.$catval['id'].'"  name="contact_id[]" id="checkid" value="'.$contactvalue['id'].'" /><input  type="hidden" id="contactid'.$quniqid.'" name="contactid'.$quniqid.'" value="'.$contactvalue['id'].'"></td>';
                                            
            //                                 $html .='<td id="name">'.$contactvalue['name'].'</td>';
            //                                 $html .='<td>'.$contactvalue['city'].'</td>';
            //                                 $html .='<td>'.$contactvalue['catname'].'</td>';
            //                                 $html .='<td id="event">';
            //                                     $html .='<select multiple class="form-control select" name="event'.$quniqid.'[]">';
            //                                     foreach ($event_details as $eventkey => $eventvalue) {
            //                                         if (in_array($eventvalue['id'], $event)){
            //                                             $html .='<option value="'.$eventvalue['id'].'" selected="selected">'.ucwords(strtolower($eventvalue['name'])).'</option>';
            //                                         }else{
            //                                             $html .='<option value="'.$eventvalue['id'].'">'.ucwords(strtolower($eventvalue['name'])).'</option>';
            //                                         }
                                                    
            //                                     }
            //                                     $html .='</select></td>';
            //                                 $html .='<td><input  class="form-control" type="number" id="adult'.$quniqid.'" name="adult'.$quniqid.'" maxlength="5"></td>';
            //                                 $html .='<td><input  class="form-control" type="number" id="child'.$quniqid.'" name="child'.$quniqid.'" maxlength="5"></td>';
            //                         $html .='</tr>';
            //                         $quniqid++;
                                   
            //                     }
                           
            //             $html .='</table>';     
            //         $html .='</div>';
            //     $html .='</div>';
                
            // }
            // // $html .='<input  type="hidden" id="totalcontact" name="totalcontact" value="'.$totalcontact.'">';
            // // $html .='</div>'; 
            // $this->data['contect'] = $html;
            // $this->data['message'] = $this->session->flashdata('message');
            // $this->data['breadcrumb']='New inviteinevent';
            // $this->data['tpl_name']= "inviteinevent_create.tpl";
            // $this->smarty->assign('data', $this->data);
            // $this->smarty->view('template.tpl'); 
        }
    }
    function invitelist(){
        //echo phpinfo();
        $event = $this->event_model->allevent_details();
        $html ='';
        $totaladult =0;
        $totalchild =0;
        $finaltotal =0;
        $totalcard  =0;
        foreach ($event as $eventkey => $eventvalue) {
            $eventid= $eventvalue['id'];
            $invitinglist = $this->inviteinevent_model->get_inviting_list($eventid);
            $totaladult = ($totaladult+$invitinglist['tadult']);
            $totalchild = ($totalchild+$invitinglist['tchild']);
            $finaltotal = ($finaltotal+$invitinglist['ftotal']);
            $totalcard = ($totalcard+$invitinglist['cid']);
            $html .='<tr>';
                $html .='<td>'.ucwords(strtolower($eventvalue['name'])).'</td>';
                $html .='<td>'.intval($invitinglist['tadult']).'</td>';
                $html .='<td>'.intval($invitinglist['tchild']).'</td>';
                $html .='<td>'.$invitinglist['cid'].'</td>';
                $html .='<td>'.intval($invitinglist['ftotal']).'</td>';
                $html .='<td>';
                    $html .='<a href="'.$this->data['base_url'].'inviteinevent/invitinglistview/'.$eventid.'" target="_blank">';
                        $html .='<span class="btn btn-warning">
                            <i class="fa fa-eye"></i> View &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
                    $html .='</a><br><br> ';
                    $html .='<a href="'.$this->data['base_url'].'report/invite_report/'.$eventid.'/ExportinExcel" target="_blank">';
                        $html .='<span class="btn btn-success">
                            <i class="fa fa-file-excel-o"></i> Export in Excel</span>';
                    $html .='</a> ';
                $html .='</td>';
                $html .='<td>';
                    $html .='<a href="'.$this->data['base_url'].'report/invite_report/'.$eventid.'/ExportinPDF" target="_blank">';
                        $html .='<span class="btn btn-danger">
                            <i class="fa fa-file-pdf-o"></i> Export in PDF</span>';
                    $html .='</a><br><br>';
                    $html .='<a href="'.$this->data['base_url'].'report/invite_report/'.$eventid.'/StickerView" target="_blank">';
                        $html .='<span class="btn btn-info">
                            <i class="fa fa-print"></i> Sticker View&nbsp;&nbsp;&nbsp;</span>';
                    $html .='</a>';

                $html .='</td>';
            $html .='</tr>'; 
        }
        $html .='<tr>';
            $html .='<td><h4><b>Total</b></h4> </td>';
            $html .='<td><h4><b>'.intval($totaladult).'</b></h4></td>';
            $html .='<td><h4><b>'.intval($totalchild).'</b></h4></td>';
            $html .='<td><h4><b>'.intval($totalcard).'</b></h4></td>';
            $html .='<td><h4><b>'.intval($finaltotal).'</b></h4></td>';
            $html .='<td colspan="2">';
                $html .='<a href="'.$this->data['base_url'].'report/event_allinone/ViewReport" target="_blank">';
                    $html .='<span class="btn btn-primary">
                        <i class="fa fa-eye"></i> ALL IN ONE VIEW </span>';
                $html .='</a>';
                $html .='<a href="'.$this->data['base_url'].'report/event_allinone/ExportinExcel" target="_blank">';
                    $html .='<span class="btn btn-success">
                        <i class="fa fa-file-excel-o"></i> ALL IN ONE EXPORT </span>';
                $html .='</a>';
            $html .='</td>';
        $html .='</tr>'; 
        $this->smarty->assign('eventwise',$html);
        $this->smarty->assign('evenininvite',$event);
        $this->data['message'] = $this->session->flashdata('message');
        $this->data['breadcrumb']='New inviteinevent';
        $this->data['tpl_name']= "invitelist.tpl";
        $this->smarty->assign('data', $this->data);
        $this->smarty->view('template.tpl');  
    }  
    function invite(){
        //post
        if($this->input->post('categoryid')!='' || $this->input->post('name')!='' || $this->input->post('city')!='' || $this->input->post('mobile')!='' || $this->input->post('address')!='')
        {
            $passdeta=array();
            $categoryid = $this->input->post('categoryid');
            $name = $this->input->post('name');
            $city=$this->input->post('city');
            $mobile=$this->input->post('mobile');
            $address=$this->input->post('address');
            $passdeta['categoryid']=$categoryid;
            $passdeta['name']=$name;
            $passdeta['city']=$city;
            $passdeta['mobile']=$mobile;
            $passdeta['address']=$address;
            $total_row = $this->inviteinevent_model->contact_record_count($passdeta);
            $per_page = $total_row;
        }else{
            $passdeta=array();
            $categoryid='';
            $name='';
            $city='';
            $mobile='';
            $address='';
            $passdeta['categoryid']=$categoryid;
            $passdeta['name']=$name;
            $passdeta['city']=$city;
            $passdeta['mobile']=$mobile;
            $passdeta['address']=$address;
            $total_row = $this->inviteinevent_model->contact_record_count($passdeta);
            $per_page = 100;
        }
        
        // Event
        $event = $this->event_model->allevent_details();   
        $this->data['event'] = $event;
        // Hotel
        $hotel = $this->event_model->allhotel_details();   
        $this->data['hotel'] = $hotel;

        //route
        $route = $this->route_model->allroute_details();   
        $route_html='';
        foreach ($route as $routekey => $routevalue) {
            $route_html .='<option value="'.$routevalue['id'].'">'.ucwords(strtolower($routevalue['name'])).'</option>';
        }
        $this->data['route_html'] = $route_html;
        
        //contact 
        $p_c = array();
        $p_c["base_url"] = base_url()."inviteinevent/invite/";        
        $p_c["total_rows"] = $total_row;      
        $p_c['per_page'] = $per_page;        
        $p_c['uri_segment'] = 3;   
        $p_c['num_links'] = $total_row;     
        $p_c['full_tag_open'] = '<ul class="pagination">';        
        $p_c['full_tag_close'] = '</ul>';        
        $p_c['first_link'] = 'First';        
        $p_c['last_link'] = 'Last';        
        $p_c['first_tag_open'] = '<li>';        
        $p_c['first_tag_close'] = '</li>';        
        $p_c['prev_link'] = '&laquo';        
        $p_c['prev_tag_open'] = '<li class="prev">';        
        $p_c['prev_tag_close'] = '</li>';        
        $p_c['next_link'] = '&raquo';        
        $p_c['next_tag_open'] = '<li>';        
        $p_c['next_tag_close'] = '</li>';        
        $p_c['last_tag_open'] = '<li>';        
        $p_c['last_tag_close'] = '</li>';        
        $p_c['cur_tag_open'] = '<li class="active"><a href="#">';        
        $p_c['cur_tag_close'] = '</a></li>';        
        $p_c['num_tag_open'] = '<li>';        
        $p_c['num_tag_close'] = '</li>';
        //
        $this->pagination->initialize($p_c);
        if($this->uri->segment(3)){
            $page = ($this->uri->segment(3)) ;
        }else{
            $page = 0;
        }
        $processdeta=array();
        $processdeta['categoryid']=$categoryid;
        $processdeta['name']=$name;
        $processdeta['city']=$city;
        $processdeta['mobile']=$mobile;
        $processdeta['address']=$address;
        $processdeta['limit']=$p_c["per_page"];
        $processdeta['start']=$page;
        $this->data["contact"]= $this->inviteinevent_model->contact_record_fetch($processdeta);
        $this->data["links"] = $this->pagination->create_links();
        //$this->data["links"] = explode('&nbsp;',$str_links);
        $this->data["totalcontact"] = $total_row;
        $this->data['category'] = $this->category_model->allcategory_details();

        // Data Listing
        $datalist =''; 
        foreach ($this->data["contact"] as $contactkey => $contactvalue) {
            if($contactvalue["id"]!=''){
                $allcheck = $this->inviteinevent_model->check_invite($contactvalue["id"]);
                if(count($allcheck)>0){
                    $datalist .='<tr id="row'.$contactvalue["id"].'">';
                        $datalist .='<td id="ch" style="width:20px;background-color:#ffeb3b;" align="center">';
                            $datalist .='<input type="checkbox" class="catchd'.$contactvalue["categoryid"].'"  name="contact_id[]" id="checkid" value="'.$contactvalue["id"].'" style="width:20px;height:20px;"/>';
                        $datalist .='</td>';
                        $datalist .='<td id="name" width="200" style="">';
                            $datalist .='<b>'.$contactvalue["name"].'</b>';
                            $datalist .='<br>';
                            $datalist .=nl2br($contactvalue["address"]);
                            $datalist .='<br>'.$contactvalue["city"];
                            $datalist .='<br>Mo .'.$contactvalue["mobile"];
                        $datalist .='</td>';
                        if($contactvalue['categoryid']!=''){
                            $datalist .='<td align="left">';
                            $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                            foreach ($category_details as $cdkey => $cdvalue) {
                                $datalist .=strtoupper($cdvalue['name'])."<br>";
                            }
                            $datalist .='</td>';
                        }else{
                            $datalist .='<td></td>';
                        }
                        $datalist .='<td id="event" align="left">';
                            $datalist .='<table  width="100%" border="1"  align="center">';
                            foreach ($event as $eventkey => $eventvalue) {
                                $checkevent = $this->inviteinevent_model->checkevent($contactvalue["id"],$eventvalue['id']);
                                $eventval = $eventvalue['id'];
                                if(!empty($checkevent)){
                                    $datalist .='<tr style="border-bottom: 1px solid #e91e63;">';
                                        $datalist .='<td width="200">';
                                            $datalist .='<input type="hidden" name="ieid'.$eventval.$contactvalue["id"].'" value="'.$checkevent['id'].'">';
                                            $datalist .='<input type="checkbox" name="event'.$contactvalue["id"].'[]" value="'.$checkevent['event'].'" checked style="width:20px;height:20px;"/>'.$eventvalue['name'];
                                        $datalist .='</td>';
                                        $datalist .='<td width="100">';
                                            $datalist .='<input  class="form-control" type="number" name="adult'.$eventval.$contactvalue["id"].'" value="'.$checkevent['adult'].'">';
                                        $datalist .='</td>';
                                        $datalist .='<td width="100">';
                                            $datalist .='<input  class="form-control" type="number" name="child'.$eventval.$contactvalue["id"].'" value="'.$checkevent['child'].'">';
                                        $datalist .='</td>';

                                        if($checkevent['vehicle']=='NA'){ $na = 'checked'; }
                                        else{ $na = ''; }
                                        if($checkevent['vehicle']=='bus'){ $bus = 'checked'; }
                                        else{ $bus = ''; }
                                        if($checkevent['vehicle']=='car'){ $car = 'checked'; }
                                        else{ $car = ''; }
                                        
                                        $datalist .='<td id="vhical" width="100" align="center">';
                                            $datalist .='<input type="radio" name="vehicle'.$eventval.$contactvalue["id"].'" value="NA" '.$na.'/>N/A<br>';
                                            $datalist .='<input type="radio" name="vehicle'.$eventval.$contactvalue["id"].'" value="bus" '.$bus.'/>Bus<br>';
                                            $datalist .='<input type="radio" name="vehicle'.$eventval.$contactvalue["id"].'" value="car" '.$car.'/>Car';
                                        $datalist .='</td>';
                                        $datalist .='<td id="hotel" align="left" width="100">';
                                            $hotel_details = explode(',',$checkevent["hotel"]);
                                            foreach ($hotel as $hotelkey => $hotelvalue) {
                                                if (in_array($hotelvalue['id'], $hotel_details)){
                                                    $datalist .='<input type="radio" name="hotel'.$eventval.$contactvalue["id"].'" value="'.$hotelvalue['id'].'" checked />'.$hotelvalue['name'].'<br>';
                                                }else{
                                                   $datalist .='<input type="radio" name="hotel'.$eventval.$contactvalue["id"].'" value="'.$hotelvalue['id'].'" />'.$hotelvalue['name'].'<br>'; 
                                                }
                                            }
                                        $datalist .='</td>';
                                        $datalist .='<td width="100">';
                                            $datalist .='<input  class="form-control"  type="text" name="room'.$eventval.$contactvalue["id"].'" value="'.$checkevent['room'].'">';
                                        $datalist .='</td>';

                                        $datalist .='<td width="100">';
                                            if($checkevent['roomdate']!='0000-00-00'){
                                                $roomdate =$checkevent['roomdate'];
                                            }else{
                                                $roomdate ='';
                                            }
                                            $datalist .='<input  class="form-control datepicker"  type="text" name="roomdate'.$eventval.$contactvalue["id"].'" value="'.$roomdate.'">';
                                        $datalist .='</td>';
                                    $datalist .='<tr>';
                                }else{
                                    $datalist .='<tr style="border-bottom: 1px solid #e91e63;">';
                                    $datalist .='<td width="200">';
                                        $datalist .='<input type="hidden" name="ieid'.$eventvalue['id'].$contactvalue["id"].'" id="ieid" value=""  />';
                                        $datalist .='<input type="checkbox" name="event'.$contactvalue["id"].'[]" value="'.$eventvalue['id'].'" style="width:20px;height:20px;"/>'.$eventvalue['name'];
                                    $datalist .='</td>';
                                    $datalist .='<td width="100">';
                                        $datalist .='<input  class="form-control" type="number" name="adult'.$eventvalue['id'].$contactvalue["id"].'" maxlength="5">';
                                    $datalist .='</td>';
                                    $datalist .='<td width="100">';
                                        $datalist .='<input  class="form-control" type="number" name="child'.$eventvalue['id'].$contactvalue["id"].'" maxlength="5">';
                                    $datalist .='</td>';
                                    $datalist .='<td id="vhical" width="100" align="center">';
                                        $datalist .='<input type="radio" name="vehicle'.$eventvalue['id'].$contactvalue["id"].'" value="NA" />N/A<br>';
                                        $datalist .='<input type="radio" name="vehicle'.$eventvalue['id'].$contactvalue["id"].'" value="bus" />Bus<br>';
                                        $datalist .='<input type="radio" name="vehicle'.$eventvalue['id'].$contactvalue["id"].'" value="car" />Car';
                                    $datalist .='</td>';
                                    $datalist .='<td id="hotel" align="left" width="100">';
                                        foreach ($hotel as $hotelkey => $hotelvalue) {
                                            $datalist .='<input type="radio" name="hotel'.$eventvalue['id'].$contactvalue["id"].'" value="'.$hotelvalue['id'].'" />'.$hotelvalue['name'].'<br>';
                                        }
                                    $datalist .='</td>';
                                    $datalist .='<td width="100">';
                                        $datalist .='<input  class="form-control"  type="text" name="room'.$eventvalue['id'].$contactvalue["id"].'" maxlength="55">';
                                    $datalist .='</td>';
                                    $datalist .='<td width="100">';
                                        $datalist .='<input  class="form-control datepicker"  type="text" name="roomdate'.$eventvalue['id'].$contactvalue["id"].'">';
                                    $datalist .='</td>';
                                    $datalist .='<tr>';                                
                                }
                            }
                            $datalist .='</table>';
                        $datalist .='</td>';
                        $datalist .='<td id="route" width="150">';
                            $datalist .='<select  class="form-control" name="route'.$contactvalue["id"].'" id="route'.$contactvalue["id"].'" >';
                                foreach ($route as $routekey => $routevalue) {
                                    $datalist .='<option value="'.$routevalue['id'].'" ';
                                        if($allcheck['route']==$routevalue['id']){
                                         $datalist .='selected';   
                                        }
                                    $datalist .='>'.ucwords(strtolower($routevalue['name'])).'</option>';
                                }
                            $datalist .='</select>';
                            $datalist .='<br><span class="btn btn-danger" style="margin-top: 5px;" onclick="return deleteinviteinevent('.$contactvalue["id"].');">Delete</span>
                            </a>';
                        $datalist .='</td>';
                    $datalist .='</tr>';
                }else{
                    $datalist .='<tr id="row'.$contactvalue["id"].'" style="border-bottom: 1px solid #8bc34a;">';
                        $datalist .='<td id="ch" style="width:20px" align="center">';
                            $datalist .='<input type="checkbox" class="catchd'.$contactvalue["categoryid"].'"  name="contact_id[]" id="checkid" value="'.$contactvalue["id"].'" style="width:20px;height:20px;"/>';
                        $datalist .='</td>';
                        $datalist .='<td id="name" width="200" style="">';
                            $datalist .='<b>'.$contactvalue["name"].'</b>';
                            $datalist .='<br>';
                            $datalist .=nl2br($contactvalue["address"]);
                            $datalist .='<br>'.$contactvalue["city"];
                            $datalist .='<br>Mo .'.$contactvalue["mobile"];
                        $datalist .='</td>';
                        if($contactvalue['categoryid']!=''){
                            $datalist .='<td align="left" width="100">';
                            $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                            foreach ($category_details as $cdkey => $cdvalue) {
                                $datalist .=strtoupper($cdvalue['name'])."<br>";
                            }
                            $datalist .='</td>';
                        }else{
                            $datalist .='<td></td>';
                        }
                        // Event Part
                        $datalist .='<td id="event" align="left">';
                            $datalist .='<table  width="100%" border="1"  align="center">';
                            foreach ($event as $eventkey => $eventvalue) {
                                $datalist .='<tr style="border-bottom: 1px solid #e91e63;">';
                                    $datalist .='<td width="200">';
                                        $datalist .='<input type="hidden" name="ieid'.$eventvalue['id'].$contactvalue["id"].'" id="ieid" value=""  />';
                                        $datalist .='<input type="checkbox" name="event'.$contactvalue["id"].'[]" value="'.$eventvalue['id'].'" style="width:20px;height:20px;"/>'.$eventvalue['name'];
                                    $datalist .='</td>';
                                    $datalist .='<td width="100">';
                                        $datalist .='<input  class="form-control" type="number" name="adult'.$eventvalue['id'].$contactvalue["id"].'" maxlength="5">';
                                    $datalist .='</td>';
                                    $datalist .='<td width="100">';
                                        $datalist .='<input  class="form-control" type="number" name="child'.$eventvalue['id'].$contactvalue["id"].'" maxlength="5">';
                                    $datalist .='</td>';
                                    $datalist .='<td id="vhical" width="100" align="center">';
                                        $datalist .='<input type="radio" name="vehicle'.$eventvalue['id'].$contactvalue["id"].'" value="NA" />N/A<br>';
                                        $datalist .='<input type="radio" name="vehicle'.$eventvalue['id'].$contactvalue["id"].'" value="bus" />Bus<br>';
                                        $datalist .='<input type="radio" name="vehicle'.$eventvalue['id'].$contactvalue["id"].'" value="car" />Car';
                                    $datalist .='</td>';
                                    $datalist .='<td id="hotel" align="left" width="100">';
                                        foreach ($hotel as $hotelkey => $hotelvalue) {
                                            $datalist .='<input type="radio" name="hotel'.$eventvalue['id'].$contactvalue["id"].'" value="'.$hotelvalue['id'].'" />'.$hotelvalue['name'].'<br>';
                                        }
                                    $datalist .='</td>';
                                    $datalist .='<td width="100">';
                                        $datalist .='<input  class="form-control"  type="text" name="room'.$eventvalue['id'].$contactvalue["id"].'" maxlength="55">';
                                    $datalist .='</td>';
                                    $datalist .='<td width="100">';
                                        $datalist .='<input  class="form-control datepicker"  type="text" name="roomdate'.$eventvalue['id'].$contactvalue["id"].'">';
                                    $datalist .='</td>';
                                $datalist .='<tr>';
                            }
                            $datalist .='</table>';
                        $datalist .='</td>';
                        $datalist .='<td id="route" width="150">';
                            $datalist .='<select  class="form-control" name="route'.$contactvalue["id"].'" id="route'.$contactvalue["id"].'" >';
                                    $datalist .=$this->data['route_html'];
                            $datalist .='</select>';
                        $datalist .='</td>';
                    $datalist .='</tr>';
                }


            }
            
        }
               
        $this->data['datalist'] = $datalist;                     
        // End Data listing
        $this->data['message'] = $this->session->flashdata('message');
        $this->data['breadcrumb']='New inviteinevent';
        $this->smarty->assign('categoryid', $categoryid);
        $this->smarty->assign('name', $name);
        $this->smarty->assign('city', $city);
        $this->smarty->assign('mobile', $mobile);
        $this->smarty->assign('address', $address);
        $this->smarty->assign('data', $this->data);
        $this->smarty->view('invite.tpl'); 
        
    }
    function invitesave(){
        if($this->input->post()){ 
            $contact_id = $this->input->post('contact_id');
            if(count($contact_id)>0){
                foreach ($contact_id as $key => $contactvalue) {
                    $contactid = $contactvalue;
                    $event = $this->input->post('event'.$contactvalue);
                    $route = $this->input->post('route'.$contactvalue);
                    //if(!empty($event) and $event[0]!=''){
                        foreach ($event as $eventkey => $eventvalue) {

                            $adult = $this->input->post('adult'.$eventvalue.$contactvalue);
                            //echo $adult;
                            $child = $this->input->post('child'.$eventvalue.$contactvalue);
                            $vehicle = $this->input->post('vehicle'.$eventvalue.$contactvalue);
                            $room = $this->input->post('room'.$eventvalue.$contactvalue);
                            $roomdate = $this->input->post('roomdate'.$eventvalue.$contactvalue);
                            $hotel = $this->input->post('hotel'.$eventvalue.$contactvalue);
                            $ieid = $this->input->post('ieid'.$eventvalue.$contactvalue);
                            $data =array();
                            $data['contactid']=$contactid;
                            $data['event']=$eventvalue;
                            $data['adult']=$adult;
                            $data['child']=$child;
                            $data['total']=($adult+$child);
                            $data['vehicle']=$vehicle;
                            $data['hotel']=$hotel;
                            $data['room']=$room;
                            $data['roomdate']=$roomdate;
                            $data['route']=$route;
                            $data['status']='1';
                            $data['is_delete']='0';
                            $data['create_datetime']=date('Y-m-d h:i:s');
                            $data['created_ip']=$_SERVER['REMOTE_ADDR'];
                            //print_r($data);
                            if($ieid!=''){
                                $data['id']=$ieid;
                                $inviteineventdata = $this->inviteinevent_model->editinviteinevent($data);
                            }else{
                                $inviteineventdata = $this->inviteinevent_model->addinviteinevent($data);
                            }  
                        }
                    //}
                }
            }
            //exit;
            $this->session->set_flashdata('message',"Invite In Event Added Successfully.");
            redirect($this->data['base_url'] . 'inviteinevent/invitelist/');
        }
    }  
    function update(){
        if($this->input->post()){            
            $data = $this->input->post('data');
            $data['status']='1';
            $data['is_delete']='0';
            $data['created_ip']=$_SERVER['REMOTE_ADDR'];
            $inviteineventdata = $this->inviteinevent_model->editinviteinevent($data);
            $this->session->set_flashdata('message',"inviteinevent Update Successfully.");
            redirect($this->data['base_url'] . 'inviteinevent/');            
        } 
        $inviteineventid = $this->uri->segment(3);
        $this->data['inviteinevent_details'] = $this->inviteinevent_model->single_inviteinevent_details($inviteineventid);
        $this->data['inviteinevent'] = $this->inviteinevent_model->allinviteinevent_details();
        $this->data['message'] = $this->session->flashdata('message');
        $this->data['breadcrumb']='Edit inviteinevent';
        $this->data['tpl_name']= "inviteinevent_create.tpl";
        $this->smarty->assign('data', $this->data);
        $this->smarty->view('template.tpl');  
    }
    function delete(){
        $inviteineventid = $this->uri->segment(3);
        if($inviteineventid!=''){            
            $data['is_delete'] = '1';
            $data['id'] = $inviteineventid;
            $editinviteinevent = $this->inviteinevent_model->editinviteinevent($data);
            $this->session->set_flashdata('message',"inviteinevent delete Successfully.");
            redirect($this->data['base_url'] . 'inviteinevent/');
        }else{
             redirect($this->data['base_url'] . 'inviteinevent/');
        }
    }
    function invitinglistview(){
        // Event
        $event = $this->event_model->allevent_details();   
        $this->data['event'] = $event;
        // Hotel
        $hotel = $this->event_model->allhotel_details();   
        $this->data['hotel'] = $hotel;

        //route
        $route = $this->route_model->allroute_details();   
        $route_html='';
        foreach ($route as $routekey => $routevalue) {
            $route_html .='<option value="'.$routevalue['id'].'">'.ucwords(strtolower($routevalue['name'])).'</option>';
        }
        $this->data['route_html'] = $route_html;

        //post
        $eventid = $this->uri->segment(3);        
        if($this->input->post('categoryid')!='' || $this->input->post('name')!='' || $this->input->post('city')!='' || $this->input->post('mobile')!='' || $this->input->post('address')!=''){$categoryid = $this->input->post('categoryid');
            $passdeta=array();
            $categoryid=$this->input->post('categoryid');
            $name=$this->input->post('name');
            $city=$this->input->post('city');
            $mobile=$this->input->post('mobile');
            $address=$this->input->post('address');
            $eventid=$this->input->post('event');
            $passdeta['categoryid']=$categoryid;
            $passdeta['name']=$name;
            $passdeta['city']=$city;
            $passdeta['mobile']=$mobile;
            $passdeta['address']=$address;
            $passdeta['eventid']=$eventid;
            $total_row = $this->inviteinevent_model->record_count($passdeta);
            $per_page = count($total_row);
        }else{
            $passdeta=array();
            $categoryid='';
            $name='';
            $city='';
            $mobile='';
            $address='';
            $passdeta['categoryid']=$categoryid;
            $passdeta['name']=$name;
            $passdeta['city']=$city;
            $passdeta['mobile']=$mobile;
            $passdeta['address']=$address;
            $passdeta['eventid']=$eventid;
            $total_row = $this->inviteinevent_model->record_count($passdeta);
            $per_page = 100;
        }
        //echo $categoryid;
        //echo count($total_row);
        //exit;
        //list 
        $p_c = array();
        $p_c["base_url"] = base_url()."inviteinevent/invitinglistview/".$eventid."/";        
        $p_c["total_rows"] = count($total_row);      
        $p_c['per_page'] = $per_page;        
        $p_c['uri_segment'] = 4;   
        $p_c['num_links'] = count($total_row);     
        $p_c['full_tag_open'] = '<ul class="pagination">';        
        $p_c['full_tag_close'] = '</ul>';        
        $p_c['first_link'] = 'First';        
        $p_c['last_link'] = 'Last';        
        $p_c['first_tag_open'] = '<li>';        
        $p_c['first_tag_close'] = '</li>';        
        $p_c['prev_link'] = '&laquo';        
        $p_c['prev_tag_open'] = '<li class="prev">';        
        $p_c['prev_tag_close'] = '</li>';        
        $p_c['next_link'] = '&raquo';        
        $p_c['next_tag_open'] = '<li>';        
        $p_c['next_tag_close'] = '</li>';        
        $p_c['last_tag_open'] = '<li>';        
        $p_c['last_tag_close'] = '</li>';        
        $p_c['cur_tag_open'] = '<li class="active"><a href="#">';        
        $p_c['cur_tag_close'] = '</a></li>';        
        $p_c['num_tag_open'] = '<li>';        
        $p_c['num_tag_close'] = '</li>';
        $this->pagination->initialize($p_c);
        if($this->uri->segment(4)){
            $page = ($this->uri->segment(4)) ;
        }else{
            $page = 0;
        }
        $processdeta=array();
        $processdeta['categoryid']=$categoryid;
        $processdeta['name']=$name;
        $processdeta['city']=$city;
        $processdeta['mobile']=$mobile;
        $processdeta['address']=$address;
        $processdeta['eventid']=$eventid;
        $processdeta['limit']=$p_c["per_page"];
        $processdeta['start']=$page;
        $this->data["record_fetch"]= $this->inviteinevent_model->record_fetch($processdeta);
        $this->data["links"] = $this->pagination->create_links();
        $this->data["totalrecord"] =count($total_row);
        $this->data['category'] = $this->category_model->allcategory_details();
        //echo "<pre>";print_r($this->data["record_fetch"]);exit;
        // Data Listing
        $datalist =''; 
        foreach ($this->data["record_fetch"] as $rfkey => $rfvalue) {
            $contactid = $rfvalue["contactid"];
            $datalist .='<tr id="row'.$contactid.'" >';
                $datalist .='<td id="ch" width="10" align="center"  >';
                    $datalist .='<input type="hidden" name="ieid'.$contactid.'" id="ieid" value="'.$rfvalue["id"].'"  />';
                    $datalist .='<input type="checkbox" class="catchd'.$rfvalue["categoryid"].'"  name="contact_id[]" id="checkid" value="'.$contactid.'" style="width:20px;height:20px;"/>';
                    $datalist .='<input type="hidden" name="currentevent" id="currentevent" value="'.$eventid.'"  />';
                $datalist .='</td>';
                $datalist .='<td id="" style="padding: 5px;">';
                    $datalist .='<input class="form-control" type="text" id="name'.$contactid.'" name="name'.$contactid.'" value="'.$rfvalue['name'].'" style="border: 3px solid #7d9748;">';
                    $datalist .='<textarea class="form-control" id="address'.$contactid.'" rows="3" name="address'.$contactid.'">'.$rfvalue["address"].'</textarea>';
                    $datalist .='<input class="form-control" type="text" id="city'.$contactid.'" name="city'.$contactid.'" value="'.$rfvalue['city'].'">';
                    $datalist .='<input class="form-control" type="text" id="mobile'.$contactid.'" name="mobile'.$contactid.'" value="'.$rfvalue['mobile'].'" placeholder="Please Enter Mobile Number">';
                $datalist .='</td>';
                if($rfvalue['categoryid']!=''){
                    $datalist .='<td align="left" width="100">';
                     // drop down
                    $datalist .='<select class="select" name="categoryid'.$contactid.'[]" id="categoryid"  multiple="">';
                        $category_details=$this->data['category'];
                        $categoryids = explode(',', $rfvalue['categoryid']);
                          foreach ($category_details as $catkey => $catvalue){
                            if (in_array($catvalue['id'], $categoryids)) {
                               $datalist .='<option value="'.$catvalue['id'].'" data-tokens="'.$catvalue['name'].'" selected>'.strtoupper($catvalue['name']).'</option>';
                            }else{
                                $datalist .='<option value="'.$catvalue['id'].'" data-tokens="'.$catvalue['name'].'" >'.strtoupper($catvalue['name']).'</option>';
                            }
                            

                          }
                    $datalist .='</select><br>';
                    // simple category print
                    $category_details = $this->contact_model->get_category($rfvalue['categoryid']);
                    foreach ($category_details as $cdkey => $cdvalue) {
                        $datalist .=strtoupper($cdvalue['name'])."<br>";
                    }
                    $datalist .='</td>';
                }else{
                    $datalist .='<td width="100"></td>';
                }
                $datalist .='<td id="event" align="left">';
                    $datalist .='<table  width="100%" border="1"  align="center">';
                    foreach ($event as $eventkey => $eventvalue) {
                        $checkevent = $this->inviteinevent_model->checkevent($contactid,$eventvalue['id']);
                        $eventval = $eventvalue['id'];
                        if(!empty($checkevent)){
                            $datalist .='<tr style="border-bottom: 1px solid #e91e63;">';
                                $datalist .='<td width="200">';
                                    $datalist .='<input type="hidden" name="ieid'.$eventval.$contactid.'" value="'.$checkevent['id'].'">';
                                    $datalist .='<input type="checkbox" name="event'.$contactid.'[]" value="'.$checkevent['event'].'" checked style="width:20px;height:20px;"/>'.$eventvalue['name'];
                                $datalist .='</td>';
                                $datalist .='<td width="100">';
                                    $datalist .='<input  class="form-control" type="number" name="adult'.$eventval.$contactid.'" value="'.$checkevent['adult'].'">';
                                $datalist .='</td>';
                                $datalist .='<td width="100">';
                                    $datalist .='<input  class="form-control" type="number" name="child'.$eventval.$contactid.'" value="'.$checkevent['child'].'">';
                                $datalist .='</td>';

                                if($checkevent['vehicle']=='NA'){ $na = 'checked'; }
                                else{ $na = ''; }
                                if($checkevent['vehicle']=='bus'){ $bus = 'checked'; }
                                else{ $bus = ''; }
                                if($checkevent['vehicle']=='car'){ $car = 'checked'; }
                                else{ $car = ''; }
                                
                                $datalist .='<td id="vhical" width="100" align="center">';
                                    $datalist .='<input type="radio" name="vehicle'.$eventval.$contactid.'" value="NA" '.$na.'/>N/A<br>';
                                    $datalist .='<input type="radio" name="vehicle'.$eventval.$contactid.'" value="bus" '.$bus.'/>Bus<br>';
                                    $datalist .='<input type="radio" name="vehicle'.$eventval.$contactid.'" value="car" '.$car.'/>Car';
                                $datalist .='</td>';
                                $datalist .='<td id="hotel" align="left" width="100">';
                                    $hotel_details = explode(',',$checkevent["hotel"]);
                                    foreach ($hotel as $hotelkey => $hotelvalue) {
                                        if (in_array($hotelvalue['id'], $hotel_details)){
                                            $datalist .='<input type="radio" name="hotel'.$eventval.$contactid.'" value="'.$hotelvalue['id'].'" checked />'.$hotelvalue['name'].'<br>';
                                        }else{
                                           $datalist .='<input type="radio" name="hotel'.$eventval.$contactid.'" value="'.$hotelvalue['id'].'" />'.$hotelvalue['name'].'<br>'; 
                                        }
                                    }
                                $datalist .='</td>';
                                $datalist .='<td width="100">';
                                    $datalist .='<input  class="form-control"  type="text" name="room'.$eventval.$contactid.'" value="'.$checkevent['room'].'">';
                                $datalist .='</td>';

                                $datalist .='<td width="100">';
                                    if($checkevent['roomdate']!='0000-00-00'){
                                        $roomdate =$checkevent['roomdate'];
                                    }else{
                                        $roomdate ='';
                                    }
                                    $datalist .='<input  class="form-control datepicker"  type="text" name="roomdate'.$eventval.$contactid.'" value="'.$roomdate.'">';
                                $datalist .='</td>';
                            $datalist .='<tr>';
                        }else{
                            $datalist .='<tr style="border-bottom: 1px solid #e91e63;">';
                            $datalist .='<td width="200">';
                                $datalist .='<input type="hidden" name="ieid'.$eventval.$contactid.'" id="ieid" value=""  />';
                                $datalist .='<input type="checkbox" name="event'.$contactid.'[]" value="'.$eventvalue['id'].'" style="width:20px;height:20px;"/>'.$eventvalue['name'];
                            $datalist .='</td>';
                            $datalist .='<td width="100">';
                                $datalist .='<input  class="form-control" type="number" name="adult'.$eventval.$contactid.'" maxlength="5">';
                            $datalist .='</td>';
                            $datalist .='<td width="100">';
                                $datalist .='<input  class="form-control" type="number" name="child'.$eventval.$contactid.'" maxlength="5">';
                            $datalist .='</td>';
                            $datalist .='<td id="vhical" width="100" align="center">';
                                $datalist .='<input type="radio" name="vehicle'.$eventval.$contactid.'" value="NA" />N/A<br>';
                                $datalist .='<input type="radio" name="vehicle'.$eventval.$contactid.'" value="bus" />Bus<br>';
                                $datalist .='<input type="radio" name="vehicle'.$eventval.$contactid.'" value="car" />Car';
                            $datalist .='</td>';
                            $datalist .='<td id="hotel" align="left" width="100">';
                                foreach ($hotel as $hotelkey => $hotelvalue) {
                                    $datalist .='<input type="radio" name="hotel'.$eventval.$contactid.'" value="'.$hotelvalue['id'].'" />'.$hotelvalue['name'].'<br>';
                                }
                            $datalist .='</td>';
                            $datalist .='<td width="100">';
                                $datalist .='<input  class="form-control"  type="text" name="room'.$eventval.$contactid.'" maxlength="55">';
                            $datalist .='</td>';
                            $datalist .='<td width="100">';
                                $datalist .='<input  class="form-control datepicker"  type="text" name="roomdate'.$eventval.$contactid.'">';
                            $datalist .='</td>';
                            $datalist .='<tr>';                                
                        }
                    }
                    $datalist .='</table>';
                $datalist .='</td>';
                $datalist .='<td id="route" width="150">';
                    $datalist .='<select  class="form-control" name="route'.$contactid.'" id="route'.$contactid.'" >';
                        foreach ($route as $routekey => $routevalue) {
                            $datalist .='<option value="'.$routevalue['id'].'" ';
                                if($rfvalue['route']==$routevalue['id']){
                                 $datalist .='selected';   
                                }
                            $datalist .='>'.ucwords(strtolower($routevalue['name'])).'</option>';
                        }
                    $datalist .='</select>';
                    $datalist .='<br><span class="btn btn-danger" style="margin-top: 5px;" onclick="return deleteinviteinevent('.$contactid.');">Delete</span>
                            </a>';
                $datalist .='</td>';
            $datalist .='</tr>';
                  
        }
        $this->data['datalist'] = $datalist;
        $this->smarty->assign('categoryid', $categoryid);
        $this->smarty->assign('name', $name);
        $this->smarty->assign('city', $city);
        $this->smarty->assign('mobile', $mobile);
        $this->smarty->assign('address', $address);
        $totalsections = $this->inviteinevent_model->record_total($processdeta);
        //echo "<pre>";print_r($totalsections);exit;
        $totaladult=$totalsections['tadult'];
        $totalchild=$totalsections['tchild'];
        $grandtotal=($totaladult+$totalchild);
        $totalsection .=' <table  width="100%" border="1" cellpadding="10" cellspacing="10">
                           <tr align="center">';
            $totalsection .='<td colspan="4" align="right" ><h5><b>Total :</b></h5> </td>';
            $totalsection .='<td><h5><b>Adult<br>'.$totaladult.'</b></h5></td>';
            $totalsection .='<td><h5><b>Child<br>'.$totalchild.'</b></h5></td>';
            $totalsection .='<td><h5><b>Total Card<br>'.$totalsections['cid'].'</b></h5></td>';
            $totalsection .='<td><h5><b>Total Member<br>'.$grandtotal.'</b></h5></td>';
        $totalsection .='</tr></table>';
        $this->smarty->assign('totalsection',$totalsection);
        $event_details = $this->event_model->single_event_details($eventid);
        $this->data['message'] = $this->session->flashdata('message');
        $this->data['breadcrumb']=strtoupper($event_details['name']);
        $this->smarty->assign('data', $this->data);
        $this->smarty->assign('currenteventid', $eventid);
        $this->smarty->view('invitinglistview.tpl');  
    } 
    // This Single Save
    // function invitinglistsave(){
    //     if($this->input->post()){ 
    //         $contact_id = $this->input->post('contactid');
    //         $contactvalue = $contact_id;
    //         $contactid = $this->input->post('contactid');
    //         $name      = $this->input->post('name'.$contactid);
    //         $address   = $this->input->post('address'.$contactid);
    //         $city      = $this->input->post('city'.$contactid);
    //         $mobile    = $this->input->post('mobile'.$contactid);
    //         if($contactid!=''){  
    //             $update_data =array();
    //             $update_data['id'] = $contactid;
    //             $update_data['name'] = $name;
    //             $update_data['address'] = $address;
    //             $update_data['city'] = $city;
    //             $update_data['mobile'] = $mobile;
    //             $updatecontact = $this->contact_model->editcontact($update_data);
    //         }
    //         $event = $this->input->post('event'.$contactvalue);
    //         $finalevent = implode(',',$event);
    //         if(!empty($event) and $event[0]==0){
    //             $eventval =array();
    //             $all_event_id = $this->event_model->get_all_event_id();
    //             foreach ($all_event_id as $eventkey => $eventvalue) {
    //                 $eventval[] = $eventvalue['id'];
    //             }
    //             $finalevent = implode(',',$eventval);
    //         }
    //         $adult = $this->input->post('adult'.$contactvalue);
    //         $child = $this->input->post('child'.$contactvalue);
    //         $totalmember = ($adult+$child);
    //         $vehicle = $this->input->post('vehicle'.$contactvalue);
    //         $room = $this->input->post('room'.$contactvalue);
    //         $roomdate = $this->input->post('roomdate'.$contactvalue);
    //         $route = $this->input->post('route'.$contactvalue);
    //         $hotel = $this->input->post('hotel'.$contactvalue);
    //         $ieid = $this->input->post('ieid'.$contactvalue);
    //         if(!empty($hotel)){
    //             $hotel = implode(',',$hotel);
    //         }else{
    //             $hotel ='';
    //         }
    //         if($contactid!='' and $finalevent!='' and $totalmember!='0'){
    //             $data =array();
    //             $data['contactid']=$contactid;
    //             $data['event']=$finalevent;
    //             $data['adult']=$adult;
    //             $data['child']=$child;
    //             $data['total']=$totalmember;
    //             $data['vehicle']=$vehicle;
    //             $data['hotel']=$hotel;
    //             $data['room']=$room;
    //             $data['roomdate']=$roomdate;
    //             $data['route']=$route;
    //             $data['status']='1';
    //             $data['is_delete']='0';
    //             $data['create_datetime']=date('Y-m-d h:i:s');
    //             $data['created_ip']=$_SERVER['REMOTE_ADDR'];
    //             $data['id']=$ieid;
    //             $inviteineventdata = $this->inviteinevent_model->editinviteinevent($data);
    //         }
    //         //exit;
    //         $currentevent = $this->input->post('currentevent');
    //         $this->session->set_flashdata('message',"Invite In Event Added Successfully.");
    //         redirect($this->data['base_url'] . 'inviteinevent/invitinglistview/'.$currentevent);
    //     }
    // }  
    // this Double save
    function invitinglistsave(){
        if($this->input->post()){ 
            $contact_id = $this->input->post('contact_id');
            if(count($contact_id)>0){
                foreach ($contact_id as $key => $contactvalue) {
                    $contactid = $contactvalue;
                    // Contact detail update
                    $name      = $this->input->post('name'.$contactvalue);
                    $address   = $this->input->post('address'.$contactvalue);
                    $city      = $this->input->post('city'.$contactvalue);
                    $mobile    = $this->input->post('mobile'.$contactvalue);
                    $categoryid = $this->input->post('categoryid'.$contactvalue);
                    if($contactvalue!=''){  
                        $update_data =array();
                        $update_data['id'] = $contactvalue;
                        $update_data['name'] = $name;
                        $update_data['address'] = $address;
                        $update_data['city'] = $city;
                        $update_data['mobile'] = $mobile;
                        $update_data['categoryid'] = implode(',',$categoryid);
                        $updatecontact = $this->contact_model->editcontact($update_data);
                    }
                    $event = $this->input->post('event'.$contactvalue);
                    $route = $this->input->post('route'.$contactvalue);
                    foreach ($event as $eventkey => $eventvalue) {
                        $adult = $this->input->post('adult'.$eventvalue.$contactvalue);
                        $child = $this->input->post('child'.$eventvalue.$contactvalue);
                        $vehicle = $this->input->post('vehicle'.$eventvalue.$contactvalue);
                        $room = $this->input->post('room'.$eventvalue.$contactvalue);
                        $roomdate = $this->input->post('roomdate'.$eventvalue.$contactvalue);
                        $hotel = $this->input->post('hotel'.$eventvalue.$contactvalue);
                        $ieid = $this->input->post('ieid'.$eventvalue.$contactvalue);
                        $data =array();
                        $data['contactid']=$contactid;
                        $data['event']=$eventvalue;
                        $data['adult']=$adult;
                        $data['child']=$child;
                        $data['total']=($adult+$child);
                        $data['vehicle']=$vehicle;
                        $data['hotel']=$hotel;
                        $data['room']=$room;
                        $data['roomdate']=$roomdate;
                        $data['route']=$route;
                        $data['status']='1';
                        $data['is_delete']='0';
                        $data['create_datetime']=date('Y-m-d h:i:s');
                        $data['created_ip']=$_SERVER['REMOTE_ADDR'];
                        if($ieid!=''){
                            $data['id']=$ieid;
                            $inviteineventdata = $this->inviteinevent_model->editinviteinevent($data);
                        }else{
                            $inviteineventdata = $this->inviteinevent_model->addinviteinevent($data);
                        }  
                    }
                }
            }
            $currentevent = $this->input->post('currentevent');
            $this->session->set_flashdata('message',"Invite In Event Update Successfully.");
            redirect($this->data['base_url'] . 'inviteinevent/invitinglistview/'.$currentevent);
        }
    }
    function contact_list_for_invite(){
        $categoryid = $this->input->post('categoryid');
        $html='';
        $html .='<table id="initscroll" border="1" data-plugin="datatable" data-scroll-x="true" data-b-auto-width="false" data-scroll-y="380" data-scroll-collapse="true" data-defer-render="false" data-paging="false" class="table table-striped table-hover display nowrap">';
            $html .='<thead>';
                $html .='<tr>';
                    $html .='<th>Event</th>';
                    $html .='<th>Name</th>';
                    $html .='<th>Category</th>';
                    $html .='<th>City</th>';
                    $html .='<th>Adult</th>';
                    $html .='<th>Child</th>';
                    //$html .='<th>Total</th>';
                $html .='</tr>';
            $html .='</thead>';
            $html .='<tbody>';
                $contact_details = $this->contact_model->contact_details($categoryid);
                $html .='<input  type="hidden" id="totalcontact" name="totalcontact" value="'.count($contact_details).'">';
                $event_details = $this->event_model->allevent_details();
                if(!empty($contact_details)){
                    foreach ($contact_details as $contactkey => $contactvalue) {
                        $quniqid = ($contactkey+1);
                        $html .='<tr>';
                            $html .='<td>';
                                $html .='<div class="checkbox-inline">';
                                   foreach ($event_details as $eventkey => $eventvalue) {
                                        $html .='<div >
                                                <input value="'.$eventvalue['id'].'" id="event'.$quniqid.'" name="event'.$quniqid.'[]" type="checkbox" checked >
                                                <span>'.ucwords(strtolower($eventvalue['name'])).'</span>
                                            </div>';
                                   }
                                $html .='</div>';
                            $html .='</td>';
                            $html .='<td><input  type="hidden" id="contactid'.$quniqid.'" name="contactid'.$quniqid.'" value="'.$contactvalue['id'].'">
                            '.strtoupper($contactvalue['name']).'</td>';
                            if($contactvalue['name']!='' and $contactvalue['categoryid']!=''){
                                $html .='<td>';
                                    $duplicat_details = $this->contact_model->duplicat_details($contactvalue['name'],'',$contactvalue['address']);
                                    foreach ($duplicat_details as $dkey => $dvalue) {
                                        $html .=ucwords(strtoupper($dvalue['catname'])).'<br>';
                                    }
                                $html .='</td>';
                              
                            }else{
                                $html .='<td>'.ucwords(strtoupper($contactvalue['catname'])).'</td>';
                            }
                            $html .='<td>'.ucwords(strtoupper($contactvalue['city'])).'</td>';
                            $html .='<td><input  class="form-control" type="number" id="adult'.$quniqid.'" name="adult'.$quniqid.'" maxlength="5"></td>';
                            $html .='<td><input  class="form-control" type="number" id="child'.$quniqid.'" name="child'.$quniqid.'" maxlength="5"></td>';
                            // $html .='<td total="">
                            //     <input  type="hidden" id="total'.$quniqid.'" name="total'.$quniqid.'" value="5">
                            // </td>';
                        $html .='</tr>';
                    }
                }
            $html .='</tbody>';
        $html .='</table>';
        echo json_encode($html);exit;

    } 
    function invite_delete(){
        $id = $this->input->post('id');
        if($id!=''){  
            // delete receipt
            $delete_data =array();
            $delete_data['is_delete'] = '1';
            $delete_data['status'] = '0';
            $delete_data['id'] = $id;
            $deleteinvite = $this->inviteinevent_model->editinviteinevent($delete_data);
            echo json_encode($deleteinvite);
        }else{
        
        }
    }
    function invite_contact_delete(){
        $id = $this->input->post('id');
        if($id!=''){  
            // delete receipt
            $delete_data =array();
            $delete_data['is_delete'] = '1';
            $delete_data['status'] = '0';
            $delete_data['contactid'] = $id;
            $deleteinvite = $this->inviteinevent_model->invite_contact_delete($delete_data);
            echo json_encode($deleteinvite);exit;
        }else{
        
        }
    }
    function invite_update(){
        $id = $this->input->post('id');
        $adult = $this->input->post('adult');
        $child = $this->input->post('child');
        if($id!=''){  
            // delete receipt
            $update_data =array();
            $update_data['id'] = $id;
            $update_data['adult'] = $adult;
            $update_data['child'] = $child;
            $totalmember = ($adult+$child);
            $update_data['total'] = $totalmember;
            $updateinvite = $this->inviteinevent_model->editinviteinevent($update_data);
            echo json_encode($updateinvite);
        }else{
        
        }
    }
    function updateinviting(){
        $contactid = $this->input->post('contactid');
        $name      = $this->input->post('name');
        $address   = $this->input->post('address');
        $city      = $this->input->post('city');
        $mobile    = $this->input->post('mobile');
        if($contactid!=''){  
            $update_data =array();
            $update_data['id'] = $contactid;
            $update_data['name'] = $name;
            $update_data['address'] = $address;
            $update_data['city'] = $city;
            $update_data['mobile'] = $mobile;
            print_r($update_data);
            //$updatecontact = $this->contact_model->editcontact($update_data);
            //echo json_encode($contactid);
        }
        $id = $this->input->post('id');
        $event = $this->input->post('event');
        $adult = $this->input->post('adult');
        $child = $this->input->post('child');
        $vehicle = $this->input->post('vehicle');
        $hotel = $this->input->post('hotel');
        $room = $this->input->post('room');
        $roomdate = $this->input->post('roomdate');
        $route = $this->input->post('route');
        if(!empty($hotel)){
            $hotel = implode(',',$hotel);
        }else{
            $hotel ='';
        }
        $finalevent = implode(',',$event);
        echo "<pre>";print_r($finalevent);
        if(!empty($event) and $event[0]==0){
            $eventval =array();
            $all_event_id = $this->event_model->get_all_event_id();
            foreach ($all_event_id as $eventkey => $eventvalue) {
                $eventval[] = $eventvalue['id'];
            }
            $finalevent = implode(',',$eventval);
        }
        if($id!=''){  
            // delete receipt
            $update_data =array();
            $update_data['id'] = $id;
            $update_data['event'] = $finalevent;
            $update_data['adult'] = $adult;
            $update_data['child'] = $child;
            $update_data['vehicle'] = $vehicle;
            $update_data['hotel'] = $hotel;
            $update_data['room'] = $room;
            $update_data['roomdate'] = $roomdate;
            $update_data['route'] = $route;
            $totalmember = ($adult+$child);
            $update_data['total'] = $totalmember;
            echo "<pre>";print_r($update_data);
            //$updateinvite = $this->inviteinevent_model->editinviteinevent($update_data);
            //echo json_encode($updateinvite);
        }
    }
    
    function eventhistory(){
        $event = $this->event_model->allevent_details();
        $html ='';
        foreach ($event as $eventkey => $eventvalue) {
            $eventid= $eventvalue['id'];
            $invitinglist = $this->inviteinevent_model->get_inviting_list($eventid);
            $html .='<tr>';
                $html .='<td>'.ucwords(strtolower($eventvalue['name'])).'</td>';
                $html .='<td>'.intval($invitinglist['tadult']).'</td>';
                $html .='<td>'.intval($invitinglist['tchild']).'</td>';
                $html .='<td>'.intval($invitinglist['ftotal']).'</td>';
                $html .='<td>';
                    $html .='<a href="'.$this->data['base_url'].'inviteinevent/eventwiseview/'.$eventid.'">';
                        $html .='<span class="btn btn-primary">
                            <i class="fa fa-eye"></i> View</span>';
                    $html .='</a> ';
                    $html .='<a href="'.$this->data['base_url'].'report/invite_report/'.$eventid.'/ExportinPDF" target="_blank">';
                        $html .='<span class="btn btn-danger">
                            <i class="fa fa-file-pdf-o"></i> Export in PDF</span>';
                    $html .='</a> ';
                    $html .='<a href="'.$this->data['base_url'].'report/invite_report/'.$eventid.'/ExportinExcel" target="_blank">';
                        $html .='<span class="btn btn-success">
                            <i class="fa fa-file-excel-o"></i> Export in Excel</span>';
                    $html .='</a> ';
                    $html .='<a href="'.$this->data['base_url'].'report/invite_report/'.$eventid.'/StickerView" target="_blank">';
                        $html .='<span class="btn btn-info">
                            <i class="fa fa-print"></i> Sticker View</span>';
                    $html .='</a>';

                $html .='</td>';
            $html .='</tr>'; 
        }
        $this->smarty->assign('eventwise',$html);
        $this->smarty->assign('evenininvite',$event);
        $this->data['message'] = $this->session->flashdata('message');
        $this->data['breadcrumb']='New inviteinevent';
        $this->data['tpl_name']= "eventhistory.tpl";
        $this->smarty->assign('data', $this->data);
        $this->smarty->view('template.tpl');  
    }
    function eventhistorys(){
        $eventid = $this->uri->segment(3);
        
        $html ='';
        $eventwiseview = $this->inviteinevent_model->eventwiseview($eventid);
        $eventwiseview = $this->unique_multidim_array($eventwiseview,'address');
        $grandtotal='0';
        $totaladult='0';
        $totalchild='0';
        foreach ($eventwiseview as $ekey => $eventvalue) {
            $grandtotal =($grandtotal+intval($eventvalue['total']));
            $totaladult =($totaladult+intval($eventvalue['adult']));
            $totalchild =($totalchild+intval($eventvalue['child']));
            $html .='<tr>';
                $html .='<td>'.ucwords(strtolower($eventvalue['name'])).'</td>';
                $html .='<td>'.ucwords(strtolower($eventvalue['mobile'])).'</td>';
                $html .='<td>'.ucwords(strtolower($eventvalue['city'])).'</td>';
                $html .='<td>';
                $duplicat_details = $this->contact_model->duplicat_details($eventvalue['name'],'',$eventvalue['address']);
                foreach ($duplicat_details as $dkey => $dvalue) {
                    $html .=ucwords(strtoupper($dvalue['catname'])).'<br>';
                }
                $html .='</td>';
                $html .='<td><input style="width:50px" type="number" name="adult'.$eventvalue['id'].'" id="adult'.$eventvalue['id'].'" value="'.($eventvalue['adult']).'"</td>';
                $html .='<td><input style="width:50px" type="number" name="child'.$eventvalue['id'].'" id="child'.$eventvalue['id'].'" value="'.($eventvalue['child']).'"</td>';
                $html .='<td>'.($eventvalue['total']).'</td>';
                $html .='<td> By '.ucwords(strtolower($eventvalue['vehicle'])).'</td>';
                $html .='<td> '.ucwords(strtolower($eventvalue['room'])).'</td>';
                if($eventvalue['roomdate']!='0000-00-00'){
                    $html .='<td> '.date('d-m-Y',strtotime($eventvalue['roomdate'])).'</td>';
                }else{
                    $html .='<td></td>';
                }
                $html .='<td>';
                    $html .='<span class="btn btn-primary" onclick="updateinviteinevent('.$eventvalue['id'].')">Update</span>';
                    $html .='<br><span class="btn btn-danger" style="margin-top: 5px;" onclick="deleteinviteinevent('.$eventvalue["id"].')">Delete</span>
                    </a>';
                $html .='</td>';
            $html .='</tr>';
        }
        $totalsection .='<table class="table">
                           <tr>';
            $totalsection .='<td colspan="4" align="right" ><h5><b>Total :</b></h5> </td>';
            $totalsection .='<td><h5><b>Adult<br>'.$totaladult.'</b></h5></td>';
            $totalsection .='<td><h5><b>Child<br>'.$totalchild.'</b></h5></td>';
            $totalsection .='<td><h5><b>Total<br>'.$grandtotal.'</b></h5></td>';
            $totalsection .='<td><a href="'.$this->data['base_url'].'inviteinevent/create/"><button class="btn btn-small btn-success pull-right">ADD NEW INVITE</button></a></td>';
        $totalsection .='</tr></table>';
        $event_details = $this->event_model->single_event_details($eventid); 
        $this->smarty->assign('evenininvite',$html);
        $this->smarty->assign('totalsection',$totalsection);
        $this->data['message'] = $this->session->flashdata('message');
        $this->data['breadcrumb']=strtoupper($event_details['name']);
        $this->data['tpl_name']= "eventwiseview.tpl";
        $this->smarty->assign('data', $this->data);
        $this->smarty->view('template.tpl');  
    } 
}
