<xf:if is="$entry.isInsert()">
	<xf:title>{{ phrase('add_cron_entry') }}</xf:title>
<xf:else />
	<xf:title>{{ phrase('edit_cron_entry:') }} {$entry.title}</xf:title>
</xf:if>

<xf:pageaction if="$entry.isUpdate() AND $entry.canEdit()">
	<xf:button href="{{ link('cron/delete', $entry) }}" icon="delete" overlay="true" />
</xf:pageaction>

<xf:if is="{{ !$entry.canEdit() }}">
	<div class="blockMessage blockMessage--important blockMessage--iconic">
		{{ phrase('only_limited_fields_in_item_may_be_edited') }}
	</div>
</xf:if>

<xf:form action="{{ link('cron/save', $entry) }}" ajax="true" class="block">

	<div class="block-container">
		<div class="block-body">

			<xf:textboxrow name="entry_id" value="{$entry.entry_id}" maxlength="{{ max_length($entry, 'entry_id') }}"
				readonly="{{ !$entry.canEdit() }}"
				label="{{ phrase('cron_entry_id') }}"
				dir="ltr" />

			<xf:textboxrow name="title" value="{{ $entry.exists() ? $entry.MasterTitle.phrase_text : '' }}"
				readonly="{{ !$entry.canEdit() }}"
				label="{{ phrase('title') }}" />

			<hr class="formRowSep" />

			<xf:formrow rowtype="input"
				label="{{ phrase('cron_callback') }}">

				<xf:macro template="helper_callback_fields" name="callback_fields" arg-data="{$entry}"
					arg-className="cron_class"
					arg-methodName="cron_method"
					arg-readOnly="{{ !$entry.canEdit() }}" />
			</xf:formrow>

			<hr class="formRowSep" />

			<xf:radiorow name="run_rules[day_type]" value="{$entry.run_rules.day_type}"
				readonly="{{ !$entry.canEdit() }}"
				label="{{ phrase('run_on_type_of_day') }}">

				<xf:option value="dom" label="{{ phrase('day_of_month:') }}">
					<xf:select name="run_rules[dom]"
						readonly="{{ !$entry.canEdit() }}"
						value="{$entry.run_rules.dom|raw}"
						multiple="true" size="8" style="width: 200px">

						<xf:option value="-1">{{ phrase('any') }}</xf:option>
						<xf:option value="1">1</xf:option>
						<xf:option value="2">2</xf:option>
						<xf:option value="3">3</xf:option>
						<xf:option value="4">4</xf:option>
						<xf:option value="5">5</xf:option>
						<xf:option value="6">6</xf:option>
						<xf:option value="7">7</xf:option>
						<xf:option value="8">8</xf:option>
						<xf:option value="9">9</xf:option>
						<xf:option value="10">10</xf:option>
						<xf:option value="11">11</xf:option>
						<xf:option value="12">12</xf:option>
						<xf:option value="13">13</xf:option>
						<xf:option value="14">14</xf:option>
						<xf:option value="15">15</xf:option>
						<xf:option value="16">16</xf:option>
						<xf:option value="17">17</xf:option>
						<xf:option value="18">18</xf:option>
						<xf:option value="19">19</xf:option>
						<xf:option value="20">20</xf:option>
						<xf:option value="21">21</xf:option>
						<xf:option value="22">22</xf:option>
						<xf:option value="23">23</xf:option>
						<xf:option value="24">24</xf:option>
						<xf:option value="25">25</xf:option>
						<xf:option value="26">26</xf:option>
						<xf:option value="27">27</xf:option>
						<xf:option value="28">28</xf:option>
						<xf:option value="29">29</xf:option>
						<xf:option value="30">30</xf:option>
						<xf:option value="31">31</xf:option>
					</xf:select>
				</xf:option>
				<xf:option value="dow" label="{{ phrase('day_of_week:') }}">
					<xf:select name="run_rules[dow]"
						readonly="{{ !$entry.canEdit() }}"
						value="{$entry.run_rules.dow|raw}"
						multiple="true" size="8" style="width: 200px">

						<xf:option value="-1">{{ phrase('any') }}</xf:option>
						<xf:option value="0">{{ phrase('day_sunday') }}</xf:option>
						<xf:option value="1">{{ phrase('day_monday') }}</xf:option>
						<xf:option value="2">{{ phrase('day_tuesday') }}</xf:option>
						<xf:option value="3">{{ phrase('day_wednesday') }}</xf:option>
						<xf:option value="4">{{ phrase('day_thursday') }}</xf:option>
						<xf:option value="5">{{ phrase('day_friday') }}</xf:option>
						<xf:option value="6">{{ phrase('day_saturday') }}</xf:option>
					</xf:select>
				</xf:option>
			</xf:radiorow>

			<xf:selectrow name="run_rules[hours]"
				readonly="{{ !$entry.canEdit() }}"
				value="{$entry.run_rules.hours|raw}"
				multiple="true" size="8" style="width: 200px"
				label="{{ phrase('run_at_hours') }}">

				<xf:option value="-1">{{ phrase('any') }}</xf:option>
				<xf:option value="0">0 {{ phrase('(midnight)') }}</xf:option>
				<xf:option value="1">1</xf:option>
				<xf:option value="2">2</xf:option>
				<xf:option value="3">3</xf:option>
				<xf:option value="4">4</xf:option>
				<xf:option value="5">5</xf:option>
				<xf:option value="6">6</xf:option>
				<xf:option value="7">7</xf:option>
				<xf:option value="8">8</xf:option>
				<xf:option value="9">9</xf:option>
				<xf:option value="10">10</xf:option>
				<xf:option value="11">11</xf:option>
				<xf:option value="12">12 {{ phrase('(noon)') }}</xf:option>
				<xf:option value="13">13</xf:option>
				<xf:option value="14">14</xf:option>
				<xf:option value="15">15</xf:option>
				<xf:option value="16">16</xf:option>
				<xf:option value="17">17</xf:option>
				<xf:option value="18">18</xf:option>
				<xf:option value="19">19</xf:option>
				<xf:option value="20">20</xf:option>
				<xf:option value="21">21</xf:option>
				<xf:option value="22">22</xf:option>
				<xf:option value="23">23</xf:option>

				<xf:explain>{{ phrase('run_times_based_on_utc_time_zone') }}</xf:explain>
			</xf:selectrow>

			<xf:selectrow name="run_rules[minutes]"
				readonly="{{ !$entry.canEdit() }}"
				value="{$entry.run_rules.minutes|raw}"
				multiple="true" size="8" style="width: 200px"
				label="{{ phrase('run_at_minutes') }}">

				<xf:option value="-1">{{ phrase('any') }}</xf:option>
				<xf:option value="0">0</xf:option>
				<xf:option value="1">1</xf:option>
				<xf:option value="2">2</xf:option>
				<xf:option value="3">3</xf:option>
				<xf:option value="4">4</xf:option>
				<xf:option value="5">5</xf:option>
				<xf:option value="6">6</xf:option>
				<xf:option value="7">7</xf:option>
				<xf:option value="8">8</xf:option>
				<xf:option value="9">9</xf:option>
				<xf:option value="10">10</xf:option>
				<xf:option value="11">11</xf:option>
				<xf:option value="12">12</xf:option>
				<xf:option value="13">13</xf:option>
				<xf:option value="14">14</xf:option>
				<xf:option value="15">15</xf:option>
				<xf:option value="16">16</xf:option>
				<xf:option value="17">17</xf:option>
				<xf:option value="18">18</xf:option>
				<xf:option value="19">19</xf:option>
				<xf:option value="20">20</xf:option>
				<xf:option value="21">21</xf:option>
				<xf:option value="22">22</xf:option>
				<xf:option value="23">23</xf:option>
				<xf:option value="24">24</xf:option>
				<xf:option value="25">25</xf:option>
				<xf:option value="26">26</xf:option>
				<xf:option value="27">27</xf:option>
				<xf:option value="28">28</xf:option>
				<xf:option value="29">29</xf:option>
				<xf:option value="30">30</xf:option>
				<xf:option value="31">31</xf:option>
				<xf:option value="32">32</xf:option>
				<xf:option value="33">33</xf:option>
				<xf:option value="34">34</xf:option>
				<xf:option value="35">35</xf:option>
				<xf:option value="36">36</xf:option>
				<xf:option value="37">37</xf:option>
				<xf:option value="38">38</xf:option>
				<xf:option value="39">39</xf:option>
				<xf:option value="40">40</xf:option>
				<xf:option value="41">41</xf:option>
				<xf:option value="42">42</xf:option>
				<xf:option value="43">43</xf:option>
				<xf:option value="44">44</xf:option>
				<xf:option value="45">45</xf:option>
				<xf:option value="46">46</xf:option>
				<xf:option value="47">47</xf:option>
				<xf:option value="48">48</xf:option>
				<xf:option value="49">49</xf:option>
				<xf:option value="50">50</xf:option>
				<xf:option value="51">51</xf:option>
				<xf:option value="52">52</xf:option>
				<xf:option value="53">53</xf:option>
				<xf:option value="54">54</xf:option>
				<xf:option value="55">55</xf:option>
				<xf:option value="56">56</xf:option>
				<xf:option value="57">57</xf:option>
				<xf:option value="58">58</xf:option>
				<xf:option value="59">59</xf:option>
			</xf:selectrow>

			<hr class="formRowSep" />

			<xf:checkboxrow>
				<xf:option name="active" selected="$entry.active"
					hint="{{ ($xf.development AND $entry.addon_id) ? phrase('field_value_maintained_addon_upgrade_explain') : '' }}">
					{{phrase('allow_cron_entry_to_run_automatically_when_scheduled') }}
				</xf:option>
			</xf:checkboxrow>

			<xf:macro template="addon_macros" name="addon_edit" arg-addOnId="{$entry.addon_id}" />
		</div>

		<xf:submitrow sticky="true" icon="save" />
	</div>

	<xf:hiddenval name="original_entry_id">{$entry.entry_id}</xf:hiddenval>
</xf:form>