<?php
	Assets::add( 'tinymce' );
	Assets::add( 'dropzone' );
	Assets::add( 'contents.min.js' );
	// Assets::add( 'contents.css' );
	AMIB::add_js_translation( trans( 'content.js-msgs' ) );
	AMIB::add_js_translation( trans( 'main.dz-js' ) );
?>
<?php $__env->startSection( 'head' ); ?>
	<script>
		var deleteUrl = "<?php echo e(route( 'delete-content-ajax' )); ?>";
		var getDataUrl = "<?php echo e(route( 'get-content-data-ajax' )); ?>";
		var uploadUrl = "<?php echo e(route( 'att-upload' )); ?>";
	</script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection( 'content' ); ?>
	<?php echo Form::model( $old_search_data, array( 'method' => 'get', 'id' => 'search_form' ) ); ?>

		<?php echo Form::label( 's_title', trans( 'content.title' ) ); ?>

		<?php echo Form::text( 's_title' ); ?>

		<?php echo Form::label( 's_type', trans( 'content.type' ) ); ?>

		<?php echo Form::select( 's_type', $s_types_select ); ?>

		<?php echo Form::submit( trans( 'main.search' ) ); ?>

	<?php echo Form::close(); ?>


	<?php if( count( $contents ) ): ?>
		<table id="contents-table" class="default">
			<thead>
				<tr>
					<th><?php echo trans( 'main.row' ); ?></th>
					<th><?php echo trans( 'content.title' ); ?></th>
					<th><?php echo trans( 'content.url' ); ?></th>
					<th><?php echo trans( 'content.type' ); ?></th>
					<th><?php echo trans( 'content.course_id' ); ?></th>
					<th></th>
				</tr>
			</thead>
			<tbody>
				<?php $row = $contents->getFrom(); ?>
				<?php foreach( $contents as $content ): ?>
					<tr data-id="<?php echo $content->id; ?>">
						<td><?php echo en2fa( $row++ ); ?></td>
						<td><?php echo e($content->title); ?></td>
						<td><input type="text" readonly value="<?php echo content_route( $content ); ?>"></td>
						<td><div class="tag"><?php echo $content->type_text; ?></div></td>
						<td><?php echo e($content->course_name); ?></td>
						<td>
							<?php echo HTML::link( '#', trans( 'main.edit' ), [ 'class' => 'button edit' ] ); ?>

							<?php echo HTML::link( '#', trans( 'main.delete' ), [ 'class' => 'button delete' ] ); ?>

						</td>
					</tr>
				<?php endforeach; ?>
			</tbody>
		</table>
		<div>
			<?php echo $contents->appends( $old_search_data )->links(); ?>

		</div>
	<?php else: ?>
		<div class="info-message"><?php echo trans( 'main.empty' ); ?></div>
	<?php endif; ?>

	<hr>

	<?php echo HTML::link( '#', trans( 'content.new' ), [ 'class' => 'button add-new' ] ); ?>


	<div id="add-edit-popup" class="white-popup mfp-hide mfp-with-anim">
		<?php echo Form::open( [ 'route' => 'add-edit-content-ajax', 'files' => true ] ); ?>

			<?php echo Form::hidden( 'old_id', null, [ 'id' => 'old_id' ] ); ?>

			<table>
				<tr>
					<td><?php echo Form::label( 'title', trans( 'content.title' ), [ 'class' => 'required' ] ); ?></td>
					<td><?php echo Form::text( 'title' ); ?></td>
				</tr>

				<tr>
					<td><?php echo Form::label( 'type', trans( 'content.type' ) ); ?></td>
					<td><?php echo Form::select( 'type', $types_select ); ?></td>
				</tr>

				<tr id="course-selection-row">
					<td><?php echo Form::label( 'course_id', trans( 'content.course_id' ) ); ?></td>
					<td><?php echo Form::select( 'course_id', $courses_select ); ?></td>
				</tr>

				<tr>
					<td><?php echo Form::label( 'body', trans( 'content.body' ), [ 'class' => 'required' ] ); ?></td>
					<td><?php echo Form::textarea( 'body' ); ?></td>
				</tr>
				
				<tr>
					<td><?php echo Form::label( 'image', trans( 'content.image' ) ); ?></td>
					<td><?php echo Form::file( 'image' ); ?></td>
				</tr>

				<tr>
					<td><?php echo Form::label( 'files', trans( 'content.files' ) ); ?></td>
					<td><?php echo $__env->make( 'inc.dropzone' , array_except(get_defined_vars(), array('__data', '__path')))->render(); ?></td>
				</tr>

				<!-- <tr>
					<td><?php echo Form::label( 'menu_order', trans( 'content.menu_order' ) ); ?></td>
					<td><?php echo Form::text( 'menu_order', '0' ); ?></td>
				</tr> -->

				<tr>
					<td colspan="2">
						<div class="progress"><div></div></div>
						<?php echo Form::submit( trans( 'main.save' ) ); ?>

					</td>
				</tr>
			</table>
		<?php echo Form::close(); ?>

	</div>
<?php $__env->stopSection(); ?>