<?php
//define('SITEURL','http://localhost/design2/');
include_once('database_connection.php');
 /* $cachefile = 'v'.date('M-d-Y').'.html';
    // define how long we want to keep the file in seconds. I set mine to 5 hours.
    $cachetime = 18000;
    // Check if the cached file is still fresh. If it is, serve it up and exit.
    if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
    include($cachefile);
        exit;
    }
    // if there is either no file OR the file to too old, render the page and capture the HTML.
    ob_start();*/
if(isset($_POST['submit']))
{
   // print_r($_POST);
        //$_SESSION['userid']=
        $COAID=$_POST['dealer'];
        $userid=1;//$_SESSION['userid'];
        $visitdate=$_POST['visitdate'];
        $newappoint=$_POST['appointarrange'];
        $appointdate=$_POST['appointdate'];
        $additional_info=$_POST['additional_info'];
        $ContactPerson=$_POST['ContactPerson'];
       // $ContactType=$_POST['ContactType'];
        $contactTypeId=$_POST['contactTypeId'];
        $TypeContactId=$_POST['TypeContactId'];
        $customerCategoryId=$_POST['customerCategoryId'];
        $discuss=$_POST['discuss'];
        $feedback=$_POST['feedback'];
        $notes=$_POST['notes'];
        $managernotes=$_POST['managernotes'];  
       $id=1;
       $sql="select max(id) as id from VisitMaster";
                $result=odbc_exec($connection,$sql);
               // print_r($result);
                while($row=odbc_fetch_array($result))
                {
                $id=$row['id'];
                $id=$id+1;
                //echo "id=".$id;
                 }
                
     $sql="insert into VisitMaster (id,COAID,salesrepid,visitdate,appointdate,newappoint,additional_info,contact_person,contactTypeId,TypeContactId,customerCategoryId,discuss,feedback,notes,managernotes) values('$id','$COAID','$userid','$visitdate','$appointdate','$newappoint','$additional_info','$ContactPerson','$contactTypeId','$TypeContactId','$customerCategoryId','$discuss','$feedback','$notes','$managernotes')";
    odbc_exec($connection,$sql);
    echo "<script>alert('Visit Saved Sucessfully');window.location='visit.php?sidebarid=21#supplier</script>";
}

?>

    <link rel="icon" href="<?php echo SITEURL;?>assets/images/favicon.png" type="image/x-icon" />
    <link rel="shortcut icon" href="<?php echo SITEURL;?>assets/images/favicon.png" type="image/x-icon" />
    <title>Sub-Page</title>

    <!--JSGrid css-->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/datatables.css" />

    <!--Google font-->
<!--     <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,500,600,700" rel="stylesheet">
 -->
    <!-- Font Awesome -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/fontawesome.css">

    <!-- ico-font -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/icofont.css">

    <!-- Themify icon -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/themify.css">

    <!-- Flag icon -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/flag-icon.css">

    <!-- prism css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/prism.css">

    <!-- Tour css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/tour.css">

    <!-- Owl css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/owlcarousel.css">

    <!-- Bootstrap css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/bootstrap.css">

    <!-- App css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/style.css">

    <!-- Chartist -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/chartist.css">

    <!-- Responsive css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/responsive.css">

    <!-- DatePicker css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/date-picker.css">

    <!--Select2 css-->
    <link rel="stylesheet" type="text/css" href="<?php echo SITEURL;?>assets/css/select2.css" />

    <!-- Animate icon -->
    <link rel="stylesheet" href="<?php echo SITEURL;?>assets/css/animate.css">
