<?php echo $this->render('admin/header.phtml'); ?>


<script type="text/javascript" language="javascript">

	$(document).ready(function () {

		<?php if( isset( $this->editOrderSuccess ) ){ ?>
			alertify.success("<i class='fa fa-check'></i> <?php echo @Lib_Lang::translate(admin_client_editorder_success); ?>");
		<?php } ?>	

		<?php if( isset( $this->addOrderFileSuccess ) ){ ?>
			alertify.success("<i class='fa fa-check'></i> <?php echo @Lib_Lang::translate(admin_addorderfile_success); ?>");
		<?php } ?>	

		<?php if( isset( $this->removeOrderFileSuccess ) ){ ?>
			alertify.success("<i class='fa fa-check'></i> <?php echo @Lib_Lang::translate(admin_removeorderfile_success); ?>");
		<?php } ?>	
		
		
		
		$(".removeFile").click(function(){
		
			var link = $(this).attr('link');
			var name = $(this).attr('name');
			alertify.set({ buttonFocus: "none", labels: {ok: "<?php echo @Lib_Lang::translate(confirm_accept); ?>", cancel: "<?php echo @Lib_Lang::translate(confirm_cancel); ?>"}});
			alertify.confirm("<?php echo @Lib_Lang::translate(confirm_remove_file); ?> "+name+"?", function (e) {
				if (e) {
					window.location.href = link;
				} else {
					return false;
				}
			});
		
		});
	});

</script>

<div class="container">		

<?php echo $this->render('admin/menu.phtml'); ?>	


	<div class="row">
		<div class="col-xs-3 col-sm-3 col-md-3">
		</div>
		<div class="col-xs-9 col-sm-9 col-md-9 text-right">
			<a href="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'order'), 'default', true); ?>" class="btn btn-default btn-sm"><i class='fa fa-list'></i> <?php echo @Lib_Lang::translate(admin_order_menu_list); ?></a>
		</div>
	</div>


<script type="text/javascript" language="javascript">

	$(document).ready(function () {	

	
	
	});

