<?php

require_once "../../../load.koolreport.php";
use \koolreport\processes\Map;
use \koolreport\processes\Limit;
use \koolreport\processes\Filter;
use \koolreport\cube\processes\Cube;
use \koolreport\pivot\processes\Pivot;
use \koolreport\processes\ColumnMeta;
use \koolreport\processes\Sort;
use \koolreport\processes\RemoveColumn;
use \koolreport\processes\OnlyColumn;
use \koolreport\core\Utility as Util;

class Report extends \koolreport\KoolReport


{
        use \koolreport\excel\BigSpreadsheetExportable;
        	use \koolreport\cloudexport\Exportable;


    use \koolreport\inputs\Bindable;
    use \koolreport\inputs\POSTBinding;

    protected function defaultParamValues()
    {
        return array(
            "dateRange"=>array(date("Y-m-d 00:00:00"),date("Y-m-d 23:59:59")),
            "textBox"=>"KoolReport is great",
            "select"=>"",
            "multiSelect"=>array(),
            "radioList"=>"",
            "checkBoxList"=>array(),
            "startDatePicker"=>date("Y-m-d 00:00:00"),
            "endDatePicker"=>date("Y-m-d 23:59:59"),
            "rangeSliderOne"=>array(50),
            "rangeSliderTwo"=>array(20,80),
        );
    }

    protected function bindParamsToInputs()
    {
        return array(
                        "dateRange"=>"dateRange",
            "customers"=>"customers",

            "select",
            "multiSelect",
            "textBox",
            "radioList",
            "checkBoxList",
            "startDatePicker",
            "endDatePicker",
            "singleSelect2",
            "multipleSelect2",
            "singleBSelect",
            "multipleBSelect",
            "rangeSliderOne",
            "rangeSliderTwo",
        );
    }

    public function settings()
    {
        $config = include "../../../config.php";
        return array(
            "dataSources"=>array(
                "databasetest"=>$config["databasetest"]            )
            
        );
    }   
    protected function setup()
    {
        
        
 if($_SESSION['stuff'] == 'admin'){
            $stuff = ""; 
        }else {
            
            $stuff = " where ea_company_providers.id_company=".$_SESSION['stuff'];
        }
        
        $this->src("databasetest")->query("
SELECT ea_services.id as serviceid, ea_services.name as servicename, CONCAT(company.name,' - ',ea_users.first_name,' - ', ea_services.name) as nameofdropdown FROM `ea_services_providers` inner join ea_services on ea_services.id=ea_services_providers.id_services inner join ea_users on ea_users.id=ea_services_providers.id_users inner join ea_company_providers on ea_company_providers.id_provider=ea_users.id inner join company on ea_company_providers.id_company=company.id
".$stuff

        )
        ->pipe($this->dataStore("customers"));
        
       
 

        $this->src("databasetest")->query("

SELECT firstname, lastname, email, phonenumber, notes, pharmacynotes, status, date_sent, date_expires,  
CONCAT("."'".Config::BASE_URL."'".",'/waitlistedit.php?q=',waitlist.hash) as editurl, 
CONCAT("."'".Config::BASE_URL."'".",'/waitlistdelete.php?q=', waitlist.hash) as deleteurl
FROM waitlist WHERE status='SENT' AND service=:service")    
->params(array(
        

            ":service"=>$this->params["customers"],

        ))
        

    ->pipe($this->dataStore("myappts"));     


        
        
    }
    
    
}
