Hi,
I have an excel file with all the sells of the company. From this file I calculate the sells per seller. I also got a MYSQL database with the goals per seller. From the total sells and the goals, I can calculate the bonus per seller. I'm trying but can't figure out how. Here is my code :
$this->src('mysql_datasource')
->query("SELECT goal FROM dataviz where seller=:seller")
->params(array(":nom"=>$_SESSION['seller']))
->saveTo($node1);
$this->src('sales')
->pipe(new Filter(array(
array("Date","=",'JUILLET'),
'or',
array("Date","=",'AOÛT'),
'or',
array("Date","=",'SEPTEMBRE'),
)))
->pipe(new Filter(array(
array("seller","=",$_SESSION['seller']),
)))
->pipe(new CalculatedColumn(array(
"total_sells"=>function($data){
return ( $data["Marge_FAS_Déclarée"] + 12 * $data["MARGE_DELTA_REC"] );
}
)))
->pipe(new CalculatedColumn(array(
"bonus"=>function($data){
return ( $data["total_sells"] - $data["goal"] );
}
)))
->pipe($node1)
->pipe($this->dataStore("bonus_calculate"));