<style>
    #suspended_sales_table th {
        background: #555;
        padding: 5px;
        color: #fff;
    }
    #suspended_sales_table tr td, #suspended_sales_table tr th{
        border: solid #CCC 1px;
    }
    input[type='submit']:hover{
        cursor: pointer;
    }
    .custom-td{
        padding: 0 !important;
    }
    #product-lot{
        padding: 0 !important;
        margin: 0 !important;
        table-layout: fixed;
    }
    #product-lot td{
        padding: 0 !important;
        margin: 0 !important;
    }
</style>

<strong><?php echo $this->lang->line('golbal_item_code'); ?></strong> : <?php echo $golbal_products[0]->product->stock_id; ?><br>
<strong><?php echo $this->lang->line('golbal_item_name'); ?></strong> : <?php echo $golbal_products[0]->product->description; ?>
<table id="suspended_sales_table" width="100%" border="1">
    <tr>
        <th style="width: 100px; background-color: #008148;"><?php echo $this->lang->line('golbal_item_location'); ?></th>
        <th style="width: 120px; background-color: #008148;"><?php echo $this->lang->line('golbal_lot_no'); ?></th>
        <th style="width: 60px; background-color: #008148;"><?php echo $this->lang->line('golbal_item_quantity'); ?></th>
        <th style="width: 60px; background-color: #008148;"><?php echo $this->lang->line('golbal_price'); ?></th>
        <th style="width: 50px; background-color: #008148;"><?php echo $this->lang->line('golbal_item_booked_quantity'); ?></th>
        <th style="width: 40px; background-color: #008148;"><?php echo $this->lang->line('golbal_item_avl_quantity'); ?></th>
        <th style="width: 50px; background-color: #008148;"><?php echo $this->lang->line('golbal_item_action'); ?></th>
    </tr>
    <?php
    $cartItems = $this->session->userdata('cart');
    
    $color_count=1;
    
    $color_code[0]="BBBBBB";
    $color_code[1]="DEDEDE";
    
    foreach ($golbal_products as $golbal_product) {

    	
    	$start_new=1;

    	$count_pro=count($golbal_product->productinfo);

    	$color_code_index=$color_count%2;
    	foreach ($golbal_product->productinfo as $info) {
    		$info->qty = !empty($info->qty) ? $info->qty : 0;
                            ?>
                            <tr style="background-color: #<?php echo $color_code[$color_code_index]?>;">
                             
            					<?php if($start_new==1){?>
                                <td rowspan="<?php echo $count_pro; ?>" style="vertical-align: middle;"><?php echo $golbal_product->product->location_name; ?></td>
            					<?php }?>
            					
                                <td align="center" style="vertical-align: middle;"><?php echo $info->lot_no ?></td>
                                <td align="center" style="vertical-align: middle;"><?php echo $info->qty; ?></td>
                                <td align="center" style="vertical-align: middle;"><?php echo number_format($info->price, 2, '.', ''); ?></td>
                                <td align="center" style="vertical-align: middle;"><?php
                                if ($this->session->userdata('cart')) {
                                	if ($cartItems[1]['item_number'] == $golbal_product->product->stock_id) {
                                		if ($cartItems[1]['location'] == $golbal_product->product->location_name) {
                                			echo count($cartItems);
                                		}
                                	}
                                } else {
                                	echo 0;
                                }
                                    ?></td>
                                <td align="center" style="vertical-align: middle;"><?php
                                if ($this->session->userdata('cart')) {
                                	if ($cartItems[1]['item_number'] == $golbal_product->product->stock_id) {
                                		if ($cartItems[1]['location'] == $golbal_product->product->location_name) {
                                			echo $info->qty - count($cartItems);
                                		} else {
                                			echo $info->qty;
                                		}
                                	} else {
                                		echo $info->qty;
                                	}
                                } else {
                                	echo $info->qty;
                                }
                                    ?></td>
                                <td align="center" style="vertical-align: middle;">
                                    <?php
                                    echo form_open('sales/globalsale');
                                    echo form_hidden('location_name', $golbal_product->product->location_name);
                                    echo form_hidden('item_id', $golbal_product->product->item_id);
                                    echo form_hidden('loc_code', $golbal_product->product->loc_code);
                                    echo form_hidden('lot_no', $info->lot_no);
                                    ?>
                                    <?php
                                    if ($info->qty - count($cartItems) > 0) {
                                    	if ($this->session->userdata('cart')) {
                                    		if ($cartItems[1]['location'] == $golbal_product->product->location_name) {
                                                ?>
                                                <input type="submit" name="submit" value="<?php echo $this->lang->line('global_add'); ?>" id="submit" class="submit_button float_right">
                                                <?php
                                    		}
                                    	} else {
                                            ?>
                                            <input type="submit" name="submit" value="<?php echo $this->lang->line('global_add'); ?>" id="submit" class="submit_button float_right">
                                            <?php
                                    	}
                                    }
                                    echo form_close()
                                    ?>
                                </td>
                              </tr>
                        <?php  
                        $start_new=0;
    	}
    	$color_count++;
    }
                ?>
</table>
