<link rel="stylesheet" href="{{ IncludeAsset('assets/lib/bootstrap-switch/css/bootstrap-switch.min.css') }}">
<link rel="stylesheet" href="{{ IncludeAsset('assets/lib/validationengine/css/validationEngine.jquery.css') }}">
<link rel="stylesheet" href="{{ IncludeAsset('assets/lib/summernote/css/summernote.css') }}">
<link rel="stylesheet" href="{{ IncludeAsset('assets/lib/chosen/css/chosen.min.css') }}">
<link rel="stylesheet" href="{{ IncludeAsset('assets/lib/tagsinput/css/jquery.tagsinput.css') }}">
<link rel="stylesheet" href="{{ IncludeAsset('assets/lib/datepicker/css/datepicker.css') }}">

<!--BEGIN INPUT TEXT FIELDS-->
<div class="row">
<div class="col-lg-12">
<form class="form-horizontal" id="ad-edit" enctype="multipart/form-data" method="post">
<div class="box dark">
<header>
	<div class="icons">
		<i class="fa fa-edit"></i>
	</div>
	<h5>
		<check if="{{ @ad->title==''}}">
			<true>
				{{ @lang_create_a_new_ad }}
			</true>
			<false>
				{{ @lang_edit }} - {{ @ad->title }} <small>| {{ @lang_last_updated }} {{ @time_last_updated }} {{ @lang_by }} {{ @ad->user_id->username }}</small>
			</false>
		</check>

	</h5>
</header>
<check if ="{{ @USER->role > 7 }}">

<!-- form section -->
<div class="row">
	<div class="col-lg-1">
		&nbsp;
	</div>
	<div class="col-lg-10">

		<div class="box dark">
			<header>
				<h5>
					{{ @lang_about_the_ad }} <small>| {{ @lang_ad_status_and_description }}</small>
				</h5>
				<!-- .toolbar -->
				<div class="toolbar">
					<ul class="nav">
						<li>
							<a class="minimize-box" data-toggle="collapse" href="#div-1">
								<i class="fa fa-chevron-up"></i>
							</a>
						</li>
					</ul>
				</div><!-- /.toolbar -->
			</header>

			<div id="div-1" class="accordion-body collapse in body">

				<check if="{{ ((!@ad->_id) || (@ad->approved == 1)) }}">
					<true>
						<div class="form-group">
							<label for="status" class="tips control-label col-lg-3"
							       title="{{ @lang_select_off_to_disable_the_ad }}.">{{ @lang_status }}</label>
							<div class="col-lg-5">
								<input type="hidden" name="status" value="0">
								<input id="status" name="status" type="checkbox" value="1" <check if="{{ @ad->status }}">checked</check>
								class="switch-small"
								data-on="success" data-off="danger"
								data-on-label="{{ @lang_on }}" data-off-label="{{ @lang_off }}">
							</div>
						</div><!-- /.form-group -->
					</true>
					<false>
						<div class="form-group">
							<label for="status" class="tips control-label col-lg-3"
							       title="{{ @lang_select_yes_to_approve_the_ad__this_will_also_set_the_status_to_on_ }}.">{{ @lang_approved }}</label>
							<div class="col-lg-5">
								<input type="hidden" name="approved" value="0">
								<input id="approved" name="approved" type="checkbox" value="1" <check if="{{ @ad->approved }}">checked</check>
								class="switch-small"
								data-on="success" data-off="danger"
								data-on-label="{{ @lang_yes }}" data-off-label="{{ @lang_no }}">
							</div>
						</div><!-- /.form-group -->
					</false>
				</check>
				<div class="form-group">
					<label for="title" class="tips control-label col-lg-3" title="{{ @lang_enter_in_a_title_for_the_ad }}.">* {{ @lang_adtitle }}</label>
					<div class="col-lg-8">
						<input class="form-control" type="text" id="title" name="title" value="{{ @ad->title }}" maxlength="256" />
					</div>
				</div><!-- /.form-group -->
				<div class="form-group">
					<label for="notes" class="tips control-label col-lg-3" title="{{ @lang_enter_in_any_notes_for_the_ad }}."> {{ @lang_notes }}</label>
					<div class="col-lg-8">
						<textarea id="notes" name="notes" class="form-control">{{ @ad->notes }}</textarea>
					</div>
				</div><!-- /.form-group -->
				<div class="form-group">
					<label for="advertiser" class="tips control-label col-lg-3"
					       title="{{ @lang_optionally_assign_an_advertiser_for_tracking_purposes }}. {{ @lang_create_new_advertisers_in_the_users_section }}.">{{ @lang_advertiser2 }}</label>
					<div class="col-lg-5">
						<select id="advertiser" name="advertiser" data-placeholder="{{ @lang_optionally_select_an_advertiser }}" class="form-control chzn-select">
							<option value = "" <check if="{{ empty(@ad->advertiser) }}">selected</check>></option>
							<repeat group="{{ @res_users }}" value="{{ @res_user }}">
								<option value="{{ @res_user->_id }}" <check if="{{ ((!empty(@ad->advertiser)) && (@res_user->_id == @ad->advertiser->_id)) }}">selected</check>>{{ @res_user->username }}</option>
							</repeat>
						</select>
					</div>
				</div><!-- /.form-group -->
			</div>
		</div>
	</div>