</script>

	
	<div class="row">
		<div class="col-xs-3 col-sm-3 col-md-3">
			<h3><?php echo @Lib_Lang::translate(admin_order_edit_top); ?></h3>
		</div>
		<div class="col-xs-9 col-sm-9 col-md-9 text-right">
		</div>
	</div>


		
	<form id="formEditOrder" method="post" class="form-horizontal">
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_id); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><?php echo$this->rowOrder['order_id']; ?></div>
	</div>
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_client_data); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
		
				<?php echo$this->rowClient['client_firstname']; ?> <?php echo$this->rowClient['client_secondname']; ?><br />
				<?php echo$this->rowClient['client_address']; ?><br /><?php echo$this->rowClient['client_zipcode']; ?> <?php echo$this->rowClient['client_city']; ?>, <?php echo$this->rowClient['client_country']; ?><br /><?php echo$this->rowClient['client_phone']; ?><br />
				<a href="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'clientedit', 'id' => $this->rowClient['client_id']), 'default', true); ?>"><i class='fa fa-edit'></i> <?php echo @Lib_Lang::translate(admin_client_list_editbutton); ?></a>
		
		</div>
	</div>
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_client_data_send); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
		
				<?php echo$this->rowOrder['order_send_client_firstname']; ?> <?php echo$this->rowOrder['order_send_client_secondname']; ?><br />
				<?php echo$this->rowOrder['order_send_client_address']; ?><br /><?php echo$this->rowOrder['order_send_client_zipcode']; ?> <?php echo$this->rowOrder['order_send_client_city']; ?>, <?php echo$this->rowOrder['order_send_client_country']; ?><br /><?php echo$this->rowOrder['order_send_client_phone']; ?>
		
		</div>
	</div>
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_client_data_invoice); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
			<?php if( $this->rowOrder['order_invoice'] == 2 ){ ?>
				<?php echo @Lib_Lang::translate(admin_client_data_invoice_2); ?><br />
				<?php echo$this->rowOrder['order_invoice_name']; ?><br />
				<?php echo$this->rowOrder['order_invoice_address']; ?><br /><?php echo$this->rowOrder['order_invoice_zipcode']; ?> <?php echo$this->rowOrder['order_invoice_city']; ?>, <?php echo$this->rowOrder['order_invoice_country']; ?><br />nip <?php echo$this->rowOrder['order_invoice_nip']; ?>
			<?php }else{ ?>
				<?php echo @Lib_Lang::translate(admin_client_data_invoice_1); ?>
			<?php } ?>
		
		</div>
	</div>
	
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_ins); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><?php echo$this->rowOrder['order_ins']; ?></div>
	</div>
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_price_product); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><?php echo number_format($this->rowOrder['order_price_product'], 2, ',', ' '); ?> zł</div>
	</div>
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_price_packr); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
			<?php echo@Lib_Lang::consta(type_pack_.$this->rowOrder['order_id_pack']);?>
		</div>
	</div>
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_price_pack); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><?php echo number_format($this->rowOrder['order_price_pack'], 2, ',', ' '); ?> zł</div>
	</div>
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_price_transportr); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
			<?php echo@Lib_Lang::consta(type_transport_.$this->rowOrder['order_id_transport']);?>
		</div>
	</div>
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_price_transport); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><?php echo number_format($this->rowOrder['order_price_transport'], 2, ',', ' '); ?> zł</div>
	</div>
	
	
	<?php if($this->rowOrder['order_id_leadtime'] != 0){ ?>
	<div class="row rowOrder">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_price_leadtime); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><?php echo @Lib_Lang::consta(type_leadtime_.$this->rowOrder['order_id_leadtime']); ?> <?php echo number_format($this->rowOrder['order_price_leadtime'], 2, ',', ' '); ?> zł</div>
	</div>
	<?php } ?>
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_price); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><?php echo number_format($this->rowOrder['order_price'], 2, ',', ' '); ?> zł</div>
	</div>
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_price_s); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
		<?php 
				if( $this->rowOrder['order_pay_type'] == 1 ){
					echo @Lib_Lang::translate(admin_order_price_s_1);
				}
				if( $this->rowOrder['order_pay_type'] == 2 ){
					echo @Lib_Lang::translate(admin_order_price_s_2);				
				}
				if( $this->rowOrder['order_pay_type'] == 3 ){
					echo @Lib_Lang::translate(admin_order_price_s_3);				
				}
		?>
		</div>
	</div>
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_clientinfo); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
			<?php echo$this->rowOrder['order_clientinfo'];?>
		</div>
	</div>
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"><?php echo @Lib_Lang::translate(admin_order_time); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
			<?php echo$this->rowOrder['order_time'];?>
		</div>
	</div>
	
	
	
	
	
	
	
	<form method="post">
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_order_status); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
		
		<?php
			$status_list = array(
				0,	// nowe
				11,	// weryfikacja zamowienia
				1,	// realizacja
				12,	// ciecie
				13,	// oklejanie
				14,	// wiercenie
				15,	// pakowanie
				4,	// oczekiwanie na odbior
				5,	// wyslane
				16,	// reklamacja
				2,	// zakonczone
				9,	// anulowane
			);
		?>
		
			<select name="order_status" class="form-control">
			
			<?php foreach( $status_list as $key => $j ){ ?>
				<option value="<?php echo$j; ?>" <?php if($this->rowOrder['order_status'] == $j)echo'selected';?>><?php echo @Lib_Lang::consta(order_status_.$j); ?></option>
			<?php } ?>
			
			<?php
			/*
				<option value="0" <?php if($this->rowOrder['order_status'] == 0)echo'selected';?>><?php echo @Lib_Lang::translate(order_status_0); ?></option>
				<option value="3" <?php if($this->rowOrder['order_status'] == 3)echo'selected';?>><?php echo @Lib_Lang::translate(order_status_3); ?></option>
				<option value="1" <?php if($this->rowOrder['order_status'] == 1)echo'selected';?>><?php echo @Lib_Lang::translate(order_status_1); ?></option>
				<option value="4" <?php if($this->rowOrder['order_status'] == 4)echo'selected';?>><?php echo @Lib_Lang::translate(order_status_4); ?></option>
				<option value="5" <?php if($this->rowOrder['order_status'] == 5)echo'selected';?>><?php echo @Lib_Lang::translate(order_status_5); ?></option>
				<option value="2" <?php if($this->rowOrder['order_status'] == 2)echo'selected';?>><?php echo @Lib_Lang::translate(order_status_2); ?></option>
				<option value="9" <?php if($this->rowOrder['order_status'] == 9)echo'selected';?>><?php echo @Lib_Lang::translate(order_status_9); ?></option>
			*/ ?>
			</select>
		</div>
		 
	</div>
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_order_status_2); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
			<select name="order_status_2" class="form-control">
			<?php for( $j = 0; $j != 10; $j++ ){ ?>
				<option value="<?php echo$j; ?>" <?php if($this->rowOrder['order_status_2'] == $j)echo'selected';?>><?php echo @Lib_Lang::consta(order_status_2_.$j); ?></option>
			<?php } ?>
			</select>
		</div>
		 
	</div>
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_order_pay); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
			<select name="order_pay" class="form-control">
				<option value="0" <?php if($this->rowOrder['order_pay'] == 0)echo'selected';?>><?php echo @Lib_Lang::translate(front_order_list_status_pay_0); ?></option>
				<option value="1" <?php if($this->rowOrder['order_pay'] == 1)echo'selected';?>><?php echo @Lib_Lang::translate(front_order_list_status_pay_1); ?></option>
			</select>
		</div>
		 
	</div>
	
					
				
