<?php



/* 

 * Author       : Jai K

 * Purpose      : View for Print Format 5 (Archanai purposes)

 * Created On   : 2016-09-23 12:14

 */

//echo "<pre>";print_r($data);die;



$items      = $data['items'];

$is_tamil   = $data['is_tamil'];

$with_god   = $items[0]['god_name'] == "1" ? TRUE : FALSE;

$with_name  = $items[0]['receipt'] == "1" ? TRUE : FALSE;

$with_footer= $items[0]['is_enable_footer'] == "1" ? TRUE : FALSE;

$amount     = $items[0]['total_price'];

$gst_lbl    = $gst > 0 ? '<span style="font-size: 10px; font-weight: normal; padding-right: 5px;">(Inclusive of GST)</span>' : '';

//echo "<br> Footer: ".$with_footer;die;

$box2  = array();

$names = !empty( $items[0]['with_names'] ) ? $items[0]['with_names'] : $data['name'];



if( $is_group ) :

    // Multiple

    $box1 = $items[0]['cat'];

   

else :

    // Single

    $item = $items[0];

   

    if( $with_god ) :

        $box1 = $item;

        $items = $item['gods'];

    else :

        $box1 = $item;

        $items = array();

    endif;

    

    if( $box1['cat']['grouping'] == "1" && $is_category == 1) :

        // Category is grouping, But Separate Receipt is checked

        $box2 = $item;

        $box1 = $item['cat'];

    endif;

    

endif;



	if($data['items'][0]['cat']['category_name'] == "Fruit Archanai"){ 		

		$style = 'background: #e3e3e3; color: #000;'; 

	}else{ 

		$style = 'background: #333; color: #fff;'; 

	}

	

    if( !$incl_footer ) :

        

        $bg = '';//$is_group ? 'background: #666;' : '';

