<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<!-- Layout add nav and footer -->
<template id="footer_custom" inherit_id="website.footer_default" name="Footer Partners Link">
    <xpath expr="//div[@id='info']/ul" position="inside">
        <li><a href="/partners">Resellers</a></li>
    </xpath>
</template>

<!-- Page -->
<template id="layout" name="Partners Layout">
    <t t-call="website.layout">
        <t t-set="additional_title">Resellers</t>
        <div id="wrap">
            <div class="oe_structure"/>
            <div class="container mt16">
                <div class="row">
                    <t t-raw="ref_content" />
                </div>
            </div>
            <div class="oe_structure"/>
        </div>
    </t>
</template>

<template id="index" name="Find Resellers">
    <t t-call="website_crm_partner_assign.layout">
        <t t-set="ref_content">
            <div class="col-md-12">
                <h1 class="text-center">
                    Looking For a Local Store?
                </h1><h2 class="text-center text-muted">
                    Contact a reseller
                </h2>
            </div>

            <div class="col-md-3 mb32" id="partner_left">

                <ul id="reseller_grades" class="nav nav-pills nav-stacked mt16">
                    <li class="nav-header"><h3>Filter by Grade</h3></li>
                    <t t-foreach="grades" t-as="grade">
                        <li t-att-class="grade['active'] and 'active' or ''">
                            <a t-attf-href="/partners#{ grade['grade_id'][0] and '/grade/%s' % grade['grade_id'][0] or '' }#{ current_country and '/country/%s' % slug(current_country) or '' }#{ '?' + (search_path or '') }">
                                <span class="badge pull-right" t-esc="grade['grade_id_count'] or ''"/>
                                <t t-esc="grade['grade_id'][1]"/>
                            </a>
                        </li>
                    </t>
                </ul>

                <ul id="reseller_countries" class="nav nav-pills nav-stacked mt16">
                    <li class="nav-header"><h3>Filter by Country</h3></li>
                    <t t-foreach="countries" t-as="country">
                        <li t-if="country['country_id']" t-att-class="country['active'] and 'active' or ''">
                            <a t-attf-href="/partners#{ current_grade and '/grade/%s' % slug(current_grade) or ''}#{country['country_id'][0] and '/country/%s' % country['country_id'][0] or '' }#{ '?' + (search_path or '') + (country['country_id'][0] == 0 and '&amp;country_all=True' or '')}">
                                <span class="badge pull-right" t-esc="country['country_id_count'] or ''"/>
                                <t t-esc="country['country_id'][1]"/>
                            </a>
                        </li>
                    </t>
                </ul>

            </div>

            <div class="col-md-8 col-md-offset-1" id="ref_content">
                <div class='navbar'>
                    <div>
                        <t t-call="website.pager"/>
                        <form action="" method="get" class="navbar-search pull-right pagination form-inline">
                            <div class="form-group pull-right">
                                <input type="text" name="search" class="search-query col-md-2 mt4 form-control" placeholder="Search" t-att-value="searches.get('search', '')"/>
                            </div>
                        </form>
                    </div>
                </div>
                <div>
                    <p t-if="not partners">No result found</p>
                    <t t-foreach="partners" t-as="partner">
                        <t t-if="last_grade != partner.grade_id.id">
                            <h3 class="text-center">
                                <span t-field="partner.grade_id"/> Partners
                            </h3>
                            <t t-set="last_grade" t-value="partner.grade_id.id"/>
                        </t>
                        <div class="media">
                            <a class="pull-left" t-attf-href="/partners/#{slug(partner)}?#{current_grade and 'grade_id=%s&amp;' % current_grade.id}#{current_country and 'country_id=%s' % current_country.id}"
                               t-field="partner.image"
                               t-field-options='{"widget": "image", "class": "media-object", "max_width": 128}'
                            ></a>
                            <div class="media-body o_partner_body" style="min-height: 64px;">
                                <a class="media-heading" t-attf-href="/partners/#{slug(partner)}?#{current_grade and 'grade_id=%s&amp;' % current_grade.id}#{current_country and 'country_id=%s' % current_country.id}">
                                    <span t-field="partner.display_name"/>
                                </a>
                                <div t-field="partner.website_short_description"/>
                                <t t-if="any([p.website_published for p in partner.implemented_partner_ids])">
                                    <small><a t-attf-href="/partners/#{slug(partner)}#right_column">
                                        <t t-raw="len([p for p in partner.implemented_partner_ids if p.website_published])"/> reference(s)
                                    </a></small>
                                </t>
                            </div>
                        </div>
                    </t>
                </div>
                <div class='navbar'>
                    <t t-call="website.pager">
                       <t t-set="classname">pull-left</t>
                    </t>
                </div>
            </div>
        </t>
    </t>
