{strip} {if empty($status)} {$_title = _w("Marketing")} {elseif $status === shopPromoModel::STATUS_ACTIVE} {$_title = _w("Active promos")} {elseif $status === shopPromoModel::STATUS_PLANNED} {$_title = _w("Scheduled promos")} {elseif $status === shopPromoModel::STATUS_COMPLETED} {$_title = _w("Completed promos")} {/if} {$wa->title($_title)} {$_active_sort = [ "field" => ifset($sort, "field", "start_datetime"), "direction" => ifset($sort, "direction", "desc"), "page" => ifset($page, 1) ]} {function name="_render_sort_uri" _data=[]} {$_is_active = ($_data["field"] === $_active_sort["field"])} {$_params = []} {$_params["status"] = "completed"} {$_page = 1} {$_params["page"] = $_page} {$_field = $_data["field"]} {$_params["sort[field]"] = $_field} {$_direction = "desc"} {if !empty($_is_active) && $_active_sort["direction"] === "desc"} {$_direction = "asc"} {/if} {$_params["sort[direction]"] = $_direction} {$marketing_url}?{$_params|http_build_query} {/function} {function name="_render_sort_icon" _data=[]} {$_is_active = ($_data["field"] === $_active_sort["field"])} {if !empty($_is_active)} {$_icon_class = "down"} {if $_active_sort["direction"] === "asc"} {$_icon_class = "up"} {/if} {/if} {/function} {/strip} {function name="_render_promo" _promo=[]} {$_promo_classes = []} {if !empty($_promo.enabled)} {$_promo_classes[] = "is-active"} {elseif !empty($_promo.is_planned)} {$_promo_classes[] = "is-planned"} {else} {$_promo_classes[] = "is-paused"} {/if} {if empty($_promo.image)} {$_promo_classes[] = "without-image"} {/if}
{$_promo.name|default:"{_w('')}"|escape}
{$roi_value = ifset($promos_stats, $_promo.id, 'roi', null)} {if !empty($promos_stats[$_promo.id]['paid_for_itself'])} {$roi_class = 'green'} {else} {$roi_class = 'red'} {/if}
[`Orders`]
{ifset($promos_stats, $_promo.id, 'orders_count', 0)}
[`Sales`]
{shop_currency_html(ifset($promos_stats, $_promo.id, 'sales', 0))}
[`ROI`]
{if $roi_value !== null} {$roi_value}% {else} — {/if}
{foreach ifset($promos_markers, $_promo.id, []) as $marker}
{/foreach}
{$_bar_states = [ "active" => [ "id" => "active", "wrapper_class" => "is-active", "point_class" => "pointer js-pause-promo", "icon_class" => "play" ], "pause" => [ "id" => "pause", "wrapper_class" => "is-stopped", "point_class" => "pointer js-play-promo", "icon_class" => "ss pause" ], "complete" => [ "id" => "complete", "wrapper_class" => "is-completed", "icon_class" => "clock" ] ]} {if empty($_promo.enabled)} {$_bar_state = $_bar_states.pause} {elseif !empty($_promo.is_planned)} {$_bar_state = $_bar_states.complete} {else} {$_bar_state = $_bar_states.active} {/if} {$_percent = ifset($_promo, 'period_percent', 0)} {$_lift = (15 * 100/320)} {if $_percent > 100 - $_lift} {$_percent = 100 - $_lift} {elseif $_percent < $_lift} {$_percent = $_lift} {/if}
{/function} {* PAGE *}
{* HEADER *}

[`Promos on website`]

{strip} {/strip}
{* BODY *}
{if empty($status) || $status === shopPromoModel::STATUS_ACTIVE} {* ACTUAL *}

[`Active promos`]

{if !empty($active_storefront)}

[`Change the sort order of active promos by using drag&drop.`]

{else}

[`Select a storefront to change active promos’ sort order.`]

{/if} {if !empty($active_promos)}
{foreach $active_promos as $_promo} {_render_promo _promo=$_promo} {/foreach}
{else}

[`No active promos.`]

{/if}
{/if} {if empty($status) || $status === shopPromoModel::STATUS_PLANNED} {* PLANNED *}

[`Scheduled promos`]

{if !empty($planned_promos)}
{foreach $planned_promos as $_promo} {$_promo.is_planned = 1} {_render_promo _promo=$_promo} {/foreach}
{else}

[`No scheduled promos.`]

{/if}
{/if} {if empty($status) || $status === shopPromoModel::STATUS_COMPLETED} {* COMPLETED *}

[`Completed promos`]

[`Complete report`]
{if !empty($completed_promos)} {foreach $completed_promos as $_promo} {/foreach}
"name"]}"> [`Promo name`]{_render_sort_icon _data=["field" => "name"]} "start_datetime"]}"> [`Beginning`]{_render_sort_icon _data=["field" => "start_datetime"]} "finish_datetime"]}"> [`End`]{_render_sort_icon _data=["field" => "finish_datetime"]} "orders_count"]}"> [`Orders`]{_render_sort_icon _data=["field" => "orders_count"]} [`Sales`] [`ROI`]
{foreach ifset($promos_markers, $_promo.id, []) as $marker}
{/foreach}
{if !empty($_promo.start_datetime)} {$_promo.start_datetime|wa_date} {elseif !empty($_promo.create_datetime)} {$_promo.create_datetime|wa_date} {else} — {/if} {if !empty($_promo.finish_datetime)} {$_promo.finish_datetime|wa_date} {else} — {/if} {ifset($promos_stats, $_promo.id, 'orders_count', 0)} {shop_currency_html(ifset($promos_stats, $_promo.id, 'sales', 0))} {$roi_value = ifset($promos_stats, $_promo.id, 'roi', null)} {if !empty($promos_stats[$_promo.id]['paid_for_itself'])} {$roi_class = 'green'} {else} {$roi_class = 'red'} {/if} {if $roi_value !== null} {$roi_value}% {else} — {/if}
{$_url_params = ''} {$_get_params = waRequest::get()} {$_get_params['status'] = 'completed'} {foreach $_get_params as $_k => $_v} {if $_k != '_' && $_k != 'page' && $_v} {if is_array($_v)} {$_param = [$_k => $_v]} {$_url_params = "`$_url_params`&`$_param|http_build_query`"} {else} {$_url_params = "`$_url_params`&`$_k`=`$_v`"} {/if} {/if} {/foreach} {$_url_params = substr($_url_params, 1)} {$wa->shop->pager($total_completed_promos|default:0, $page, $_url_params)} {else}

[`No completed promos.`]

{/if}
{/if} {foreach $additional_html.bottom as $_html} {$_html} {/foreach}
{capture assign="_promo_pause_template_dialog"}

[`Pause promo`]

[`Promo “%promo_name%” will be paused.`]

[`Operation of all tools enabled for this promo will be discontinued—special product prices will be replaced by their ordinary prices, UTM tags will no longer be used to register incoming customer traffic, orders will not be counted by applied coupons, etc.`]

{/capture} {capture assign="_promo_play_template_dialog"}

[`Resume promo`]

[`Promo “%promo_name%” will be resumed.`]

{/capture} {capture assign="_sort_notice_dialog"}

[`Promos cannot be sorted`]

[`Select a storefront to change active promos’ sort order.`]

{/capture}