<!---- 
Author 	: Ladur / Tanggal : 12-08-2014	
Revisi 	: Ferry / Tanggal : 17-02-2015
Revisi 	: Fachri / Tanggal : 26-05-2015
-->

<?php
//---------Untuk privellege jika dia ada tombol save----------
	if($group_user->SavePrivillage == 1){
		$cek_autority_save  = "";
	}
	else{
		$cek_autority_save 	= "disabled";
	}
//-------------end----------------------------

if($this->session->userdata('jobtitle_status')==3){
	$SalesmanCode = $this->session->userdata('username');
}
else{
	$SalesmanCode = '';
}
?>
<div class="easyui-layout" data-options="fit:true,border:false">
    <!-- Top View-->
    <div id="form-header" data-options="region:'north',border:false" >
        <div id="form-header-wrapper">
            <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td align="left" valign="middle">
                    <a href="#" class="easyui-linkbutton" iconCls="icon-document" plain="true" onclick="parent.tab_add('New Sales Quotation', '<?=$menu_link?>', 'icon-add', 'add')">New</a>
                	<a href="#" class="easyui-linkbutton" id="refresh-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="location.reload()">Refresh</a>
                </td>							
                <td align="right">								
                    <span class="form-title"><?=$menu_label?></span>
                </td>
            </tr>
            </table>		     	
        </div>			
    </div>
    <!-- End of Top View -->	

    <!-- Center View -->
    <div id="form-body" data-options="region:'center',border:false">
        <div id="form-wrapper" class="easyui-panel" style="padding:5px;" fit="true">
            <form id="frm_sales_quotation" name="frm_sales_quotation" method="post">
				<input type="hidden" name="detail" id="detail" />
                
            	<!-- Form Header -->
                <table width="100%" height="140" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="50%" valign="top">
                        <table width="100%" cellpadding="0" cellspacing="1">
                        <tr height="26">
                            <td width="135"><b>Customer</b></td>
                            <td width="10"><b>:</b></td>
                            <td colspan="5">
                                <select class="combo-grid" id="cmb_customer" 
                                    name="cmb_customer" required 
                                    style="width:320px;height:20px;" 
                                    data-options="
                                        panelWidth: 320, 
                                        idField: 'CustomerCode',
                                        textField: 'CustomerName',
                                        url: '<?php echo base_url(); ?>custom/get_data/customer_with_rate',
                                        method: 'get',
                                        columns: [[
                                        {field:'CustomerCode',title:'Customer Code',width:110,halign:'center'},
                                        {field:'CustomerName',title:'Customer Name',width:190,halign:'center'}
                                        ]],
                                        fitColumns: true
                                    ">
                                </select>
                            </td>
                        </tr>
                        <tr height="20">
                            <td><b>Billing Address</b></td>
                            <td width="10"><b>:</b></td>
                            <td>&nbsp;</td>
                            <td width="120"><b>Shipping Address</b></td>
                            <td width="10"><b>:</b></td>
                            <td>&nbsp;</td>
                            <td width="114" rowspan="2">&nbsp;</td>
                        </tr>
                        <tr height="20">
                            <td colspan="3">
                                <textarea name="txa_address" id="txa_address" rows="4" style="width:225px;resize:none;" readonly></textarea>
                            </td>
                            <td colspan="3">
                                <textarea name="txa_ship_to" id="txa_ship_to" rows="4" style="width:225px;resize:none;"></textarea>
                            </td>
                        </tr>
                        </table>
                    </td>
                    <td width="50%" valign="top">
                        <table width="100%" cellpadding="0" cellspacing="1" style="margin-top:4px;">
                        <tr height="20">
                            <td rowspan="7" valign="top">&nbsp;</td>
                            <td width="121">&nbsp;</td>
                            <td width="190" style="background:#333399;text-align:center;color:#FFF;">Salesman</td>
                            <td width="122" style="background:#333399;text-align:center;color:#FFF;">SQuo. Date</td>
                        </tr>
                        <tr height="20">
                            <td>&nbsp;</td>
                            <td>
                            	<select colspan="2" class="combo-grid"
                                    id="cmb_salesman" name="cmb_salesman" 
                                    required <?=($SalesmanCode=='')?'':'readonly'?>
                                    style="width:243px; height:20px;" 
                                    data-options="
                                    	value:'<?=$SalesmanCode?>',
                                        panelWidth: 243,
                                        idField: 'EmployeeCode',
                                        textField: 'EmployeeName',
                                        url: '<?php echo base_url(); ?>custom/get_data/sales',
                                        method: 'get',
                                        columns: [[
                                        {field:'EmployeeCode',title:'Employee Code',width:120,halign:'center'},
                                        {field:'EmployeeName',title:'Employee Name',width:150,halign:'center'}
                                        ]],
                                        fitColumns: true
                                    ">
                                </select>
                            </td>
                            <td><input name="txt_sq_date" id="txt_sq_date" type="text" class="easyui-datebox validBackward" value='<?=$sq_date?>' style="width:122px;height:20px" required editable="false" /></td>
                        </tr>
                        <tr height="20">
                        	<td>&nbsp;</td>
                            <td style="background:#333399;text-align:center;color:#FFF;">Cust. POrd. No.</td>
                            <td style="background:#333399;text-align:center;color:#FFF;">Cust. POrd. Date</td>
                        </tr>
                        <tr height="20">
                            <td>&nbsp;</td>
                            <td><input type="text" name="txt_po_no" id="txt_po_no" class="easyui-validatebox textbox" style="width:243px;height:18px;text-align:center;" required  /></td>
                            <td><input name="txt_po_date" id="txt_po_date" type="text" class="easyui-datebox" style="width:122px;height:20px" required editable="false" /></td>
                        </tr>
                        </table>
                    </td>
                </tr>
                </table>
                <!-- End of form header -->
		
                <!--Datagrid-->
                <div class="easyui-tabs" data-options="tabHeight:18" style="margin:5px 0px;">
                    <div id="tab_general" title="Items">
                        <table id="dtg_item" class="easyui-edatagrid"
                            toolbar="#toolbar" idField="id" 
                            rownumbers="true" fitColumns="true" 
                            singleSelect="true" style="height:250px;"
                        >
                            <thead>
                            <tr>
                                <th field="ItemCode" 	 		width="50"  data-options="align:'left',halign:'center'"  	editor="{type:'item_inventory',options:{required:true}}">Item Code</th>
                                <th field="ItemDesc" 	 		width="200" data-options="align:'left',halign:'center'"   	editor="description" >Description</th>
                                <th field="ItemQty" 	 		width="20"  data-options="align:'center',halign:'center'" 	editor="{type:'numberbox',options:{precision:2,decimalSeparator:',',groupSeparator:'.',min:0.01,required:true}}" formatter="formatRp" >Qty</th>
                                <th field="ItemUnit" 	 		width="20"  data-options="align:'center',halign:'center'" 	editor="unit">Unit</th>
                                <th field="RequiredDate" 		width="30"  data-options="align:'center',halign:'center'" 	editor="{type:'datebox',options:{required:true,editable:false}}">Required Date</th>
                                <th field="Item_CategoryID" 	width="50"  data-options="align:'left',halign:'center'" 	editor="{type:'item_category',options:{readonly:true}}" hidden>Item Category</th>
                                <th field="ItemCategoryCode" 	width="50"  data-options="align:'left',halign:'center'" 	editor="{type:'category_code',options:{readonly:true}}" hidden>Item Category Code</th>
                                <th field="ItemStatus"       	width="30"  data-options="align:'left',halign:'center'" 	editor="{type:'item_status',options:{readonly:true}}" hidden>Item Status</th>
                            </tr>
                            </thead>
                        </table>

                        <div id="toolbar">
                            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add_row();">New</a>
                            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="remove_row();">Delete</a>						
                        </div>
                    </div>					
                </div>

                <div>
                    <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="33%" valign="top">
                            <table width="100%" cellpadding="0" cellspacing="1">
                            <tr>
                                <td width="120" valign="top" style="padding-top:4px;"><b>Description</b></td>
                                <td width="10" valign="top" style="padding-top:4px;"><b>:</b></td>
                                <td>
                                    <textarea id="txa_description" name="txa_description" rows="4" style="width:323px;resize:none;"></textarea>
                                </td>
                            </tr>
                            </table>
                        </td>
                        <td width="13%" valign="top">
                        	<input type="hidden" name="sub_total" id="sub_total" value="0"/>
                            <input type="hidden" name="txt_currency_code" id="txt_currency_code" />
                            <input type="hidden" name="txt_rate" id="txt_rate" />
                        </td>
                    </tr>
                    </table>
                </div>	
			</form>		
        </div>
    </div>
	
    <div id="form-footer" data-options="region:'south',border:false">
    	<table width="100%" cellpadding="0" cellspacing="0">
        <tr>
        	<td>&nbsp;</td>
            <td align="right">
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-document" onclick="show_legend();" plain="true">Legend</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-help" onclick="" plain="true">Help</a>
                <a id="save_button" href="javascript:void(0)" class="easyui-linkbutton form-button save-button" iconCls="icon-save" onclick="insert_data();" <?php echo $cek_autority_save;?>>Save</a> 								
                <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-cancel" onclick="parent.tab_close('tt')">Close</a>	
    		</td>
         </tr>
         </table>
    </div>	
