<style>
    .myresult {
        -webkit-print-color-adjust: exact;
    }
    .nodata{
        background-color: #72B4EC;
        color: white;
        border-radius: 13px;
        margin: 14px;
        font-size: 24px;
        text-align: center;
        padding: 5px;
    }
</style>

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">التقارير</a></li>
            <li class="active">تقرير عملاء بالمنتجات</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">تقرير عملاء بالمنتجات

                <a href="{$youtubes[77]->url}" target="_blank" class="hidden-print"><img src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube" style="width: 2%;"></a>
            </div>
            <div class="panel-body">
                <form class="form-inline hidden-print" action="clientsWithProductsReport.php?page=products" method="post">
                    <div class="form-group">
                        <label class="sr-only">من التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" name="datefrom" >
                    </div>
                    <div class="form-group">
                        <label class="sr-only">إلى التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" name="dateto" >
                    </div>
                    <div style="clear: both"></div>
                    <br />

                    <div style="clear: both"></div>
                    <br />

                    <div class="form-group col-lg-3">
                        <label class="sr-only">تصنيف المنتج</label>
                        <select class="select2 wdt300 productCattt2" data-level="0"  name="productCatId0" id="productCatId0" >
                            <option value="-1">اختر تصنيف</option>
                            <option value="-2"> كل التصنيفات</option>
                            {foreach $catDataReport as $data}
                            <option value="{$data->productCatId}">{$data->productCatName}</option>
                            {/foreach}
                        </select>
                        <input type="hidden" id="level" name="level" value="0">
                    </div>
                    <div id="manyParents2">

                    </div>

                    <div style="clear: both"></div>
                    <br />
                    <button type="submit" class="btn btn-primary">بحث</button>
                </form>
                <div class="color-white" style="margin-top: 14px;margin-bottom: 11px;">
                    <input type="radio" name="clients_product" value="" onclick="document.location.href = 'http://localhost/erp/controllers/clientsWithProductsReport.php'"/>عملاء
                    <input type="radio" name="clients_product" value="" checked="checked" onclick="document.location.href = 'somepage.htm'"/>منتجات
                </div>
            </div>
            <div class="panel panel-default panel-m">
                <!-- Default panel contents -->
                <div class="panel-heading">{$message}</div>
                <div class="panel-body">
                    {if $thereData eq 1}
                    <hr/>
                    {literal}
                    <style>

                        tr:nth-child(even){background-color: #cecece}
                        .product{
                            background-color: #cde3f7;
                        }
                        table, th, td {
                            border: 1px solid black;
                            text-align: center;
                            font-weight: bold;
                        }
                        th {
                            background-color: #357ebd;
                            color: white;
                        }
                        @media print {
                            @page {
                                size: landscape;
                                margin: 0;
                            }

                            .willprint ,.willprint td,.willprint th {
                                font-family: arial;
                                font-size: 14px;
                                border-collapse: collapse;
                                border: 1px solid #333 !important;
                            }
                            .willprint th{
                                background: #aaa !important;
                            }
                            .willprint tr:even-child td{
                                background: #333 !important;
                                color: #fff !important;
                            }
                        }

                        .excel_btn{
                            margin-right: 12px;
                            margin-bottom: 11px;
                            margin-top: 10px;
                        }
                        .hidden-print{
                            margin-bottom: 11px;
                            margin-top: 10px;
                        }
                    </style>
                    {/literal}
                    <table id="table2excel table-black" class=" willprint" style="width: 100%">
                        <thead>
                            <tr>
                                <th >#</th>
                                <th  colspan="2"> المنتجات</th>
                                {foreach $allClients as $prod}
                                <th colspan="2"> {$prod->clientname}</th>
                                {/foreach}
                            </tr>
                        </thead>
                        <tbody>
                            {for $x = 0 ; $x <= $count_allproductData ; $x++}
                            {assign var=i value=0}
                            {foreach $allProductsData[$x]['productDataArr'][0] as $data}
                            <tr>
                                <th  rowspan="2">{$x+1}</th>
                                <td class="product"  rowspan="2">{$data}</td>
                                <td>عدد</td>
                                {foreach $allClients as $prod}
                                {if $prod->clientid|in_array:$allProductsData[$x]['product_data_array']}
                                <td colspan="2">{$allProductsData[$x]['productDataArr'][1][$i]->netNo}</td>
                                {else}
                                <td colspan="2">0</td>
                                {/if}
                                {/foreach}
                            </tr>
                            <tr>
                                <td>قيمة</td>
                                {foreach $allClients as $prod}
                                {if $prod->clientid|in_array:$allProductsData[$x]['product_data_array']}
                                <td colspan="2">{$allProductsData[$x]['productDataArr'][1][$i]->netVal}</td>
                                {assign var=i value=$i+1}
                                {else}
                                <td colspan="2">0</td>
                                {/if}
                                {/foreach}
                            </tr>
                            {/foreach}
                            {/for}
                        </tbody>
                    </table>
                    <div class="clearfix"></div>
                    <hr />
                    <div class="hidden-print">
                        <button type="button" onclick="print_Custom('mycustomheader');" class="btn btn-success pull-right hidden-print">طباعة</button>
                        <button style="margin-top: 10px;margin-right: 8px;" class="btn btn-success pull-right excelFile" data-tblId ="excelTable" data-path="">ملف اكسل</button>
                        <span id="ExcelStatus"></span>
                    </div>
                    {else}
                    <div class="nodata">عفوا لا توجد نتائج</div>
                    {/if}
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