</div>
<!-- /form section -->

<!-- form section -->
<div class="row">
	<div class="col-lg-1">
		&nbsp;
	</div>
	<div class="col-lg-10">
		<div class="box dark">
			<header>
				<h5>
					{{ @lang_ad_grouping }} <small>| {{ @lang_ad_grouping_for_this_ad }}</small>
				</h5>
				<!-- .toolbar -->
				<div class="toolbar">
					<ul class="nav">
						<li>
							<a class="minimize-box" data-toggle="collapse" href="#div-2">
								<i class="fa fa-chevron-up"></i>
							</a>
						</li>
					</ul>
				</div><!-- /.toolbar -->
			</header>

			<div id="div-2" class="accordion-body collapse in body">
				<div class="form-group">
					<label for="groups" class="tips control-label col-lg-3"
					       title="{{ @lang_select_any_ad_groupings }}. {{ @lang_all_ads_in_the_same_group_will_be_cycled_together }}.">{{ @lang_ad_group_membership }}</label>
					<div class="col-lg-5">
						<select id="groups" name="groups[]" data-placeholder="{{ @lang_select_any_groups }}" class="form-control chzn-select" multiple>
							<repeat group="{{ @res_groups }}" value="{{ @res_group }}">
								<option value="{{ @res_group._id }}" <check if="{{ in_array(@res_group._id, @group_ids)}}">selected</check>>{{ @res_group.title }}</option>
							</repeat>
						</select>
					</div>
				</div><!-- /.form-group -->
				<div class="form-group">
					<label for="keywords" class="tips control-label col-lg-3" title="{{ @lang_comma_separated_list_of_keywords_to_target_this_ad_ }}">{{ @lang_keywords }}</label>
					<div class="col-lg-8">
						<input class="form-control" type="text" id="keywords" name="keywords" data-placement="top" value="{{ @ad->keywords }}" maxlength="256" />
					</div>
				</div><!-- /.form-group -->

			</div>
		</div>
	</div>
</div>
<!-- /form section -->

