<?php
use yii\helpers\Html;
use frontend\models\Uploads;
if (Yii::$app->user->identity->ingroup('Global Admins') == true) {
	$uploads = Uploads::find()
	->select([
		'category', 
		'title', 
		'revision', 
		'status', 
		'jobno', 
		'created_at', 
		'updated_at', 
		'id', 
	])
	->where(['or', ['jobno' => $model->jobno], ['actid' => $model->id]])
	->andwhere(['not', ['status' => 'Deleted']])
	->orderby(['category' => SORT_ASC])
	->all();
} else {
	$uploads = Uploads::find()
	->select([
		'category', 
		'title', 
		'revision', 
		'status', 
		'jobno', 
		'created_at', 
		'updated_at', 
		'id', 
	])
	->where(['or', ['jobno' => $model->jobno], ['actid' => $model->id]])
	->orWhere(['actid' => $model->id])
	->andwhere(['not', ['status' => 'Deleted']])
	->andwhere(['category' => 'TEF'])
	->all();
}
?>
<div class="Uploaders">
	<div class="row">
		<div class="col-md-2 center">TEF</div>
		<div class="col-md-2 center">Order</div>
		<div class="col-md-2 center">Quotation</div>
		<div class="col-md-2 center">Enquiry</div>
		<div class="col-md-2 center">Other</div>
	</div>
	<div class="row">
		<div class="col-md-2">
			<?= \kartik\file\FileInput::widget([
		    'name' => 'upload',
		    'options'=>[
		        'multiple'=>true,
		        'webkitdirectory' =>true
		    	],
		    'pluginOptions' => [
		        'uploadUrl' => \yii\helpers\Url::to(['/upload/ajaxdbupload', 'relatedid' => $model->id, 'relatedto' => $model->jobno, 'category' => 'TEF']),
		        'maxFileCount' => 10,
		    ]
			]); ?>
			
		</div>
		<div class="col-md-2">
			<?= \kartik\file\FileInput::widget([
		    'name' => 'upload',
		    'options'=>[
		        'multiple'=>true,
		        'webkitdirectory' =>true
		    	],
		    'pluginOptions' => [
		        'uploadUrl' => \yii\helpers\Url::to(['/upload/ajaxdbupload', 'relatedid' => $model->id, 'relatedto' => $model->jobno, 'category' => 'Order']),
		        'maxFileCount' => 10,
		    ]
			]); ?>	
		</div>
		<div class="col-md-2">
			<?= \kartik\file\FileInput::widget([
		    'name' => 'upload',
		    'options'=>[
		        'multiple'=>true,
		        'webkitdirectory' =>true
		    	],
		    'pluginOptions' => [
		        'uploadUrl' => \yii\helpers\Url::to(['/upload/ajaxdbupload', 'relatedid' => $model->id, 'relatedto' => $model->jobno, 'category' => 'Quotation']),
		        'maxFileCount' => 10,
		    ]
			]); ?>	
		</div>
		<div class="col-md-2">
			<?= \kartik\file\FileInput::widget([
		    'name' => 'upload',
		    'options'=>[
		        'multiple'=>true,
		        'webkitdirectory' =>true
		    	],
		    'pluginOptions' => [
		        'uploadUrl' => \yii\helpers\Url::to(['/upload/ajaxdbupload', 'relatedid' => $model->id, 'relatedto' => $model->jobno, 'category' => 'Enquiry']),
		        'maxFileCount' => 10,
		    ]
			]); ?>	
		</div>
		<div class="col-md-2">
			<?= \kartik\file\FileInput::widget([
		    'name' => 'upload',
		    'options'=>[
		        'multiple'=>true,
		        'webkitdirectory' =>true
		    	],
		    'pluginOptions' => [
		        'uploadUrl' => \yii\helpers\Url::to(['/upload/ajaxdbupload', 'relatedid' => $model->id, 'relatedto' => $model->jobno, 'category' => 'Other']),
		        'maxFileCount' => 10,
		    ]
			]); ?>	
		</div>
	</div>
	
	<div class="files">
		<?= $this->render('//upload/files', ['files' => $uploads]); ?>
	</div>
	
	
</div>




