var rebort_type = 0;
function rebort(s)
{
    $('#rebort1').modal('show');
    $('.date').val(date_today);
    rebort_type = s;
}
function get_rebort()
{
    $('#rebort1').modal('hide');
    if(rebort_type == 0)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        if(emp_acc[19] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
            var txt = `
            <div class="row card-body">
            <div class="row col-12">
            <div class="form-group col-5">
                    <label>البداية</label>
                    <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
            </div>
            <div class="form-group col-5">
                <label>النهاية</label>
                    <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
            </div>
            <div class="form-groub col-2" style="margin-top:25px">
                <button class="btn btn-success" onclick="update_rebort(0)">تحديث</button>
            </div>
            </div>  
            <div class="card-body">         
            <table id="example1" class="table_image table table-bordered table-striped">           
            <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
                      <tr>
                          <th>اسم العميل</th>
                          <th>الرقم المسلسل</th>
                          <th> اسم الموظف</th>
                          <th>التاريخ</th>
                          <th>الوقت</th>
                      </tr>
                  </thead>
                    <tbody>
    
                    </tbody>
              </table>
           </div>
           </div>
           
           `;
           $('#pg_body').html(txt);
    
           $(function () {
    
            var table = $("#example1").DataTable({
                    dom: 'Bfrtip',
                    //'paging':false,
                    "responsive": true, "lengthChange": false, "autoWidth": false,
                    buttons: ["colvis","copy", "excel", "pdf", "print"],
                    
                            "processing": true,
                            "serverSide": true,
                            "ajax":{
                                url :"model/class/rebort_1.php",
                                type: "POST",  
                                dataType:"JSON",
                                data:{s:start,e:end},
                            }
                            
                }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
            
          });
           
            get_page();	    
        }
   

    }
    if(rebort_type == 1)
    {
        
        get_total_mony("SELECT sum(mony_cus) as `value` FROM `cus` where 1 ","total_mony");
        var start = $('#start_date').val();
        var end = $('#end_date').val();


        if(emp_acc[19] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(1)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
                  <tr>
                  <th>اسم العميل</th>
                  <th>الاشتراك</th>
                  <th>الرقم المسلسل</th>
                  <th>المديونية</th>
                  </tr>
              </thead>
                <tbody>

                </tbody>
          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_2.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });

        get_page();	     
        }  

    }
    if(rebort_type == 2)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        if(emp_acc[21] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(2)">تحديث</button>
        </div>
        </div>           
          <table id="Table1 card-body" class="mdl-data-table dataTable" cellspacing="0" width="100%">
           <thead style="">
                <tbody>
                    <tr>
                        <td>اجمالى العملاء الجدد</td>
                        <td id="all_cus_new"></td>
                    </tr>
                    <tr>
                    <td>  اجمالي التجديدات</td>
                    <td id="all_cus_old"></td>
                </tr>
                    <tr>
                        <td>اجمالى الاستلامات</td>
                        <td id="all_mony_cus"></td>
                    </tr>
                    <tr>
                        <td>اجمالى العملاء النشطون</td>
                        <td id="all_cus_active"></td>
                    </tr>
                    <tr>
                        <td>اجمالى المديونيات</td>
                        <td id="all_paid_mony"></td>
                    </tr>
					                    <tr>
                        <td>اجمالى المصروفات</td>
                        <td id="all_exp_mony"></td>
                    </tr>
										                    <tr>
                        <td>اجمالى الخدمات</td>
                        <td id="all_i_mony"></td>
                    </tr>
               															                    <tr>
                        <td>اجمالى الايرادات</td>
                        <td id="all_inp_mony"></td>
                    </tr>
                </tbody>
          </table>
       </div>`;
       $('#pg_body').html(txt);
       get_page();	       

       $.ajax({
           url:"model/class/rebort_3.php",
           type:"POST",
           dataType:"JSON",
           data:{s:start,e:end},
           success:function(data)
           {
                $('#all_cus_new').text(data.num_cus_new);
                $('#all_cus_old').text(data.num_cus_old);
                $('#all_mony_cus').text(data.total_paid);
                $('#all_paid_mony').text(data.total_stay);
                $('#all_cus_active').text(data.total_active);
                $('#all_exp_mony').text(data.exp);
                $('#all_i_mony').text(data.service);
                $('#all_inp_mony').text(data.inp);
           
           }
       })
        }
    }
    if(rebort_type == 3)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        if(emp_acc[19] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(3)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
        <tr>
        <th>اسم الموظف</th>
        <th>اسم المستخدم</th>
        <th>كلمة السر</th>
        <th>التاريخ</th>
        <th>الوقت</th>
    </tr>
              </thead>
                <tbody>

                </tbody>
          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_4.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });

        }
    
        get_page();	       

    }
    if(rebort_type == 4)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        get_total_mony("SELECT sum(value_exp) as `value` FROM `exp_mony` left join `expen` on `expen`.`id_expense` = `exp_mony`.`id_exp`  left join `emp` on `emp`.`id_emp` = `exp_mony`.`id_user` where `exp_mony`.`date_exp` between '"+start+"' and '"+end+"'","total_mony");
      
      
        if(emp_acc[21] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
      
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(4)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
        <tr>
        <th>اسم المصروف</th>
        <th>القيمة</th>
        <th>اسم الموظف</th>
        <th>اسم الاشتراك</th>
        <th>الملاحظات</th>
        <th>التاريخ</th>
        <th>الوقت</th>
    </tr>
              </thead>
                <tbody>

                </tbody>
          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_5.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });

        get_page();	       
    }

    }
    if(rebort_type == 5)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        if(emp_acc[21] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
        get_total_mony("SELECT sum(value_inp) as `value` FROM `inp_mony` left join `inp` on `inp`.`id_inp` = `inp_mony`.`id_inp`  left join `emp` on `emp`.`id_emp` = `inp_mony`.`id_user` where `inp_mony`.`date_inp` between '"+start+"' and '"+end+"'","total_mony");
        
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(5)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
        <tr>
        <th>اسم الايراد</th>
        <th>القيمة</th>
        <th>اسم الموظف</th>
        <th> اسم المجموعة</th>
        <th>الملاحظات</th>
        <th>التاريخ</th>
        <th>الوقت</th>
    </tr>
              </thead>
                <tbody>

                </tbody>

          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_6.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });

        get_page();	     
    }  

    }
    if(rebort_type == 6)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        get_total_mony("SELECT sum(x) as `value` FROM `mony` where `mony`.`date` between '"+start+"' and '"+end+"'","total_mony");



        if(emp_acc[19] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{

        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(6)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
        <tr>
        <th>اسم العميل</th>
        <th>الاشتراك</th>
        <th>الكود</th>
        <th>القيمة</th>
        <th>اسم الموظف</th>
        <th>الملاحظات</th>
        <th>التاريخ</th>
        <th>الوقت</th>
    </tr>
              </thead>
                <tbody>

                </tbody>

          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_7.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });

        get_page();	
    }       

    }
    if(rebort_type == 7)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        get_total_mony("SELECT sum(paid) as `value` FROM `stock_mony` where `stock_mony`.`date` between '"+start+"' and '"+end+"'","total_mony");
       
       
        if(emp_acc[19] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
       
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(7)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
        <tr>
        <th>اسم العميل</th>
        <th>الاشتراك</th>
        <th>القيمة</th>
        <th>اسم الموظف</th>
        <th>التاريخ</th>
        <th>الوقت</th>
    </tr>
              </thead>
                <tbody>

                </tbody>

          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_8.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });
       
        get_page();	       
    }
    }
    if(rebort_type == 8)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        if(emp_acc[21] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
        $('#tbody_cata').html('');

        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(8)">تحديث</button>
        </div>
        </div>           
          <table id="Table1 card-body" class="mdl-data-table tbody_cata dataTable" cellspacing="0" width="100%">
           <thead style="">

              </thead>
                <tbody id="tbody_cata">
                </tbody>
          </table>
       </div>`;
       $('#pg_body').html(txt);
       get_page();	       

       $.ajax({ url :"model/class/rebort_9.php",
                type: "POST",  
                dataType:"JSON",
                data:{s:start,e:end},
                success:function(response)
                {
                    var l = response.length;
                    for(var i = 0;i < l;i++)
                    {
                        if(response[i].value == null)
                        {
                            var value = 0
                        }else{
                            var value = response[i].value;
                        }
                        var html_code = "<tr><td>"+value+"</td><td>"+response[i].name_cata+"</td></tr>";
                        $('#tbody_cata').append(html_code);
                    }
                }
        });
    }
    }
    if(rebort_type == 9)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        if(emp_acc[20] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
        get_total_mony("SELECT sum(p_b) as `value` FROM `sales` where `sales`.`date` between '"+start+"' and '"+end+"'","total_mony");
        get_total_mony("SELECT sum(tax) as `value` FROM `sales` where `sales`.`date` between '"+start+"' and '"+end+"'","total_mony_1");
        get_total_mony("SELECT sum(p_f) as `value` FROM `sales` where `sales`.`date` between '"+start+"' and '"+end+"'","total_mony_2");
       
       
       
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(9)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
        <tr>
        <th>اسم الصنف</th>
        <th>العدد</th>
        <th>السعر قبل الخصم</th>
        <th>الخصم</th>
        <th>السعر بعد الخصم</th>
        <th>الملاحظات</th>
        <th>اسم الموظف</th>
        <th>الوقت</th>
    </tr>
              </thead>
                <tbody>

                </tbody>


                <tfooter>
                <tr>
                    <th colspan="3" style="text-align:right" id="total_mony">Total:</th>
                    <th colspan="1" style="text-align:right" id="total_mony_1">Total:</th>
                    <th colspan="1" style="text-align:right" id="total_mony_2">Total:</th>
                    <th></th>
                </tr>
            </tfooter>
          </table>
       </div>
       
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_10.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });
      get_page();	  

    }

    }
    if(rebort_type == 11)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        if(emp_acc[21] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(11)">تحديث</button>
        </div>
        </div>           
          <table id="Table1 card-body" class="table card-body" cellspacing="0" width="100%">
                <tbody>
                    <tr class="success">
                        <td id="all_paid_safe"></td>
                        <td>اجمالى الاستلامات</td>
                    <tr>
                    <tr class="success">
                        <td id="all_service_safe"></td>
                        <td>اجمالى الخدمات</td>
                    <tr>
                    <tr class="success">
                        <td id="all_sales_safe"></td>
                        <td>اجمالى المبيعات</td>
                    <tr>
                    <tr class="success">
                        <td id="all_inp_safe"></td>
                        <td>اجمالى الايرادات</td>
                    <tr>
                    <tr class="warning">
                        <td id="all_exp_safe"></td>
                        <td>اجمالى المصروفات</td>
                    <tr>
                    <tr class="success">
                        <td id="all_safe"></td>
                        <td>صافى الربح</td>
                     <tr>
                </tbody>
          </table>
       </div>`;
       $('#pg_body').html(txt);
       get_page();	       
       
        $.ajax({
                url :"model/class/rebort_11.php",
                type: "POST",  
                dataType:"JSON",
                data:{s:start,e:end},
                success:function(data)
                {
                    $('#all_paid_safe').text(data.paid);
                    $('#all_service_safe').text(data.service);
                    $('#all_sales_safe').text(data.sales);
                    $('#all_inp_safe').text(data.inp);
                    $('#all_exp_safe').text(data.exp);
                    $('#all_safe').text(data.all);
                }
        });
    }
    }
    if(rebort_type == 12)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        if(emp_acc[20] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
        $('#tbody_cata').html('');
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(12)">تحديث</button>
        </div>
        </div>           
          <table id="Table1 " class=" card-body mdl-data-table dataTable" cellspacing="0" width="100%">
           <thead style="">

              </thead>
                <tbody  id="tbody_sales">
                </tbody>
          </table>
       </div>`;
       $('#pg_body').html(txt);
       get_page();	       

       $.ajax({ url :"model/class/rebort_12.php",
                type: "POST",  
                dataType:"JSON",
                data:{s:start,e:end},
                success:function(response)
                {
                    var l = response.length;
                    for(var i = 0;i < l;i++)
                    {
                        if(response[i].value == null)
                        {
                            var value = 0
                        }else{
                            var value = response[i].value;
                        }
                        var html_code = "<tr><td>"+value+"</td><td>"+response[i].name_cata+"</td></tr>";
                        $('#tbody_sales').append(html_code);
                    }
                }
        });      
    } 
    }
    if(rebort_type == 13)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();

        if(emp_acc[19] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(13)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
        <tr>
        <th>اسم العميل</th>
        <th>الكود</th>
        <th>اسم الموظف</th>
        <th>التاريخ</th>
        <th>الوقت</th>
    </tr>
              </thead>
                <tbody>

                </tbody>

          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_13.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });

        get_page();	   
    }      
    }

    if(rebort_type == 15)
    {
        var start = $('#start_date').val();
        var end = $('#end_date').val();

        if(emp_acc[19] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
        
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(15)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
        <tr>
        <th>اسم الموظف</th>
        <th>الكود</th>
        <th>البداية</th>
        <th>النهاية</th>
        <th>التاريخ</th>
    </tr>
              </thead>
                <tbody>

                </tbody>

          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_15.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });

        get_page();	  
    }       
    }
    if(rebort_type == 16){
        var start = $('#start_date').val();
        var end = $('#end_date').val();


        if(emp_acc[19] == 0){
            sweetAlert("لا يوجد صلاحيه","","error")
        }else{
                
        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(16)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
        <tr>
        <th>#</th>
        <th>اسم العميل</th>
        <th>الكود</th>
        <th>الخصم</th>
        <th>الملاحظات</th>
        <th>الموظف</th>
        <th>التاريخ</th>
    </tr>
              </thead>
                <tbody>

                </tbody>

          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_16.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });	
        get_page();	 
    }          
    }
    if(rebort_type == 17){
        var start = $('#start_date').val();
        var end = $('#end_date').val();


        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
        <button class="btn btn-success" onclick="update_rebort(17)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
        <tr>
        <th>#</th>
        <th>اسم العميل</th>
        <th>الهاتف</th>
        <th>البوست</th>
        <th>ID</th>
        <th>الملاحظات</th>
        <th>التاريخ</th>
    </tr>
              </thead>
                <tbody>

                </tbody>

          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_17.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });


        get_page();	           
    }
}
function get_total_mony(txt,id)
{
    $.ajax({
        url:"model/class/class.php",
        type:"POST",
        dataType:"JSON",
        data:{txt:txt,type:1},
        success:function(data)
        {
            $('#'+id).text("Total :  "+data[0].value);
        }
    })
}
function update_rebort(s)
{
    var start = $('#start_date_update').val();
    var end = $('#end_date_update').val();
    if(s == 0)
    {

        var txt = `
        <div class="row card-body">
        <div class="row col-12">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
             <button class="btn btn-success" onclick="update_rebort(0)">تحديث</button>
        </div>
        </div>  
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
    <tr>
        <th>اسم العميل</th>
        <th>الرقم المسلسل</th>
        <th> اسم الموظف</th>
        <th>التاريخ</th>
        <th>الوقت</th>
    </tr>
              </thead>
                <tbody>

                </tbody>

          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_1.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });

    }
    if(s == 1)
    {
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(1)">تحديث</button>
        </div>
        </div>           
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
                  <tr>
                  <th>اسم العميل</th>
                  <th>  الاشتراك</th>
                  <th>الرقم المسلسل</th>
                 
                  <th>التاريخ</th>

                  </tr>
              </thead>
                <tbody>

                </tbody>
          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);
       
       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_2.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });
        get_page();
    }
    if(s == 2)
    {
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(2)">تحديث</button>
        </div>
        </div>           
          <table id="Table1" class="card-body mdl-data-table dataTable" cellspacing="0" width="100%">
           <thead style="">
                <tbody>
                    <tr>
                        <td>اجمالى العملاء الجدد</td>
                        <td id="all_cus_new"></td>
                    </tr>
                    <tr>
                        <td>اجمالى الاستلامات</td>
                        <td id="all_mony_cus"></td>
                    </tr>
                    <tr>
                        <td>اجمالى العملاء النشطون</td>
                        <td id="all_cus_active"></td>
                    </tr>
                    <tr>
                        <td>اجمالى المديونيات</td>
                        <td id="all_paid_mony"></td>
                    </tr>
					                    <tr>
                        <td>اجمالى المصروفات</td>
                        <td id="all_exp_mony"></td>
                    </tr>
										                    <tr>
                        <td>اجمالى الخدمات</td>
                        <td id="all_i_mony"></td>
                    </tr>
															                    <tr>
                        <td>اجمالى الايرادات</td>
                        <td id="all_inp_mony"></td>
                    </tr>
                </tbody>
          </table>
       </div>`;
       $('#pg_body').html(txt);
       get_page();	       

       $.ajax({
           url:"model/class/rebort_3.php",
           type:"POST",
           dataType:"JSON",
           data:{s:start,e:end},
           success:function(data)
           {
                $('#all_cus_new').text(data.num_cus_new);
                $('#all_mony_cus').text(data.total_paid);
                $('#all_paid_mony').text(data.total_stay);
                $('#all_cus_active').text(data.total_active);
                $('#all_exp_mony').text(data.exp);
                $('#all_i_mony').text(data.service);
                $('#all_inp_mony').text(data.inp);
           
           }
       })
       get_page();
    }
    if(s == 3)
    {
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(3)">تحديث</button>
        </div>
        </div>           
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
                  <tr>
                      <th>اسم الموظف</th>
                      <th>اسم المستخدم</th>
                      <th>كلمة السر</th>
                      <th>التاريخ</th>
                      <th>الوقت</th>
                  </tr>
              </thead>
                <tbody>

                </tbody>
          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);
       

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_4.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });


        get_page();
    }
    if(s == 4)
    {
        get_total_mony("SELECT sum(value_exp) as `value` FROM `exp_mony` left join `expen` on `expen`.`id_expense` = `exp_mony`.`id_exp`  left join `emp` on `emp`.`id_emp` = `exp_mony`.`id_user` where `exp_mony`.`date_exp` between '"+start+"' and '"+end+"'","total_mony");
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(4)">تحديث</button>
        </div>
        </div>           
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
                  <tr>
                      <th>اسم المصروف</th>
                      <th>القيمة</th>
                      <th>اسم الموظف</th>
                      <th>الملاحظات</th>
                      <th>التاريخ</th>
                      <th>الوقت</th>
                  </tr>
              </thead>
                <tbody>
                <tfoot>
                <tr>
                    <th colspan="1" style="text-align:right" id="total_mony">Total:</th>
                    <th></th>
                </tr>
            </tfoot>
                </tbody>
          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);
       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_5.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });
 
        get_page();     
    }
    if(s == 5)
    {
        get_total_mony("SELECT sum(value_inp) as `value` FROM `inp_mony` left join `inp` on `inp`.`id_inp` = `inp_mony`.`id_inp`  left join `emp` on `emp`.`id_emp` = `inp_mony`.`id_user` where `inp_mony`.`date_inp` between '"+start+"' and '"+end+"'","total_mony");
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(5)">تحديث</button>
        </div>
        </div>           
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
                  <tr>
                      <th>اسم المصروف</th>
                      <th>القيمة</th>
                      <th>اسم الموظف</th>
                      <th>اسم المجموعة</th>
                      <th>الملاحظات</th>
                      <th>التاريخ</th>
                      <th>الوقت</th>
                  </tr>
              </thead>
                <tbody>

                </tbody>

                <tfooter>
                <tr>
                    <th colspan="1" style="text-align:right" id="total_mony">Total:</th>
                    <th></th>
                </tr>
            </tfooter>
          </table>
       </div>
       </div>
       `;
       $('#pg_body').html(txt);
       

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_6.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });
   
        get_page();   
    }
    if(s == 6)
    {
        get_total_mony("SELECT sum(x) as `value` FROM `mony` where `mony`.`date` between '"+start+"' and '"+end+"'","total_mony");
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(6)">تحديث</button>
        </div>
        </div>           
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
                  <tr>
                      <th>اسم العميل</th>
					  <th>الكود</th>
                      <th>القيمة</th>
                      <th>اسم الموظف</th>
                      <th>الملاحظات</th>
                      <th>التاريخ</th>
                      <th>الوقت</th>
                  </tr>
              </thead>
                <tbody>

                </tbody>
                <tfooter>
                <tr>
                    <th colspan="1" style="text-align:right" id="total_mony">Total:</th>
                    <th></th>
                </tr>
            </tfooter>
          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);
       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_7.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });
	  
        get_page();    
    }
    if(s == 7)
    {
        get_total_mony("SELECT sum(paid) as `value` FROM `stock_mony` where `stock_mony`.`date` between '"+start+"' and '"+end+"'","total_mony");
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(7)">تحديث</button>
        </div>
        </div>           
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
                  <tr>
                      <th>اسم العميل</th>
                      <th>القيمة</th>
                      <th>اسم الموظف</th>
                      <th>التاريخ</th>
                      <th>الوقت</th>
                  </tr>
              </thead>
                <tbody>

                </tbody>
                <tfooter>
                <tr>
                    <th colspan="1" style="text-align:right" id="total_mony">Total:</th>
                    <th></th>
                </tr>
            </tfooter>
          </table>
       </div>
       </div>
       
       `;
       $('#pg_body').html(txt);
       

       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_8.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });

        get_page();	      
    }
    if(s == 8)
    {
        $('#tbody_cata').html('');
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(8)">تحديث</button>
        </div>
        </div>           
          <table id="Table1" class=" card-body mdl-data-table dataTable" cellspacing="0" width="100%">
           <thead style="">

              </thead>
                <tbody id="tbody_cata">
                </tbody>
          </table>
       </div>`;
       $('#pg_body').html(txt);
       $.ajax({ url :"model/class/rebort_9.php",
                type: "POST",  
                dataType:"JSON",
                data:{s:start,e:end},
                success:function(response)
                {
                    var l = response.length;
                    for(var i = 0;i < l;i++)
                    {
                        if(response[i].value == null)
                        {
                            var value = 0
                        }else{
                            var value = response[i].value;
                        }
                        var html_code = "<tr><td>"+value+"</td><td>"+response[i].name_cata+"</td></tr>";
                        $('#tbody_cata').append(html_code);
                    }
                }
        });
        get_page();
    }
    if(s == 9)
    {
        get_total_mony("SELECT sum(p_b) as `value` FROM `sales` where `sales`.`date` between '"+start+"' and '"+end+"'","total_mony");
        get_total_mony("SELECT sum(tax) as `value` FROM `sales` where `sales`.`date` between '"+start+"' and '"+end+"'","total_mony_1");
        get_total_mony("SELECT sum(p_f) as `value` FROM `sales` where `sales`.`date` between '"+start+"' and '"+end+"'","total_mony_2");
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(9)">تحديث</button>
        </div>
        </div>           
        <div class="card-body">         
        <table id="example1" class="table_image table table-bordered table-striped">           
        <thead style="color:white;background-color:#007bff;font-family:bold;font-size:19px">
                  <tr>
                      <th>اسم الصنف</th>
                      <th>العدد</th>
                      <th>السعر قبل الخصم</th>
                      <th>الخصم</th>
                      <th>السعر بعد الخصم</th>
                      <th>الملاحظات</th>
                      <th>اسم الموظف</th>
                      <th>الوقت</th>
                  </tr>
              </thead>
                <tbody>

                </tbody>
                <tfooter>
                <tr>
                    <th colspan="3" style="text-align:right" id="total_mony">Total:</th>
                    <th colspan="1" style="text-align:right" id="total_mony_1">Total:</th>
                    <th colspan="1" style="text-align:right" id="total_mony_2">Total:</th>
                    <th></th>
                </tr>
            </tfooter>
          </table>
       </div>
       </div>
       `;
       $('#pg_body').html(txt);
       
       
       $(function () {

        var table = $("#example1").DataTable({
                dom: 'Bfrtip',
                //'paging':false,
                "responsive": true, "lengthChange": false, "autoWidth": false,
                buttons: ["colvis","copy", "excel", "pdf", "print"],
                
                        "processing": true,
                        "serverSide": true,
                        "ajax":{
                            url :"model/class/rebort_10.php",
                            type: "POST",  
                            dataType:"JSON",
                            data:{s:start,e:end},
                        }
                        
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        
      });

        get_page();      
    }
    if(s == 11)
    {
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(11)">تحديث</button>
        </div>
        </div>           
          <table id="Table1" class="card-body table" cellspacing="0" width="100%">
                <tbody>
                <tr class="success">
                <td id="all_paid_safe"></td>
                <td>اجمالى الاستلامات</td>
            <tr>
            <tr class="success">
                <td id="all_service_safe"></td>
                <td>اجمالى الخدمات</td>
            <tr>
            <tr class="success">
                <td id="all_sales_safe"></td>
                <td>اجمالى المبيعات</td>
            <tr>
            <tr class="success">
                <td id="all_inp_safe"></td>
                <td>اجمالى الايرادات</td>
            <tr>
            <tr class="warning">
                <td id="all_exp_safe"></td>
                <td>اجمالى المصروفات</td>
            <tr>
            <tr class="success">
                <td id="all_safe"></td>
                <td>صافى الربح</td>
             <tr>
                </tbody>
          </table>
       </div>`;
       $('#pg_body').html(txt);
       
        $.ajax({
                url :"model/class/rebort_11.php",
                type: "POST",  
                dataType:"JSON",
                data:{s:start,e:end},
                success:function(data)
                {
                    $('#all_paid_safe').text(data.paid);
                    $('#all_service_safe').text(data.service);
                    $('#all_sales_safe').text(data.sales);
                    $('#all_inp_safe').text(data.inp);
                    $('#all_exp_safe').text(data.exp);
                    $('#all_safe').text(data.all);
                }
        });     
        get_page();
    }
    if(s == 12)
    {
        $('#pg_body').html('');
        var txt = `
        <div class="row card-body">
        <div class="row col-12 card-body">
        <div class="form-group col-5">
                <label>البداية</label>
                <input type="date" value="`+start+`" id="start_date_update" class="form-control date" />
        </div>
        <div class="form-group col-5">
            <label>النهاية</label>
                <input type="date" value="`+end+`" id="end_date_update" class="form-control date" />
        </div>
        <div class="form-groub col-2" style="margin-top:25px">
            <button class="btn btn-success" onclick="update_rebort(12)">تحديث</button>
        </div>
        </div>           
          <table id="Table1" class=" card-body mdl-data-table dataTable" cellspacing="0" width="100%">
           <thead style="">

              </thead>
                <tbody id="tbody_sales">
                </tbody>
          </table>
       </div>`;
       $('#pg_body').html(txt);
       $.ajax({ url :"model/class/rebort_12.php",
                type: "POST",  
                dataType:"JSON",
                data:{s:start,e:end},
                success:function(response)
                {
                    var l = response.length;
                    for(var i = 0;i < l;i++)
                    {
                        if(response[i].value == null)
                        {
                            var value = 0
                        }else{
                            var value = response[i].value;
                        }
                        var html_code = "<tr><td>"+value+"</td><td>"+response[i].name_cata+"</td></tr>";
                        $('#tbody_sales').append(html_code);
                    }
                }
        });
        get_page();      
    }
}