</div>


<!-- Dialog Inventory -->
 <div id="dialog-inventory-sq" class="easyui-dialog" 
    style="width:850px;height:523px;top:27px;background-color:#F8F8F8;padding:0px;" 
    closed="true" data-options="modal:true, iconCls:'icon-save'"  buttons="#dialog-buttons-inventory-sq" 
>
	<div id="tab_purchase_req" class="easyui-tabs" style="width:835px;height:485px; background-color:#F8F8F8;" data-options="fit:true,plain:true">
        <div title="Item" style="padding:10px" >
            <table width="100%">
            	<tr>
                <td width="310"><b>Item Category</b></td>
                <td><b>:</b></td>

                <td>
                    <select name="cmb_ItemCategoryID" id="cmb_ItemCategoryID" class="easyui-combobox" style="width:512px;" editable="true" 
                            data-options="
                            valueField:'ItemCategoryID',
                            textField:'ItemCategoryName',
                            url:'<?php echo base_url(); ?>custom/get_data/itemcategory_no_asset',
                            onSelect: function(rec){
                                var id = rec.ItemCategoryID;
                                search_all_item();
                            }
                        ">
                    </select>
                </td>
            </tr>

            <tr>
                <td><b><span class="header_code">Item Code</span></b></td>
                <td><b>:</b></td>
                
                <td>
                    <input type="text" style="width:510px;height:20px" name="txt_ItemCode" id="txt_ItemCode" class="easyui-validatebox" onkeyup="search_all_item();" />
                </td>
            </tr>
            
            <tr>
                <td><b><span class="header_name">Item Name</span></b></td>
                <td><b>:</b></td>
                
                <td>
                    <input type="text" style="width:510px;height:20px" name="txt_ItemDesc" id="txt_ItemDesc" class="easyui-validatebox" onkeyup="search_all_item();" />
                </td>
            </tr>
            </table>
            <table id="grid_pop_up" class="easyui-datagrid" singleSelect="true" remoteSort="false" pagesize="150" fitColumns="true" style="width:812px;height:313px" 
                data-options = "border:true,view:scrollview,autoRowheight:false"
                url="<?=base_url()?>custom/get_data/search_all_item"                    
            >                        
                <thead>
                    <tr>
                        <th field="ItemCode"        	width="293" sortable="true" halign='center'><span class="header_code">Item Code</span></th>
                        <th field="ItemDesc"        	width="430" sortable="true" halign='center'><span class="header_name">Item Name</span></th>
                        <th field="ItemCategoryName"   	width="430" sortable="true" halign='center'><span class="header_name">Item Category Name </span></th>
                        <th field="ItemCategoryID"  	width="200" sortable="true" halign='center' hidden><span class="header_name">Item Category</span></th>
                    </tr>
                </thead>
            </table>
            <!-- Dialog Button for Dialog Item-->
            <div style="border:none; margin-top:10px; float:right;">
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onClick="choose_inventory_sq();">&nbsp; OK &nbsp; &nbsp;</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onClick="modal_close('dialog-inventory-sq');">Cancel</a>
            </div>
            <!-- End of Dialog Button for Dialog Item-->
        </div>
        <div title="Services / Expenses" style="padding:10px">
            <table width="100%">
            	<tr>
                <td width="310"><b>Item Category</b></td>
                <td><b>:</b></td>

                <td>
                    <select name="cmb_ItemCategoryID" id="cmb_ItemCategoryID" class="easyui-combobox" style="width:512px;" editable="false" disabled="disabled"
                            data-options="
                            valueField:'ItemCategoryID',
                            textField:'ItemCategoryName',
                            url:'',
                            onSelect: function(rec){
                                var id = rec.ItemCategoryID;
                                search_servis_item();
                            }
                        ">
                    </select>
                </td>
            </tr>

            <tr>
                <td><b><span class="header_code">Item Code</span></b></td>
                <td><b>:</b></td>
                
                <td>
                    <input type="text" style="width:510px;height:20px" name="txt_ItemCode_Servis" id="txt_ItemCode_Servis" class="easyui-validatebox" onkeyup="search_servis_item();" />
                </td>
            </tr>
            
            <tr>
                <td><b><span class="header_name">Item Name</span></b></td>
                <td><b>:</b></td>
                
                <td>
                    <input type="text" style="width:510px;height:20px" name="txt_ItemDesc_Servis" id="txt_ItemDesc_Servis" class="easyui-validatebox" onkeyup="search_servis_item();" />
                </td>
            </tr>
            </table>
            <table id="tt_choose_servis" class="easyui-datagrid" singleSelect="true" remoteSort="false" pagesize="150" fitColumns="true" style="width:812px;height:313px" 
                data-options = "border:true,view:scrollview,autoRowheight:false"
                url="<?=base_url()?>custom/get_data/search_service"                   
            >                        
                <thead>
                    <tr>
                        <th field="ItemCode"        width="293" sortable="true" halign='center'><span class="header_code">Service / Expense Name</span></th>
                        <th field="ItemDesc"        width="430" sortable="true" halign='center'><span class="header_name">Description</span></th>
                        <th field="ItemCategoryID"  width="200" sortable="true" halign='center' hidden><span class="header_name">Item Category</span></th>
                    </tr>
                </thead>
            </table>
            <!-- Dialog Button for Dialog servis-->
            <div style="border:none; margin-top:10px; float:right;">
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onClick="choose_servis();">&nbsp; OK &nbsp; &nbsp;</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onClick="modal_close('dialog-inventory-sq');">Cancel</a>
            </div>
        </div>
    </div>
