<?php 
    use \koolreport\inputs\DateRangePicker;
    use \koolreport\inputs\Select;
    use \koolreport\inputs\DateTimePicker;
    use \koolreport\inputs\Select2;
    use \koolreport\widgets\koolphp\Table;
use \koolreport\datagrid\DataTables;
use \koolreport\morris_chart;
use \koolreport\sparklines;
use \koolreport\widgets\google;

use \koolreport\core\Utility as Util;
    
?>

              
<div class="report-content">
        <?php
    echo '<a href='.'"'.'logout.php'.'"'.'>'.'<image src='.'"'.Config::BASE_URL.'/leftarrow.png'.'"'. 'width='.'"'.'100'.'"'. 'height='.'"'.'50'.'"'.'>'.'</a>'.'<br>';

    ?>
    <div class="text-center">
        <h1>Amjay Software Appointment Report</h1>
        <p class="lead">
            List all appointments
        </p>
    </div>
    <form method="post">
        <div class="row">
            <div class="col-md-8 offset-md-2">
                <div class="form-group">
                <?php
                DateRangePicker::create(array(
                    "name"=>"dateRange"
                ))
                ?>
                </div>
        
        <div class="col-md-6">
                        
                        
                            <br><br><strong>Select</strong>
                        <?php
                        Select2::create(array(
                            "name"=>"customers",
                            "dataStore"=>  $this->dataStore("customers"),
                        
                                "dataBind"=>array("text"=>"name","value"=>"id"),

                            "attributes"=>array(
                                "class"=>"form-control",
                            )
                        ));
                        ?>  
                    
                        
                   
                    </div>
                <div class="form-group text-center">
                    <button class="btn btn-success"><i class="glyphicon glyphicon-refresh"></i> Load</button>     
                    <?php
                             if($this->dataStore("myappts")->countData()>0){

                    ?>
                    <button type="submit" class="btn btn-primary" formaction="exportex.php?type=XLSX">Download XLSX</button>
			<button type="submit" class="btn btn-primary" formaction="exportex.php?type=ODS">Download ODS</button>
			<button type="submit" class="btn btn-primary" formaction="exportex.php?type=CSV">Download CSV</button>
			<button type="submit" class="btn btn-primary" formaction="exportpdf.php?type=cloudPDF">
				PDF</button>
		
			<?php
                             }
			?>
                </div>
            </div>
        </div>
    </form>
       
  
 
			


 <?php
 
 

   DataTables::create(array(
            "dataStore"=>$this->dataStore("myappts"),
            "removeDuplicate"=>array("name", "concatday", "end_datetime"),
 "options"=>array(
     
        "searching"=>true, 
         "order" => [],
    ),
    
    "searchOnEnter" => true,
    "searchMode" => "or", 
            "cssClass"=>array(
                "table"=>"table table-bordered",
            ),
             "columns"=>array(
                  
                "concatday"=>array(
                    "label"=>"Start-date",
                ),
                 "name"=>array(
                    "label"=>"Service Name",
                ),
                 "starttimefixed"=>array(
                    "label"=>"Start-time",
                ),
                "endtimefixed"=>array(
                    "label"=>"End-time",
                ),
                 "booktimefixed"=>array(
                    "label"=>"Book-time",
                ),
                 "companyname"=>array(
                    "label"=>"Company",
                ),
             
                
                "first_name"=>array(
                    "label"=>"First Name",
                ),
                "last_name"=>array(
                    "label"=>"Last Name",
                ),
                "email"=>array(
                    "label"=>"Email",
                ),
                "phone_number"=>array(
                    "label"=>"Phone Number",
                ),
                "address"=>array(
                    "label"=>"Address",
                ),
                 "city"=>array(
                    "label"=>"City",
                ),
                 "zipcode"=>array(
                    "label"=>"Zipcode",
                ),
                "birthdate"=>array(
                    "label"=>"Birthdate",
                ),
                 "concatbookday"=>array(
                    "label"=>"Date booked",
                ),
                 "booktimefixed"=>array(
                    "label"=>"Time booked",
                ),
                "usernotes"=>array(
                    "label"=>"Customer Notes",
                ),
                "apptnotes"=>array(
                    "label"=>"Backend notes",
                ),
                 "editurl"=>array(
                     "formatValue"=>function($editurl)
				            {
				                return "<a target='_blank' href='$editurl'>EDIT</a>";
				            },
                    "label"=>"EDIT",
                ),
                "deleteurl"=>array(
                     "formatValue"=>function($deleteurl)
				            {
				                return "<a target='_blank' href='$deleteurl'>DELETE</a>";
				            },
                    "label"=>"DELETE",
                ),

                 
)
            
           ));
   ?>
</div>