</template>

<template id="ref_country" inherit_id="website_crm_partner_assign.index" customize_show="True" name="Left World Map">
    <xpath expr="//ul[@id='reseller_countries']" position="after">
        <!-- modal for large map -->
        <div class="modal fade partner_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
          <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title">World Map</h4>
                </div>
                <iframe t-attf-src="/google_map/?width=898&amp;height=485&amp;partner_ids=#{ google_map_partner_ids }&amp;partner_url=/partners/"
                style="width:898px; height:485px; border:0; padding:0; margin:0;"></iframe>
            </div>
          </div>
        </div>
        <!-- modal end -->
        <h3>World Map<button class="btn btn-link" data-toggle="modal" data-target=".partner_map_modal"><span class="fa fa-external-link" /></button></h3>
        <ul class="nav">
            <iframe t-attf-src="/google_map?width=260&amp;height=240&amp;partner_ids=#{ google_map_partner_ids }&amp;partner_url=/partners/"
                style="width:260px; height:240px; border:0; padding:0; margin:0;" scrolling="no"></iframe>
        </ul>
    </xpath>
</template>

<template id="partner" name="Partner Detail">
    <t t-call="website_crm_partner_assign.layout">
        <t t-set="ref_content">
            <div class="col-md-5">
                <ol class="breadcrumb">
                    <li><a t-attf-href="/partners#{current_grade and '/grade/%s' % slug(current_grade)}#{current_country and '/country/%s' % slug(current_country)}">Our Partners</a></li>
                    <li class="active"><span t-field="partner.display_name"/></li>
                </ol>
            </div>
            <t t-call="website_partner.partner_detail">
                <t t-set="right_column">
                    <div id="right_column" class="mb16"><t t-call="website_crm_partner_assign.references_block"/></div>
                </t>
            </t>
        </t>
    </t>
</template>

<template id="grade_in_detail" inherit_id="website_partner.partner_detail">
  <xpath expr="//*[@id='partner_name']" position="after">
    <h3 class="col-md-12 text-center text-muted" t-if="partner.grade_id and partner.grade_id.website_published">
      <span t-field="partner.grade_id"/> Partner</h3>
  </xpath>
</template>

<template id="references_block" name="Partner References Block">
    <t t-if="any([p.website_published for p in partner.implemented_partner_ids])">
        <h3 id="references">References</h3>
        <div t-foreach="partner.implemented_partner_ids" t-as="reference" class="media">
          <t t-if="reference.website_published">
            <a class="pull-left" t-attf-href="/customers/#{slug(reference)}">
                <span t-field="reference.image_small" t-field-options='{"widget": "image", "class": "center-block"}'/>
            </a>
            <div class="media-body" style="min-height: 64px;">
                <a class="media-heading" t-attf-href="/customers/#{slug(reference)}">
                    <span t-field="reference.self"/>
                </a>
                <div t-field='reference.website_short_description'/>
            </div>
          </t>
        </div>
    </t>
</template>

</data>
</openerp>
