<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[135]->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" 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;font-size: 12px;font-weight: bold;">
                    <input class="color-white" style="margin-left: 6px;" type="radio" name="clients_product" value="" checked="checked" onclick="document.location.href = 'http://localhost/erp/controllers/clientsWithProductsReport.php'"/>عملاء
                    <input class="color-white" style="margin-left: 6px;" type="radio" name="clients_product" value=""  onclick="document.location.href = 'http://localhost/erp/controllers/clientsWithProductsReport.php?page=products'"/>منتجات
                </div>

            </div>
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">{$message}</div>
                <div class="panel-body" style="overflow-x: auto;">
                    {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" class="table-black willprint" style="width: 100%">
                        <thead>
                            <tr >
                                <th rowspan="2" class="clientpro">#</th>
                                <th rowspan="2" class="clientpro"> العملاء</th>
                                {foreach $allProducts as $prod}
                                <th colspan="2" class="clientpro"> {$prod->productName}</th>
                                {/foreach}

                            </tr>
                            <tr>
                                {foreach $allProducts as $prod}
                                <th class="parentclientpro">عدد </th>
                                <th class="parentclientpro">قيمة </th>
                                {/foreach}

                            </tr>
                        </thead>
                        <tbody>
                            {for $x = 0 ; $x <= $count_allData ; $x++}
                            <tr>
                                {assign var=i value=1}
                                {foreach $allData[$x]['clientDataArr'][0] as $data}
                                <th>{$x+1}</th>
                                <td class="product">{$data}</td>
                                {assign var=i value=$i+1}
                                {/foreach}

                                {assign var=i value=0}
                                {foreach $allProducts as $prod}
                                {if $prod->productId|in_array:$allData[$x]['client_data_array']}
                                <td>{$allData[$x]['clientDataArr'][1][$i]->netNo}</td>
                                <td>{$allData[$x]['clientDataArr'][1][$i]->netVal}</td>
                                {assign var=i value=$i+1}
                                {else}
                                <td>0</td>
                                <td>0</td>
                                {/if}
                                {/foreach}
                            </tr>
                            {/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 ="table2excel" data-path="">ملف اكسل</button>
                        <span id="ExcelStatus"></span>
                    </div>
                    {else}
                    <div class="nodata">عفوا لا توجد نتائج</div>
                    {/if}
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