<script type="text/javascript" language="javascript">

		jQuery(function($){
			$("[name='order_datasend']").mask('9999-99-99',{placeholder:"____-__-__"});
		});
	
		jQuery(function($){
			$("input[name='order_datasend']").datetimepicker({
				lang:'<?php echo@LANG; ?>',
				timepicker:false, 
				format:'Y-m-d'
			});
		});
		
</script>	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_order_datasend); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input placeholder="____-__-__" name="order_datasend" value="<?php if( $this->rowOrder['order_datasend']!='0000-00-00' ) echo $this->rowOrder['order_datasend']; ?>" class="form-control" /></div>
	</div>
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_order_nr); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input maxlength="200" name="order_nr" value="<?php echo $this->rowOrder['order_nr']; ?>" class="form-control" /></div>
	</div>
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_order_infoshop); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><textarea name="order_infoshop" class="form-control"><?php echo $this->rowOrder['order_infoshop']; ?></textarea></div>
	</div>
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_order_infoshop_insite); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><textarea name="order_infoshop_insite" class="form-control"><?php echo $this->rowOrder['order_infoshop_insite']; ?></textarea></div>
	</div>
	
	
	
	
	
	
	
	
	
	
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
			<input class="btn btn-primary" type="submit" value="<?php echo @Lib_Lang::translate(order_status_send); ?>" />
		</div>		
	</div>
	
	
	
	
	</form>
	
	
	
	
<script type="text/javascript" language="javascript">

	$(document).ready(function () {	
	
		$('[name="order_file_submit"]').click(function(){
		
			var err = 0;
		
			if( $('[name="order_file"]').val() == '' ){
				err++;
				alertify.error("<i class='fa fa-remove'></i> <?php echo @Lib_Lang::translate(order_send_addfile_error); ?>");
			}
			
			if( err != 0 ) return false;
		});
	
	});

</script>
	
	<form id="formAddFile" method="post" class="form-horizontal" enctype="multipart/form-data">		
	
		<div class="row">
			<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"></div>
			<div class="col-xs-12 col-sm-8 col-md-8">
			</div>		
		</div>
		
		
		<div class="row">
			<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"></div>
			<div class="col-xs-12 col-sm-8 col-md-8">
				<input id="fileElem" type="file" name="order_file" class="form-control fileInput" /> 
				<input class="btn btn-primary" type="submit" name="order_file_submit" value="<?php echo @Lib_Lang::translate(order_status_send_addfile); ?>" />
				
				
				
				