</div>
<?php $this->load->view('v_custom_pop_up');?>
<script type="text/javascript">
var SavePrivillage = '<?php echo $group_user->SavePrivillage;?>';

$(document).ready(function(){
	$('#frm_sales_quotation').click(function(){
		$('#dtg_item').edatagrid('saveRow');
	});
	
	$('#cmb_customer').combogrid({
        onSelect:function(rowIndex, rowData){
            var Address = rowData.CustomerAddress + ', ' + rowData.CustomerCityName + ', ' + rowData.CustomerStateName + ', ' + rowData.CustomerCountryName;
            
			$('#txa_address').val(Address);
            $('#txa_ship_to').val(Address);
        }
    });
	
	$('#txt_sq_date').datebox({
		onChange:function(){
			url             = base_url + 'list/sales_quotation/get_squo_number';                
			var SQou_Date   = $('#txt_sq_date').datebox('getValue');
			
			$.post(url, {SQou_Date:SQou_Date}, function(result){
				if (result.status === true){
					$('#txt_sq_no').val(result.number);
				} 
			},'json');
		}
	});  
	
	$('#dtg_item').datagrid({
            onBeginEdit:function(rowIndex){
				save_button_begendedit(SavePrivillage);
                
            },
            
            onEndEdit: function(){
				save_button_endedit(SavePrivillage);
            }
	});    
	
	datagrid_item_type_status("dtg_item");//untuk warna grid  
});

