{% extends 'Admin/Sidebar2.html' %}
{% block content %}
{% load widget_tweaks %}
{% load static%}

<head>
    <!-- Font special for pages-->
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i" rel="stylesheet">

    <!-- Main CSS-->
    <link href="{% static "css/main.css" %}"rel="stylesheet" media="all">

    <style>
        .input_field {
              width: 100%;
              padding: 12px 20px;
              border: 1px solid #ccc;
              border-radius: 10px;
        }

        .table th
        {
              padding-top: 3px;
              vertical-align: initial;
              border-top: 0px;
              font-weight: bold;
        }

        .table td
        {
              vertical-align: initial;
              border-top: 0px;
        }

        .card-5 .card-body
        {
            padding: 52px 85px;
            padding-bottom: 0px;
        }
    </style>
</head>
<div style="background-color: white;" class=" >
    <div class="wrapper wrapper 0">
        <div style="margin-left: 0px;" class="card card-5">

            {% if messages %}

        <ul class="messages">
            {% for message in messages %}
            <li  {% if message.tags %} class=" {{ message.tags }} " {% endif %}> {{ message }} </li>
            {% endfor %}
        </ul>

            {% endif %}

            <div class="card-heading">
                <h2 class="title mt-3" style="color: #02111f;"> PREDICT CUSTOMER RETENTION </h2>
                <h4 CLASS="title mt-3" style="color: #02111f;">BASED ON THE FACTORS AFFECTING FOR CUSTOMER SATISFACTION</h4>
            </div>

           <div class="card-body">
                 <form action="/Admin/Customer_Frequency/" method="post">
                     {% csrf_token %}
                     {{form}}

                        <div class="container">
                          <div class="row mt-5 mb-3">
                            <div class="col text-center">
                              <input type="submit" value="PREDICT" class="btn w-50" style="background: #02111f; border-radius: 50px;"/>
                            </div>
                          </div>
                        </div>
                 </form>
                 <br>
                 <div class="text-right"></div>
                 <br>
           </div>
       </div>
   </div>
   <div id="myDiv">
       <div id="div_print">
           <div class="card card-body printableArea">
               <div role="alert">
                    <div class="container" style="overflow-x:auto;">
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th>Customer ID  </th>
                                    <th>Customer Name  </th>
                                    <th>Next Purchase In </th>
                                    <th>Purchased Frequency </th>
                                    <th>Impact on Profitability </th>
                                </tr>
                            </thead>
                            <tbody>
                                {% if d %}
                                {% for i in d %}
                                <tr>
                                    <td>{{i.CustomerID}} </td>
                                    <td>{{i.CustomerName}} </td>
                                    <td>{{i.NextPurchaseDay}} </td>
                                    <td>{{i.Frequency}} </td>
                                    <td>{{i.persontageImpact}} % </td>
                                </tr>
                                {% endfor %}
                                {% endif %}
                            </tbody>
                        </table>
                    </div>
               </div>
           </div>
       </div>
   </div>

   <script language="javascript">
        function printdiv(printpage) {
            var headstr = "<html><head><title></title></head><body>";
            var footstr = "</body>";
            var newstr = document.all.item(printpage).innerHTML;
            var oldstr = document.body.innerHTML;
            document.body.innerHTML = headstr + newstr + footstr;
            window.print();
            document.body.innerHTML = oldstr;
            location.reload();
            return false;
        }
   </script>

   <div class="alert alert-primary fixed-bottom mb-0 text-center" style="background: #747578; border: none; color: white;" role="alert"  > © SERVPORT 2022   </div>

</div>

{% endblock content %}