?>

        <?php #if($is_category == 1) {?>

        <tr>

            <td colspan="4">

                <div style="border: 1px dashed #000; border-radius: 10px; padding: 10px; min-height: 40px; <?php echo empty( $box1['cat']) ? $style : 'background: #fff; color: #000;' ?>" >

                    <?php if( file_exists( $box1['image'] ) ) : ?>

                        <div style="width: 30%; display: inline-block; text-align: center; float: left;">

                            <img style="width: 60px; height: 40px;" src="<?php echo BASE_URL.$box1['image']; ?>" />

                        </div>

                    

                        <div style="width: 60%; display: inline-block; text-align: center;">

                    <?php else : ?>

                        <div style="width: 100%; display: inline-block; text-align: center;">

                    <?php endif; ?>

                            <div style="font-family: amudham; border: none; text-align: center; width: 100%; font-weight: bolder; font-size: 22px;"><?php echo $box1['tamil_name']; ?></div>

                            <div style="font-size: 16px;"><?php echo $box1['name']; ?></div>

                            <?php if( ($data['items'][0]['cat']['category_name'] != "Fruit Archanai") && ($data['items'][0]['cat']['category_name'] != "Coconut Archanai")){ ?>

                                <div style="font-size: 16px;">S$<?php echo $data['items'][0]['price']; ?></div>

                            <?php } ?>

                        </div>

                </div>

                

            	

            </td>

        </tr>

        

        <?php 

            if( !empty( $box2 ) ) :

            ?>

            <tr>

                <td colspan="4">

                    <div style="border: 1px dashed #000; border-radius: 10px; padding: 10px; min-height: 40px;">



                        <?php if( file_exists( $box2['image'] ) ) : ?>

                            <div style="width: 30%; display: inline-block; text-align: center; float: left;">

                                <img style="width: 60px; height: 40px;" src="<?php echo BASE_URL.$box2['image']; ?>" />

                            </div>

                        

                            <div style="width: 65%; display: inline-block; text-align: center; float: left;">

                        <?php else : ?>

                            <div style="width: 100%; display: inline-block; text-align: center; float: left;">

                        <?php endif; ?>

                        

                                <div style="font-family: amudham; border: none; text-align: center; width: 100%; font-weight: bolder; font-size: 22px;"><?php echo $box2['tamil_name']; ?></div>

                                <div style="font-size: 16px;"><?php echo $box2['name']; ?></div>

                            </div>

                        

                    </div>

                </td>

                

                

            </tr>

        <?php

            endif; // Box 2

            

            if( !empty( $items ) ) :

                foreach( $items as $k => $item ) :

                    /*if( empty($item['name']) ) :

                        continue;

                    endif;*/

                ?>

                    <tr>

                        <td style="font-size: 16px;" <?php if( $with_god ) { ?> colspan="2" <?php } ?>><?php echo $item['name']; ?></td>

						<?php if( !$with_god ) { ?><td style="font-size: 16px;"><?php echo $item['price']; ?></td><?php } ?>

                        <td style="font-weight:bold; font-size:20px;" valign="bottom" align="right"><?php echo $item['qty']; ?></td>

                    </tr>

                    <tr>

                        <td colspan="3" style="border-bottom:1px dotted #000; font-size: 16px;"><?php echo tamil( $item['tamil_name'], 'border: none; font-weight: bolder; font-size: 22px; width: 100%;' ); ?></td>

                    </tr>

                    <tr height="3"></tr>    

                <?php 

                endforeach; 

            endif;

        ?>

            

        <tr height="10"></tr>    

        <?php

            if( $with_name ) :

        ?>

            <tr>

                    <td  colspan="4">

                        <div style="float: left; width: 95px; ">பெயர் / Name</div>

                        

                        <div style="text-align: right; float: right;">நட்சத்திரம் / Star</div>

                    </td>    

            </tr>

            <tr height="5"></tr>

        <?php 

            foreach( $names as $k => $name ) :

            ?>

                <tr>

                    <td colspan="4" style="font-size: 16px;"><?php echo $is_tamil || substr($name[0], 0, 3) == 'TAM' ? tamil( substr( $name[0], 3 ) ) : substr( $name[0], 3 ); ?></td>

                </tr>

                <tr>

                    <td colspan="4" style="border-bottom:2px dotted #000; font-size: 14px;"><?php echo $name[1]; ?></td>

                </tr>

                <tr height="5"></tr>

            <?php

            endforeach;

        endif; ?>

        

        <tr>

        	<td colspan="2" style="font-size:16px; border-bottom:1px dashed #000;" align="left"><?php echo "Qty: ".$total_qty; ?></td>

        	<td colspan="2" style="font-weight:bold; font-size:16px; border-bottom:1px dashed #000;" align="right"><?php echo 'S$'. number_format( $amount, 2 )."<br>".$gst_lbl; ?></td>

        </tr>

        

    </table>

    <?php

        if( strlen($data['rec_msg'] ) > 3 ) :

            $rec_msg = substr( $data['rec_msg'], 3);

            ?>

            <div style="width: 100%; margin: 5px 0px; min-height: 10px; text-align: center;">

                <div style="padding: 10px; border-bottom: 1px solid #999; <?php echo substr($data['rec_msg'], 0, 3) == "TAM" ? 'font-family: amudham; font-weight: bold; letter-spacing: 1px; font-size: 14px;' : ''; ?>" ><?php echo $rec_msg; ?></div>

            </div>

            <?php

        endif;

    ?>

    

    <table width="247" border="0" style="font-family:Verdana; font-size:12px;">

        

        <?php 

            else : 

                // With Footer

            ?>

                

            <tr>

                <td colspan="2">

                    <table border="0" width="100%" style="border-collapse:collapse;">

                        <tr>

                            <td align="left" valign="top" style="width:10px; border:none; display:block; padding:0; margin:0;"><img src="<?php echo BASE_URL; ?>assets/billing/images/lft_top_stroke.jpg" /></td>

                            <td style="width:260px; border-top:2px solid #000;"></td>

                            <td align="left" style="width:10px; border:none; display:block; padding:0; margin:0;"><img src="<?php echo BASE_URL; ?>assets/billing/images/rt_top_stroke.jpg" /></td>

                        </tr>

                            <tr>

                            <td style="border-left:2px solid #000;">&nbsp;</td>

                            <td align="center" style="color:#000;">அர்ச்சனை முடிந்ததும் இப்பகுதியை அர்ச்சகரிடம் காட்டி உங்கள் காளாஞிசியைப் பெற்றுக்கொள்ளவும்</td>

                            <td style="border-right:2px solid #000;">&nbsp;</td>

                        </tr>

                        <tr>

                            <td height="3" colspan="3" style="border-left:2px solid #000; border-right:2px solid #000;"></td>

                        </tr>

                        <tr>

                            <td style="border-left:2px solid #000;">&nbsp;</td>

                            <td align="center"style="color:#000;">Please retain this portion to collect Archana</td>

                            <td style="border-right:2px solid #000;">&nbsp;</td>

                        </tr>

                        <tr>

                            <td align="left" style="width:10px; border:none; display:block; padding:0; margin:0;"><img src="<?php echo BASE_URL; ?>assets/billing/images/lft_bt_stroke.jpg" /></td>

                            <td style="border-bottom:2px solid #000;"></td>

                            <td align="left" style="width:10px; border:none; display:block; padding:0; margin:0;"><img src="<?php echo BASE_URL; ?>assets/billing/images/rt_bt_stroke.jpg" /></td>

                            </tr>

                    </table>

                </td>

            </tr>

            <tr height="3"></tr>

            <tr>

                    <td colspan="2" style="font-weight:bold; font-size:16px;" align="center"><?php echo $gst_lbl . ' S$' .(is_array( $amount ) ? number_format( $amount[0], 2 ) : number_format( $amount, 2 )); ?></td>

            </tr>

        <?php 

       		endif;

        ?>