<br />
<hr />
<h4><?php echo @Lib_Lang::translate(orderfile_file); ?></h4>
<table class="table table-striped table-bordered table-hover">
	<thead>
		<tr>
			<th><?php echo @Lib_Lang::translate(orderfile_lp); ?></th>
			<th><?php echo @Lib_Lang::translate(orderfile_name); ?></th>
			<th><?php echo @Lib_Lang::translate(orderfile_size); ?></th>
			<th><?php echo @Lib_Lang::translate(orderfile_date); ?></th>
			<th></th>
		</tr>
	</thead>
	<tbody>		
<?php 
			$i = 0;
			foreach( $this->dataOrderFile as $fileDocKey => $fileDocVal ){
			$i++;
?>

		<tr>
			<td><?php echo $i; ?>.</td>
			<td><a href="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'orderfileopen', 'id' => $fileDocVal['order_file_id']), null, true); ?>" target="_blank"><?php echo $fileDocVal['order_file_filename']; ?></a></td>
			<td><?php echo round($fileDocVal['order_file_filesize']/1024,2); ?> KB</td>
			<td><?php echo $fileDocVal['order_file_ins']; ?></td>
			<td class="text-center">
				<a name="<?php echo $fileDocVal['order_file_filename']; ?>" link="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'orderfileremove', 'id' => $fileDocVal['order_id'], 'idf' => $fileDocVal['order_file_id']), null, true); ?>" class="btn btn-xs btn-danger removeFile">X</a>
			</td>
		</tr>

<?php			
			}
		?>

	</tbody>
</table>	

				
				
				
				
				
			</div>		
		</div>
	
	</form>
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_order_product); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">

		
	<p class="text-right">	
	<a href="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'export', 'id' => $this->rowOrder['order_id']), 'default', true); ?>" class="btn btn-default"><i class='fa fa-file-excel-o'></i> <?php echo @Lib_Lang::translate(admin_order_list_exportbutton); ?></a>	
	<br />
	</p>
	<table class="table table-striped table-bordered table-hover">
	<thead>
		<tr>
			<th><?php echo ''; ?></th>
			<th><?php echo @Lib_Lang::translate(admin_orderproduct_info); ?></th>
			<th><?php echo @Lib_Lang::translate(admin_orderproduct_count); ?></th>
			<th><?php echo @Lib_Lang::translate(admin_orderproduct_price); ?></th>
		</tr>
	</thead>
	<tbody>
	<?php $i = 0; foreach ($this->dataProductOrder as $key => $val): $i++; ?>
		<tr>
			<td>
				<?php echo$i; ?>.
			</td>
			<td>
				<?php echo @Lib_Lang::consta(product_name_.$val['product_id']); ?>
				
				<?php if( $val['product_shop'] == 0 ){ ?>
				
					<script type="text/javascript" language="javascript">
						$(document).ready(function () {
							
							$("#produkt<?php echo $val['order_product_id']; ?>").load("<?php echo $this->url(array('controller' => 'admin', 'action' => 'ordereditproduct'), 'default', true); ?>",{product_id: '<?php echo$val['product_id']; ?>', order_product_id: '<?php echo$val['order_product_id']; ?>'}, function(){});
	
						});
					</script>
					<div id="produkt<?php echo $val['order_product_id']; ?>"></div>
				
				<?php } ?>
			</td>
			<td><?php echo $val['order_product_amount']; ?> x <b><?php echo number_format($val['order_product_price'], 2, ',', ' '); ?></b> zł</td>
			<td><?php echo number_format($val['order_product_amount']*$val['order_product_price'], 2, ',', ' '); ?></td>
		</tr>	
	<?php endforeach; ?>
	</tbody>
	</table>

	
		</div>
	</div>
		
	</form>	
		
</div>

<?php echo $this->render('admin/footer.phtml'); ?>