<?php $__env->startSection('header'); ?>
<script src="<?php echo App::make("myadmin")->asset('/ckeditor/ckeditor.js'); ?>"></script>
<script src="../../../js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="<?php echo asset('css/bootstrap-datetimepicker.min.css'); ?>" />
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<style type="text/css" media="screen">
    img#preview{
        width:150px;
        height:150px;
        padding:2px;
        border:1px solid #000;
    }
	.btn-my{  
		background: #006633;
		width: 100px;  
		height: 100px;  
		-moz-border-radius: 50%;  
		-webkit-border-radius: 50%;  
		border-radius: 50%;  
	}  
	.btn-my:hover {  
        background: #BFEC3E;   
        color:#e75616;  
    }  
</style>
<div>
    <?php echo Form::model($product, array(
		'url' => array('admin/product/limitedupdate', $product->id),
        'class'=>'form-horizontal well',
        'method' => 'get'  //put
    )); ?>


	<?php if($errors->has()): ?>
			<div class="alert alert-warning" role="alert"><?php echo $errors->first(); ?></div>
	<?php endif; ?>

    <div class="form-group ">
		<h3><label class="col-sm-2 control-label">限時活動 : </label></h3>
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label">限時編碼</label>
        <div class="col-sm-10">
				<label class="control-label"><?php echo $product->product_code; ?></label> 
        </div>
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label">商品名稱</label>
        <div class="col-sm-10">
				<label class="control-label"><?php echo $product->title; ?></label> 
        </div>
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label">商品條件</label>
        <div class="col-sm-10">
				<label class="control-label"><?php echo $product->format; ?></label> 
        </div>
    </div>

	    <div class="form-group ">
    	    <label class="col-sm-2 control-label">限時定價</label>
        	<div class="col-sm-10">
	            <?php echo Form::number('price', null, array('class' => 'form-control')); ?>

    	    </div>
	    </div>
    	<div class="form-group ">
        	<label class="col-sm-2 control-label">限時售價</label>
	        <div class="col-sm-10">
    	        <?php echo Form::number('selling_price', null, array('class' => 'form-control')); ?>

        	</div>
	    </div>
	    <div class="form-group ">
    	    <label class="col-sm-2 control-label">架上數量</label>
        	<div class="col-sm-10">
	            <?php echo Form::number('available_amount', null, array('class' => 'form-control')); ?>

    	    </div>
	    </div>

    	<div class="form-group ">
        	<label class="col-sm-2 control-label">最大數量</label>
	        <div class="col-sm-10">
    	        <?php echo Form::number('stock_amount', null, array('class' => 'form-control')); ?>

	        </div>
    	</div>
	    <div class="form-group ">
    	    <label class="col-sm-2 control-label">顯示狀態</label>
        	<div class="col-sm-10">
	        	<div class="col-sm-1">    <?php echo Form::radio('is_available', '上架' ); ?>上架 </div>
		        <div class="col-sm-1">    <?php echo Form::radio('is_available', '下架' ); ?>下架 </div>
        	</div>
	    </div>
	<?php if($cid == 0): ?>
    	<div class="form-group">
        	<label class="col-sm-2 control-label">起始時間</label>
			<div id="datetimepicker1" class="col-sm-3 input-append date">  
    			<input type="text" name="starting_time" id="startid"></input>  
	    	    <span class="glyphicon glyphicon-calendar add-on btn" data-time-icon="icon-time" data-date-icon="icon-calendar"></span>  
	    	</div>  
    	</div>
	<?php else: ?>
    	<div class="form-group">
        	<label class="col-sm-2 control-label">起始時間</label>
	        <div class="col-sm-10">
				<label class="control-label"><?php echo $product->starting_time; ?></label> 
     	   </div>
    	</div>

	<?php endif; ?>
	    <div class="form-group">
    	    <label class="col-sm-2 control-label">結束時間</label>
			<div id="datetimepicker2" class="col-sm-3 input-append date">  
	    		<input type="text" name="ended_time" id="endid"></input>  
		        <span class="glyphicon glyphicon-calendar add-on btn" data-time-icon="icon-time" data-date-icon="icon-calendar"></span>  
	    	</div>  
    	</div>


	    <div class="form-group ">
    	    <label class="col-sm-2 control-label">建立時間</label>
        	<div class="col-sm-10">
				<label class="control-label"><?php echo $product->created_at; ?></label> 
    	    </div>
	    </div>

    <hr>
    <div class="form-group">
        <label class="col-sm-2 control-label"></label>
        <div class="col-sm-10">
            <input type="submit" id="submit_activity" value="編輯完成" class="btn btn-primary"  />
        </div>
    </div>
    <?php echo Form::close(); ?>

</div>

<script type="text/javascript">
	$(function() {
		$("#datetimepicker1,#datetimepicker2").datetimepicker({
			language: 'en',
			pickTime: 'true',
			format: 'yyyy-MM-dd hh:mm:ss'
		});
	});
</script>
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		var cid = <?php echo $cid; ?>;
		var product = <?php echo $product; ?>;
//		$("#codeid").text(product['product_code']);
//		$("#titleid").text(product['title']);
//		$("#formatid").text(product['format']);
//		$("#create_at_id").text(product['created_at']);
		$("#startid").val(product['starting_time']);
		$("#endid").val(product['ended_time']);

		$("#operatorid").keyup(function(){
//			console.log($(this).val());
			var stock = <?php echo $product->activities_num; ?>;
			if($(this).val())
				$('#total_activities').text(parseInt($(this).val())+parseInt(stock) );
			else
				$('#total_activities').text(parseInt(stock));
		});
/*		
		if(cid == 1){
			$("#submit_activity").click(function(){
				var total = $("#total_activities").text();
				if(total == parseInt(total, 10))
					console.log(total);
//			window.location = "<?php echo URL::to('admin/product/instock'); ?>" + "/" + id + "/" + total;
			});
		}
*/
	});
	
</script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js-snippet'); ?>
    <?php echo $__env->make('Myadmin::js.preview', array('bind' => 'input[name=image]','target' => '#preview'), array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <?php echo $__env->make('Myadmin::js.ckeditor', array(
        'target' => 'origin_content',
    ), array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('Myadmin::layout.basic', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>