<!-- form section -->
<div class="row">
	<div class="col-lg-1">
		&nbsp;
	</div>
	<div class="col-lg-10">

		<div class="box dark">
			<header>
				<h5>
					{{ @lang_ad_limiting }} <small>| {{ @lang_ad_limits_and_weighting }}</small>
				</h5>
				<!-- .toolbar -->
				<div class="toolbar">
					<ul class="nav">
						<li>
							<a class="minimize-box" data-toggle="collapse" href="#div-3">
								<i class="fa fa-chevron-up"></i>
							</a>
						</li>
					</ul>
				</div><!-- /.toolbar -->
			</header>

			<div id="div-3" class="accordion-body collapse in body">
				<div class="form-group">
					<label for="weight" class="tips control-label col-lg-3" title="{{ @lang_set_the_weight__with_10_being_shown_the_most_often__and_0_only_shown_when_no_other_ads_are_available }}.">* {{ @lang_weight }}</label>
					<div class="col-lg-2">
						<input class="form-control" type="text" id="weight" name="weight" value="{{ @ad->weight }}" />
					</div>
				</div><!-- /.form-group -->
				<div class="form-group">
					<label for="start_date" class="tips control-label col-lg-3"
					       title="{{ @lang_you_can_select_a_date_for_the_ad_to_start_showing }} (yyyy-mm-dd).">{{ @lang_ad_start_date }}</label>
					<div class="col-lg-2">
						<input class="form-control datepicker" type="text" id="start_date" name="start_date" value="{{ @ad->start_date }}" />
					</div>
				</div><!-- /.form-group -->
				<div class="form-group">
					<label for="end_date" class="tips control-label col-lg-3"
					       title="{{ @lang_you_can_select_a_date_for_the_ad_to_stop_showing }} (yyyy-mm-dd).">{{ @lang_ad_end_date }}</label>
					<div class="col-lg-2">
						<input class="form-control datepicker" type="text" id="end_date" name="end_date" value="{{ @ad->end_date }}" />
					</div>
				</div><!-- /.form-group -->
				<hr />
				<div class="form-group">
					<label for="impressions_limit_num" class="tips control-label col-lg-3" title="{{ @lang_enter_the_number_of_impressions_to_allow_in_the_entered_timeframe }}.">{{ @lang_limit_impressions }}</label>
					<div class="col-lg-2">
						<input class="form-control" type="text" id="impressions_limit_num" name="impressions_limit_num" value="{{ @ad->impressions_limit_num }}" />
					</div>
				</div><!-- /.form-group -->
				<div class="form-group">
					<label for="clicks_limit_num" class="tips control-label col-lg-3" title="{{ @lang_enter_the_number_of_clicks_to_allow_in_the_entered_timeframe }}.">{{ @lang_limit_clicks }}</label>
					<div class="col-lg-2">
						<input class="form-control" type="text" id="clicks_limit_num" name="clicks_limit_num" value="{{ @ad->clicks_limit_num }}" />
					</div>
				</div><!-- /.form-group -->
				<div class="form-group">
					<label for="limit_time" class="tips control-label col-lg-3" title="{{ @lang_enter_the_number_of_days_in_the_limit_cycle }}.">{{ @lang_limit_timeframe }}</label>
					<div class="col-lg-2">
						<div class="input-group">
							<input class="form-control" type="text" id="limit_time" name="limit_time" value="{{ @ad->limit_time }}" /><span class="input-group-addon">days</span>
						</div>
					</div>
				</div><!-- /.form-group -->
			</div>
		</div>
	</div>
</div>
<!-- /form section -->