<!--     <link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css"/>
 -->
    <style>

        table#invoice {
            table-layout: fixed;
        }

        table#invoice {
            font-size: small;
        }

        .tabbed-card .col-1,
        .col-2,
        .col-3,
        .col-4,
        .col-5,
        .col-6,
        .col-7,
        .col-8,
        .col-9,
        .col-10,
        .col-11,
        .col-12,
        .col,
        .col-auto,
        .col-sm-1,
        .col-sm-2,
        .col-sm-3,
        .col-sm-4,
        .col-sm-5,
        .col-sm-6,
        .col-sm-7,
        .col-sm-8,
        .col-sm-9,
        .col-sm-10,
        .col-sm-11,
        .col-sm-12,
        .col-sm,
        .col-sm-auto,
        .col-md-1,
        .col-md-2,
        .col-md-3,
        .col-md-4,
        .col-md-5,
        .col-md-6,
        .col-md-7,
        .col-md-8,
        .col-md-9,
        .col-md-10,
        .col-md-11,
        .col-md-12,
        .col-md,
        .col-md-auto,
        .col-lg-1,
        .col-lg-2,
        .col-lg-3,
        .col-lg-4,
        .col-lg-5,
        .col-lg-6,
        .col-lg-7,
        .col-lg-8,
        .col-lg-9,
        .col-lg-10,
        .col-lg-11,
        .col-lg-12,
        .col-lg,
        .col-lg-auto,
        .col-xl-1,
        .col-xl-2,
        .col-xl-3,
        .col-xl-4,
        .col-xl-5,
        .col-xl-6,
        .col-xl-7,
        .col-xl-8,
        .col-xl-9,
        .col-xl-10,
        .col-xl-11,
        .col-xl-12,
        .col-xl,
        .col-xl-auto {
            padding-left: 4px !important;
            padding-right: 4px !important;

        }

        #select2-cheque_cboVendor-container {
            font-size: smaller;
        }

        .card.full-card {
            top: 0px !important;
            left: 0px !important;
            right: 0px !important;
            height: 100% !important;
            width: 100% !important;
        }

        .lbl_edit {
            color: blue;
            text-align: center;
        }
    </style>


</head>