function insert_data() {
	$('#dtg_item').edatagrid('saveRow');
	var cek = $('#dtg_item').datagrid('getRows');
	
	var cmb_salesman 	= $('#cmb_salesman').combogrid('getValue');
	var txt_po_no 	 	= $('#txt_po_no').val();
	var txt_po_date 	= $('#txt_po_date').datebox('getValue');
	
	
	err_qty = 0;
	
	$.each(cek, function( index, value ) {
		if(parseInt(value.ItemQty) == 0) {
			err_qty++;
		}
	});
	
	if(err_qty > 0) {
		$.messager.alert('Unseccessfull','Qty tidak boleh lebih kecil atau sama dengan Nol (0).','error',function(){	
			$('#dtg_item').datagrid('reload'); 	
		});
	}
	else if((txt_po_date == "") || (txt_po_no == "") || (txt_po_date == "")){
		$.messager.alert('Unseccessfull','Silahkan lengkapi form salesman, customer po number, customer po date','error',function(){	
			
		});
	}
	else {
		if(check_required_date()){
			var i=$('#dtg_item').datagrid('getRows');
			var detail = JSON.stringify(i);
			$("#detail").val(detail);							
			save_transaction('<?=$menu_link?>','#frm_sales_quotation');
		}
	}
}

function check_required_date(){
	dtg_item = $('#dtg_item').datagrid('getRows');
	
	validate = true;
	$.each(dtg_item,function(index,row){
		today	= new Date();
        today	= Date.parse(today.getMonth()+1+'/'+today.getDate()+'/'+today.getFullYear());
		
		datebox_value = row.RequiredDate.split('-');
		datebox_value = datebox_value[1] +'-'+ datebox_value[0] +'-'+ datebox_value[2];
		datebox_value = Date.parse(datebox_value);
	});
	
	if(datebox_value < today){
		$.messager.alert('Perhatian','Tidak bisa memilih tanggal dibawah tanggal saat ini untuk Required Date.');
		validate = false;
	}
	
	return validate;
}

