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

class report extends MY_Controller{
    function __construct(){
        parent::__construct();
        $this->load->model('category_model', '', TRUE);
        $this->load->model('contact_model', '', TRUE);
        $this->load->model('event_model', '', TRUE);
        $this->load->model('inviteinevent_model', '', TRUE);
        $this->load->model('route_model', '', TRUE);
        $this->load->model('hotel_model', '', TRUE);
        $this->load->library("Pdf");
    }
    function contact_report(){
        if($this->input->post()){
            $catagory = $this->input->post('check_all');
            $contact = $this->input->post('contact_id');
            $reportview = $this->input->post('reportview');
            //print_r($catagory);exit;
            if(!empty($catagory)){
               $catagory_id =$catagory;
            }else{
                $catagory_id = '';
            }
          
            if(!empty($contact)){
                $contact_id =$contact;
            }else{
                $contact_id = '';
            }
            ob_clean();
            if($reportview=='View Report'){
                $contact_details = $this->contact_model->contact_full_details($catagory_id,$contact_id);
                if(!empty($contact_details)){
                    //$contact_details = $this->unique_multidim_array($contact_details,'name'); 
                    
                    $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                            $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                    $html .='<th width="470" colspan="5">';
                                    $catname_count = array_count_values(array_column($contact_details, 'categoryid'));
                                    if(!empty($catname_count)){
                                        foreach ($catname_count as $cckey => $ccvalue) {
                                            $category_details = $this->contact_model->get_category($cckey);
                                            $catname='';
                                            foreach ($category_details as $cdkey => $cdvalue) {
                                                if(count($category_details)>0){
                                                  $catname .=strtoupper($cdvalue['name'])." & ";  
                                                }else{
                                                    $catname .=strtoupper($cdvalue['name'])." ";  
                                                }
                                                
                                            }
                                            $html .= $catname. "=". $ccvalue."&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;&nbsp;&nbsp;&nbsp;";
                                        }
                                    }
                                    $html .='</th>';
                                    $html .='<th width="70"> TOTAL  : '.count($contact_details).'</th>';
                            $html .='</tr>';
                            $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                                $html .='<th width="30">Sr No.</th>';
                                $html .='<th width="150">Name</th>';
                                $html .='<th width="150">Address</th>';
                                $html .='<th width="70">City</th>';
                                $html .='<th width="70">Contact Number</th>';
                                $html .='<th width="70">Category</th>';
                            $html .='</tr>';
                            if(!empty($contact_details)){
                                $i=0;
                                foreach ($contact_details as $contactkey => $contactvalue) {
                                    $html .='<tr>';
                                        $html .='<td width="30"  align="center">'.($i+1).'</td>';
                                        $html .='<td width="150" align="left">'.ucwords(strtolower($contactvalue['name'])).'</td>';
                                        $html .='<td width="150"  align="left">'.ucwords(strtolower(nl2br($contactvalue['address']))).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['city'])).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['mobile'])).'</td>';
                                        if($contactvalue['categoryid']!=''){
                                            $html .='<td width="70"  align="left">';
                                            $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                                            foreach ($category_details as $cdkey => $cdvalue) {
                                                $html .=strtoupper($cdvalue['name'])."<br>";
                                            }
                                            $html .='</td>';
                                        }else{
                                            $html .='<td width="70"  align="left">'.ucwords(strtoupper($contactvalue['catname'])).'</td>';
                                        }
                                    $html .='</tr>';
                                    $i++;
                                }
                            }
                        $html .= '</table>';
                        echo $html;
                    
                }
                exit;
            }
            if($reportview=='Export in PDF'){
                $pdf = new Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
                $pdf->SetFont('helvetica', '', 8);
                $pdf->AddPage();
                $contact_details = $this->contact_model->contact_full_details($catagory_id,$contact_id);
                if(!empty($contact_details)){
                    //$contact_details = $this->unique_multidim_array($contact_details,'name');  
                    $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                        $html .='<tr align="center" style="font-size:10px;font-weight:bold;">';
                                $html .='<th width="470" colspan="5">';
                                $catname_count = array_count_values(array_column($contact_details, 'categoryid'));
                                if(!empty($catname_count)){
                                   foreach ($catname_count as $cckey => $ccvalue) {
                                        $category_details = $this->contact_model->get_category($cckey);
                                        $catname='';
                                        foreach ($category_details as $cdkey => $cdvalue) {
                                            if(count($category_details)>0){
                                              $catname .=strtoupper($cdvalue['name'])." & ";  
                                            }else{
                                                $catname .=strtoupper($cdvalue['name'])." ";  
                                            }
                                            
                                        }
                                        $html .= $catname. "=". $ccvalue."&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;&nbsp;&nbsp;&nbsp;";
                                    }
                                }
                                $html .='</th>';
                                $html .='<th width="70"> TOTAL  : '.count($contact_details).'</th>';
                        $html .='</tr>';
                        $html .='<tr align="center" style="font-size:8px;font-weight:bold;">';
                            $html .='<th width="30">Sr No.</th>';
                            $html .='<th width="150">Name</th>';
                            $html .='<th width="150">Address</th>';
                            $html .='<th width="70">City</th>';
                            $html .='<th width="70">Contact Number</th>';
                            $html .='<th width="70">Category</th>';
                        $html .='</tr>';
                        if(!empty($contact_details)){
                            $i=0;
                            foreach ($contact_details as $contactkey => $contactvalue) {
                                $html .='<tr>';
                                    $html .='<td width="30"  align="center">'.($i+1).'</td>';
                                    $html .='<td width="150" align="left">'.ucwords(strtolower($contactvalue['name'])).'</td>';
                                    $html .='<td width="150"  align="left">'.ucwords(strtolower(nl2br($contactvalue['address']))).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['city'])).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['mobile'])).'</td>';
                                    if($contactvalue['categoryid']!=''){
                                        $html .='<td width="70"  align="left">';
                                        $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                                        foreach ($category_details as $cdkey => $cdvalue) {
                                            $html .=strtoupper($cdvalue['name'])."<br>";
                                        }
                                        $html .='</td>';
                                    }else{
                                        $html .='<td width="70"  align="left">'.ucwords(strtoupper($contactvalue['catname'])).'</td>';
                                    }
                                $html .='</tr>';
                                $i++;
                            }
                        }
                    $html .= '</table>';
                    $pdf->writeHTML($html, true, 0, true, 0);
                }
                $pdf->Output('contact_list.pdf', 'I');  
            }
            if($reportview=='Export in Excel'){
                header("Content-type: application/vnd-ms-excel");
                header("Content-Disposition: attachment; filename=contact_list.xls");
                $contact_details = $this->contact_model->contact_full_details($catagory_id,$contact_id);
                if(!empty($contact_details)){
                    //$contact_details = $this->unique_multidim_array($contact_details,'name');  
                    $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                        $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                $html .='<th width="470" colspan="5">';
                                $catname_count = array_count_values(array_column($contact_details, 'categoryid'));
                                if(!empty($catname_count)){
                                   foreach ($catname_count as $cckey => $ccvalue) {
                                        $category_details = $this->contact_model->get_category($cckey);
                                        $catname='';
                                        foreach ($category_details as $cdkey => $cdvalue) {
                                            if(count($category_details)>0){
                                              $catname .=strtoupper($cdvalue['name'])." & ";  
                                            }else{
                                                $catname .=strtoupper($cdvalue['name'])." ";  
                                            }
                                            
                                        }
                                        $html .= $catname. "=". $ccvalue."&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;&nbsp;&nbsp;&nbsp;";
                                    }
                                }
                                $html .='</th>';
                                $html .='<th width="70"> TOTAL  : '.count($contact_details).'</th>';
                        $html .='</tr>';
                        $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                            $html .='<th width="30">Sr No.</th>';
                            $html .='<th width="150">Name</th>';
                            $html .='<th width="150">Address</th>';
                            $html .='<th width="70">City</th>';
                            $html .='<th width="70">Contact Number</th>';
                            $html .='<th width="70">Category</th>';
                        $html .='</tr>';
                        if(!empty($contact_details)){
                            $i=0;
                            foreach ($contact_details as $contactkey => $contactvalue) {
                                $html .='<tr>';
                                    $html .='<td width="30"  align="center">'.($i+1).'</td>';
                                    $html .='<td width="150" align="left">'.ucwords(strtolower($contactvalue['name'])).'</td>';
                                    $html .='<td width="150"  align="left">'.ucwords(strtolower(nl2br($contactvalue['address']))).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['city'])).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['mobile'])).'</td>';
                                    if($contactvalue['categoryid']!=''){
                                        $html .='<td width="70"  align="left">';
                                        $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                                        foreach ($category_details as $cdkey => $cdvalue) {
                                            $html .=strtoupper($cdvalue['name'])."<br>";
                                        }
                                        $html .='</td>';
                                    }else{
                                        $html .='<td width="70"  align="left">'.ucwords(strtoupper($contactvalue['catname'])).'</td>';
                                    }
                                    
                                $html .='</tr>';
                                $i++;
                            }
                        }
                    $html .= '</table>';
                    echo $html;
                }
                exit;
            }
            if($reportview=='Sticker View'){
                mysql_query ("set character_set_results='utf8'");    
                date_default_timezone_set('Asia/Kolkata');
                // create new PDF document
                $pdf = new Pdf(PDF_PAGE_ORIENTATION, 'mm', 'A4', true, 'UTF-8', false);

                // set document information
                $pdf->SetCreator(PDF_CREATOR);
                $pdf->SetAuthor('Maksud Creators');
                $pdf->SetTitle('Address Labels');
                $pdf->SetSubject('');
                $pdf->SetKeywords('');
                //remove header and footer
                $pdf->setPrintHeader(false);
                $pdf->setPrintFooter(false);
                // set default monospaced font
                $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
                // set margins
                $pdf->setTopMargin(13.0);
                $pdf->SetRightMargin(6.0);
                $pdf->setHeaderMargin(13);
                $pdf->SetFooterMargin(13.0); //13mm
                // set auto page breaks
                $pdf->SetAutoPageBreak(TRUE, 13.0);
                // set image scale factor
                $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
                // set a barcode on the page footer
                //$pdf->setBarcode(date('Y-m-d H:i:s'));
                // set font
                $pdf->SetFont('helvetica', '', 11);
                // add a page
                $pdf->AddPage();
                $pdf->SetFont('helvetica', '', 10);
                // define barcode style
                $style = array(
                        'position' => '',
                        'align' => 'L',
                        'stretch' => false,
                        'fitwidth' => false,
                        'cellfitalign' => '',
                        'border' => false,
                        'hpadding' => 'auto',
                        'vpadding' => 'auto',
                        'fgcolor' => array(0,0,0),
                        'bgcolor' => false, //array(255,255,255),
                        'text' => true,
                        'font' => 'helvetica',
                        'fontsize' => 8,
                        'stretchtext' => 0
                );
                $counter = 1;
                $i=1;

                $contact = $this->contact_model->contact_full_details($catagory_id,$contact_id);

                if(!empty($contact)){
                    foreach ($contact as $contactkey => $row) {

                        $x = $pdf->GetX();
                        $y = $pdf->GetY();
                        $pdf->setCellMargins(0,0,2.5,0);
                        $pdf->SetXY($x,$y);
                        $name = $row['name'];
                        $address = ucwords(strtolower($row['address']));
                        $city = ucfirst(strtolower($row['city']));
                        $mobile = $row['mobile'];
                        $msg = 'To , '.$name."\n".$address."\n".''.$city."\n".'Mo : '.$mobile;
                        $pdf->MultiCell(63.5, 10, $msg, 0, 'L', 0, 0, '', '', true);
                        if($counter == 3)
                        {
                            $pdf->Ln(46.5);
                            $counter = 1;
                        }else{
                            $counter++;
                        }
                        if($i==18)
                        {
                            $pdf->AddPage();
                            $i = 1;
                        }else{
                            $i++;
                        }
                    }
                }
                ob_end_clean();
                $fname = "Address_Labels".time().".pdf";
                $pdf->Output($fname, 'I');
            }
        }
    }
    function invite_report(){
        $event = $this->uri->segment(3);
        $reportview = $this->uri->segment(4);
        ob_clean();
        if($reportview=='ViewReport'){ 
            if($event!=''){
                $grandtotal='0';
                $totaladult='0';
                $totalchild='0';
                $eventid = $event;
               
                $eventwiseview = $this->inviteinevent_model->eventwiseview($eventid);
                $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                    $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                            $html .='<th width="470" colspan="8">';
                            $e_d = $this->event_model->single_event_details($event);
                            $html .=strtoupper($e_d['name'])."&nbsp;&nbsp;";
                            $html .='</th>';
                            
                    $html .='</tr>';
                    $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                        $html .='<th width="55">Sr No.</th>';
                        $html .='<th width="250">Name</th>';
                        $html .='<th width="70">Number</th>';
                        $html .='<th width="70">City</th>';
                        $html .='<th width="70">Category</th>';
                        $html .='<th width="70">Adult</th>';
                        $html .='<th width="70">Child</th>';
                        $html .='<th width="70">Total</th>';
                    $html .='</tr>';
                    if(!empty($eventwiseview)){
                        foreach ($eventwiseview as $ekey => $eventvalue) {
                            $grandtotal =($grandtotal+intval($eventvalue['total']));
                            $totaladult =($totaladult+intval($eventvalue['adult']));
                            $totalchild =($totalchild+intval($eventvalue['child']));
                            $html .='<tr>';
                                $html .='<td width="55"  align="center">'.($ekey+1).'</td>';
                                $html .='<td width="250" align="left">'.ucwords(strtolower($eventvalue['name'])).'</td>';
                                $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['mobile'])).'</td>';
                                $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                               $html .='<td width="70" align="left">';
                                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  width="70" align="right">'.intval($eventvalue['adult']).'</td>';
                                $html .='<td  width="70" align="right">'.intval($eventvalue['child']).'</td>';
                                $html .='<td  width="70" align="right">'.intval($eventvalue['total']).'</td>';
                            $html .='</tr>';
                        }
                    }
                    $html .='<tr>';
                        $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                        $html .='<td width="70" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                        $html .='<td width="70" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                        $html .='<td width="70" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                    $html .='</tr>';
                $html .= '</table>';
                echo $html;
            }else{
                $event = $this->event_model->allevent_details();
                foreach ($event as $eventkey => $eventvalue) {
                   $eventwiseview = $this->inviteinevent_model->eventwiseview($eventvalue['id']);
                   //$eventwiseview = $this->unique_multidim_array($eventwiseview,'address');
                   $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                        $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                $html .='<th width="470" colspan="8">';
                                    $html .=strtoupper($eventvalue['name'])."";
                                $html .='</th>';
                                
                        $html .='</tr>';
                        $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                            $html .='<th width="55">Sr No.</th>';
                            $html .='<th width="250">Name</th>';
                            $html .='<th width="70">Number</th>';
                            $html .='<th width="70">City</th>';
                            $html .='<th width="70">Category</th>';
                            $html .='<th width="70">Adult</th>';
                            $html .='<th width="70">Child</th>';
                            $html .='<th width="70">Total</th>';
                        $html .='</tr>';
                        if(!empty($eventwiseview)){
                            foreach ($eventwiseview as $ekey => $eventvalue) {
                                $grandtotal =($grandtotal+intval($eventvalue['total']));
                                $totaladult =($totaladult+intval($eventvalue['adult']));
                                $totalchild =($totalchild+intval($eventvalue['child']));
                                $html .='<tr>';
                                    $html .='<td width="55"  align="center">'.($ekey+1).'</td>';
                                    $html .='<td width="250" align="left">'.ucwords(strtolower($eventvalue['name'])).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['mobile'])).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                    $html .='<td width="70" align="left">';
                                        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  width="70" align="right">'.intval($eventvalue['adult']).'</td>';
                                    $html .='<td  width="70" align="right">'.intval($eventvalue['child']).'</td>';
                                    $html .='<td  width="70" align="right">'.intval($eventvalue['total']).'</td>';
                                $html .='</tr>';
                            }
                        }
                        $html .='<tr>';
                            $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                            $html .='<td width="70" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                            $html .='<td width="70" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                            $html .='<td width="70" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                        $html .='</tr>';
                   $html .= '</table>';
                   echo $html;
                }
            }
            exit;
        }
        if($reportview=='ExportinExcel'){
            header("Content-type: application/vnd-ms-excel");
            header("Content-Disposition: attachment; filename=invite_list.xls");
            if($event!=''){
                $grandtotal='0';
                $totaladult='0';
                $totalchild='0';
                $eventid = $event;
                $eventwiseview = $this->inviteinevent_model->eventwiseview($eventid);

                $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                    $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                            $html .='<th width="470" colspan="9">';
                            $e_d = $this->event_model->single_event_details($event);
                            $html .=strtoupper($e_d['name'])."&nbsp;&nbsp;";
                            $html .='</th>';
                            
                    $html .='</tr>';
                    $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                        $html .='<th width="55">Sr No.</th>';
                        $html .='<th width="250">Name</th>';
                        $html .='<th width="250">Address</th>';
                        $html .='<th width="70">Number</th>';
                        $html .='<th width="70">City</th>';
                        $html .='<th width="70">Category</th>';
                        $html .='<th width="70">Adult</th>';
                        $html .='<th width="70">Child</th>';
                        $html .='<th width="70">Total</th>';
                    $html .='</tr>';
                    if(!empty($eventwiseview)){
                        foreach ($eventwiseview as $ekey => $eventvalue) {
                            $grandtotal =($grandtotal+intval($eventvalue['total']));
                            $totaladult =($totaladult+intval($eventvalue['adult']));
                            $totalchild =($totalchild+intval($eventvalue['child']));
                            $html .='<tr>';
                                $html .='<td width="55"  align="center">'.($ekey+1).'</td>';
                                $html .='<td width="250" align="left">'.ucwords(strtolower($eventvalue['name'])).'</td>';
                                $html .='<td width="250" align="left">'.$eventvalue['address'].'</td>';
                                $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['mobile'])).'</td>';
                                $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                $html .='<td width="70" align="left">';
                                    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  width="70" align="right">'.intval($eventvalue['adult']).'</td>';
                                $html .='<td  width="70" align="right">'.intval($eventvalue['child']).'</td>';
                                $html .='<td  width="70" align="right">'.intval($eventvalue['total']).'</td>';
                            $html .='</tr>';
                        }
                    }
                    $html .='<tr>';
                        $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                        $html .='<td width="70" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                        $html .='<td width="70" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                        $html .='<td width="70" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                    $html .='</tr>';
                $html .= '</table>';
                echo $html;
            }else{
                $event = $this->event_model->allevent_details();
                foreach ($event as $eventkey => $eventvalue) {
                   $eventwiseview = $this->inviteinevent_model->eventwiseview($eventvalue['id']);
                   $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                        $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                $html .='<th width="470" colspan="9">';
                                    $html .=strtoupper($eventvalue['name'])."";
                                $html .='</th>';
                                
                        $html .='</tr>';
                        $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                            $html .='<th width="55">Sr No.</th>';
                            $html .='<th width="250">Name</th>';
                            $html .='<th width="250">Address</th>';
                            $html .='<th width="70">Number</th>';
                            $html .='<th width="70">City</th>';
                            $html .='<th width="70">Category</th>';
                            $html .='<th width="70">Adult</th>';
                            $html .='<th width="70">Child</th>';
                            $html .='<th width="70">Total</th>';
                        $html .='</tr>';
                        if(!empty($eventwiseview)){
                            foreach ($eventwiseview as $ekey => $eventvalue) {
                                $grandtotal =($grandtotal+intval($eventvalue['total']));
                                $totaladult =($totaladult+intval($eventvalue['adult']));
                                $totalchild =($totalchild+intval($eventvalue['child']));
                                $html .='<tr>';
                                    $html .='<td width="55"  align="center">'.($ekey+1).'</td>';
                                    $html .='<td width="250" align="left">'.ucwords(strtolower($eventvalue['name'])).'</td>';
                                    $html .='<td width="250" align="left">'.ucwords(strtolower($eventvalue['address'])).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['mobile'])).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                    $html .='<td width="70" align="left">';
                                        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  width="70" align="right">'.intval($eventvalue['adult']).'</td>';
                                    $html .='<td  width="70" align="right">'.intval($eventvalue['child']).'</td>';
                                    $html .='<td  width="70" align="right">'.intval($eventvalue['total']).'</td>';
                                $html .='</tr>';
                            }
                        }
                        $html .='<tr>';
                            $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                            $html .='<td width="70" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                            $html .='<td width="70" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                            $html .='<td width="70" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                        $html .='</tr>';
                   $html .= '</table>';
                   echo $html;
                }
            }
            exit;
        }
        if($reportview=='ExportinPDF'){
            $pdf = new Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
            $pdf->SetFont('helvetica', '', 10);
            if($event!=''){
                $pdf->AddPage(); 
                $grandtotal='0';
                $totaladult='0';
                $totalchild='0';
                $eventid = $event;
                $eventwiseview = $this->inviteinevent_model->eventwiseview($eventid);
                
                $html = '<table border="1" cellpadding="3" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                    $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                            $html .='<th colspan="8">';
                            $e_d = $this->event_model->single_event_details($event);
                            $html .=strtoupper($e_d['name'])."&nbsp;&nbsp;";
                            $html .='</th>';
                            
                    $html .='</tr>';
                    $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                        $html .='<th width="30">Sr No.</th>';
                        $html .='<th width="150">Name</th>';
                        $html .='<th width="70">Number</th>';
                        $html .='<th width="70">City</th>';
                        $html .='<th width="100">Category</th>';
                        $html .='<th width="40">Adult</th>';
                        $html .='<th width="40">Child</th>';
                        $html .='<th width="40">Total</th>';
                    $html .='</tr>';
                    if(!empty($eventwiseview)){
                        foreach ($eventwiseview as $ekey => $eventvalue) {
                            $grandtotal =($grandtotal+intval($eventvalue['total']));
                            $totaladult =($totaladult+intval($eventvalue['adult']));
                            $totalchild =($totalchild+intval($eventvalue['child']));
                            $html .='<tr>';
                                $html .='<td width="30"  align="center">'.($ekey+1).'</td>';
                                $html .='<td width="150" align="left">'.ucwords(strtolower(nl2br($eventvalue['name']))).'<br>'.ucwords(strtolower(nl2br($eventvalue['address']))).'</td>';
                                $html .='<td width="70"  align="left">'.ucwords(strtolower(nl2br($eventvalue['mobile']))).'</td>';
                                $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                $html .='<td width="100" align="left">';
                                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  width="40" align="right">'.intval($eventvalue['adult']).'</td>';
                                $html .='<td  width="40" align="right">'.intval($eventvalue['child']).'</td>';
                                $html .='<td  width="40" align="right">'.intval($eventvalue['total']).'</td>';
                            $html .='</tr>';
                        }
                    }
                    $html .='<tr style="font-size:14px;font-weight:bold;">';
                        $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                        $html .='<td width="40" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                        $html .='<td width="40" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                        $html .='<td width="40" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                    $html .='</tr>';
                $html .= '</table>';
                $pdf->writeHTML($html, true, 0, true, 0);
            }else{
                $event = $this->event_model->allevent_details();
                foreach ($event as $eventkey => $eventvalue) {
                   $pdf->AddPage();
                   $grandtotal='0';
                   $totaladult='0';
                   $totalchild='0'; 
                   $eventwiseview = $this->inviteinevent_model->eventwiseview($eventvalue['id']);
                   //$eventwiseview = $this->unique_multidim_array($eventwiseview,'address');
                   $html = '<table border="1" cellpadding="3" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                        $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                $html .='<th colspan="8">';
                                    $html .=strtoupper($eventvalue['name'])."&nbsp;&nbsp;";
                                $html .='</th>';
                                
                        $html .='</tr>';
                        $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                            $html .='<th width="30">Sr No.</th>';
                            $html .='<th width="150">Name</th>';
                            $html .='<th width="70">Number</th>';
                            $html .='<th width="70">City</th>';
                            $html .='<th width="100">Category</th>';
                            $html .='<th width="40">Adult</th>';
                            $html .='<th width="40">Child</th>';
                            $html .='<th width="40">Total</th>';
                        $html .='</tr>';
                        if(!empty($eventwiseview)){
                            foreach ($eventwiseview as $ekey => $eventvalue) {
                                $grandtotal =($grandtotal+intval($eventvalue['total']));
                                $totaladult =($totaladult+intval($eventvalue['adult']));
                                $totalchild =($totalchild+intval($eventvalue['child']));
                                $html .='<tr>';
                                    $html .='<td width="30"  align="center">'.($ekey+1).'</td>';
                                    $html .='<td width="150" align="left">'.ucwords(strtolower(nl2br($eventvalue['name']))).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower(nl2br($eventvalue['mobile']))).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                    $html .='<td width="100" align="left">';
                                        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  width="40" align="right">'.intval($eventvalue['adult']).'</td>';
                                    $html .='<td  width="40" align="right">'.intval($eventvalue['child']).'</td>';
                                    $html .='<td  width="40" align="right">'.intval($eventvalue['total']).'</td>';
                                $html .='</tr>';
                            }
                        }
                        $html .='<tr style="font-size:14px;font-weight:bold;">';
                            $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                            $html .='<td width="40" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                            $html .='<td width="40" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                            $html .='<td width="40" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                        $html .='</tr>';
                    $html .= '</table>';
                    $pdf->writeHTML($html, true, 0, true, 0);
                }
            }
            $pdf->Output('contact_list.pdf', 'I');  
        }
        if($reportview=='StickerView'){
            mysql_query ("set character_set_results='utf8'");    
            date_default_timezone_set('Asia/Kolkata');
            // create new PDF document
            $pdf = new Pdf(PDF_PAGE_ORIENTATION, 'mm', 'A4', true, 'UTF-8', false);

            // set document information
            $pdf->SetCreator(PDF_CREATOR);
            $pdf->SetAuthor('Maksud Creators');
            $pdf->SetTitle('Address Labels');
            $pdf->SetSubject('');
            $pdf->SetKeywords('');
            //remove header and footer
            $pdf->setPrintHeader(false);
            $pdf->setPrintFooter(false);
            // set default monospaced font
            $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
            // set margins
            $pdf->setTopMargin(13.0);
            $pdf->SetRightMargin(6.0);
            $pdf->setHeaderMargin(13);
            $pdf->SetFooterMargin(13.0); //13mm
            // set auto page breaks
            $pdf->SetAutoPageBreak(TRUE, 13.0);
            // set image scale factor
            $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
            // set a barcode on the page footer
            //$pdf->setBarcode(date('Y-m-d H:i:s'));
            // set font
            $pdf->SetFont('helvetica', '', 11);
            // add a page
            $pdf->AddPage();
            $pdf->SetFont('helvetica', '', 10);
            // define barcode style
            $style = array(
                    'position' => '',
                    'align' => 'L',
                    'stretch' => false,
                    'fitwidth' => false,
                    'cellfitalign' => '',
                    'border' => false,
                    'hpadding' => 'auto',
                    'vpadding' => 'auto',
                    'fgcolor' => array(0,0,0),
                    'bgcolor' => false, //array(255,255,255),
                    'text' => true,
                    'font' => 'helvetica',
                    'fontsize' => 8,
                    'stretchtext' => 0
            );
            $counter = 1;
            $i=1;
            if($event!=''){
                $grandtotal='0';
                $totaladult='0';
                $totalchild='0';
                $eventid = $event;
                $eventwiseview = $this->inviteinevent_model->eventwiseview($eventid);
                //$eventwiseview = $this->unique_multidim_array($eventwiseview,'address');
                if(!empty($eventwiseview)){
                    foreach ($eventwiseview as $ekey => $row) {
                        $x = $pdf->GetX();
                        $y = $pdf->GetY();
                        $pdf->setCellMargins(0,0,2.5,0);
                        $pdf->SetXY($x,$y);
                        $name = $row['name'];
                        $address = ucwords(strtolower($row['address']));
                        $city = ucfirst(strtolower($row['city']));
                        $mobile = $row['mobile'];
                        $msg = 'To , '.$name."\n".$address."\n".''.$city."\n".'Mo : '.$mobile;
                        $pdf->MultiCell(63.5, 10, $msg, 0, 'L', 0, 0, '', '', true);
                        if($counter == 3)
                        {
                            $pdf->Ln(46.5);
                            $counter = 1;
                        }else{
                            $counter++;
                        }
                        if($i==18)
                        {
                            $pdf->AddPage();
                            $i = 1;
                        }else{
                            $i++;
                        }
                    }
                }
            }
            ob_end_clean();
            //Close and output PDF document
            $pdf->Output('Address_Labels.pdf', 'I');
        }
    }
    function contact(){
        if($this->input->post()){
            $catagory = $this->input->post('catagory');
            $reportview = $this->input->post('reportview');
            ob_clean();
            if($reportview=='View Report'){
                if(!empty($catagory)){
                    $catagory = $this->input->post('catagory');
                    foreach ($catagory as $catagorykey => $catagoryvalue) {
                        $cat_details = $this->category_model->single_category_details($catagoryvalue);
                        $contact_details = $this->contact_model->contact_details($catagoryvalue);
                        $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                            $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                    $html .='<th width="470" colspan="5">'.strtoupper($cat_details['name']).'</th>';
                                     $html .='<th width="70"> TOTAL  : '.count($contact_details).'</th>';
                            $html .='</tr>';
                            $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                                $html .='<th width="30">Sr No.</th>';
                                $html .='<th width="150">Name</th>';
                                $html .='<th width="150">Address</th>';
                                $html .='<th width="70">City</th>';
                                $html .='<th width="70">Contact Number</th>';
                                $html .='<th width="70">Category</th>';
                            $html .='</tr>';
                            if(!empty($contact_details)){
                                foreach ($contact_details as $contactkey => $contactvalue) {
                                    $html .='<tr>';
                                        $html .='<td width="30"  align="center">'.($contactkey+1).'</td>';
                                        $html .='<td width="150" align="left">'.ucwords(strtolower($contactvalue['name'])).'</td>';
                                        $html .='<td width="150"  align="left">'.ucwords(strtolower(nl2br($contactvalue['address']))).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['city'])).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['mobile'])).'</td>';
                                        $html .='<td width="70"  align="left">';
                                        if($contactvalue['categoryid']!=''){
                                            $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                                            foreach ($category_details as $cdkey => $cdvalue) {
                                                $html .=strtoupper($cdvalue['name'])."<br>";
                                            }
                                        }
                                        $html .='</td>';
                                    $html .='</tr>';
                                }
                            }
                        $html .= '</table>';
                        echo $html;
                    }
                }else{
                    $catagory = $this->category_model->allcategory_details();
                    foreach ($catagory as $catagorykey => $catagoryvalue) {
                       
                        $contact_details = $this->contact_model->contact_details($catagoryvalue['id']);
                        $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                            $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                    $html .='<th width="470" colspan="5">'.strtoupper($catagoryvalue['name']).'</th>';
                                     $html .='<th width="70"> TOTAL  : '.count($contact_details).'</th>';
                            $html .='</tr>';
                            $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                                $html .='<th width="30">Sr No.</th>';
                                $html .='<th width="150">Name</th>';
                                $html .='<th width="150">Address</th>';
                                $html .='<th width="70">City</th>';
                                $html .='<th width="70">Contact Number</th>';
                                $html .='<th width="70">Category</th>';
                            $html .='</tr>';
                            if(!empty($contact_details)){
                                foreach ($contact_details as $contactkey => $contactvalue) {
                                    $html .='<tr>';
                                        $html .='<td width="30"  align="center">'.($contactkey+1).'</td>';
                                        $html .='<td width="150" align="left">'.ucwords(strtolower($contactvalue['name'])).'</td>';
                                        $html .='<td width="150"  align="left">'.ucwords(strtolower(nl2br($contactvalue['address']))).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['city'])).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['mobile'])).'</td>';
                                        $html .='<td width="70"  align="left">';
                                        if($contactvalue['categoryid']!=''){
                                            $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                                            foreach ($category_details as $cdkey => $cdvalue) {
                                                $html .=strtoupper($cdvalue['name'])."<br>";
                                            }
                                        }
                                        $html .='</td>';
                                        
                                    $html .='</tr>';
                                }
                            }
                        $html .= '</table>';
                        echo $html;
                    }
                }
                exit;
            }
            if($reportview=='Export in PDF'){
                $pdf = new Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
                $pdf->SetFont('helvetica', '', 8);
                if(!empty($catagory)){
                    $catagory = $this->input->post('catagory');
                    foreach ($catagory as $catagorykey => $catagoryvalue) {
                        $pdf->AddPage(); 
                        $cat_details = $this->category_model->single_category_details($catagoryvalue);
                        $contact_details = $this->contact_model->contact_details($catagoryvalue);
                        $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                            $html .='<tr align="center" style="font-size:10px;font-weight:bold;">';
                                    $html .='<th width="470" colspan="5">'.strtoupper($cat_details['name']).'</th>';
                                     $html .='<th width="70"> TOTAL  : '.count($contact_details).'</th>';
                            $html .='</tr>';
                            $html .='<tr align="center" style="font-size:8px;font-weight:bold;">';
                                $html .='<th width="30">Sr No.</th>';
                                $html .='<th width="150">Name</th>';
                                $html .='<th width="150">Address</th>';
                                $html .='<th width="70">City</th>';
                                $html .='<th width="70">Contact Number</th>';
                                $html .='<th width="70">Category</th>';
                            $html .='</tr>';
                            if(!empty($contact_details)){
                                foreach ($contact_details as $contactkey => $contactvalue) {
                                    $html .='<tr>';
                                        $html .='<td width="30"  align="center">'.($contactkey+1).'</td>';
                                        $html .='<td width="150" align="left">'.ucwords(strtolower($contactvalue['name'])).'</td>';
                                        $html .='<td width="150"  align="left">'.ucwords(strtolower(nl2br($contactvalue['address']))).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['city'])).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['mobile'])).'</td>';
                                        $html .='<td width="70"  align="left">';
                                        if($contactvalue['categoryid']!=''){
                                            $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                                            foreach ($category_details as $cdkey => $cdvalue) {
                                                $html .=strtoupper($cdvalue['name'])."<br>";
                                            }
                                        }
                                        $html .='</td>';
                                    $html .='</tr>';
                                }
                            }
                        $html .= '</table>';
                        $pdf->writeHTML($html, true, 0, true, 0);
                    }
                }else{
                    $catagory = $this->category_model->allcategory_details();
                    foreach ($catagory as $catagorykey => $catagoryvalue) {
                        $pdf->AddPage(); 
                        $contact_details = $this->contact_model->contact_details($catagoryvalue['id']);
                        $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                            $html .='<tr align="center" style="font-size:10px;font-weight:bold;">';
                                    $html .='<th width="470" colspan="5">'.strtoupper($catagoryvalue['name']).'</th>';
                                     $html .='<th width="70"> TOTAL  : '.count($contact_details).'</th>';
                            $html .='</tr>';
                            $html .='<tr align="center" style="font-size:8px;font-weight:bold;">';
                                $html .='<th width="30">Sr No.</th>';
                                $html .='<th width="150">Name</th>';
                                $html .='<th width="150">Address</th>';
                                $html .='<th width="70">City</th>';
                                $html .='<th width="70">Contact Number</th>';
                                $html .='<th width="70">Category</th>';
                            $html .='</tr>';
                            if(!empty($contact_details)){
                                foreach ($contact_details as $contactkey => $contactvalue) {
                                    $html .='<tr>';
                                        $html .='<td width="30"  align="center">'.($contactkey+1).'</td>';
                                        $html .='<td width="150" align="left">'.ucwords(strtolower($contactvalue['name'])).'</td>';
                                        $html .='<td width="150"  align="left">'.ucwords(strtolower(nl2br($contactvalue['address']))).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['city'])).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['mobile'])).'</td>';
                                        $html .='<td width="70"  align="left">';
                                        if($contactvalue['categoryid']!=''){
                                            $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                                            foreach ($category_details as $cdkey => $cdvalue) {
                                                $html .=strtoupper($cdvalue['name'])."<br>";
                                            }
                                        }
                                        $html .='</td>';
                                    $html .='</tr>';
                                }
                            }
                        $html .= '</table>';
                        $pdf->writeHTML($html, true, 0, true, 0);
                    }
                } 
                $pdf->Output('contact_list.pdf', 'I');  
            }
            if($reportview=='Export in Excel'){
                header("Content-type: application/vnd-ms-excel");
                header("Content-Disposition: attachment; filename=contact_list.xls");
                if(!empty($catagory)){
                    $catagory = $this->input->post('catagory');
                    foreach ($catagory as $catagorykey => $catagoryvalue) {
                        $cat_details = $this->category_model->single_category_details($catagoryvalue);
                        $contact_details = $this->contact_model->contact_details($catagoryvalue);
                        $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                            $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                    $html .='<th width="470" colspan="5">'.strtoupper($cat_details['name']).'</th>';
                                     $html .='<th width="70"> TOTAL  : '.count($contact_details).'</th>';
                            $html .='</tr>';
                            $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                                $html .='<th width="30">Sr No.</th>';
                                $html .='<th width="150">Name</th>';
                                $html .='<th width="150">Address</th>';
                                $html .='<th width="70">City</th>';
                                $html .='<th width="70">Contact Number</th>';
                                $html .='<th width="70">Category</th>';
                            $html .='</tr>';
                            if(!empty($contact_details)){
                                foreach ($contact_details as $contactkey => $contactvalue) {
                                    $html .='<tr>';
                                        $html .='<td width="30"  align="center">'.($contactkey+1).'</td>';
                                        $html .='<td width="150" align="left">'.ucwords(strtolower($contactvalue['name'])).'</td>';
                                        $html .='<td width="150"  align="left">'.ucwords(strtolower(nl2br($contactvalue['address']))).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['city'])).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['mobile'])).'</td>';
                                        $html .='<td width="70"  align="left">';
                                        if($contactvalue['categoryid']!=''){
                                            $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                                            foreach ($category_details as $cdkey => $cdvalue) {
                                                $html .=strtoupper($cdvalue['name'])."<br>";
                                            }
                                        }
                                        $html .='</td>';
                                        
                                    $html .='</tr>';
                                }
                            }
                        $html .= '</table>';
                        echo $html;
                    }
                }else{
                    $catagory = $this->category_model->allcategory_details();
                    foreach ($catagory as $catagorykey => $catagoryvalue) {
                       
                        $contact_details = $this->contact_model->contact_details($catagoryvalue['id']);
                        $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                            $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                    $html .='<th width="470" colspan="5">'.strtoupper($catagoryvalue['name']).'</th>';
                                     $html .='<th width="70"> TOTAL  : '.count($contact_details).'</th>';
                            $html .='</tr>';
                            $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                                $html .='<th width="30">Sr No.</th>';
                                $html .='<th width="150">Name</th>';
                                $html .='<th width="150">Address</th>';
                                $html .='<th width="70">City</th>';
                                $html .='<th width="70">Contact Number</th>';
                                $html .='<th width="70">Category</th>';
                            $html .='</tr>';
                            if(!empty($contact_details)){
                                foreach ($contact_details as $contactkey => $contactvalue) {
                                    $html .='<tr>';
                                        $html .='<td width="30"  align="center">'.($contactkey+1).'</td>';
                                        $html .='<td width="150" align="left">'.ucwords(strtolower($contactvalue['name'])).'</td>';
                                        $html .='<td width="150"  align="left">'.ucwords(strtolower(nl2br($contactvalue['address']))).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['city'])).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($contactvalue['mobile'])).'</td>';
                                        $html .='<td width="70"  align="left">';
                                        if($contactvalue['categoryid']!=''){
                                            $category_details = $this->contact_model->get_category($contactvalue['categoryid']);
                                            foreach ($category_details as $cdkey => $cdvalue) {
                                                $html .=strtoupper($cdvalue['name'])."<br>";
                                            }
                                        }
                                        $html .='</td>';
                                        
                                    $html .='</tr>';
                                }
                            }
                        $html .= '</table>';
                        echo $html;
                    }
                }
                exit;
            }
            if($reportview=='Sticker View'){
                mysql_query ("set character_set_results='utf8'");    
                date_default_timezone_set('Asia/Kolkata');
                // create new PDF document
                $pdf = new Pdf(PDF_PAGE_ORIENTATION, 'mm', 'A4', true, 'UTF-8', false);

                // set document information
                $pdf->SetCreator(PDF_CREATOR);
                $pdf->SetAuthor('Maksud Creators');
                $pdf->SetTitle('Address Labels');
                $pdf->SetSubject('');
                $pdf->SetKeywords('');
                //remove header and footer
                $pdf->setPrintHeader(false);
                $pdf->setPrintFooter(false);
                // set default monospaced font
                $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
                // set margins
                $pdf->setTopMargin(13.0);
                $pdf->SetRightMargin(6.0);
                $pdf->setHeaderMargin(13);
                $pdf->SetFooterMargin(13.0); //13mm
                // set auto page breaks
                $pdf->SetAutoPageBreak(TRUE, 13.0);
                // set image scale factor
                $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
                // set a barcode on the page footer
                //$pdf->setBarcode(date('Y-m-d H:i:s'));
                // set font
                $pdf->SetFont('helvetica', '', 11);
                // add a page
                $pdf->AddPage();
                $pdf->SetFont('helvetica', '', 10);
                // define barcode style
                $style = array(
                        'position' => '',
                        'align' => 'L',
                        'stretch' => false,
                        'fitwidth' => false,
                        'cellfitalign' => '',
                        'border' => false,
                        'hpadding' => 'auto',
                        'vpadding' => 'auto',
                        'fgcolor' => array(0,0,0),
                        'bgcolor' => false, //array(255,255,255),
                        'text' => true,
                        'font' => 'helvetica',
                        'fontsize' => 8,
                        'stretchtext' => 0
                );
                $counter = 1;
                $i=1;
                if(!empty($catagory)){
                    $catagory = $this->input->post('catagory');
                    $cat_details = $this->category_model->single_category_details($catagoryvalue); 
                    foreach ($catagory as $catagorykey => $catagoryvalue) {
                        $contact_details = $this->contact_model->contact_details($catagoryvalue);
                        if(!empty($contact_details)){
                            foreach ($contact_details as $contactkey => $row) {
                                //print_r($row);
                                $x = $pdf->GetX();
                                $y = $pdf->GetY();
                                $pdf->setCellMargins(0,0,2.5,0);
                                // $pdf->Cell(63.5,5, 'To , Maksud Khan', 0, 0, 'L', FALSE, '', 0, FALSE, 'C', 'B');
                                //$pdf->MultiCell(63.5, 0, ' To , Maksud Khan'."\n", 0, 'L', 0, 0, '', '', true);
                                $pdf->SetXY($x,$y);
                                $name = $row['name'];
                                $address = ucwords(strtolower($row['address']));
                                $city = ucfirst(strtolower($row['city']));
                                $mobile = $row['mobile'];
                                $msg = 'To , '.$name."\n".$address."\n".''.$city."\n".'Mo : '.$mobile;
                                $pdf->MultiCell(63.5, 10, $msg, 0, 'L', 0, 0, '', '', true);
                                if($counter == 3)
                                {
                                    $pdf->Ln(46.5);
                                    $counter = 1;
                                }else{
                                    $counter++;
                                }
                                if($i==18)
                                {
                                    $pdf->AddPage();
                                    $i = 1;
                                }else{
                                    $i++;
                                }
                            }
                        }
                    }
                }
                ob_end_clean();
                //Close and output PDF document
                $pdf->Output('Address_Labels.pdf', 'I');
            }
        }
        $this->data['category'] = $this->category_model->allcategory_details();
        $this->data['message'] = $this->session->flashdata('message');
        $this->data['breadcrumb']='Category Details';
        $this->data['tpl_name']= "report_contact_details.tpl";
        $this->smarty->assign('data', $this->data);
        $this->smarty->view('template.tpl');  
    }
    function invite(){
        if($this->input->post()){
            $event = $this->input->post('event');
            $reportview = $this->input->post('reportview');
            ob_clean();
            if($reportview=='View Report'){
                if(!empty($event)){
                    $event = $this->input->post('event');
                    $grandtotal='0';
                    $totaladult='0';
                    $totalchild='0';
                    $eventid = implode(',',$event);
                    $vehicle = $this->input->post('vehicle');
                    $roomdate = $this->input->post('roomdate');
                    $route = $this->input->post('route');
                    $hotel = $this->input->post('hotel');
                    $data['eventid']=$eventid;
                    $data['vehicle']=$vehicle;
                    $data['roomdate']=$roomdate;
                    $data['route']=$route;
                    $data['hotel']=$hotel;
                    $eventwiseview = $this->inviteinevent_model->reportdetailview($data);
                    $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                        $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                $html .='<th width="470" colspan="8">';
                                foreach ($event as $eventkey => $eventvalue) {
                                    $e_d = $this->event_model->single_event_details($eventvalue); 
                                    $html .=strtoupper($e_d['name'])."&nbsp;&nbsp;";
                                }
                                $html .='</th>';
                                $r_d = $this->route_model->single_route_details($route); 
                                $rd=strtoupper($r_d['name']);
                                $h_d = $this->hotel_model->single_hotel_details($hotel); 
                                $hd=strtoupper($h_d['name']);
                                $html .='<th colspan="2">Route : '.$rd.'</th>';
                                $html .='<th colspan="2">Hotel : '.$hd.'</th>';
                        $html .='</tr>';
                        $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                            $html .='<th width="55">Sr No.</th>';
                            $html .='<th width="250">Name</th>';
                            $html .='<th width="70">City</th>';
                            $html .='<th width="70">Number</th>';
                            $html .='<th width="70">Category</th>';
                            $html .='<th width="70">Adult</th>';
                            $html .='<th width="70">Child</th>';
                            $html .='<th width="70">Total</th>';
                            $html .='<th width="70">Vehicle</th>';
                            $html .='<th width="70">Room</th>';
                            $html .='<th width="70">Room Date</th>';
                            $html .='<th width="70">Route</th>';
                        $html .='</tr>';
                        if(!empty($eventwiseview)){
                            foreach ($eventwiseview as $ekey => $eventvalue) {
                                $grandtotal =($grandtotal+intval($eventvalue['total']));
                                $totaladult =($totaladult+intval($eventvalue['adult']));
                                $totalchild =($totalchild+intval($eventvalue['child']));
                                $html .='<tr>';
                                    $html .='<td width="55"  align="center">'.($ekey+1).'</td>';
                                    $html .='<td width="250" align="left">'.ucwords(strtolower($eventvalue['name']))."<br>".ucwords(strtolower(nl2br($eventvalue['address']))).'</td>';
                                    
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['mobile'])).'</td>';
                                   $html .='<td width="70" align="left">';
                                    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  width="70" align="right">'.intval($eventvalue['adult']).'</td>';
                                    $html .='<td  width="70" align="right">'.intval($eventvalue['child']).'</td>';
                                    $html .='<td  width="70" align="right">'.intval($eventvalue['total']).'</td>';
                                    $html .='<td  width="70" align="right">'.ucwords(strtolower($eventvalue['vehicle'])).'</td>';
                                    $html .='<td  width="70" align="right">'.ucwords(strtolower($eventvalue['room'])).'</td>';
                                    if($eventvalue['roomdate']!='0000-00-00'){
                                        $html .='<td width="70" align="right"> '.date('d-m-Y',strtotime($eventvalue['roomdate'])).'</td>';
                                    }else{
                                        $html .='<td></td>';
                                    }
                                    $html .='<td  width="70" align="right">'.ucwords(strtolower($eventvalue['route'])).'</td>';
                                $html .='</tr>';
                            }
                        }
                        $html .='<tr>';
                            $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                            $html .='<td width="70" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                            $html .='<td width="70" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                            $html .='<td width="70" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                            $html .='<td  width="70" align="center">';
                                $vehicleby = array_count_values(array_column($eventwiseview, 'vehicle'));
                                                if(!empty($vehicleby)){
                                                    foreach ($vehicleby as $vehiclebykey => $vehiclebyvalue) {
                                                        $html .=ucwords(strtolower($vehiclebykey)). " = ". $vehiclebyvalue."<br>";
                                                    }
                                                }
                             $html .='</td>';
                             $html .='<td  colspan="3" width="70" align="center"></td>'; 
                        $html .='</tr>';
                    $html .= '</table>';
                    echo $html;
                }else{
                    $event = $this->event_model->allevent_details();
                    foreach ($event as $eventkey => $eventvalue) {
                       $eventwiseview = $this->inviteinevent_model->eventwiseview($eventvalue['id']);
                       $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                            $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                    $html .='<th width="470" colspan="8">';
                                        $html .=strtoupper($eventvalue['name'])."";
                                    $html .='</th>';
                                    
                            $html .='</tr>';
                            $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                                $html .='<th width="55">Sr No.</th>';
                                $html .='<th width="250">Name</th>';
                                $html .='<th width="70">Number</th>';
                                $html .='<th width="70">City</th>';
                                $html .='<th width="70">Category</th>';
                                $html .='<th width="70">Adult</th>';
                                $html .='<th width="70">Child</th>';
                                $html .='<th width="70">Total</th>';
                            $html .='</tr>';
                            if(!empty($eventwiseview)){
                                foreach ($eventwiseview as $ekey => $eventvalue) {
                                    $grandtotal =($grandtotal+intval($eventvalue['total']));
                                    $totaladult =($totaladult+intval($eventvalue['adult']));
                                    $totalchild =($totalchild+intval($eventvalue['child']));
                                    $html .='<tr>';
                                        $html .='<td width="55"  align="center">'.($ekey+1).'</td>';
                                        $html .='<td width="250" align="left">'.ucwords(strtolower($eventvalue['name'])).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['mobile'])).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                        $html .='<td width="70" align="left">';
                                        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  width="70" align="right">'.intval($eventvalue['adult']).'</td>';
                                        $html .='<td  width="70" align="right">'.intval($eventvalue['child']).'</td>';
                                        $html .='<td  width="70" align="right">'.intval($eventvalue['total']).'</td>';
                                    $html .='</tr>';
                                }
                            }
                            $html .='<tr>';
                                $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                                $html .='<td width="70" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                                $html .='<td width="70" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                                $html .='<td width="70" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';

                            $html .='</tr>';
                       $html .= '</table>';
                       echo $html;
                    }
                }
                exit;
            }
            if($reportview=='Export in Excel'){
                header("Content-type: application/vnd-ms-excel");
                header("Content-Disposition: attachment; filename=invite_list.xls");
                if(!empty($event)){
                    $grandtotal='0';
                    $totaladult='0';
                    $totalchild='0';
                    $eventid = implode(',',$event);
                    $vehicle = $this->input->post('vehicle');
                    $roomdate = $this->input->post('roomdate');
                    $route = $this->input->post('route');
                    $data['eventid']=$eventid;
                    $data['vehicle']=$vehicle;
                    $data['roomdate']=$roomdate;
                    $data['route']=$route;
                    $hotel = $this->input->post('hotel');
                    $data['hotel']=$hotel;
                    $eventwiseview = $this->inviteinevent_model->reportdetailview($data);
                    $html = '<table border="1" cellpadding="3" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                        $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                $html .='<th colspan="7">';
                                foreach ($event as $eventkey => $eventvalue) {
                                    $e_d = $this->event_model->single_event_details($eventvalue); 
                                    $html .=strtoupper($e_d['name'])."&nbsp;&nbsp;";
                                }
                                $html .='</th>';
                                $r_d = $this->route_model->single_route_details($route); 
                                $rd=strtoupper($r_d['name']);
                                $html .='<th colspan="2">Route : '.$rd.'</th>';
                                $h_d = $this->hotel_model->single_hotel_details($hotel); 
                                $hd=strtoupper($h_d['name']);
                                $html .='<th colspan="2">Hotel : '.$hd.'</th>';
                        $html .='</tr>';
                        $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                            $html .='<th width="30">Sr No.</th>';
                            $html .='<th width="170">Name</th>';
                            $html .='<th width="70">City</th>';
                            $html .='<th width="70">Number</th>';
                            
                            $html .='<th width="120">Category</th>';
                            $html .='<th width="40">Adult</th>';
                            $html .='<th width="40">Child</th>';
                            $html .='<th width="40">Total</th>';
                            $html .='<th width="65">Vehicle</th>';
                            $html .='<th width="70">Room</th>';
                            $html .='<th width="70">Room Date</th>';
                        $html .='</tr>';
                        if(!empty($eventwiseview)){
                            foreach ($eventwiseview as $ekey => $eventvalue) {
                                $grandtotal =($grandtotal+intval($eventvalue['total']));
                                $totaladult =($totaladult+intval($eventvalue['adult']));
                                $totalchild =($totalchild+intval($eventvalue['child']));
                                $html .='<tr>';
                                    $html .='<td width="30"  align="center">'.($ekey+1).'</td>';
                                    $html .='<td width="170" align="left">'.ucwords(strtolower(nl2br($eventvalue['name'])))."<br>".ucwords(strtolower(nl2br($eventvalue['address']))).'</td>';
                                    
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower(nl2br($eventvalue['mobile']))).'</td>';
                                    $html .='<td width="120" align="left">';
                                    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  width="40" align="right">'.($eventvalue['adult']).'</td>';
                                    $html .='<td  width="40" align="right">'.($eventvalue['child']).'</td>';
                                    $html .='<td  width="40" align="right">'.($eventvalue['total']).'</td>';
                                    $html .='<td  width="65" align="right">'.ucwords(strtolower($eventvalue['vehicle'])).'</td>';
                                    $html .='<td  width="70" align="right">'.ucwords(strtolower($eventvalue['room'])).'</td>';
                                    if($eventvalue['roomdate']!='0000-00-00'){
                                        $html .='<td width="70" align="right"> '.date('d-m-Y',strtotime($eventvalue['roomdate'])).'</td>';
                                    }else{
                                        $html .='<td></td>';
                                    }
                                $html .='</tr>';
                            }
                        }
                        $html .='<tr style="font-size:14px;font-weight:bold;">';
                            $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                            $html .='<td width="40" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                            $html .='<td width="40" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                            $html .='<td width="40" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                            $html .='<td  width="65" align="center">';
                                $vehicleby = array_count_values(array_column($eventwiseview, 'vehicle'));
                                if(!empty($vehicleby)){
                                    foreach ($vehicleby as $vehiclebykey => $vehiclebyvalue) {
                                        $html .=ucwords(strtolower($vehiclebykey)). " = ". $vehiclebyvalue."<br>";
                                    }
                                }
                             $html .='</td>';
                             $html .='<td width="70" align="center"></td>'; 
                             $html .='<td width="70" align="center"></td>'; 
                        $html .='</tr>';

                    $html .= '</table>';
                    echo $html;
                }else{
                    $event = $this->event_model->allevent_details();
                    foreach ($event as $eventkey => $eventvalue) {
                       $eventwiseview = $this->inviteinevent_model->eventwiseview($eventvalue['id']);
                       $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                            $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                    $html .='<th width="470" colspan="8">';
                                        $html .=strtoupper($eventvalue['name'])."";
                                    $html .='</th>';
                                    
                            $html .='</tr>';
                            $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                                $html .='<th width="55">Sr No.</th>';
                                $html .='<th width="250">Name</th>';
                                $html .='<th width="70">City</th>';
                                $html .='<th width="70">Number</th>';
                                $html .='<th width="70">Category</th>';
                                $html .='<th width="70">Adult</th>';
                                $html .='<th width="70">Child</th>';
                                $html .='<th width="70">Total</th>';
                            $html .='</tr>';
                            if(!empty($eventwiseview)){
                                foreach ($eventwiseview as $ekey => $eventvalue) {
                                    $grandtotal =($grandtotal+intval($eventvalue['total']));
                                    $totaladult =($totaladult+intval($eventvalue['adult']));
                                    $totalchild =($totalchild+intval($eventvalue['child']));
                                    $html .='<tr>';
                                        $html .='<td width="55"  align="center">'.($ekey+1).'</td>';
                                        
                                        $html .='<td width="250" align="left">'.ucwords(strtolower(nl2br($eventvalue['name'])))."<br>".ucwords(strtolower(nl2br($eventvalue['address']))).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['mobile'])).'</td>';
                                        
                                        $html .='<td width="70" align="left">';
                                        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  width="70" align="right">'.intval($eventvalue['adult']).'</td>';
                                        $html .='<td  width="70" align="right">'.intval($eventvalue['child']).'</td>';
                                        $html .='<td  width="70" align="right">'.intval($eventvalue['total']).'</td>';
                                    $html .='</tr>';
                                }
                            }
                            $html .='<tr>';
                                $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                                $html .='<td width="70" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                                $html .='<td width="70" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                                $html .='<td width="70" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                            $html .='</tr>';
                       $html .= '</table>';
                       echo $html;
                    }
                }
                exit;
            }
            if($reportview=='Export in PDF'){
                $pdf = new Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

                $pdf->SetFont('helvetica', '', 10);
                if(!empty($event)){
                    $pdf->AddPage('L', ['format' => PDF_PAGE_FORMAT]);
                    $grandtotal='0';
                    $totaladult='0';
                    $totalchild='0';
                    $eventid = implode(',',$event);
                    $vehicle = $this->input->post('vehicle');
                    $roomdate = $this->input->post('roomdate');
                    $route = $this->input->post('route');
                    $data['eventid']=$eventid;
                    $data['vehicle']=$vehicle;
                    $data['roomdate']=$roomdate;
                    $data['route']=$route;
                    $hotel = $this->input->post('hotel');
                    $data['hotel']=$hotel;
                    $eventwiseview = $this->inviteinevent_model->reportdetailview($data);
                    $html = '<table border="1" cellpadding="3" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                        $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                $html .='<th colspan="7">';
                                foreach ($event as $eventkey => $eventvalue) {
                                    $e_d = $this->event_model->single_event_details($eventvalue); 
                                    $html .=strtoupper($e_d['name'])."&nbsp;&nbsp;";
                                }
                                $html .='</th>';
                                $r_d = $this->route_model->single_route_details($route); 
                                $rd=strtoupper($r_d['name']);
                                $html .='<th colspan="2">Route : '.$rd.'</th>';
                                $h_d = $this->hotel_model->single_hotel_details($hotel); 
                                $hd=strtoupper($h_d['name']);
                                $html .='<th colspan="2">Hotel : '.$hd.'</th>';
                        $html .='</tr>';
                        $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                            $html .='<th width="30">Sr No.</th>';
                            $html .='<th width="170">Name</th>';
                            
                            $html .='<th width="70">City</th>';
                            $html .='<th width="70">Number</th>';
                            $html .='<th width="120">Category</th>';
                            $html .='<th width="40">Adult</th>';
                            $html .='<th width="40">Child</th>';
                            $html .='<th width="40">Total</th>';
                            $html .='<th width="65">Vehicle</th>';
                            $html .='<th width="70">Room</th>';
                            $html .='<th width="70">Room Date</th>';
                        $html .='</tr>';
                        if(!empty($eventwiseview)){
                            foreach ($eventwiseview as $ekey => $eventvalue) {
                                $grandtotal =($grandtotal+intval($eventvalue['total']));
                                $totaladult =($totaladult+intval($eventvalue['adult']));
                                $totalchild =($totalchild+intval($eventvalue['child']));
                                $html .='<tr>';
                                    $html .='<td width="30"  align="center">'.($ekey+1).'</td>';
                                   
                                     $html .='<td width="170" align="left">'.ucwords(strtolower(nl2br($eventvalue['name'])))."<br>".ucwords(strtolower(nl2br($eventvalue['address']))).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                    $html .='<td width="70"  align="left">'.ucwords(strtolower(nl2br($eventvalue['mobile']))).'</td>';
                                   
                                    $html .='<td width="120" align="left">';
                                    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  width="40" align="right">'.($eventvalue['adult']).'</td>';
                                    $html .='<td  width="40" align="right">'.($eventvalue['child']).'</td>';
                                    $html .='<td  width="40" align="right">'.($eventvalue['total']).'</td>';
                                    $html .='<td  width="65" align="right">'.ucwords(strtolower($eventvalue['vehicle'])).'</td>';
                                    $html .='<td  width="70" align="right">'.ucwords(strtolower($eventvalue['room'])).'</td>';
                                    if($eventvalue['roomdate']!='0000-00-00'){
                                        $html .='<td width="70" align="right"> '.date('d-m-Y',strtotime($eventvalue['roomdate'])).'</td>';
                                    }else{
                                        $html .='<td></td>';
                                    }
                                $html .='</tr>';
                            }
                        }
                        $html .='<tr style="font-size:14px;font-weight:bold;">';
                            $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                            $html .='<td width="40" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                            $html .='<td width="40" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                            $html .='<td width="40" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                            $html .='<td  width="65" align="center">';
                                $vehicleby = array_count_values(array_column($eventwiseview, 'vehicle'));
                                if(!empty($vehicleby)){
                                    foreach ($vehicleby as $vehiclebykey => $vehiclebyvalue) {
                                        $html .=ucwords(strtolower($vehiclebykey)). " = ". $vehiclebyvalue."<br>";
                                    }
                                }
                             $html .='</td>';
                             $html .='<td  colspan="3" width="70" align="center"></td>'; 
                        $html .='</tr>';

                    $html .= '</table>';
                    $pdf->writeHTML($html, true, 0, true, 0);
                }else{
                    $event = $this->event_model->allevent_details();
                    foreach ($event as $eventkey => $eventvalue) {
                       $pdf->AddPage();
                       $grandtotal='0';
                       $totaladult='0';
                       $totalchild='0'; 
                       $eventwiseview = $this->inviteinevent_model->eventwiseview($eventvalue['id']);
                       $html = '<table border="1" cellpadding="3" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
                            $html .='<tr align="center" style="font-size:14px;font-weight:bold;">';
                                    $html .='<th colspan="8">';
                                        $html .=strtoupper($eventvalue['name'])."&nbsp;&nbsp;";
                                    $html .='</th>';
                                    
                            $html .='</tr>';
                            $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                                $html .='<th width="30">Sr No.</th>';
                                $html .='<th width="150">Name</th>';
                                $html .='<th width="70">Number</th>';
                                $html .='<th width="70">City</th>';
                                $html .='<th width="100">Category</th>';
                                $html .='<th width="40">Adult</th>';
                                $html .='<th width="40">Child</th>';
                                $html .='<th width="40">Total</th>';
                            $html .='</tr>';
                            if(!empty($eventwiseview)){
                                foreach ($eventwiseview as $ekey => $eventvalue) {
                                    $grandtotal =($grandtotal+intval($eventvalue['total']));
                                    $totaladult =($totaladult+intval($eventvalue['adult']));
                                    $totalchild =($totalchild+intval($eventvalue['child']));
                                    $html .='<tr>';
                                        $html .='<td width="30"  align="center">'.($ekey+1).'</td>';
                                        $html .='<td width="150" align="left">'.ucwords(strtolower(nl2br($eventvalue['name']))).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower(nl2br($eventvalue['mobile']))).'</td>';
                                        $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                                       $html .='<td width="100" align="left">';
                                        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  width="40" align="right">'.intval($eventvalue['adult']).'</td>';
                                        $html .='<td  width="40" align="right">'.intval($eventvalue['child']).'</td>';
                                        $html .='<td  width="40" align="right">'.intval($eventvalue['total']).'</td>';
                                    $html .='</tr>';
                                }
                            }
                            $html .='<tr style="font-size:14px;font-weight:bold;">';
                                $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                                $html .='<td width="40" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                                $html .='<td width="40" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                                $html .='<td width="40" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
                            $html .='</tr>';
                        $html .= '</table>';
                        $pdf->writeHTML($html, true, 0, true, 0);
                    }
                }
                $pdf->Output('contact_list.pdf', 'I');  
            }
            if($reportview=='Sticker View'){
                mysql_query ("set character_set_results='utf8'");    
                date_default_timezone_set('Asia/Kolkata');
                // create new PDF document
                $pdf = new Pdf(PDF_PAGE_ORIENTATION, 'mm', 'A4', true, 'UTF-8', false);

                // set document information
                $pdf->SetCreator(PDF_CREATOR);
                $pdf->SetAuthor('Maksud Creators');
                $pdf->SetTitle('Address Labels');
                $pdf->SetSubject('');
                $pdf->SetKeywords('');
                //remove header and footer
                $pdf->setPrintHeader(false);
                $pdf->setPrintFooter(false);
                // set default monospaced font
                $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
                // set margins
                $pdf->setTopMargin(13.0);
                $pdf->SetRightMargin(6.0);
                $pdf->setHeaderMargin(13);
                $pdf->SetFooterMargin(13.0); //13mm
                // set auto page breaks
                $pdf->SetAutoPageBreak(TRUE, 13.0);
                // set image scale factor
                $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
                // set a barcode on the page footer
                //$pdf->setBarcode(date('Y-m-d H:i:s'));
                // set font
                $pdf->SetFont('helvetica', '', 11);
                // add a page
                $pdf->AddPage();
                $pdf->SetFont('helvetica', '', 10);
                // define barcode style
                $style = array(
                        'position' => '',
                        'align' => 'L',
                        'stretch' => false,
                        'fitwidth' => false,
                        'cellfitalign' => '',
                        'border' => false,
                        'hpadding' => 'auto',
                        'vpadding' => 'auto',
                        'fgcolor' => array(0,0,0),
                        'bgcolor' => false, //array(255,255,255),
                        'text' => true,
                        'font' => 'helvetica',
                        'fontsize' => 8,
                        'stretchtext' => 0
                );
                $counter = 1;
                $i=1;
                $event = $this->input->post('event');
                if(!empty($event)){
                    $grandtotal='0';
                    $totaladult='0';
                    $totalchild='0';
                    $eventid = implode(',',$event);
                    $vehicle = $this->input->post('vehicle');
                    $roomdate = $this->input->post('roomdate');
                    $route = $this->input->post('route');
                    $data['eventid']=$eventid;
                    $data['vehicle']=$vehicle;
                    $data['roomdate']=$roomdate;
                    $data['route']=$route;
                    $hotel = $this->input->post('hotel');
                    $data['hotel']=$hotel;
                    $eventwiseview = $this->inviteinevent_model->reportdetailview($data);
                    if(!empty($eventwiseview)){
                        foreach ($eventwiseview as $contactkey => $row) 
                        {
                            //print_r($row);
                            $x = $pdf->GetX();
                            $y = $pdf->GetY();
                            $pdf->setCellMargins(0,0,2.5,0);
                            // $pdf->Cell(63.5,5, 'To , Maksud Khan', 0, 0, 'L', FALSE, '', 0, FALSE, 'C', 'B');
                            //$pdf->MultiCell(63.5, 0, ' To , Maksud Khan'."\n", 0, 'L', 0, 0, '', '', true);
                            $pdf->SetXY($x,$y);
                            $name = $row['name'];
                            $address = ucwords(strtolower($row['address']));
                            $city = ucfirst(strtolower($row['city']));
                            $mobile = $row['mobile'];
                            $msg = 'To , '.$name."\n".$address."\n".''.$city."\n".'Mo : '.$mobile;
                            $pdf->MultiCell(63.5, 10, $msg, 0, 'L', 0, 0, '', '', true);
                            if($counter == 3)
                            {
                                $pdf->Ln(46.5);
                                $counter = 1;
                            }else{
                                $counter++;
                            }
                            if($i==18)
                            {
                                $pdf->AddPage();
                                $i = 1;
                            }else{
                                $i++;
                            }
                        }
                    }
                }
                ob_end_clean();
                //Close and output PDF document
                $pdf->Output('Address_Labels.pdf', 'I');
            }
        }
        $this->data['route'] = $this->route_model->allroute_details();
        $this->data['event'] = $this->event_model->allevent_details();
        $this->data['hotel'] = $this->event_model->allhotel_details();
        $this->data['message'] = $this->session->flashdata('message');
        $this->data['breadcrumb']='Category Details';
        $this->data['tpl_name']= "report_invite_details.tpl";
        $this->smarty->assign('data', $this->data);
        $this->smarty->view('template.tpl');  
    }
    function unique_multidim_array($array, $key) { 
        $temp_array = array(); 
        $i = 0; 
        $key_array = array(); 
        
        foreach($array as $val) { 
            if (!in_array($val[$key], $key_array)) { 
                $key_array[$i] = $val[$key]; 
                $temp_array[$i] = $val; 
            } 
            $i++; 
        } 
        return $temp_array; 
    }   
    // Total Record
    function invite_totalrecord(){
        ob_clean();
        header("Content-type: application/vnd-ms-excel");
        header("Content-Disposition: attachment; filename=invite_list.xls");
        
        $grandtotal='0';
        $totaladult='0';
        $totalchild='0';
        $eventwiseview = $this->inviteinevent_model->invite_totalrecord();
        $html = '<table border="1" cellpadding="4" cellspacing="0" align="center" width="100%" style="font-weight:normal;">';
            $html .='<tr align="center" style="font-size:12px;font-weight:bold;">';
                $html .='<th width="55">Sr No.</th>';
                $html .='<th width="250">Name</th>';
                $html .='<th width="250">Address</th>';
                $html .='<th width="70">Number</th>';
                $html .='<th width="70">City</th>';
                $html .='<th width="70">Category</th>';
                $html .='<th width="70">Adult</th>';
                $html .='<th width="70">Child</th>';
                $html .='<th width="70">Total</th>';
            $html .='</tr>';
            if(!empty($eventwiseview)){
                foreach ($eventwiseview as $ekey => $eventvalue) {
                    $grandtotal =($grandtotal+intval($eventvalue['total']));
                    $totaladult =($totaladult+intval($eventvalue['adult']));
                    $totalchild =($totalchild+intval($eventvalue['child']));
                    $html .='<tr>';
                        $html .='<td width="55"  align="center">'.($ekey+1).'</td>';
                        $html .='<td width="250" align="left">'.ucwords(strtolower($eventvalue['name'])).'</td>';
                        $html .='<td width="250" align="left">'.$eventvalue['address'].'</td>';
                        $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['mobile'])).'</td>';
                        $html .='<td width="70"  align="left">'.ucwords(strtolower($eventvalue['city'])).'</td>';
                        $html .='<td width="70" align="left">';
                            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  width="70" align="right">'.intval($eventvalue['adult']).'</td>';
                        $html .='<td  width="70" align="right">'.intval($eventvalue['child']).'</td>';
                        $html .='<td  width="70" align="right">'.intval($eventvalue['total']).'</td>';
                    $html .='</tr>';
                }
            }
            $html .='<tr>';
                $html .='<td colspan="5" align="right" ><h5><b>Total :</b></h5> </td>';
                $html .='<td width="70" align="right"><h5><b>'.$totaladult.'</b></h5></td>';
                $html .='<td width="70" align="right"><h5><b>'.$totalchild.'</b></h5></td>';
                $html .='<td width="70" align="right"><h5><b>'.$grandtotal.'</b></h5></td>';
            $html .='</tr>';
        $html .= '</table>';
        echo $html;
        
        exit;
        
    }
    function event_allinone(){
        //$event = $this->uri->segment(3);
        $reportview = $this->uri->segment(3);
        $event = $this->event_model->allevent_details(); 
        ob_clean();
        if($reportview=='ViewReport'){ 
            $grandtotal='0';
            $totaladult='0';
            $totalchild='0';
            $passdata = array();
            $datalist ='<table  width="100%" border="1" cellpadding="1" cellspacing="1">
                        <tr align="center" style="background:#7d9748;color: white;font-size: 15px;">';
                            $datalist .='<td align="center" width="10">Sr No.</td>';
                            $datalist .='<td align="center" width="250">Name</td>';
                            $datalist .='<td align="center" width="250">Address</td>';
                            $datalist .='<td align="center" width="100">City</td>';
                            $datalist .='<td align="center" width="50">Number</td>';
                            $datalist .='<td align="center" width="100">Category</td>';
                            $datalist .='<td align="center">';
                                $datalist .='<table width="100%" border="1" align="center">';
                                    $datalist .='<tr>';
                                        $datalist .='<td align="center" width="250">Event</td>';
                                        $datalist .='<td align="center" width="100">Adult</td>';
                                        $datalist .='<td align="center" width="100">Child</td>';
                                        $datalist .='<td align="center" width="100">Vehicle</td>';
                                        $datalist .='<td align="center" width="100">Hotel</td>';
                                        $datalist .='<td align="center" width="100">Room</td>';
                                        $datalist .='<td align="center" width="100">Room Date</td>';
                                    $datalist .='</tr>';
                                $datalist .='</table>';
                            $datalist .='</td>';                       
                            $datalist .='<td align="center">Card</td>';
                        $datalist .='</tr>';
            $record_fetch= $this->inviteinevent_model->allinone_record_fetch($passdata);
            foreach ($record_fetch as $rfkey => $rfvalue) {
                $contactid = $rfvalue["contactid"];
                $datalist .='<tr>';
                    $datalist .='<td id="ch" width="10" align="center"  >';
                        $datalist .=($rfkey+1);
                    $datalist .='</td>';
                    $datalist .='<td>';
                        $datalist .=ucwords($rfvalue['name']);
                    $datalist .='</td>';
                    $datalist .='<td>';
                        $datalist .=ucwords(nl2br($rfvalue["address"]));
                    $datalist .='</td>';
                    $datalist .='<td>';
                        $datalist .=ucwords($rfvalue['city']);
                    $datalist .='</td>';
                    $datalist .='<td width="50">';
                        $datalist .=nl2br($rfvalue['mobile']);
                    $datalist .='</td>';
                    $datalist .='<td align="left" width="100">';
                        if($rfvalue['categoryid']!=''){
                            // 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>';
                    $datalist .='<td id="event" align="left">';
                        $datalist .='<table  width="100%" border="1"  align="center">';
                        $checkevents = $this->inviteinevent_model->allinone_checkevent($contactid);
                        foreach ($checkevents as $eventkey => $checkevent) {
                            $datalist .='<tr align="center" style="border-bottom: 1px solid #e91e63;">';
                                $datalist .='<td width="250">';
                                    $datalist .=ucwords($checkevent['eventname']);
                                $datalist .='</td>';
                                $datalist .='<td width="100" align="center">';
                                    $datalist .=$checkevent['adult'];
                                $datalist .='</td>';
                                $datalist .='<td width="100" align="center">';
                                    $datalist .=$checkevent['child'];
                                $datalist .='</td>';
                                $datalist .='<td id="vhical" width="100" align="center">';
                                    $datalist .=ucwords($checkevent['vehicle']);
                                $datalist .='</td>';
                                $datalist .='<td id="hotel" align="center" width="100">';
                                    $datalist .=$checkevent["hotel"]; 
                                $datalist .='</td>';
                                $datalist .='<td width="100" align="center">';
                                    $datalist .=$checkevent['room'];
                                $datalist .='</td>';
                                $datalist .='<td width="100" align="center" >';
                                    if($checkevent['roomdate']!='0000-00-00'){
                                        $roomdate =date('d-m-Y',strtotime($checkevent['roomdate']));
                                    }else{
                                        $roomdate ='';
                                    }
                                    $datalist .=$roomdate;
                                $datalist .='</td>';
                            $datalist .='<tr>';
                        }
                        $datalist .='</table>';
                    $datalist .='</td>';
                    if(count($checkevents) > 1){
                        $datalist .='<td style="background-color:red;" align="center">';
                            $datalist .=count($checkevents);
                        $datalist .='</td>';
                    }else{
                        $datalist .='<td align="center">';
                            $datalist .=count($checkevents);
                        $datalist .='</td>';
                    }
                $datalist .='</tr>';
                      
            }
            $datalist .= '</table>';
            echo $datalist;
            exit;
        }
        if($reportview=='ExportinExcel'){
            header("Content-type: application/vnd-ms-excel");
            header("Content-Disposition: attachment; filename=All_IN_ONE.xls");
            $grandtotal='0';
            $totaladult='0';
            $totalchild='0';
            $passdata = array();
            $datalist ='<table  width="100%" border="1" cellpadding="1" cellspacing="1">
                        <tr align="center" style="background:#7d9748;color: white;font-size: 15px;">';
                            $datalist .='<td align="center" width="10">Sr No.</td>';
                            $datalist .='<td align="center" width="250">Name</td>';
                            $datalist .='<td align="center" width="250">Address</td>';
                            $datalist .='<td align="center" width="100">City</td>';
                            $datalist .='<td align="center" width="50">Number</td>';
                            $datalist .='<td align="center" width="100">Category</td>';
                            $datalist .='<td align="center">';
                                $datalist .='<table width="100%" border="1" align="center">';
                                    $datalist .='<tr>';
                                        $datalist .='<td align="center" width="250">Event</td>';
                                        $datalist .='<td align="center" width="100">Adult</td>';
                                        $datalist .='<td align="center" width="100">Child</td>';
                                        $datalist .='<td align="center" width="100">Vehicle</td>';
                                        $datalist .='<td align="center" width="100">Hotel</td>';
                                        $datalist .='<td align="center" width="100">Room</td>';
                                        $datalist .='<td align="center" width="100">Room Date</td>';
                                    $datalist .='</tr>';
                                $datalist .='</table>';
                            $datalist .='</td>';                       
                            $datalist .='<td align="center">Card</td>';
                        $datalist .='</tr>';
            $record_fetch= $this->inviteinevent_model->allinone_record_fetch($passdata);
            foreach ($record_fetch as $rfkey => $rfvalue) {
                $contactid = $rfvalue["contactid"];
                $datalist .='<tr>';
                    $datalist .='<td id="ch" width="10" align="center"  >';
                        $datalist .=($rfkey+1);
                    $datalist .='</td>';
                    $datalist .='<td>';
                        $datalist .=ucwords($rfvalue['name']);
                    $datalist .='</td>';
                    $datalist .='<td>';
                        $datalist .=ucwords(nl2br($rfvalue["address"]));
                    $datalist .='</td>';
                    $datalist .='<td>';
                        $datalist .=ucwords($rfvalue['city']);
                    $datalist .='</td>';
                    $datalist .='<td width="50">';
                        $datalist .=nl2br($rfvalue['mobile']);
                    $datalist .='</td>';
                    $datalist .='<td align="left" width="100">';
                        if($rfvalue['categoryid']!=''){
                            // 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>';
                    $datalist .='<td id="event" align="center">';
                        $checkevents = $this->inviteinevent_model->allinone_checkevent($contactid);
                        $datalist .='<table  width="100%" border="1"  align="center">';
                        
                        foreach ($checkevents as $eventkey => $checkevent) {
                            $datalist .='<tr align="center" style="border-bottom: 1px solid #e91e63;">';
                                $datalist .='<td width="250">';
                                    $datalist .=ucwords($checkevent['eventname']);
                                $datalist .='</td>';
                                $datalist .='<td width="100" align="center">';
                                    $datalist .=$checkevent['adult'];
                                $datalist .='</td>';
                                $datalist .='<td width="100" align="center">';
                                    $datalist .=$checkevent['child'];
                                $datalist .='</td>';
                                $datalist .='<td id="vhical" width="100" align="center">';
                                    $datalist .=ucwords($checkevent['vehicle']);
                                $datalist .='</td>';
                                $datalist .='<td id="hotel" align="center" width="100">';
                                    $datalist .=$checkevent["hotel"]; 
                                $datalist .='</td>';
                                $datalist .='<td width="100" align="center">';
                                    $datalist .=$checkevent['room'];
                                $datalist .='</td>';
                                $datalist .='<td width="100" align="center" >';
                                    if($checkevent['roomdate']!='0000-00-00'){
                                        $roomdate =date('d-m-Y',strtotime($checkevent['roomdate']));
                                    }else{
                                        $roomdate ='';
                                    }
                                    $datalist .=$roomdate;
                                $datalist .='</td>';
                            $datalist .='<tr>';
                        }
                        $datalist .='</table>';
                    $datalist .='</td>';
                    if(count($checkevents) > 1){
                        $datalist .='<td style="background-color:red;" align="center">';
                            $datalist .=count($checkevents);
                        $datalist .='</td>';
                    }else{
                        $datalist .='<td align="center">';
                            $datalist .=count($checkevents);
                        $datalist .='</td>';
                    }
                $datalist .='</tr>';
                      
            }
            $datalist .= '</table>';
            echo $datalist;
            exit;
        }
        // if($reportview=='StickerView'){
        //     mysql_query ("set character_set_results='utf8'");    
        //     date_default_timezone_set('Asia/Kolkata');
        //     // create new PDF document
        //     $pdf = new Pdf(PDF_PAGE_ORIENTATION, 'mm', 'A4', true, 'UTF-8', false);

        //     // set document information
        //     $pdf->SetCreator(PDF_CREATOR);
        //     $pdf->SetAuthor('Maksud Creators');
        //     $pdf->SetTitle('Address Labels');
        //     $pdf->SetSubject('');
        //     $pdf->SetKeywords('');
        //     //remove header and footer
        //     $pdf->setPrintHeader(false);
        //     $pdf->setPrintFooter(false);
        //     // set default monospaced font
        //     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        //     // set margins
        //     $pdf->setTopMargin(13.0);
        //     $pdf->SetRightMargin(6.0);
        //     $pdf->setHeaderMargin(13);
        //     $pdf->SetFooterMargin(13.0); //13mm
        //     // set auto page breaks
        //     $pdf->SetAutoPageBreak(TRUE, 13.0);
        //     // set image scale factor
        //     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        //     // set a barcode on the page footer
        //     //$pdf->setBarcode(date('Y-m-d H:i:s'));
        //     // set font
        //     $pdf->SetFont('helvetica', '', 11);
        //     // add a page
        //     $pdf->AddPage();
        //     $pdf->SetFont('helvetica', '', 10);
        //     // define barcode style
        //     $style = array(
        //             'position' => '',
        //             'align' => 'L',
        //             'stretch' => false,
        //             'fitwidth' => false,
        //             'cellfitalign' => '',
        //             'border' => false,
        //             'hpadding' => 'auto',
        //             'vpadding' => 'auto',
        //             'fgcolor' => array(0,0,0),
        //             'bgcolor' => false, //array(255,255,255),
        //             'text' => true,
        //             'font' => 'helvetica',
        //             'fontsize' => 8,
        //             'stretchtext' => 0
        //     );
        //     $counter = 1;
        //     $i=1;
        //     if($event!=''){
        //         $grandtotal='0';
        //         $totaladult='0';
        //         $totalchild='0';
        //         $eventid = $event;
        //         $eventwiseview = $this->inviteinevent_model->eventwiseview($eventid);
        //         //$eventwiseview = $this->unique_multidim_array($eventwiseview,'address');
        //         if(!empty($eventwiseview)){
        //             foreach ($eventwiseview as $ekey => $row) {
        //                 $x = $pdf->GetX();
        //                 $y = $pdf->GetY();
        //                 $pdf->setCellMargins(0,0,2.5,0);
        //                 $pdf->SetXY($x,$y);
        //                 $name = $row['name'];
        //                 $address = ucwords(strtolower($row['address']));
        //                 $city = ucfirst(strtolower($row['city']));
        //                 $mobile = $row['mobile'];
        //                 $msg = 'To , '.$name."\n".$address."\n".''.$city."\n".'Mo : '.$mobile;
        //                 $pdf->MultiCell(63.5, 10, $msg, 0, 'L', 0, 0, '', '', true);
        //                 if($counter == 3)
        //                 {
        //                     $pdf->Ln(46.5);
        //                     $counter = 1;
        //                 }else{
        //                     $counter++;
        //                 }
        //                 if($i==18)
        //                 {
        //                     $pdf->AddPage();
        //                     $i = 1;
        //                 }else{
        //                     $i++;
        //                 }
        //             }
        //         }
        //     }
        //     ob_end_clean();
        //     //Close and output PDF document
        //     $pdf->Output('Address_Labels.pdf', 'I');
        // }
    }
}