{$_title = "[`Reports`]"} {$_is_won_chart = waRequest::request("chart", null)} {* DATE *} {$filter_dates = [ "30" => [ "id" => "30", "uri" => crmHelper::getUrl(["timeframe" => 30, "start" => null, "end" => null]), "name" => _w('Last %d day', 'Last %d days', 30), "group_by" => "days", "timeframe" => 30 ], "90" => [ "id" => "90", "uri" => crmHelper::getUrl(["timeframe" => 90, "start" => null, "end" => null]), "name" => _w('Last %d day', 'Last %d days', 90), "group_by" => "days", "timeframe" => 90 ], "365" => [ "id" => "365", "uri" => crmHelper::getUrl(["timeframe" => 365, "start" => null, "end" => null]), "name" => _w('Last %d day', 'Last %d days', 365), "group_by" => "months", "timeframe" => 365 ], "all" => [ "id" => "all", "uri" => crmHelper::getUrl(["timeframe" => "all", "start" => null, "end" => null]), "name" => "[`All time`]", "group_by" => "months", "timeframe" => "all" ], "custom" => [ "id" => "custom", "uri" => "javascript:void(0);", "name" => "[`Select dates...`]", "group_by" => "", "timeframe" => "custom" ] ]} {if $timeframe && !empty($filter_dates[$timeframe])} {$selected_filter_date = $filter_dates[$timeframe]} {else} {$selected_filter_date = reset($filter_dates)} {/if}
{* need for generation uri, "custom" timeframe *} {foreach $fields as $_field} {if !empty($active_fields[$_field.id])} {/if} {/foreach}
{if !empty($charts)}{/if}
{if !empty($stages) && !empty($closed)} {* Default view *} {if empty($charts)}

{$won_deals_stat.count} {_w('deal won', 'deals won', $won_deals_stat.count)}. [`Total won amount`]: {$won_deals_stat.amount|wa_format_amount_currency:$won_deals_stat.currency_id}

{$_stages_count = $stages|count} {$_start = 100} {$_min = 30} {$_count = _w('%d deal', '%d deals', $closed)} {foreach $stages as $_stage} {$_opacity = ($_min + ( (100 - $_min) * $_stage@iteration/$_stages_count))/100} {$_percent = $_stage.rest_percent|floor} {$_start = $_percent} {$_count = _w('%d deal', '%d deals', $_stage.rest)} {/foreach}
{$_stage.name|escape}
{$_count}
{$_percent}% ({_w('%d deal lost', '%d deals lost', $_stage.lost)})
[`WON`]
{$_count}
{if !empty($reasons)} {$_min = 0} {$_max = 0} {foreach $reasons as $_reason} {if $_reason.cnt > $_max} {$_max = $_reason.cnt} {/if} {if $_reason.cnt < $_min} {$_min = $_reason.cnt} {/if} {/foreach} {$_delta = $_max - $_min}

[`Deal loss reasons`]

    {foreach $reasons as $_reason} {if $_reason.lost_id} {$_name = $_reason.name} {elseif $_reason.lost_id === '0'} {$_name = '[`Other`]'} {else} {$_name = '[`Not specified`]'} {/if} {$_percent = round($_reason.cnt*100/$_max)}
  • {$_name|escape}
    {$_reason.cnt}
  • {/foreach}
{/if}
{* Chart view *} {else}

{$won_deals_stat.count} {_w('deal won', 'deals won', $won_deals_stat.count)}. [`Total won amount`]: {$won_deals_stat.amount|wa_format_amount_currency:$won_deals_stat.currency_id}

{**}
{*
*} {**} {*
*}
{/if} {else}
[`There are no closed deals for specified period.`]
{/if}