function open_inventory(){ 
   modal_open('Inventory','dialog-inventory-sq');
}

function choose_servis() {
    var selected_data = $('#tt_choose_servis').datagrid('getSelected');
   
	flag 				= true;
	item 				= $('#dtg_item').datagrid('getRows');
	
	$.each(item, function(index,value){
		if(selected_data.ItemCode == value.ItemCode){
			$.messager.alert('Unseccessfull','Item sudah tersedia.','error',function(){	
				$('#tt_choose_servis').datagrid('reload'); 	
			});
			flag = false;
		}
	});	
	
	if(flag != false){
		$('.item_inventory').val(selected_data.ItemCode);
		$('.description').val(selected_data.ItemDesc);
		$('.unit').val(selected_data.ItemUnit);
		$('.item_category').val(selected_data.ItemCategoryID);
		$('.category_code').val(selected_data.ItemCategoryCode);
		$('.item_status').val(selected_data.ItemStatus);
		
		modal_close('dialog-inventory-sq');
	}
}

function choose_inventory_sq() {
    var selected_data = $('#grid_pop_up').datagrid('getSelected');
	
	flag = true;
	item = $('#dtg_item').datagrid('getRows');

	$.each(item, function(index,value){
		if(selected_data.ItemCode == value.ItemCode){
			$.messager.alert('Unseccessfull','Item sudah tersedia.','error',function(){	
				$('#grid_pop_up').datagrid('reload'); 	
			});
			flag = false;
		}
	});		
	
	if(flag != false){
		$('.item_inventory').val(selected_data.ItemCode);
		$('.description').val(selected_data.ItemDesc);
		$('.unit').val(selected_data.ItemUnit);
		$('.price').val(selected_data.ItemPrice);
		$('.max_item').val(selected_data.ItemQty - selected_data.ItemBooks);
		$('.item_category').val(selected_data.ItemCategoryID);
		$('.category_code').val(selected_data.ItemCategoryCode);
		$('.item_status').val(selected_data.ItemStatus);
		
		modal_close('dialog-inventory-sq');	
	}
}

$('input[name="rdo_ItemToggle"]').click(function(){    
	if($(this).val() == 0){
		$('#cmb_inventory_category').combobox('enable');
		//SQ Item inventori
		$('#grid_pop_up').datagrid({
			url:'<?=base_url()?>custom/get_data/search_inventory'
		});
		
		$('span.header_code').text('Item Code');
		$('span.header_name').text('Item Name');
		$('span#theader_code').text('Item Code');
		$('span#theader_name').text('Description');
	}
	else if($(this).val() == 1){
		$('#cmb_inventory_category').combobox('disable');
		
		//SQ expense inventori
		$('#grid_pop_up').datagrid({
			url:'<?=base_url()?>custom/get_data/search_service'
		});
		
		$('span.header_code').text('Service / Expense Name');
		$('span.header_name').text('Description');
		$('span#theader_code').text('Item Code');
		$('span#theader_name').text('Description');
	}
});

/*====================functiom remove row========================================================*/
function remove_row(){
	var selectedrow     = $('#dtg_item').datagrid('getSelected');
	var row_index       = $('#dtg_item').datagrid('getRowIndex', selectedrow);
	
	$.messager.confirm('Confirmation :', 'Anda yakin, Anda ingin menghapus item "' + selectedrow.ItemCode + '"?',  
		function(r){
			if (r){
				/*====================on beg in edit saat grid di klik maka tombol save disable===================*/
				$('.save-button').linkbutton('enable');
				/*=================================end============================================================*/
					
				$('#dtg_item').datagrid('deleteRow', row_index);
			}
		}
	);
}
/*================================end===============================================================*/

