{extends file="admin-layout.tpl"}

{block name="page-title"}{intl l='Search'}{/block}

{block name="check-resource"}admin.search{/block}
{block name="check-access"}view{/block}

{block name="main-content"}
{$searchTerm = {$smarty.get.search_term|trim}}

{capture name="more_results"}
    <tr>
        <td colspan="99">
            <div class="alert alert-info text-center">
                {intl l="More results are available."}
                <br/>
                {intl l="Please refine your search to see the other results."}
            </div>
        </td>
    </tr>
{/capture}

<div class="modules">

    <div id="wrapper" class="container">

        <div class="clearfix">
            <ul class="breadcrumb pull-left">
                <li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
                <li><a href="#">{intl l="Search for '%term'" term=$searchTerm}</a></li>
            </ul>
        </div>

        {hook name="search.top" location="search_top" }

        <div class="row">
            <div class="col-md-12">
                {if $searchTerm|strlen > 2}
                {* customer search *}
                <div class="general-block-decorator">
                    <div class="table-responsive">
                        <table class="table table-striped table-condensed table-left-aligned">
                            <caption class="clearfix">
                                {intl l='Customer'}
                            </caption>
                            {ifloop rel="customer_list"}
                            <thead>
                            <tr>
                                <th class="object-title">
                                    {intl l="customer ref"}
                                </th>

                                <th class="object-title">
                                    {intl l="company"}
                                </th>

                                <th>
                                    {intl l="firstname & lastname"}
                                </th>
                                <th>
                                    {intl l="Email address"}
                                </th>
                                {hook name="customers.header" location="customer_list_header" }

                                <th>
                                    {intl l="last order"}
                                </th>

                                <th>{intl l='order amount'}</th>

                                <th class="actions">{intl l="Actions"}</th>
                            </tr>
                            </thead>

                            <tbody>
                            {loop name="customer_list" type="customer" current="false" visible="*" backend_context="1" search_mode="sentence" search_term=$searchTerm search_in="ref,firstname,lastname,email" limit=26}
                                {assign "lastOrderDate" ''}
                                {assign "lastOrderAmount" ''}
                                {assign "lastOrderCurrency" ''}
                                {$hasOrders = false}

                                {loop type="order" name="last-order" customer=$ID order="create-date-reverse" limit="1"}
                                {assign "lastOrderDate" "{format_date date=$CREATE_DATE}"}
                                {assign "lastOrderAmount" "{format_number number=$TOTAL_TAXED_AMOUNT}"}
                                {loop type="currency" name="order-currency" id=$CURRENCY}
                                {assign "lastOrderCurrency" $SYMBOL}
                                {/loop}
                                {$hasOrders = true}
                                {/loop}

                                {if $LOOP_COUNT < 26}
                                <tr>
                                    <td><a href="{url path='/admin/customer/update' customer_id=$ID}">{$REF}</a></td>

                                    <td>
                                        {$COMPANY}
                                    </td>

                                    <td class="object-title">
                                        {$FIRSTNAME} {$LASTNAME}
                                    </td>
                                    <td>
                                        {mailto address="{$EMAIL}" encode="hex"}
                                    </td>
                                    {hook name="customers.row" location="customer_list_row" customer_id={$ID}}

                                    <td>
                                        {$lastOrderDate}
                                    </td>

                                    <td>
                                        {$lastOrderCurrency} {$lastOrderAmount}
                                    </td>

                                    <td class="actions">
                                          {if $hasOrders}
                                            {$deleteClass = 'disabled'}
                                            {$deleteTitle = {intl l='This customer has orders, and can\'t be deleted.'}}
                                            {$deleteHref = ''}
                                        {else}
                                            {$deleteClass = 'customer-delete'}
                                            {$deleteTitle = {intl l='Delete this customer and all his orders'}}
                                            {$deleteHref = '#delete_customer_dialog'}
                                        {/if}
                                        {include file='renderer/buttons.html' buttons=[
                                            [
                                                'type' => 'edit',
                                                'title' => {intl l='Edit this customer'},
                                                'href' => {url path='/admin/customer/update' customer_id=$ID page=$page},
                                                'auth' => ['resource' => 'admin.customer']
                                            ],
                                            [
                                                'title' => {intl l="Send a mail to this customer"},
                                                'href' => "mailto:$EMAIL",
                                                'icon' => ['class' => 'glyphicon glyphicon-envelope'],
                                                'auth' => ['resource' => 'admin.customer']
                                            ],
                                            [
                                                'type' => 'delete',
                                                'class' => $deleteClass,
                                                'title' => $deleteTitle,
                                                'href' => $deleteHref,
                                                'data' => [
                                                    'id' => $ID,
                                                    'toggle' => 'modal'
                                                ],
                                                'auth' => ['resource' => 'admin.customer']
                                            ]
                                        ]}
                                    </td>

                                </tr>
                                {else}
                                    {$smarty.capture.more_results nofilter}
                                {/if}
                            {/loop}
                            </tbody>
                            {/ifloop}
                        </table>
                        {elseloop rel="customer_list"}
                            <div class="alert alert-info">
                                {intl l="No customer found for \"%term\"" term=$searchTerm}
                            </div>
                        {/elseloop}
                    </div>
                </div>
                {* end customer search *}

                {* order search *}
                <div class="general-block-decorator">
                    <div class="table-responsive">
                        <table class="table table-striped table-condensed table-left-aligned">
                            <caption class="clearfix">
                                {intl l='Orders'}
                            </caption>
                            <thead>
                            {ifloop rel="order-search"}
                            <tr>
                                <th>{intl l="Order n°"}</th>
                                <th>{intl l="Date & Hour"}</th>
                                <th>{intl l="Invoice"}</th>
                                <th>{intl l="Delivery"}</th>
                                <th>{intl l="Transaction"}</th>
                                <th>{intl l="Company"}</th>
                                <th>{intl l="Name"}</th>
                                <th>{intl l="Amount"}</th>
                                <th>{intl l="Status"}</th>
                                
                                {hook name="orders.table-header" location="orders_table_header" }
                                
                                <th class="actions">{intl l="Actions"}</th>
                            </tr>
                            </thead>

                            <tbody>
                            {loop type="order" name="order-search" backend_context=1 customer="*" search_term=$searchTerm search_in="ref,customer_ref,customer_firstname,customer_lastname,customer_email,invoice_ref,transaction_ref,delivery_ref" limit=26}
                                {loop type="order_address" name="order-invoice-address" id=$INVOICE_ADDRESS}
                                {assign "orderInvoiceFirstName" $FIRSTNAME}
                                {assign "orderInvoiceLastName" $LASTNAME}
                                {assign "orderInvoiceCompany" $COMPANY}
                                {/loop}

                                {loop type="order-status" name="order-status" id=$STATUS}
                                {assign "orderStatus" $TITLE}
                                {assign "orderStatusLabel" "order_$CODE"}
                                {assign "orderStatusCodeColor" $COLOR}
                                {/loop}

                                {loop type="currency" name="order-currency" id=$CURRENCY}
                                {assign "currencySymbol" $SYMBOL}
                                {/loop}

                            {if $LOOP_COUNT < 26}
                                <tr>
                                    <td><a href="{url path="/admin/order/update/%id" id=$ID}">{$REF}</a></td>
                                    <td>{format_date date=$CREATE_DATE}</td>
                                    <td>{$INVOICE_REF}</td>
                                    <td>{$DELIVERY_REF}</td>
                                    <td>{$TRANSACTION_REF}</td>
                                    <td>{$orderInvoiceCompany}</td>
                                    <td><a href="{url path='/admin/customer/update' customer_id=$CUSTOMER}">{$orderInvoiceFirstName|ucwords} {$orderInvoiceLastName|upper}</a></td>
                                    <td>{format_money number=$TOTAL_TAXED_AMOUNT symbol=$currencySymbol}</td>
                                    <td><span class="label" style="background-color: {$orderStatusCodeColor};">{$orderStatus}</span></td>

                                    {hook name="orders.table-row" location="orders_table_row" order_id={$ID}}
                                    <td>
                                        {$buttons = [
                                            [
                                                'type' => 'edit',
                                                'title' => {intl l='Edit this order'},
                                                'href' => {url path="/admin/order/update/%id" id=$ID},
                                                'auth' => ['resource' => 'admin.order']
                                            ]
                                        ]}

                                        {include file='renderer/buttons.html' buttons=$buttons}
                                    </td>
                                </tr>
                            {else}
                                {$smarty.capture.more_results nofilter}
                            {/if}
                            {/loop}
                            </tbody>
                            {/ifloop}
                        </table>
                        {elseloop rel="order-search"}
                            <div class="alert alert-info">
                                {intl l="No order found for \"%term\"" term=$searchTerm}
                            </div>
                        {/elseloop}
                    </div>
                </div>
                {* end order search *}

                {* category search *}
                <div class="general-block-decorator">
                    <div class="table-responsive">
                        <table class="table table-striped table-condensed table-left-aligned">
                            <caption class="clearfix">
                                {intl l='Category'}
                            </caption>
                            {ifloop rel="category-search"}
                            <thead>
                            <tr>
                                <th>{intl l="ID"}</th>
                                <th></th>
                                <th>{intl l="Category title"}</th>
                                
                                {hook name="categories.header" location="category_list_header" }
                                
                                <th class="text-center">
                                    {intl l='Online'}
                                </th>
                                <th class="actions">{intl l="Actions"}</th>
                            </tr>
                            </thead>

                            <tbody>
                            {loop type="category" name="category-search" backend_context=1 visible="*" search_mode="sentence" search_term=$searchTerm search_in="title,chapo,description,postscriptum" return_url=false  limit=26}

                            {if $LOOP_COUNT < 26}
                            <tr>
                                <td>{$ID}</td>
                                <td></td>
                                <td class="object-title"><a href="{url path="/admin/categories/update" category_id={$ID}}">{$TITLE}</a></td>
                                
                                {hook name="categories.row" location="category_list_row" category_id={$ID} }
                                
                                <td class="text-center">
                                    {loop type="auth" name="can_change" role="ADMIN" resource="admin.category" access="UPDATE"}
                                        <div class="make-switch switch-small categoryVisibleToggle" data-id="{$ID}"  data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
                                            <input type="checkbox" class="categoryVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
                                        </div>
                                    {/loop}

                                    {elseloop rel="can_change"}
                                        <div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
                                            <input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
                                        </div>
                                    {/elseloop}
                                </td>
                                 <td class="actions">
                                     {include file='renderer/buttons.html' buttons=[
                                        [
                                            'type' => 'folder-open',
                                            'title' => {intl l='Browse this category'},
                                            'href' => {url path='admin/categories' category_id=$ID}
                                        ],
                                        [
                                            'type' => 'edit',
                                            'title' => {intl l='Edit this category'},
                                            'href' => {url path='/admin/categories/update' category_id=$ID},
                                            'auth' => ['resource' => 'admin.category']
                                        ],
                                        [
                                            'type' => 'delete',
                                            'class' => 'category-delete',
                                            'title' => {intl l='Delete this category'},
                                            'href' => '#category_delete_dialog',
                                            'data' => [
                                                'id' => $ID,
                                                'toggle' => 'modal'
                                            ],
                                            'auth' => ['resource' => 'admin.category']
                                        ]
                                    ]}
                                  </td>
                            </tr>
                            {else}
                                {$smarty.capture.more_results nofilter}
                            {/if}
                            {/loop}
                            </tbody>
                            {/ifloop}
                        </table>
                        {elseloop rel="category-search"}
                            <div class="alert alert-info">
                                {intl l="No category found for \"%term\"" term=$searchTerm}
                            </div>
                        {/elseloop}

                    </div>
                </div>
                {* end category search *}

                {* product search *}
                <div class="general-block-decorator">
                    <div class="table-responsive">
                        <table class="table table-striped table-condensed table-left-aligned">
                            <caption class="clearfix">
                                {intl l='Product'}
                            </caption>
                            {ifloop rel="product-search"}
                            <thead>
                            <tr>
                                <th>{intl l="ID"}</th>
                                <th></th>
                                <th>{intl l="Reference"}</th>
                                <th>{intl l="Product title"}</th>
                                 <th class="text-right">
                                    {intl l='Price'}
                                 </th>
                                 <th class="text-center">
                                    {intl l='Online'}
                                 </th>
                                <th class="actions">{intl l="Actions"}</th>
                            </tr>
                            </thead>

                            <tbody>
                            {loop type="product" name="product-search" backend_context=1 visible="*" search_mode="sentence" search_term=$searchTerm search_in="ref,title,chapo,description,postscriptum" return_url=false  limit=26}
                            {if $LOOP_COUNT < 26}
                                {$id_product=$ID}
                                 <tr>
                                     <td>{$ID}</td>

                                     <td>
                                     {loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
                                       <a href="{url path='/admin/products/update' product_id=$OBJECT_ID page=$page}" title="{intl l='Edit this product'}">
                                         <img src="{$IMAGE_URL nofilter}" alt="{$TITLE}" />
                                       </a>
                                     {/loop}
                                     </td>

                                     <td class="object-title">
                                         <a href="{url path='/admin/products/update' product_id=$ID page=$page}" title="{intl l='Edit this product'}">{$REF}</a>
                                         {if $VIRTUAL}<span class="glyphicon glyphicon-download text-muted" title="{intl l='Virtual product'}"></span>{/if}
                                     </td>

                                     <td class="object-title"><a href="{url path='/admin/products/update' product_id=$ID page=$page}" title="{intl l='Edit this product'}">{$TITLE}</a></td>

                                     {hook name="products.row" location="product_list_row" product_id={$ID}}

                                     <td class="text-right"><a href="{url path='/admin/products/update' product_id=$ID page=$page current_tab='prices'}" title="{intl l='Edit Prices'}">{format_money number=$BEST_PRICE symbol={currency attr="symbol"}}</a></td>

                                     <td class="text-center">
                                            {loop type="auth" name="can_change" role="ADMIN" resource="admin.product" access="UPDATE"}
                                                <div class="make-switch switch-small productVisibleToggle" data-id="{$ID}"  data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
                                                    <input type="checkbox" class="productVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
                                                </div>
                                            {/loop}

                                            {elseloop rel="can_change"}
                                                <div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
                                                    <input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
                                                </div>
                                            {/elseloop}
                                     </td>


                                     <td class="actions">
                                        {include file='renderer/buttons.html' buttons=[
                                            [
                                                'type' => 'edit',
                                                'title' => {intl l='Edit this product'},
                                                'href' => {url path='/admin/products/update' product_id=$ID page=$page},
                                                'auth' => ['resource' => 'admin.product']
                                            ],
                                            [
                                                'type' => 'delete',
                                                'class' => 'product-delete',
                                                'title' => {intl l='Delete this product'},
                                                'href' => '#product_delete_dialog',
                                                'data' => [
                                                    'id' => $ID,
                                                    'toggle' => 'modal'
                                                ],
                                                'auth' => ['resource' => 'admin.product']
                                            ]
                                        ]}
                                      </td>
                                 </tr>
                            {else}
                                {$smarty.capture.more_results nofilter}
                            {/if}
                            {/loop}
                            </tbody>
                            {/ifloop}
                        </table>
                        {elseloop rel="product-search"}
                            <div class="alert alert-info">
                                {intl l="No product found for \"%term\"" term=$searchTerm}
                            </div>
                        {/elseloop}
                    </div>
                </div>
                {* end product search *}

                {* folder search *}
                <div class="general-block-decorator">
                    <div class="table-responsive">
                        <table class="table table-striped table-condensed table-left-aligned">
                            <caption class="clearfix">
                                {intl l='Folder'}
                            </caption>
                            {ifloop rel="folder-search"}
                            <thead>
                            <tr>
                                <th>{intl l="ID"}</th>
                                <th></th>
                                <th>{intl l="Folder title"}</th>
                                
                                {hook name="folders.header" location="folder_list_header" }
                                
                                <th class="text-center">
                                    {intl l='Online'}
                                </th>
                                <th class="actions">{intl l="Actions"}</th>
                            </tr>
                            </thead>

                            <tbody>
                            {loop type="folder" name="folder-search" backend_context=1 visible="*" search_mode="sentence" search_term=$searchTerm search_in="title,chapo,description,postscriptum" return_url=false  limit=26}
                            {if $LOOP_COUNT < 26}
                                <tr>
                                    <td>{$ID}</td>
                                    <td></td>

                                    <td class="object-title"><a href="{url path="/admin/folders/update/%id" id=$ID}">{$TITLE}</a></td>
                                    
                                    {hook name="folders.row" location="folder_list_row" folder_id={$ID} }
                                    
                                    <td class="text-center">
                                        {loop type="auth" name="can_change" role="ADMIN" resource="admin.folder" access="UPDATE"}
                                            <div class="make-switch switch-small folderVisibleToggle" data-id="{$ID}"  data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
                                                <input type="checkbox" class="folderVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
                                            </div>
                                        {/loop}

                                        {elseloop rel="can_change"}
                                            <div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
                                                <input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
                                            </div>
                                        {/elseloop}
                                    </td>

                                    <td class="actions">
                                        {include file='renderer/buttons.html' buttons=[
                                            [
                                                'type' => 'folder-open',
                                                'title' => {intl l='Browse this folder'},
                                                'href' => {url path='admin/folders' parent=$ID}
                                            ],
                                            [
                                                'type' => 'edit',
                                                'title' => {intl l='Edit this folder'},
                                                'href' => {url path="/admin/folders/update/%id" id=$ID},
                                                'auth' => ['resource' => 'admin.folder']
                                            ],
                                            [
                                                'type' => 'delete',
                                                'class' => 'folder-delete',
                                                'title' => {intl l='Delete this folder and all its contents'},
                                                'href' => '#folder_delete_dialog',
                                                'data' => [
                                                    'id' => $ID,
                                                    'toggle' => 'modal'
                                                ],
                                                'auth' => ['resource' => 'admin.folder']
                                            ]
                                        ]}
                                    </td>
                                </tr>
                            {else}
                                {$smarty.capture.more_results nofilter}
                            {/if}
                            {/loop}
                            </tbody>
                            {/ifloop}
                        </table>
                        {elseloop rel="folder-search"}
                            <div class="alert alert-info">
                                {intl l="No folder found for \"%term\"" term=$searchTerm}
                            </div>
                        {/elseloop}
                    </div>
                </div>
                {* end folder search *}

                {* content search *}
                <div class="general-block-decorator">
                    <div class="table-responsive">
                        <table class="table table-striped table-condensed table-left-aligned">
                            <caption class="clearfix">
                                {intl l='Content'}
                            </caption>
                            {ifloop rel="content-search"}
                            <thead>
                            <tr>
                                <th>{intl l="ID"}</th>
                                <th></th>
                                <th>{intl l="Content title"}</th>
                                
                                {hook name="contents.header" location="content_list_header" }
    
                                <th class="text-center">
                                    {intl l='Online'}
                                </th>
                                <th class="actions">{intl l="Actions"}</th>
                            </tr>
                            </thead>

                            <tbody>
                            {loop type="content" name="content-search" backend_context=1 visible="*" search_mode="sentence" search_term=$searchTerm search_in="title,chapo,description,postscriptum" return_url=false  limit=26}
                            {if $LOOP_COUNT < 26}
                                <tr>
                                    <td>{$ID}</td>
                                    <td></td>

                                    <td class="object-title"><a href="{url path="/admin/content/update/%id" id=$ID}">{$TITLE}</a></td>
                                    
                                    {hook name="contents.row" location="content_list_row" }
                                    
                                    <td class="text-center">
                                        {loop type="auth" name="can_change" role="ADMIN" resource="admin.content" access="UPDATE"}
                                            <div class="make-switch switch-small contentVisibleToggle" data-id="{$ID}"  data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
                                                <input type="checkbox" class="contentVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
                                            </div>
                                        {/loop}

                                        {elseloop rel="can_change"}
                                            <div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
                                                <input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
                                            </div>
                                        {/elseloop}
                                    </td>

                                    <td class="actions">
                                         {include file='renderer/buttons.html' buttons=[
                                            [
                                                'type' => 'edit',
                                                'title' => {intl l='Edit this content'},
                                                'href' => {url path="/admin/content/update/{$ID}"},
                                                'auth' => ['resource' => 'admin.content']
                                            ],
                                            [
                                                'type' => 'delete',
                                                'class' => 'content-delete',
                                                'title' => {intl l='Delete this content'},
                                                'href' => '#content_delete_dialog',
                                                'data' => [
                                                    'id' => $ID,
                                                    'toggle' => 'modal'
                                                ],
                                                'auth' => ['resource' => 'admin.content']
                                            ]
                                        ]}
                                    </td>
                                </tr>
                            {else}
                                {$smarty.capture.more_results nofilter}
                            {/if}
                            {/loop}
                            </tbody>
                            {/ifloop}
                        </table>
                        {elseloop rel="content-search"}
                            <div class="alert alert-info">
                                {intl l="No content found for \"%term\"" term=$searchTerm}
                            </div>
                        {/elseloop}

                    </div>
                </div>
                {* end content search *}

                {* brand search *}
                <div class="general-block-decorator">
                    <div class="table-responsive">
                        <table class="table table-striped table-condensed table-left-aligned">
                            <caption class="clearfix">
                                {intl l='Brand'}
                            </caption>
                            {ifloop rel="brand-search"}
                                <thead>
                                <tr>
                                    <th>{intl l="ID"}</th>
                                    <th></th>
                                    <th>{intl l="Brand title"}</th>

                                    {hook name="brands.table-header" }

                                    <th class="text-center">
                                        {intl l='Online'}
                                    </th>
                                    <th class="actions">{intl l="Actions"}</th>
                                </tr>
                                </thead>

                                <tbody>
                                {loop type="brand" name="brand-search" backend_context=1 visible="*" search_mode="sentence" search_term=$searchTerm search_in="title,chapo,description,postscriptum" return_url=false  limit=26}

                                {if $LOOP_COUNT < 26}
                                    <tr>
                                        <td>{$ID}</td>
                                        <td></td>
                                        <td class="object-title"><a href="{url path="/admin/brand/update/$ID"}">{$TITLE}</a></td>

                                        {hook name="brands.table-row" brand_id=$ID}

                                        <td class="text-center">
                                            {loop type="auth" name="can_change" role="ADMIN" resource="admin.brand" access="UPDATE"}
                                                <div class="make-switch switch-small brandVisibleToggle" data-id="{$ID}"  data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
                                                    <input type="checkbox" class="brandVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
                                                </div>
                                            {/loop}

                                            {elseloop rel="can_change"}
                                                <div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
                                                    <input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
                                                </div>
                                            {/elseloop}
                                        </td>
                                        <td class="actions">
                                            {include file='renderer/buttons.html' buttons=[
                                            [
                                            'type' => 'edit',
                                            'title' => {intl l='Edit this brand'},
                                            'href' => {url path="/admin/brand/update/{$ID}"},
                                            'auth' => ['resource' => 'admin.brand']
                                            ],
                                            [
                                            'type' => 'delete',
                                            'class' => 'brand-delete',
                                            'title' => {intl l='Delete this brand'},
                                            'href' => '#brand_delete_dialog',
                                            'data' => [
                                            'id' => $ID,
                                            'toggle' => 'modal'
                                            ],
                                            'auth' => ['resource' => 'admin.brand']
                                            ]
                                            ]}
                                        </td>
                                    </tr>
                                {else}
                                    {$smarty.capture.more_results nofilter}
                                {/if}
                                {/loop}
                                </tbody>
                            {/ifloop}
                        </table>
                        {elseloop rel="brand-search"}
                            <div class="alert alert-info">
                                {intl l="No brand found for \"%term\"" term=$searchTerm}
                            </div>
                        {/elseloop}

                    </div>
                </div>
                {* end brand search *}


                {else}
                <div class="alert alert-warning">
                    {intl l="Your search is too short"}
                </div>
                {/if}
            </div>
        </div>

        {hook name="search.bottom" location="search_bottom" }

    </div>
</div>

{* -- Delete category confirmation dialog ----------------------------------- *}

{capture "category_delete_dialog"}
    <input type="hidden" name="category_id" id="category_delete_id" value="" />

    {hook name="category.delete-form" location="category_delete_form" }
{/capture}

{include
    file = "includes/generic-confirm-dialog.html"

    dialog_id       = "category_delete_dialog"
    dialog_title    = {intl l="Delete category"}
    dialog_message  = {intl l="Do you really want to delete this category and all its content ?"}

    form_action         = {token_url path='/admin/categories/delete'}
    form_content        = {$smarty.capture.category_delete_dialog nofilter}
}

{* -- Delete product confirmation dialog ------------------------------------ *}

{capture name="product_delete_dialog"}
    <input type="hidden" name="product_id" id="product_delete_id" value="" />

    {hook name="product.delete-form" location="product_delete_form" }
{/capture}

{include
    file = "includes/generic-confirm-dialog.html"

    dialog_id       = "product_delete_dialog"
    dialog_title    = {intl l="Delete product"}
    dialog_message  = {intl l="Do you really want to delete this product and all it's components (images, documents)?<br>This can't be canceled."}

    form_action         = {token_url path='/admin/products/delete'}
    form_content        = {$smarty.capture.product_delete_dialog nofilter}
}

{* -- Delete folder confirmation dialog ----------------------------------- *}

{capture name="folder_delete_dialog"}
    <input type="hidden" name="folder_id" id="folder_delete_id" value="" />

    {hook name="folder.delete-form" location="folder_delete_form" }
{/capture}

{include
    file = "includes/generic-confirm-dialog.html"

    dialog_id       = "folder_delete_dialog"
    dialog_title    = {intl l="Delete folder"}
    dialog_message  = {intl l="Do you really want to delete this folder and all its content ?"}

form_action         = {token_url path='/admin/folders/delete'}
form_content        = {$smarty.capture.folder_delete_dialog nofilter}
}

{* -- Delete content confirmation dialog ----------------------------------- *}

{capture name="content_delete_dialog"}
    <input type="hidden" name="content_id" id="content_delete_id" value="" />

    {hook name="content.delete-form" location="folder_content_form" }
{/capture}

{include
    file = "includes/generic-confirm-dialog.html"

    dialog_id       = "content_delete_dialog"
    dialog_title    = {intl l="Delete content"}
    dialog_message  = {intl l="Do you really want to delete this content ?"}

form_action         = {token_url path='/admin/content/delete'}
form_content        = {$smarty.capture.content_delete_dialog nofilter}
}

{* -- Delete customer confirmation dialog ----------------------------------- *}
{capture "customer_delete_dialog"}
    <input type="hidden" name="page" value="{$page}">
    <input type="hidden" name="customer_id" id="delete_customer_id">

    {hook name="customer.delete-form" location="customer_delete_form" }
{/capture}

{include
    file = "includes/generic-confirm-dialog.html"

    dialog_id       = "delete_customer_dialog"
    dialog_title    = {intl l="Delete customer"}
    dialog_message  = {intl l="Do you really want to delete this customer ?"}

    form_action         = {token_url path='/admin/customer/delete'}
    form_content        = {$smarty.capture.customer_delete_dialog nofilter}
    form_id             = "customer_delete_dialog"
}


{* -- Delete brand confirmation dialog ----------------------------------- *}

{capture "brand_delete_dialog"}
    <input type="hidden" name="brand_id" id="brand_delete_id" value="" />

    {hook name="brand.delete-form" }
{/capture}

{include
    file = "includes/generic-confirm-dialog.html"

    dialog_id       = "brand_delete_dialog"
    dialog_title    = {intl l="Delete brand"}
    dialog_message  = {intl l="Do you really want to delete this brand ?"}

    form_action         = {token_url path='/admin/brand/delete'}
    form_content        = {$smarty.capture.brand_delete_dialog nofilter}
}

{/block}

{block name="javascript-initialization"}
 {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
        <script src="{$asset_url}"></script>
    {/javascripts}

    {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
        <script src="{$asset_url}"></script>
    {/javascripts}
    {javascripts file='assets/js/jquery.typewatch.js'}
        <script src="{$asset_url}"></script>
    {/javascripts}
    <script>
        $(function() {

            // Set proper customer ID in delete form
            $('a.customer-delete').click(function(ev) {
                $('#delete_customer_id').val($(this).data('id'));
            });

            // Set proper category ID in delete form
            $('a.category-delete').click(function(ev) {
                $('#category_delete_id').val($(this).data('id'));
            });

            // Set proper product ID in delete form
            $('a.product-delete').click(function(ev) {
                $('#product_delete_id').val($(this).data('id'));
            });

            // Set proper folder ID in delete form
            $('a.folder-delete').click(function(ev) {
                $('#folder_delete_id').val($(this).data('id'));
            });

            // Set proper content ID in delete form
            $('a.content-delete').click(function(ev) {
                $('#content_delete_id').val($(this).data('id'));
            });

            // Set proper brand ID in delete form
            $('a.brand-delete').click(function(ev) {
                $('#brand_delete_id').val($(this).data('id'));
            });

            {* Toggle object visibility *}

            $(".categoryVisibleToggle").on('switch-change', function(event, data) {
                $.ajax({
                   url : "{url path='admin/categories/toggle-online'}",
                   data : {
                       category_id : $(this).data('id'),
                       action : 'visibilityToggle'
                   }
                });
            });

            $(".productVisibleToggle").on('switch-change', function(event, data) {
                $.ajax({
                   url : "{url path='admin/products/toggle-online'}",
                   data : {
                       product_id : $(this).data('id'),
                       action : 'visibilityToggle'
                   }
                });
            });

            $(".folderVisibleToggle").on('switch-change', function(event, data) {
                $.ajax({
                    url : "{url path='admin/folders/toggle-online'}",
                    data : {
                        folder_id : $(this).data('id'),
                        action : 'visibilityToggle'
                    }
                });
            });

            $(".contentVisibleToggle").on('switch-change', function(event, data) {
                $.ajax({
                    url : "{url path='admin/content/toggle-online'}",
                    data : {
                        content_id : $(this).data('id'),
                        action : 'visibilityToggle'
                    }
                });
            });

            $(".brandVisibleToggle").on('switch-change', function(event, data) {
                $.ajax({
                    url : "{url path='admin/brand/toggle-online'}",
                    data : {
                        brand_id : $(this).data('id'),
                        action : 'visibilityToggle'
                    }
                });
            });

        });
    </script>
{/block}

{block name="javascript-last-call"}
    {hook name="search.js" location="search-js" }
{/block}
