 <script>
pageMeta.fragmentClass = 'DeskPRO.Agent.PageFragment.Page.NewDeal';
pageMeta.title = 'New Deal';
pageMeta.deal_id = 0;

//pageMeta.labelsAutocompleteUrl        = '{#{ path('agent_ajax_labels_autocomplete', {'label_type': 'ticket'}) }#}';
//pageMeta.uploadAttachUrl              = '{#{ path('agent_accept_upload') }#}';

{% set baseId = el_uid() %}
pageMeta.baseId = '{{ baseId }}';
</script>
{# scroll containers #}
<div class="layout-content with-scrollbar page-new-ticket page-new-content">
<div class="scrollbar disable"><div class="track"><div class="thumb"><div class="end"></div></div></div></div>
<div class="scroll-viewport"><div class="scroll-content">
{# /scroll containers #}

    <form id="{{baseId}}_newdeal">

        <div class="section title-section" id="{{baseId}}_title_section">
            <div class="content">
                    <h4>{{ phrase('agent.general.title') }}</h4>
                    <input type="text" name="newdeal[title]" class="title" id="{{baseId}}_title" value="" />
            </div>
        </div>

        <div class="section cat-section" id="{{baseId}}_cat_section">
            <div class="content">
               <div class="col">
                <button class="clean-white small switch-user" id="{{baseId}}_switch_user" style="display: none">{{ phrase('agent.general.change_user') }}</button>
		<div id="{{baseId}}_choose_user">
			<div
				id="{{baseId}}_user_searchbox"
				data-element-handler="DeskPRO.Agent.ElementHandler.PersonSearchBox"
				data-search-url="{{ path('agent_peoplesearch_performquick', {'format': 'json', 'limit': 10, 'start_with': 'a'}) }}"
				data-highlight-term="1"
				data-touch-focus="1"
				data-search-param="term"
				data-position-bound="#{{baseId}}_userselect"
			>
                                {{ phrase('agent.general.person') }}:
				<input type="text" id="{{baseId}}_userselect" class="select-user term" placeholder="{{ phrase('agent.general.choose_person_for_ticket') }}" />
				<input type="hidden" name="newdeal[person][id]" value="{{ deal.person.id }}" class="person-id" id="{{baseId}}_person_id" />

				<script type="text/x-deskpro-tmpl" class="user-row-tpl">
					<li>
						<a>
						<span class="user-name"></span>
						<address>&lt;<span class="user-email"></span>&gt;</address>
						<div class="bound-fade"></div>
					</a></li>
				</script>
				<div class="person-search-box" style="display: none">
					<section>
						<ul class="results-list">

						</ul>
						<footer>
							<span class="create-user">{{ phrase('agent.general.create_a_new_person') }}</span>
						</footer>
					</section>
				</div>
			</div>
		</div>
		<div id="{{baseId}}_user_choice">

		</div>
		<br class="clear" />

            </div>
            <div class="col">
                <button class="clean-white small switch-org" id="{{baseId}}_switch_org" style="display: none">{{ phrase('agent.deal.change_organization') }}</button>
                <div class="org-edit" style="display: block" id="{{baseId}}_org_edit_wrap">
			<div
				class="org-input"
				id="{{baseId}}_org_searchbox"
				data-element-handler="DeskPRO.Agent.ElementHandler.OrgSearchBox"
				data-search-url="{{ path('agent_orgsearch_quicknamesearch', {'format': 'json', 'limit': 10, 'start_with': 'a'}) }}"
				data-highlight-term="1"
				data-touch-focus="1"
				data-search-param="term"
				data-position-bound="@parent(.org-input)"
			>
				{{ phrase('agent.general.organization') }}:
				<input type="text" class="org-name" placeholder="{{ phrase('agent.general.enter_organization_name') }}" value="{{ person.organization.name }}" />
				<input type="hidden" class="org-id" name="newdeal[organizations][id]" value="{{ person.organization.id|default(0) }}" />
				<script type="text/x-deskpro-tmpl" class="user-row-tpl">
					<li>
						<a>
						<span class="org-name"></span>
						<div class="bound-fade"></div>
					</a></li>
				</script>
				<div class="person-search-box org" style="display: none">
					<section>
						<ul class="results-list">

						</ul>
						<footer>
							<span class="create-org">{{ phrase('agent.general.create_a_new_organization') }}</span>
						</footer>
					</section>
				</div>
			</div>
			<div class="pos-input" {% if not deal.person.organization %}style="display: none"{% endif %}>
				<label>{{ phrase('agent.general.position') }}:</label>
				<input type="text" class="org-pos-set" placeholder="{{ phrase('agent.general.set_a_position') }}" value="{{ deal.person.organization_position }}" />
			</div>
		</div>

                <div id="{{baseId}}_org_choice">

		</div>


            </div>
            <br class="clear" />
            </div>
        </div>

        <div class="section department-section" id="{{baseId}}_dep_section">
            <div class="content">
                    <div class="col">
                            <h4>{{ phrase('agent.general.type') }}</h4>
                            {% include 'AgentBundle:Deal:select-deal-options.html.twig' with {
                                'name': 'newdeal[deal_type]',
                                'with_blank': true,
                                'with_blank2': true,
                                'blank_title': '{{ phrase('agent.deal.set_deal_type') }}',
                                'options': deal_type,
                                'add_classname': 'select-deal-type'
                            } %}
                    </div>
                    <div class="col">
                            <h4>{{ phrase('agent.deal.stage') }}</h4>
                            <dd class="set-deal-stage">
                            {% include 'AgentBundle:Deal:select-deal-options.html.twig' with {
                                'name': 'newdeal[deal_stage]',
                                'with_blank': true,
                                'with_blank2': true,
                                'blank_title': 'Set Deal {{ phrase('agent.deal.stage') }}',
                                'options': deal_stage,
                                'add_classname': 'select-stage-type'
                            } %}
                            </dd>
                    </div>
                    <div class="col">
                            <h4>{{ phrase('agent.general.assignment') }}</h4>
                            <input type="hidden" name="newdeal[agent_id]" value="{{person.id}}" id="{{baseId}}_agent_id" />

                            <span id="{{baseId}}_assign_btn" class="agent-prop-links">
                                    <span id="{{baseId}}_agent_label">{{ phrase('agent.general.me') }}</span>
                            </span>
                    </div>
                <div class="col">
                    <h4>{{ phrase('agent.deal.visibility') }}</h4>
                    <select id="{{baseId}}_visibility" name="newdeal[visibility]">
                        <option value="0">{{ phrase('agent.general.private') }}</option>
                        <option value="1">{{ phrase('agent.general.public') }}</option>

                    </select>
                </div>
                    <br class="clear" />
            </div>
        </div>


        <div class="section department-section" id="{{baseId}}_dep_section">
            <div class="content">
                    <div class="col">
                            <h4>{{ phrase('agent.general.type') }}</h4>
                            {% include 'AgentBundle:Deal:select-deal-options.html.twig' with {
                                'name': 'newdeal[deal_currency]',
                                'with_blank': true,
                                'with_blank2': true,
                                'blank_title': 'Set Currency',
                                'options': deal_currency,
                                'add_classname': 'select-currency'
                            } %}
                    </div>
                    <div class="col">
                            <h4>{{ phrase('agent.general.value') }}</h4>
                            <input type="text" name="newdeal[deal_value]" class="deal-value" id="{{baseId}}_deal_value" value="" />
                    </div>
                    <div class="col">
                            <h4>{{ phrase('agent.deal.probability') }}</h4>
                            <input type="text" name="newdeal[probability]" class="probability" value="{{deal.probability}}" id="{{baseId}}_probability" />
                    </div>
                    <br class="clear" />
            </div>
        </div>

        <div class="section other-section" id="{{baseId}}_other_section">
            <div class="content">
		{# Tab Container #}
		<div class="tab-container">
			<nav id="{{baseId}}_other_props_tabs_wrap">
				<ul id="{{baseId}}_other_props_tabs">
					<li data-tab-for="> .tab-properties">{{ phrase('agent.general.properties') }}</li>
					<li data-tab-for="> .tab-attach">{{ phrase('agent.general.attachments') }}</li>
				</ul>
			</nav>
			<div class="content-wrapper" id="{{baseId}}_other_props_tabs_content" style="display: none">
				{# Tab Properties #}
				<div class="tab-properties" style="display: none">
					<dl>

					</dl>
				</div>
				{# /Tab Properties #}

				{# Tab Attach #}
				<div class="tab-attach" style="display: none">
					{% include 'AgentBundle:Common:attach-row-tmpl.html.twig' with {formname: 'newdeal[attach][]'} %}
					<h6>{{ phrase('agent.general.attachments') }}</h6>
					<div class="file-input">
						<input type="file" name="file-upload" multiple="multiple" /> <button class="clean-gray xxx-small">{{ phrase('agent.general.upload') }}</button>
					</div>
					<ul class="files file-list"></ul>
				</div>
				{# /Tab Attach #}
			</div>
		</div>
		{# /Tab Container #}
	</div>
</div>

        <div class="foot">
            <button class="submit-trigger clean-white">{{ phrase('agent.general.create_deal') }}</button>
        </div>

    </form>


<div class="optionbox reply-agent-team-ob" id="{{baseId}}_agent_assign_ob">
    	<header>
            <h4>{{ phrase('agent.general.assignment') }}s</h4>
            <span class="close close-trigger"></span>
        </header>
    	<div class="col">
		<section data-section-name="agents">
			<header>
				<h3>{{ phrase('agent.general.agents') }}</h3>
				<input type="text" class="filter-box" placeholder="{{ phrase('agent.general.filter') }}" />
			</header>
			<ul>
				<li class="me last-me {% if deal.assigned_agent.id == deal.person.id or not deal.assigned_agent %}on{% endif %}">
					<input type="radio" name="{{baseId}}_agent" value="{{ deal.person.id }}" {% if deal.assigned_agent.id == deal.person.id or not deal.assigned_agent.id %}checked="checked"{% endif %} />
					<label><span class="agent-pic agent-label-{{ deal.person.id }}" style="background-image: url({{ deal.person.getPictureUrl(16) }})">{{ phrase('agent.general.me') }}</span></label>
				</li>

				<li>
					<input type="radio" name="{{bsaeId}}_agent" value="0" />
					<label><span class="agent-pic agent-label-0">{{ phrase('agent.general.unassigned') }}</span></label>
				</li>

				{% for agent in agents %}
					{% if agent.id != person.id %}
						<li {% if deal.assigned_agent.id == agent.id %}class="on"{% endif %}>
							<input type="radio" name="{{baseId}}_agent" value="{{ agent.id }}" {% if deal.assigned_agent.id == agent.id %}checked="checked"{% endif %} />
							<label><span class="agent-pic agent-label-{{ agent.id }}" style="background-image: url({{ agent.getPictureUrl(16) }})">{{ agent.display_name }}</span></label>
							<div class="bound-fade"></div>
						</li>
					{% endif %}
				{% endfor %}
			</ul>
		</section>
	</div>

    	<br class="clear" />
    	<footer>
           <button class="save-trigger">{{ phrase('agent.general.apply') }}</button>
        </footer>
    </div>


{# scroll containers #}
</div></div>
</div>
{# /scroll containers #}