function add_row(){
	var cmb_salesman 	= $('#cmb_salesman').combogrid('getValue');
	var txt_po_no 	 	= $('#txt_po_no').val();
	var txt_po_date 	= $('#txt_po_date').datebox('getValue');
	
	if((txt_po_date == "") || (txt_po_no == "") || (txt_po_date == "")){
		$.messager.alert('Unseccessfull','Silahkan lengkapi form salesman, customer po number, customer po date','error',function(){	
			
		});
	}
	else{
		$('#dtg_item').edatagrid('addRow');
	}
}

$.extend($.fn.datagrid.defaults.editors, {
    item_inventory: {
        init: function(container, options){
            var input = $('<input type="text" class="item_inventory" onClick="open_inventory()" style="height:18px;" readonly/>').appendTo(container);
            return input.validatebox(options);
        },
        destroy: function(target){
            $(target).remove();
        },
        getValue: function(target){
            return $(target).val();
        },
        setValue: function(target, value){
            $(target).val(value);
        },
        resize: function(target, width){
            $(target)._outerWidth(width);
        }
    },
            
    item_category: {
        init: function(container, options){
            var input = $('<input type="text" class="item_category" style="height:18px;" readonly/>').appendTo(container);
            return input.validatebox(options);
        },
        destroy: function(target){
            $(target).remove();
        },
        getValue: function(target){
            return $(target).val();
        },
        setValue: function(target, value){
            $(target).val(value);
        },
        resize: function(target, width){
            $(target)._outerWidth(width);
        }
    },
	
    description: {
        init: function(container, options){
            var input = $('<input type="text" class="description" style="width:350px;height:18px;" readonly/>').appendTo(container);
            return input.validatebox(options);
        },
        destroy: function(target){
            $(target).remove();
        },
        getValue: function(target){
            return $(target).val();
        },
        setValue: function(target, value){
            $(target).val(value);
        },
        resize: function(target, width){
            $(target)._outerWidth(width);
        }
    },
            
    unit: {
        init: function(container, options){
            var input = $('<input type="text" class="unit" style="width:82px;height:18px;text-align:center;" readonly/>').appendTo(container);
            return input.validatebox(options);
        },
        destroy: function(target){
            $(target).remove();
        },
        getValue: function(target){
            return $(target).val();
        },
        setValue: function(target, value){
            $(target).val(value);
        },
        resize: function(target, width){
            $(target)._outerWidth(width);
        }
    },
            
    price: {
        init: function(container, options){
            var input = $('<input type="text" class="price" style="height:18px;" onChange="get_amount(this.value)" />').appendTo(container);
            return input.validatebox(options);
        },
        destroy: function(target){
            $(target).remove();
        },
        getValue: function(target){
            return $(target).val();
        },
        setValue: function(target, value){
            $(target).val(value);
        },
        resize: function(target, width){
            $(target)._outerWidth(width);
        }
    },
	  
    qty: {
        init: function(container, options){
            var input = $('<input type="text" class="qty" onChange="get_amount(this.value)" style="height:18px;" />').appendTo(container);
            return input.validatebox(options);
        },
        destroy: function(target){
            $(target).remove();
        },
        getValue: function(target){
            return $(target).val();
        },
        setValue: function(target, value){
            $(target).val(value);
        },
        resize: function(target, width){
            $(target)._outerWidth(width);
        }
    },
	
    item_status: {
        init: function(container, options){
            var input = $('<input type="text" class="item_status" style="height:18px;" readonly/>').appendTo(container);
            return input.validatebox(options);
        },
        destroy: function(target){
            $(target).remove();
        },
        getValue: function(target){
            return $(target).val();
        },
        setValue: function(target, value){
            $(target).val(value);
        },
        resize: function(target, width){
            $(target)._outerWidth(width);
        }
    },
	
    max_item: {
        init: function(container, options){
            var input = $('<input type="text" class="max_item" style="height:18px;" readonly />').appendTo(container);
            return input.validatebox(options);
        },
        destroy: function(target){
            $(target).remove();
        },
        getValue: function(target){
            return $(target).val();
        },
        setValue: function(target, value){
            $(target).val(value);
        },
        resize: function(target, width){
            $(target)._outerWidth(width);
        }
    }
});
</script>