<body>

    <!-- Loader starts -->
    <div class="loader-wrapper">
        <div class="loader bg-white">
            <div class="line"></div>
            <div class="line"></div>
            <div class="line"></div>
            <div class="line"></div>
            <h4>Have a great day at work today <span>&#x263A;</span></h4>
        </div>
    </div>
    <!-- Loader ends -->

    <!--page-wrapper Start-->
    <div class="page-wrapper">

        <!--Page Body Start-->
        <div class="page-body-wrapper">

            <!--Page Body Start-->
            <div class="page-body" style="margin-top:0!important">

                <!-- Container-fluid starts -->
                <div class="container-fluid">

                    <div class="row">
                        <div class="col-sm-12 col-xl-12 xl-100">
                            <div class="card">
                                <div class="card-header">
                                    <h5>Dealers Vists</h5>
                                    <span>Use this form to define customer Visits.</span>
                                    <div class="card-header-right">
                                        <i class="icofont icofont-maximize full-card"></i>
                                        <i class="icofont icofont-minus minimize-card"></i>
                                    </div>
                                </div>

                                <div class="card-body">
                                    <ul class="nav nav-tabs" id="myTab" role="tablist">
                                        <li class="nav-item">
                                            <a class="nav-link active" id="supplier-tabs" data-toggle="tab"
                                                href="#supplier" role="tab" aria-controls="supplier"
                                                aria-selected="true">Search</a>
                                        </li>

                                        <li class="nav-item">
                                            <a class="nav-link" id="basic-tab" data-toggle="tab" href="#basic"
                                                role="tab" aria-controls="basic" aria-selected="false">Basic</a>
                                        </li>

                                    </ul>
                                    <div class="tab-content" id="myTabContent">

                                        <div class="tab-pane fade" id="basic" role="tabpanel"
                                            aria-labelledby="basic-tab">

                                                                                 <form id="InvoiceForm" method="post">
                                                <div class="row m-20 form-group">
                                                    <h5>
                                                        <span class="lbl_edit" id="RetreiveKeyField"></span>
                                                    </h5>
                                                </div>
    <div class="row m-20 form-group">
                                             <label class="col-sm-12 col-md-12 col-form-label" style="background-color:#ab8ce4;text-align: center;">Report Date Information</label>
 
                                                </div>


                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Select Dealer</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                       <select class="col-12 col-md-12 col-sm-6 form-control" id="dealer" name="dealer"  tabindex="-1" aria-hidden="true">
                                                                    <option value="" data-select2-id="2">--Select Customer </option>
                                                                <?php 
                                                $result=odbc_exec($connection,'select COAID,COAName from accounts where under=54 and natureid=14');
  while ($row = odbc_fetch_array($result)) {
   echo "<option value='".$row['COAID']."'>".$row['COAName']."</option>";
  }
                                                                ?>

                                                                </select>
                                                    </div>
                                                </div>

                                                <!-- <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Opening Balance</label>
                                                    <div class="col-12 col-md-4 col-sm-6">   
                                                    <input type="number" name="Attr1" class="form-control" placeholder="Opening Balance" id="attr1">
                                                    </div>
                                                </div> -->

                                                <div class="row m-20 form-group">
                                                    <label for="inputEmail3" class="col-sm-3 col-form-label">Contact Date
                                                        </label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                        <div class="select2-drpdwn">
                                                            <div class="mb-2">
                                                                <input type="date" name="visitdate" id="visitdate" class="form-control">
                                                              
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>



                                                <div class="row m-20 form-group">
                                                    <label for="inputEmail3" class="col-sm-3 col-form-label">New Appointment Arrange</label>
                                                    <div class="col-2 col-md-2 col-sm-6">
                                                        <div class="select2-drpdwn">
                                                            <div class="mb-2">
                                                                <input type="radio" id="appointarrange1" name="appointarrange" class="form-group" value="1">Yes 
                                                                <input type="radio" id="appointarrange0" name="appointarrange" class="form-group" value="0">No 
                                                                
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="row m-20 form-group">
                                                    <label for="inputEmail3" class="col-sm-3 col-form-label">New Appointment 
                                                        Date</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                        <div class="select2-drpdwn">
                                                            <div class="mb-2">
                                                                        <input type="date" name="appointdate" id="appointdate" class="form-control">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Addition info Appointment</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                        <input type="text" id="additional_info" name="additional_info" class="form-control" placeholder="Additional Infomration" id="attr6">
                                                    </div>
                                                </div>
                                                <div class="row m-20 form-group">
                                             <label class="col-sm-12 col-md-12 col-form-label" style="background-color:#ab8ce4;text-align: center;">Contact Information</label>
 
                                                </div>
                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Contact Person 1</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                        <input type="text" name="ContactPerson" class="form-control" placeholder="Contact Person 1" id="contactperson1">
                                                    </div>
                                                </div>
                                                                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Contact Type</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                           <select class="col-12 col-md-12 col-sm-6 form-control" id="contactTypeId" name="contactTypeId"  tabindex="-1" aria-hidden="true">
                                                                    <option value="" data-select2-id="2">--Select Contact  Type--</option>
                                                                <option value="9" data-mastervalueid="9" data-mastervalue="CORPORATE">Telephone</option><option value="10" data-mastervalueid="10" data-mastervalue="INDIVIDUALS">Physical</option></select>
                                                    </div>
                                                </div>
                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Type of Contact</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                           <select class="col-12 col-md-12 col-sm-6 form-control" id="TypeContactId" name="TypeContactId"  tabindex="-1" aria-hidden="true">
                                                            <option value="" data-select2-id="2">--Select Type of Contact  --</option>
                                                 <?php 
                                                $result=odbc_exec($connection,'select id,title from TypeContact');
  while ($row = odbc_fetch_array($result)) {
   echo "<option value='".$row['id']."'>".$row['title']."</option>";
  }
                                                                ?>

                                                            </select>
                                                    </div>
                                                </div>

                                                     <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Customer Category</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                           <select class="col-12 col-md-12 col-sm-6 form-control" id="customerCategoryId" name="customerCategoryId"  tabindex="-1" aria-hidden="true">
                                                                    <option value="" data-select2-id="2">--Select Customer Category</option>
                                                                                              <?php 
                                                $result=odbc_exec($connection,'select id,title from CustomerCategory');
  while ($row = odbc_fetch_array($result)) {
   echo "<option value='".$row['id']."'>".$row['title']."</option>";
  }
                                                                ?>

                                                                     </select>
                                                    </div>

                                                </div>
                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">What has been Discuss</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                        <textarea id="discuss" name="discuss" class="form-control" placeholder="Discuss" id="attr4"></textarea>
                                                    </div>
                                                </div>

                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Feedback</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                        <textarea  name="feedback" class="form-control" placeholder="Feedback" id="feedback"></textarea>
                                                    </div>
                                                </div>
      <div class="row m-20 form-group">
                                             <label class="col-sm-12 col-md-12 col-form-label" style="background-color:#ab8ce4;text-align: center;">Notes</label>
 
                                                </div>
                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Sales Rep Note</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                        <textarea name="notes" class="form-control" placeholder="Sales Rep Note" id="notes"></textarea>
                                                    </div>
                                                </div>


                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Sales Manager Notes</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                        <textarea name="managernotes" class="form-control" placeholder="Sales Manager Notes" id="managernotes">
                                                            </textarea>
                                                    </div>
                                                </div>

                                                <div class="row m-20 form-group" style="display: none;">
                                                    <label class="col-sm-3 col-form-label">Contact Person1 Info</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                        <textarea name="Attr12" class="form-control" placeholder="Contact Person Info" id="attr12" cols="30" rows="3"></textarea>
                                                    </div>
                                                </div>



                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-3 col-form-label">Visit Card Picture</label>
                                                    <div class="col-12 col-md-4 col-sm-6">
                                                        <input type="file" name="ContactDesignation1" class="form-control" placeholder="Contact Designation 1" id="contactdesignation1">
                                                    </div>
                                                </div>



                                                <!--Opening Balance End-->

                                                <div class="card-footer">
                                                    <!-- onclick="javascript:void(0);submitInvoice(this)"-->
                                                    <button class="btn btn-primary" name="submit" type="submit" >Submit</button>
                                                    <button class="btn btn-secondary" onclick="javascript:void(0);resetInvoice(this)">Clear</button>
                                                    <button class="btn btn-danger" onclick="javascript:void(0);ClearForm(true)">Cancel</button>
                                                </div>
                                            </form>

                                        </div>

                                        <div class="tab-pane fade  show active" id="supplier" role="tabpanel"
                                            aria-labelledby="supplier-tab">

                                            <!-- <form id="searchForm" onsubmit="return false;">
                                                <div class="row m-20 form-group">
                                                    <label class="col-sm-1 col-12 col-md-1  col-form-label">Account Name</label>
                                                    <div class="col-12 col-md-2 col-sm-2 m-b-20">                                           
                                                        <input type="text"  class="form-control" aria-describedby="basic-addon2" placeholder="Search" id="Search_Account" name="COAName">
                                                    </div>
                                                
                                                    <label class="col-sm-1 col-12 col-md-1  col-form-label">Trade License #</label>
                                                    <div class="col-12 col-md-2 col-sm-2 m-b-20">                                           
                                                        <input type="text"  class="form-control" aria-describedby="basic-addon2" placeholder="Search" id="Search_Attr4" name="Attr4">
                                                    </div>
                                                
                                                    <label class="col-sm-1 col-12 col-md-1  col-form-label">Category</label>
                                                    <div class="col-12 col-md-2 col-sm-2 m-b-20">                                           
                                                        <input type="text"  class="form-control" aria-describedby="basic-addon2" placeholder="Search" id="Search_Category" name="Category">
                                                    </div>
                                                
                                                    <label class="col-sm-1 col-12 col-md-1  col-form-label">Mob</label>
                                                    <div class="col-12 col-md-2 col-sm-2 m-b-20">                                            
                                                        <input type="text"  class="form-control" aria-describedby="basic-addon2" placeholder="Search" id="Search_Attr10" name="Attr10">
                                                    </div>
                                                
                                                    <label class="col-sm-1 col-12 col-md-1  col-form-label">VAT #</label>
                                                    <div class="col-12 col-md-2 col-sm-2 m-b-20">                                            
                                                        <input type="text"  class="form-control" aria-describedby="basic-addon2" placeholder="Search" id="Search_Attr15" name="Attr15">
                                                    </div>

                                                    <button class="btn btn-primary m-b-20"   onclick="javascript:void(0);doPost(this)">Search</button>
                                                </div>
                                            </form> -->
                                            <form id="searchForm" onsubmit="return false;">
                                                <div class="row m-2 m-l-0 form-group">

                                                    <div class="col-12 col-sm-2 col-md-2 form-group">
                                                        <!-- <label for="Search_Group" class="col-form-label-xsm">Customer Name</label> -->
                                                        <input type="text" class="form-control form-control-sm"
                                                            placeholder="Customer Name" id="Search_Account"
                                                            name="COAName" />
                                                    </div>

                                                    <div class="col-12 col-sm-2 col-md-2 form-group">
                                                        <!-- <label for="Search_Description" class="col-form-label-xsm">Trade Lic #</label> -->
                                                        <input type="text" class="form-control form-control-sm"
                                                            placeholder="Trade License #" id="Search_Attr4"
                                                            name="Attr4" />
                                                    </div>

                                                    <div class="col-12 col-sm-2 col-md-2 form-group">
                                                        <!-- <label for="Search_Category" class="col-form-label-xsm">Category</label> -->
                                                        <input type="text" class="form-control form-control-sm"
                                                            placeholder="Category" id="Search_Category"
                                                            name="Category" />
                                                    </div>
                                                    <!-- <div class="col-12 col-sm-2 col-md-2 form-group">
                                                        <input type="text" class="form-control form-control-sm"  placeholder="Level3" id="Search_L3" name="L3"/>
                                                    </div>
                                                    <div class="col-12 col-sm-2 col-md-2 form-group">
                                                        <input type="text" class="form-control form-control-sm"  placeholder="Level2" id="Search_L2" name="L2"/>
                                                    </div>
                                                    <div class="col-12 col-sm-2 col-md-2 form-group">
                                                        <input type="text" class="form-control form-control-sm"  placeholder="Level1" id="Search_L1" name="L1"/>
                                                    </div> -->

                                                    <div class="col-12 col-sm-2 col-md-2 form-group">
                                                        <!-- <label for="Search_Code" class="col-form-label-xsm">Mobile</label> -->
                                                        <input type="text" class="form-control form-control-sm"
                                                            placeholder="Mobile" id="Search_Attr10" name="Attr10" />
                                                    </div>
                                                    <div class="col-12 col-sm-2 col-md-2 form-group">
                                                        <!-- <label for="Search_Level" class="col-form-label-xsm">VAT REG #</label> -->
                                                        <input type="text" class="form-control form-control-sm"
                                                            placeholder="TRN #" id="Search_Attr15" name="Attr15" />
                                                    </div>

                                                    <div class="col-12 col-sm-2 col-md-2 form-group">
                                                        <!-- <label for="Search_Level" class="col-form-label-xsm"></label> -->
                                                        <button class="btn-primary form-control form-control-sm"
                                                            onclick="javascript:void(0);doPost(this)">Search</button>
                                                    </div>

                                                </div>
                                            </form>

                                            <div class="table-responsive mt-2">

                                                <table
                                                    class="table table-bordered table-hover table-striped table-condensed"
                                                    id="invoice">
                                                    <thead class="thead-light">
                                                        <tr>
                                                            <th>Dealer Id</th>
                                                            <th>Account Name</th>
                                                            <th>Visit Date</th>
                                                            <th>Appointment Date</th>
                                                            <th>Sales Person</th>
                                                             <th>Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <!-- <tr id="invoice-no-data">
                                                                <td colspan="7" style="text-align:center"> 
                                                                    There's no data 
                                                                </td>
                                                            </tr> -->
                                                    </tbody>
                                                </table>

                                            </div>

                                        </div>

                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>

                </div>

                <!-- Container-fluid Ends -->
            </div>
            <!--Page Body Ends-->

        </div>
    </div>

    <!-- latest jquery-->
    <script src="<?php echo SITEURL;?>assets/js/jquery-3.2.1.min.js"></script>

    <!-- Bootstrap js-->
    <script src="<?php echo SITEURL;?>assets/js/bootstrap/popper.min.js"></script>
    <script src="<?php echo SITEURL;?>assets/js/bootstrap/bootstrap.js"></script>

    <!-- Counter js-->
    <script src="<?php echo SITEURL;?>assets/js/counter/jquery.waypoints.min.js"></script>
    <script src="<?php echo SITEURL;?>assets/js/counter/jquery.counterup.min.js"></script>
    <!-- <script src="<?php echo SITEURL;?>assets/js/counter/counter-custom.js"></script> -->

    <!-- owlcarousel js-->
    <script src="<?php echo SITEURL;?>assets/js/owlcarousel/owl.carousel.js"></script>

    <!-- prism js -->
    <script src="<?php echo SITEURL;?>assets/js/prism/prism.min.js"></script>

    <!-- clipboard js -->
    <script src="<?php echo SITEURL;?>assets/js/clipboard/clipboard.min.js"></script>

    <!-- custom card js  -->
    <script src="<?php echo SITEURL;?>assets/js/custom-card/custom-card.js"></script>

    <!--Height Equal Js-->
    <script src="<?php echo SITEURL;?>assets/js/height-equal.js"></script>

    <!-- Sidebar jquery-->
    <script src="<?php echo SITEURL;?>assets/js/sidebar-menu.js"></script>
    <script src="<?php echo SITEURL;?>assets/js/compact-small-button.js"></script>

    <!-- Theme js-->
    <script src="<?php echo SITEURL;?>assets/js/script.js"></script>

    <!-- tour js -->
    <script src="<?php echo SITEURL;?>assets/js/tour/intro.js"></script>
    <script src="<?php echo SITEURL;?>assets/js/tour/intro-init.js"></script>

    <!-- Chartist  -->
    <script src="<?php echo SITEURL;?>assets/js/chartis/chartist.js"></script>

    <!--Sparkline  Chart JS-->
    <script src="<?php echo SITEURL;?>assets/js/sparkline/sparkline.js"></script>

    <!--Dashboard business js-->
    <!-- <script  src="<?php echo SITEURL;?>assets/js/dashboard-business.js"></script> -->
    <script src="<?php echo SITEURL;?>assets/js/date-picker/datepicker.js"></script>
    <script src="<?php echo SITEURL;?>assets/js/date-picker/datepicker.en.js"></script>

    <script src="<?php echo SITEURL;?>assets/js/bootbox.min.js"></script>

    <!-- bootstrap notify js -->
    <script src="<?php echo SITEURL;?>assets/js/notify/bootstrap-notify.min.js"></script>

    <!-- Select2 js -->
    <script type="text/javascript" src="<?php echo SITEURL;?>assets/js/select2/select2.full.min.js"></script>