<!-- form section -->
<div class="row">
	<div class="col-lg-1">
		&nbsp;
	</div>
	<div class="col-lg-10">

		<div class="box dark">
			<header>
				<h5>
					{{ @lang_geotargeting }} <small>| {{ @lang_where_ads_are_shown }}</small>
				</h5>
				<!-- .toolbar -->
				<div class="toolbar">
					<ul class="nav">
						<li>
							<a class="minimize-box" data-toggle="collapse" href="#div-4">
								<i class="fa fa-chevron-up"></i>
							</a>
						</li>
					</ul>
				</div><!-- /.toolbar -->
			</header>

			<div id="div-4" class="accordion-body collapse in body">
				<div class="form-group">
					<label for="geo_onoff" class="tips control-label col-lg-3" title="{{ @lang_select__in_selected_only__to_show_only_in_those_select_locations__or__all_but_selected__to_show_in_locations_other_than_those_selected }}.">{{ @lang_in_or_not_in }}</label>
					<div class="col-lg-3">
						<select class="form-control" id="geo_onoff" name="geo_onoff">
							<option value="1" <check if="{{ @ad->geo_onoff == 1}}">selected</check>>{{ @lang_in_selected_only }}</option>
							<option value="2" <check if="{{ @ad->geo_onoff == 2}}">selected</check>>{{ @lang_in_all_but_selected }}</option>
							<option value="0" <check if="{{ @ad->geo_onoff == 0}}">selected</check>></option>
						</select>
					</div>
				</div><!-- /.form-group -->
				<div class="form-group">
					<label for="geo_countries" class="tips control-label col-lg-3"
					       title="{{ @lang_any_countries_to_display__or_not_display_this_ad_in }}. {{ @lang_select_in_or_not_in_first }}.">{{ @lang_countries }}</label>
					<div class="col-lg-5">
						<select id="geo_countries" name="geo_countries[]" data-placeholder="{{ @lang_select_any_countries }}" class="form-control chzn-select" multiple <check if="{{ @ad->geo_countries == null }}"> disabled="disabled"</check> >
						<repeat group="{{ @arrCountries }}" value="{{ @country }}">
							<option value="{{ @country.country_code }}" <check if="{{ in_array(@country.country_code,@ad->geo_countries) }}">selected</check> >{{ @country.name }}</option>
						</repeat>
						</select>
					</div>
				</div><!-- /.form-group -->
				<div class="form-group">
					<label for="geo_regions" class="tips control-label col-lg-3"
					       title="{{ @lang_any_regions_to_display__or_not_display_this_ad_in }}. {{ @lang_select_a_country_first }}.">{{ @lang_regions }}</label>
					<div class="col-lg-5">
						<select id="geo_regions" name="geo_regions[]" data-placeholder="{{ @lang_select_any_regions }}" class="form-control chzn-select" multiple <check if="{{ @ad->geo_regions == null }}"> disabled="disabled"</check>>
						<check if="{{ @ad->geo_regions == null }}">
							<true>
								<option value=""></option>
							</true>
							<false>
								<repeat group="{{ @arrRegions }}" value="{{ @region }}">
									<option value="{{ @region.country_code.'|'.@region.region_code }}" <check if="{{ in_array(@region.country_code.'|'.@region.region_code,@ad->geo_regions) }}">selected</check> >{{ @region.name }}</option>
								</repeat>
							</false>
						</check>
						</select>
					</div>
				</div><!-- /.form-group -->
				<div class="form-group">
					<label for="geo_cities" class="tips control-label col-lg-3"
					       title="{{ @lang_any_cities_to_display__or_not_display_this_ad_in }}. {{ @lang_select_a_region_first }}.">{{ @lang_cities }}</label>
					<div class="col-lg-5">
						<select id="geo_cities" name="geo_cities[]" data-placeholder="{{ @lang_select_any_cities }}" class="form-control chzn-select" multiple <check if="{{ @ad->geo_cities == null }}"> disabled="disabled"</check>>
						<check if="{{ @ad->geo_cities == null }}">
							<true>
								<option value=""></option>
							</true>
							<false>
								<repeat group="{{ @arrCities }}" value="{{ @city }}">
									<option value="{{ @city.country_code.'|'.@city.region_code.'|'.@city.name_encoded }}" <check if="{{ in_array(@city.country_code.'|'.@city.region_code.'|'.@city.name_encoded, @ad->geo_cities) }}">selected</check> >{{ @city.name }}</option>
								</repeat>
							</false>
						</check>
						</select>
					</div>
				</div><!-- /.form-group -->

			</div>
		</div>
	</div>
</div>
<!-- /form section -->
</check>

<include href="{{ @include_type }}" ></include>

<div class="row">
	<div class="col-lg-1">
		&nbsp;
	</div>
	<div class="col-lg-10">
		<br />
		<button type="submit" class="btn btn-success" id="save">{{ @lang_save }}</button>&nbsp;
		<a href="index.php?ads&list " class="btn btn-sm btn-metis-5">{{ @lang_cancel }}</a>
		<div><br /></div>
	</div>
</div>

</div>
<input type="hidden" name="type" id="type" value="{{ @ad->type}}" />
<input type="hidden" name="type_{{ @ad.type }}" id="type_{{ @ad.type }}" value="1" />
</form>
</div>
</div>
