So, in the way that our internal application is written, the parent class calls a javascript method that simply displays an alert telling the user that an error has occurred..
In this new app that I am writing, we want to do something different. If a user tries to access this particular page without entering specific request values, then we want to throw an exception.
So, I define my class and build out my construct method.
Then I use a method that I have named getData that I am going to post here to give you an idea of where I am with this... In the getData method, I am checking for the request values and if not present, I am trying to throw the exception. Problem is it is not working as I want. Instead, it still throws the javaScript alert from the Parent class. So, I feel like I need to override that Parent method, but not sure how to do so as I am brand new to OOP in PHP. Here's part of my code. I would appreciate any help given.
public function getData() {
$qStr = array();
// get the criteria values from the report template app
$crit = json_decode($this->getRequestValue("criteria_values"), true);
// THIS IS WHERE I AM TRYING TO THROW THE EXCEPTION.......
if($crit == "" || $crit == null){
throw new Exception("Error Processing Request", 1);
}else{
if (is_array($crit)) {
$qStr = array_merge($qStr, $crit);
}
$ordLst = array();
$db = new DbProvider();
$ret = $db->findWhere("statussheet", $qStr);
//$trkInfo = $db->findWhere("truckrequests",array("siteid"=>"DET"));
$trkInfo = $db->findOpen("truckrequests");
$truckInfo = array();
$stats = array();
//$trkInf = json_decode(json_encode($trkInfo), true);
// $retArr = json_decode(json_encode($ret), true);
foreach ($trkInfo->data as $trow) {
$ordNbr = $trow->detail[0]->ordnbr;
$truckInfo[$ordNbr] = $trow;
//$tord = $trow->detail[0]->ordnbr;
// var_dump($truckInfo);
}
$dets = array();
foreach($ret->data as $statRow) {
if (isset($truckInfo[$statRow->ordnbr])) {
$statRow->covered = "Yes"; //var_export($truckInfo[$statRow->ordnbr], true);
$statRow->dateship = $truckInfo[$statRow->ordnbr]->dateship;
// $statRow->carrier = var_export($truckInfo[$statRow->ordnbr], true);
$trkDets = 'trknbr='.(string)$truckInfo[$statRow->ordnbr]->detail[0]->trknbr.'&ordnbr=';
$trkDets .=$ordNbr;
$statRow->carrier = $truckInfo[$statRow->ordnbr]->detail[0]->trknbr.'<a href = "../../../logistics/TruckList/TruckRequestDocument.php?'.$trkDets.'"target="_blank"><br>See Details</a>';
}
else {
$statRow->covered = "No";
$statRow->carrier = "Not yet released";
$statRow->dateship = "Not yet scheduled";
}
$statRow->remaining = (float) $statRow->totord - (float) $statRow->shipped;
if ($statRow->orderstatus != "RDY" && $statRow->orderstatus != "NM") {
$statRow->orderstatus = "WIP";
}
$dets[] = $statRow;
}
$ret->data = array_values($dets);
echo json_encode($ret);
}
//var_dump($ret->data);
}
$app = new newStatSheet();
$app->dispatch();