<!-- <script  src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script  src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script> -->
    <script  src="<?php echo SITEURL;?>assets/js/datatables/jquery.dataTables.min.js"></script>
    <script  src="<?php echo SITEURL;?>assets/js/datatables/datatable.custom.js"></script>

    <script>
        var table;
$(document).ready(function (data) {
    table=$('#invoice').dataTable( {
  "sAjaxDataProp":"",
             "stateSave": false,
                    "bProcessing": false,
                    "autoWidth": false,
                    "bServerSide": false,
                    "sAjaxSource": "addDealers.php?viewVisit=dealers",
         "columns": [
            { "data": "id" },
            { "data": "COAName" },
            { "data": "visitdate" },
            { "data": "appointdate" },
            { "data": "salesrepid" },
            { "data": "col_Action", sWidth: "10%" },//Action

        ]

        

    } );
          $("#searchForm input").keyup( function () {
            var index = $(this).attr('index');
            table.fnFilter(this.value, index);
        });


    /* dataTable.fnSetColumnVis(0,false);
     dataTable.fnSetColumnVis(3,false);
     dataTable.fnSetColumnVis(9,false);
*/


   /*  $('#example').DataTable( {
"bProcessing": true,
"sAjaxDataProp":"",
"bServerSide": true,
        "ajax": 'addDealers.php?view=dealers',
        "columns": [
            { "data": "COAName" },
            { "data": "Attr4" },
            { "data": "Attr10" },
            { "data": "Attr11" },
            { "data": "Attr15" }
        ]
    } );*/


} );
$(document).on("click",".edit1",function(){
    //alert('call');
//table.ajax.reload();
var data=$(this).parent().parent().parent().find("td").eq(0).html();
//alert('called edit'+data);
data='id='+data;
$.ajax({
            type:'GET',
            url:'ajaxdata.php',
            data:data,
            success: function(data)
            {
            //alert(data);
            var myObj = JSON.parse(data);
    $("#dealer").val(myObj[0].COAID);
    $("#visitdate").val(myObj[0].visitdate);
          //  alert(myObj[0].newappoint);
    if(myObj[0].newappoint==1)
    {
        $("#appointarrange1").attr("checked",true);
            }
            else
            {
         $("#appointarrange0").attr("checked",true);      
            }
    
    $("#appointdate").val(myObj[0].appointdate);
    $("#additional_info").val(myObj[0].additional_info);
    $("#contactperson1").val(myObj[0].contact_person);
    $("#contactTypeId").val(myObj[0].contactTypeId);
    $("#TypeContactId").val(myObj[0].TypeContactId);
    $("#customerCategoryId").val(myObj[0].customerCategoryId);
    $("#discuss").val(myObj[0].discuss);
    $("#feedback").val(myObj[0].feedback);
    $("#notes").val(myObj[0].notes);
    $("#managernotes").val(myObj[0].managernotes);
$("#visitid").val(myObj[0].id);
$("#submit").html("update");
$("#submit").attr('name',"update");
$("#basic-tab").click();
}
});

});
$(document).on("click","#supplier-tabs",function(){
    //alert('call');
//table.ajax.reload();
});


    </script>
</body>

</html>
<?php
// We're done! Save the cached content to a file
    /*$fp = fopen($cachefile, 'w');
    fwrite($fp, ob_get_contents());
    fclose($fp);
    // finally send browser output
    ob_end_flush();*/
?>