Hi,
I want to use a custom function, with a $_session variable inside. The problem is : the $_SESSION variable seems to be undefined inside this function, whereas it works outside this function. When I use the $_SESSION with Filter it works fine.
here is my code :
$this->src('sales')
->pipe(new Filter(array(
array("Ccial","=",$_SESSION['Username']),
'or',
array("ACC","=",$_SESSION['Username']),
)))
->pipe(new Map(array(
'{value}' => function($row, $metaData) {
if ($row['Société'] != null && trim($row['Société']) != '' && trim($row['Société']) != '-')
return array($row);
},
)))
->pipe(new Filter(array(
array("Ccial","!=",null),
array("Société","!=",null),
)))
->pipe(new CalculatedColumn(array(
"PO"=>function($data){
return ($data["Marge_FAS_Déclarée"] + 12 * $data["MARGE_DELTA_REC"]);
}
)))
->pipe(new CalculatedColumn(array(
"Challenge"=>function($data){
if ($_SESSION['Username'] !='VALIFAX' && $data["ACC"]!='VALIFAX' ){
if ($data["Prospect_Client"]=='client' ){
return ( ($data["Marge_FAS_Déclarée"] + 12 * $data["MARGE_DELTA_REC"])*1.1 );
}
else {
return ( ($data["Marge_FAS_Déclarée"] + 12 * $data["MARGE_DELTA_REC"]) ) ;
}
}
else {
if ($data["Prospect_Client"]=='client' ){
return ( 2.5 * ($data["Marge_FAS_Déclarée"] + 12 * $data["MARGE_DELTA_REC"])*1.1 );
}
else {
return ( 2.5 * ($data["Marge_FAS_Déclarée"] + 12 * $data["MARGE_DELTA_REC"]) ) ;
}
}
}
)))
->pipe(new Filter($filter_args))
->pipe($this->dataStore('commandes'));