<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 str_replace("</br>"," - ",$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);

    	
    	if($count_pro>0){
    		$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')) {
                                	$count_booked=0;
                                	foreach ($cartItems as $c_sbk_key => $c_sbk_value) {
                                		if($c_sbk_value['item_number']==$golbal_product->product->stock_id && $c_sbk_value['location']==$golbal_product->product->loc_code && $c_sbk_value['lot_no']==$info->lot_no){
                                			$count_booked+=$c_sbk_value['quantity'];
                                		}
                                	}
                                }

                                echo $count_booked;
                                    ?></td>
                                <td align="center" style="vertical-align: middle;"><?php
                                echo $info->qty-$count_booked;
                                    ?></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);
                                    echo form_hidden('price', $info->price);
                                    echo form_hidden('description', $golbal_products[0]->product->description);
                                    echo form_hidden('discount', $info->discount_percent);
                                    echo form_hidden('vat_rate', $golbal_products[0]->product->vat_rate);
                                    echo form_hidden('stock_qty', $info->qty);
                                    echo form_hidden('item_size_id', $golbal_products[0]->product->item_size_id);

                                    echo form_hidden('trans_of', "global_sale");
                                    ?>
                                    <?php
                                    if ($info->qty - count($cartItems) > 0) {
                                    	if ($this->session->userdata('cart')) {
                                    		if ($cartItems[1]['location'] == $golbal_product->product->loc_code) {
                                                ?>
                                                <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++;
    	}else{ ?>
    	
    	   <tr style="background-color: #<?php echo $color_code[$color_code_index]?>;">
    	   	 <td  style="vertical-align: middle;"><?php echo $golbal_product->product->location_name; ?></td>
    	     <td colspan="7" align="center" style="vertical-align: middle; color:#FF0000; font-weight:bold;">There is no stock available</td>
    		</tr>
    	
    		
<?php     	
    	}
    }
                ?>
</table>
