<script type="text/javascript">
$(document).ready(function() {

$('.update_stt').keyup(function(event) {
	var id = $(this).attr('rel');
	var table = 'transport_photo';
	var value = $(this).val();
	$.ajax ({
		type: "POST",
		url: "ajax/update_stt.php",
		data: {id:id,table:table,value:value},
		success: function(result) {
		}
	});
});
$('.delete_images').click(function(){
if (confirm('Bạn có muốn xóa hình này ko ? ')) {
var id = $(this).attr('title');
	var table = 'transport_photo';
var links = "<?=_upload_transport;?>";
$.ajax ({
type: "POST",
url: "ajax/delete_images.php",
data: {id:id,table:table,links:links},
success: function(result) {
}
});
$(this).parent().slideUp();
}
return false;
});
$('.themmoi').click(function(e) {
$.ajax ({
type: "POST",
url: "ajax/khuyenmai.php",
success: function(result) {
$('.load_sp').append(result);
}
});
});
$('.delete').click(function(e) {
$(this).parent().remove();
});

});

</script>
<?php
function get_main_list()
{
	global $item;
$sql="select * from table_transport_list where type='".$_GET['type']."' order by stt asc";
$stmt=mysql_query($sql);
$str='
<select id="id_list" name="id_list" data-level="0" data-type="'.$_GET['type'].'" data-table="table_transport_cat" data-child="id_cat" class="main_select select_danhmuc form-control">
	<option value="">Chọn danh mục 1</option>';
	while ($row=@mysql_fetch_array($stmt))
	{
	if($row["id"]==(int)@$item["id_list"])
	$selected="selected";
	else
	$selected="";
	$str.='<option value='.$row["id"].' '.$selected.'>'.$row["ten_vi"].'</option>';
	}
$str.='</select>';
return $str;
}
function get_main_cat()
{
	global $item;
$sql="select * from table_transport_cat where id_list='".$item['id_list']."' and type='".$_GET['type']."' order by stt asc";
$stmt=mysql_query($sql);
$str='
<select id="id_cat" name="id_cat" data-level="1" data-type="'.$_GET['type'].'" data-table="table_transport_item" data-child="id_item" class="main_select select_danhmuc form-control">
	<option value="">Chọn danh mục 2</option>';
	while ($row=@mysql_fetch_array($stmt))
	{
	if($row["id"]==(int)@$item["id_cat"])
	$selected="selected";
	else
	$selected="";
	$str.='<option value='.$row["id"].' '.$selected.'>'.$row["ten_vi"].'</option>';
	}
$str.='</select>';
return $str;
}
function get_main_item()
{
	global $item;
$sql="select * from table_transport_item where id_cat='".$item['id_cat']."' and type='".$_GET['type']."' order by stt asc";
$stmt=mysql_query($sql);
$str='
<select id="id_item" name="id_item" data-level="2" data-type="'.$_GET['type'].'" data-table="table_transport_sub" data-child="id_sub" class="main_select select_danhmuc form-control">
	<option value="">Chọn danh mục 3</option>';
	while ($row=@mysql_fetch_array($stmt))
	{
	if($row["id"]==(int)@$item["id_item"])
	$selected="selected";
	else
	$selected="";
	$str.='<option value='.$row["id"].' '.$selected.'>'.$row["ten_vi"].'</option>';
	}
$str.='</select>';
return $str;
}
function get_main_sub()
{
	global $item;
$sql="select * from table_transport_sub where id_item='".$item['id_item']."' and type='".$_GET['type']."' order by stt asc";
$stmt=mysql_query($sql);
$str='
<select id="id_sub" name="id_sub" class="main_select">
	<option value="">Chọn danh mục 3</option>';
	while ($row=@mysql_fetch_array($stmt))
	{
	if($row["id"]==(int)@$item["id_sub"])
	$selected="selected";
	else
	$selected="";
	$str.='<option value='.$row["id"].' '.$selected.'>'.$row["ten_vi"].'</option>';
	}
$str.='</select>';
return $str;
}
?>
<div class="wrapper">
	<div class="control_frm breadcrumb" style="margin-top:25px;">
		<div class="bc">
			<ul id="breadcrumbs" class="breadcrumbs">
				<li><a <?php if($_GET['type']!="phuongcham") { ?>href="index.php?com=transport&act=add<?php if($_REQUEST['type']!='') echo'&type='. $_REQUEST['type'];?>"<?php } ?>><span>Thêm <?=$title_main?></span></a></li>
				<li class="current"><a href="#" onclick="return false;">Thêm</a></li>
			</ul>
			<div class="clear"></div>
		</div>
	</div>
	<form name="supplier" id="validate" class="form" action="index.php?com=transport&act=save<?php if($_REQUEST['type']!='') echo'&type='. $_REQUEST['type'];?>" method="post" enctype="multipart/form-data">
		<div class="card">
			<div class="card-header">
				<div class="title chonngonngu">
					<ul>
						<li><a href="vi" class="active tipS validate[required]" title="Chọn tiếng việt "><img src="./images/icon-vi.png" alt="" class="tiengviet" />Tiếng Việt</a></li>
						<li><a href="en" class="tipS validate[required]" title="Chọn tiếng anh "><img src="./images/icon-en.png" alt="" class="tienganh" />Tiếng Anh</a></li>
						<!-- <li><a href="cn" class="tipS validate[required]" title="Chọn tiếng trung "><img src="./images/icon-cn.png" alt="" class="tiengtrung" />Tiếng Trung</a></li> -->
					</ul>
				</div>
			</div>
			<div class="card-body">
				
				<?php if($config_list=='true'){ ?>
				<div class="formRow">
					<label>Chọn danh mục 1</label>
					<div class="formRight">
						<?=get_main_list()?>
					</div>
					<div class="clear"></div>
				</div>
				<?php } ?>
				<?php if($config_cat=='true'){ ?>
				<div class="formRow">
					<label>Chọn danh mục 2</label>
					<div class="formRight">
						<?=get_main_cat()?>
					</div>
					<div class="clear"></div>
				</div>
				<?php } ?>
				<?php if($config_item=='true'){ ?>
				<div class="formRow">
					<label>Chọn danh mục 3</label>
					<div class="formRight">
						<?=get_main_item()?>
					</div>
					<div class="clear"></div>
				</div>
				<?php } ?>
				<?php if($config_sub=='true'){ ?>
				<div class="formRow">
					<label>Chọn danh mục 4</label>
					<div class="formRight">
						<?=get_main_sub()?>
					</div>
					<div class="clear"></div>
				</div>
				<?php } ?>
				<?php if($config_images=='true'){?>
				<div class="formRow">
					<label>Tải hình ảnh:</label>
					<div class="formRight">
						<input type="file" id="file" name="file" />
						<img src="./images/question-button.png" alt="Upload hình" class="icon_question tipS" original-title="Tải hình ảnh (ảnh JPEG, GIF , JPG , PNG)">
						<div class="note"> width : <?php echo _width_thumb*$ratio_;?> px , Height : <?php echo _height_thumb*$ratio_;?> px </div>
					</div>
					<div class="clear"></div>
				</div>
				<?php if($_GET['act']=='edit'){?>
				<div class="formRow">
					<label>Hình Hiện Tại :</label>
					<div class="formRight">
						
						<div class="mt10"><img src="<?=_upload_transport.$item['thumb']?>"  alt="NO PHOTO" width="100" /></div>
					</div>
					<div class="clear"></div>
				</div>
				<?php } } ?>
				<?php if($config_img=='true'){ ?>
				<div class="formRow">
					<label>Hình ảnh kèm theo: </label>
					<div class="formRight">
						<a class="file_input" data-jfiler-name="files" data-jfiler-extensions="jpg, jpeg, png, gif"><img src="images/image_add.png" alt="" width="100"></a>
						
						
						<?php if($act=='edit'){?>
						<?php if(count($ds_photo)!=0){?>
						<?php for($i=0;$i<count($ds_photo);$i++){?>
						<div class="item_trich">
							<img class="img_trich" width="140px" height="110px" src="<?=_upload_transport.$ds_photo[$i]['photo']?>" />
							<input type="text" rel="<?=$ds_photo[$i]['id']?>" value="<?=$ds_photo[$i]['stt']?>" class="update_stt tipS" />
							<a class="delete_images" title="<?=$ds_photo[$i]['id']?>"><img src="images/delete.png"></a>
						</div>
						<?php } ?>
						
						<?php }?>
						<?php }?>
					</div>
					<div class="clear"></div>
				</div>
				<?php } ?>
				<?=$input_text("Tiêu Đề",'ten_vi',$item,'vi')?>
				<?=$input_text("Tiêu Đề (Tiếng Anh)",'ten_en',$item,'en')?>
				<?=$input_text("Mã vận đơn",'bill_id',$item)?>
				<?=$input_text("Mã Đơn Hàng",'order_id',$item)?>

				
			</div>
		</div>
		<div class="card mt-3">
			<div class="card-header bg-info text-white">
				<span class="card-title">Thông Tin Người Gửi</span>
			</div>
			<div class="card-body">
				<?=$input_text("Tên người gửi",'nguoigui_vi',$item)?>
				<?=$input_text("Địa Chỉ người gửi",'diachigui_vi',$item)?>
				<?=$input_text("Điện thoại người gửi",'dienthoaigui_vi',$item)?>
			</div>
		</div>
		<div class="card mt-3">
			<div class="card-header bg-info text-white">
				<span class="card-title">Thông Tin Người Nhận</span>
			</div>
			<div class="card-body">
				<?=$input_text("Tên người nhận",'nguoinhan_vi',$item)?>
				<?=$input_text("Địa Chỉ người nhận",'diachinhan_vi',$item)?>
				<?=$input_text("Điện thoại người nhận",'dienthoainhan_vi',$item)?>
			</div>
		</div>
		<div class="widget card">
			<div class="card-header title bg-danger text-white mt-3">
				Cập nhật tình trạng đơn hàng
			</div>
			<?php if($_GET['type']=='lkweb'){ ?>
				<div class="formRow">
					<label>Link</label>
					<div class="formRight">
						<input type="text" name="link" title="Nhập link" id="link" class="form-control tipS" value="<?=@$item['link']?>" />
					</div>
					<div class="clear"></div>
				</div>
				<?php } ?>
				<?php if($config_mota=='true'){ ?>
				<div class="formRow lang_hidden lang_vi active">
					<label>Mô tả</label>
					<div class="formRight">
						<textarea rows="4" cols="" title="Nhập mô tả . " class="form-control tipS" name="mota_vi"><?=@$item['mota_vi']?></textarea>
					</div>
					<div class="clear"></div>
				</div>
				<div class="formRow lang_hidden lang_en">
					<label>Mô tả (Tiếng anh)</label>
					<div class="formRight">
						<textarea rows="4" cols="" title="Nhập mô tả . " class="form-control tipS" name="mota_en"><?=@$item['mota_en']?></textarea>
					</div>
					<div class="clear"></div>
				</div>
				<div class="formRow lang_hidden lang_cn">
					<label>Mô tả (Tiếng trung)</label>
					<div class="formRight">
						<textarea rows="4" cols="" title="Nhập mô tả . " class="form-control tipS" name="mota_cn"><?=@$item['mota_cn']?></textarea>
					</div>
					<div class="clear"></div>
				</div>
				<?php } ?>
				<?php if($config_noidung=='true') { ?>
				<div class="formRow lang_hidden lang_vi active">
					<label>Nội Dung</label>
					<div class="ck_editor">
						<textarea id="noidung_vi" name="noidung_vi"><?=@$item['noidung_vi']?></textarea>
					</div>
					<div class="clear"></div>
				</div>
				
				<div class="formRow lang_hidden lang_en">
					<label>Nội Dung (Tiếng anh)</label>
					<div class="ck_editor">
						<textarea id="noidung_en" name="noidung_en"><?=@$item['noidung_en']?></textarea>
					</div>
					<div class="clear"></div>
				</div>
				<div class="formRow lang_hidden lang_cn">
					<label>Nội Dung (Tiếng trung)</label>
					<div class="ck_editor">
						<textarea id="noidung_cn" name="noidung_cn"><?=@$item['noidung_cn']?></textarea>
					</div>
					<div class="clear"></div>
				</div>
				<?php } ?>
		</div>
		<div class="widget my-3">
			<div class="formRow">
				<label>Hiển thị : <img src="./images/question-button.png" alt="Chọn loại" class="icon_que tipS" original-title="Bỏ chọn để không hiển thị danh mục này ! "> </label>
				<div class="formRight">
					
					<input type="checkbox" name="hienthi" id="check1" value="1" <?=(!isset($item['hienthi']) || $item['hienthi']==1)?'checked="checked"':''?> />
					
					
				</div>
				<div class="clear"></div>
			</div>
			<div class="formRow">
				<label>Số thứ tự: </label>
				<div class="formRight">
					<input type="text" class="form-control tipS" value="<?=isset($item['stt'])?$item['stt']:1?>" name="stt" style="width:40px; text-align:center;" onkeypress="return OnlyNumber(event)" original-title="Số thứ tự của danh mục, chỉ nhập số">
				</div>
				<div class="clear"></div>
			</div>
		</div>
		<div class="widget">
			<div class="title"><img src="./images/icons/dark/record.png" alt="" class="titleIcon" />
				<h6>Nội dung seo</h6>
			</div>
			
			<div class="formRow">
				<label>Title</label>
				<div class="formRight">
					<input type="text" value="<?=@$item['title']?>" name="title" title="Nội dung thẻ meta Title dùng để SEO" class="form-control tipS" />
				</div>
				<div class="clear"></div>
			</div>
			
			<div class="formRow">
				<label>Từ khóa</label>
				<div class="formRight">
					<input type="text" value="<?=@$item['keywords']?>" name="keywords" title="Từ khóa chính cho danh mục" class="form-control tipS" />
				</div>
				<div class="clear"></div>
			</div>
			
			<div class="formRow">
				<label>Description:</label>
				<div class="formRight">
					<textarea rows="4" cols="" title="Nội dung thẻ meta Description dùng để SEO" class="form-control tipS" name="description"><?=@$item['description']?></textarea>
					<input readonly="readonly" type="text" style="width:25px; margin-top:10px; text-align:center;" name="des_char" value="<?=@$item['des_char']?>" /> ký tự <b>(Tốt nhất là 68 - 170 ký tự)</b>
				</div>
				<div class="clear"></div>
			</div>
			
			<div class="formRow">
				<div class="formRight">
					<input type="hidden" name="type" id="id_this_type" value="<?=$_REQUEST['type']?>" />
					<input type="hidden" name="id" id="id_this_post" value="<?=@$item['id']?>" />
					<input type="submit" class="btn btn-primary" onclick="TreeFilterChanged2(); return false;" value="Hoàn tất" />
					<a href="index.php?com=transport&act=man<?php if($_REQUEST['type']!='') echo'&type='. $_REQUEST['type'];?>" onClick="if(!confirm('Bạn có muốn thoát không ? ')) return false;" title="" class="btn btn-secondary tipS" original-title="Thoát">Thoát</a>
				</div>
				<div class="clear"></div>
			</div>
		</div>
	</form>        </div>
	<script>
	$(document).ready(function() {
	$('.file_input').filer({
	showThumbs: true,
	templates: {
box: '<ul class="jFiler-item-list"></ul>',
item: '<li class="jFiler-item">\
	<div class="jFiler-item-container">\
		<div class="jFiler-item-inner">\
			<div class="jFiler-item-thumb">\
				<div class="jFiler-item-status"></div>\
				<div class="jFiler-item-info">\
					<span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
				</div>\
				{{fi-image}}\
			</div>\
			<div class="jFiler-item-assets jFiler-row">\
				<ul class="list-inline pull-left">\
					<li><span class="jFiler-item-others">{{fi-icon}} {{fi-size2}}</span></li>\
				</ul>\
				<ul class="list-inline pull-right">\
					<li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
				</ul>\
				</div>\<input type="text" name="stthinh[]" class="stthinh" placeholder="Nhập STT" />\
			</div>\
		</div>\
	</li>',
	itemAppend: '<li class="jFiler-item">\
		<div class="jFiler-item-container">\
			<div class="jFiler-item-inner">\
				<div class="jFiler-item-thumb">\
					<div class="jFiler-item-status"></div>\
					<div class="jFiler-item-info">\
						<span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
					</div>\
					{{fi-image}}\
				</div>\
				<div class="jFiler-item-assets jFiler-row">\
					<ul class="list-inline pull-left">\
						<span class="jFiler-item-others">{{fi-icon}} {{fi-size2}}</span>\
					</ul>\
					<ul class="list-inline pull-right">\
						<li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
					</ul>\
					</div>\<input type="text" name="stthinh[]" class="stthinh" placeholder="Nhập STT" />\
				</div>\
			</div>\
		</li>',
		progressBar: '<div class="bar"></div>',
		itemAppendToEnd: true,
		removeConfirmation: true,
		_selectors: {
		list: '.jFiler-item-list',
		item: '.jFiler-item',
		progressBar: '.bar',
		remove: '.jFiler-item-trash-action',
		}
		},
		addMore: true
		});
		});
		</script>