// Find if User is able for purchasing $OK_to_purchase = 0; $cnpj = $objUser->CNPJ_CPF; if ($_SESSION["userType"] == 1 or $_SESSION["userType"] == 3 or $_SESSION["userType"] == 4) { $OK_to_purchase = 1; } // Check if an item will be deleted if ($action == $strDelete) { $objCart = new Cart($dbcat); $objCart->removeId($ID); } else { // Check if an item had its media changed if ($action == "changePrice") { $objCart = new Cart($dbcat); $objCart->search($ID); searchMedia($dbcat, $objMedia, $objCart->media); $objCart->media = $matMedia[$mid]->getMedia(); $sql = "SELECT * FROM Scene WHERE SceneId='" . $objCart->sceneId . "'"; $dbcat->query($sql) or $dbcat->error($sql); $row = $dbcat->fetchRow(); //$objCart->price = getPriceFromSatellite( $row["Satellite"], 1, $objCart->media ); $objCart->price -= $objMedia[0]->getPrice($_SESSION['userLang']); $objCart->price += $matMedia[$mid]->getPrice($_SESSION['userLang']); // Apply changes $objCart->modify(); } } // Searching for cart $sql = "SELECT * FROM Cart WHERE Cart.sesskey='{$PHPSESSID}'"; $dbcat->query($sql) or $dbcat->error($sql); $itens = $dbcat->numRows();
function execute($parUserId) { // Arrays require "arrays.php"; //Verify item status if ($this->status != 'B' and $this->status != 'Q') { return 1; } // Flags $inproduction = true; // Searching Scene $sql = "SELECT * FROM Scene WHERE SceneId='" . $this->sceneId . "'"; $this->bd->query($sql) or die("<br> Error on execution/result sql = {$sql} <br>"); $itens = $this->bd->numRows(); if ($itens == 0) { die("Erro nas Cenas"); } $row = $this->bd->fetchRow(); $this->bd->freeResult($results); // Scene data $res = explode(".", $row["SceneId"]); $sufix = $res[1]; $satCod = $row["Satellite"]; $sensor = $row["Sensor"]; if ($satCod == "P6" and ($sensor == "LIS3" or $sensor == "AWIF")) { $date_IRS = $row["Date"]; $path_IRS = $row["Path"]; $row_IRS = $row["Row"]; } for ($i = 0; $i < $matSatCod[0]; $i++) { if ($satCod == $matSatCod[$i]) { break; } } $satName = $matSatName[$i]; $taName = $satName . "Scene"; if ($GLOBALS["stationDebug"]) { echo "\n RequestClass - Satelite = " . $satName . " TabName = " . $taName . " UserName = "******"\n"; } //Finding Gralha/Fred $sql = "SELECT * FROM {$taName} WHERE SceneId='" . $this->sceneId . "'"; if ($GLOBALS["stationDebug"]) { echo "RequestClass - Sql Command: " . $sql . "\n"; } $this->bd->query($sql); $row = $this->bd->fetchRow() or die("<br> Error on execution/result sql = {$sql} <br>"); $file = $row["Gralha"]; $this->bd->freeResult(); if ($GLOBALS["stationDebug"]) { echo "RequestClass - File = " . $file . "\n"; } // Creating p2u argument $argument = $parUserId . ";" . $this->reqId . ";" . $this->sceneId . ";" . $file . ";" . $this->numItem . ";" . $this->restoration; $procPar = 0; if ($GLOBALS["stationDebug"]) { echo "RequestClass - Argument = " . $argument . "\n"; } // Instantiating P2 class searchMedia($this->bd, $objMedia, $this->media); $execClass = $objMedia[0]->getExecClass(); if ($GLOBALS["stationDebug"]) { echo "1 - RequestClass - starting P2U or P2C = " . $execClass . "\n"; } if ($satCod == "P6" and ($sensor == "LIS3" or $sensor == "AWIF")) { include_once "listFiles.php"; if ($sensor == "LIS3") { $sensor = "LISS3"; } else { $sensor = "AWIFS"; } $dir_path = getTiffDir($satCod); $res = explode("-", $date_IRS); $date_dir = $res[0] . "_" . $res[1]; $date_aux = $res[0] . $res[1] . $res[2]; $tiff_dir = $dir_path . "{$date_dir}/{$satCod}" . "_{$sensor}" . "_{$date_aux}/{$path_IRS}" . "_{$row_IRS}"; // $tiffs = listFiles2($tiff_dir,""); // $cmd = "ls -1 $tiff_dir"; // $res = shell_exec($cmd); // $tiffs = explode("\n",$res); $aux_tiffs = glob($tiff_dir . "/*"); $index = 0; foreach ($aux_tiffs as $file) { $tiffs[$index] = basename($file); $index++; } print_r($tiffs); $argument = $parUserId . ";" . $this->reqId . ";" . $this->sceneId . ";" . $tiff_dir . ";" . $this->numItem . ";" . $satCod; if ($GLOBALS["stationDebug"]) { echo "RequestClass ====> starting P2U for P6 products - Argument = {$argument} \n"; } if ($GLOBALS["stationDebug"]) { echo "\n RequestClass =====> tifdir = {$tiff_dir} \n"; } $p2u = new p2u($argument); } else { // GLS // === if ($sufix == "GLS") { $sql = "SELECT Gralha FROM LandsatScene WHERE SceneId='" . $this->sceneId . "'"; $this->bd->query($sql) or die("<br> Error on execution/result sql = {$sql} <br>"); $itens = $this->bd->numRows(); if ($itens == 0) { die("Erro nas Cenas"); } $row = $this->bd->fetchRow(); $this->bd->freeResult($results); $gralha = $row["Gralha"]; decodeGralha($gralha, $satellite, $number, $instrument, $channel_gralha, $type, $date, $path, $row); if ($number == 5) { $sat_prefix = "LT5"; } else { $sat_prefix = "LE7"; } $year = substr($date, 0, 4); $timestamp = strtotime($date); $julian_date = strftime('%j', $timestamp); $sql = "SELECT Dataset FROM Scene WHERE SceneId='" . $this->sceneId . "'"; if ($GLOBALS["stationDebug"]) { echo "\n =====> RequestClass - Sql Command: " . $sql . "\n"; } $this->bd->query($sql); $row_result = $this->bd->fetchRow() or die("\n =====> Request.Class - execute ====> Error on execution/result sql = {$sql} \n"); $dataset = $row_result["Dataset"]; $this->bd->freeResult(); if ($dataset == "GLS2000") { $target_tiffs = "*" . $path . "*" . $row . "*" . $date . "*.tar.gz"; } else { $target_tiffs = "*" . $path . "*" . $row . "*" . $year . $julian_date . "*.tar.gz"; } $dir_path = getTiffDir($sufix); $tiff_dir = $dir_path . $satellite . $number; $cmd = "find {$tiff_dir} -name {$target_tiffs}"; $cmd = addslashes($cmd); echo "\n =====> Request.Class - execute ====> com = {$cmd} \n"; $output = shell_exec($cmd); $output = substr($output, 0, strlen($output) - 1); if ($output == "") { die("\n =====> Request.Class - execute ====> No files : {$target_tiffs} !"); } $tiffs = explode("\n", $output); sort($tiffs); echo "\ntiffs = \n"; print_r($tiffs); echo "\n"; $argument = $parUserId . ";" . $this->reqId . ";" . $this->sceneId . ";" . $tiffs[0] . ";" . $this->numItem . ";" . $sufix; echo "\nargument = \n"; print_r($argument); echo "\n"; $p2u = new p2u($argument); // echo "\n<br> argument = $argument"; } else { $p2u = new $execClass($argument); $tiffs = $p2u->getTiffs(); } } // print_r($tiffs); // For generation of a product if ($sensor == "CCD") { $bands_all = array(0 => "5", 1 => "BAND1", 2 => "BAND2", 3 => "BAND3", 4 => "BAND4", 5 => "BAND5"); $bands_lacking = 0; foreach ($tiffs as $tiff_found) { $one_tiff = basename($tiff_found); for ($i = 1; $i <= $bands_all[0]; $i++) { $found = strstr($one_tiff, $bands_all[$i]); if ($found) { $bands_all[$i] = 1; $bands_lacking += 1; } } } for ($i = 1; $i < 6; $i++) { if ($bands_all[$i] != 1) { $bands_lacking += 1; } } } if ($sensor != "CCD") { $factor = 1; } else { if ($bands_lacking > 0) { $factor = 6; } else { $factor = 5; } } // We could have two repeated bands 3 (CCD1XS and CCD2XS), plus bands 1,2 and 4, and no PAN, and we would have 5 bands on directory! // if(trim($this->productId)== "" and count($tiffs) < $factor) if (count($tiffs) < $factor) { // Tiff does not exist in disk, lets build it from gralha if ($GLOBALS["stationDebug"]) { echo "RequestClass - Tiff not found, looking for {$file}\n"; } $gralhas = findSimilarGralhainDisk($file); $count_gralhas = count($gralhas); if ($count_gralhas > 0 or count($tiffs) > 0) { $gralhas_files = array(0 => "CCD1XS", 1 => "CCD2XS", 2 => "CCD2PAN"); foreach ($gralhas as $filedir) { if ($GLOBALS["stationDebug"]) { echo "<br> \n RequestClass - {$filedir} found <br> \n"; } if ($sensor == "CCD") { decodeGralha(basename($filedir), $satellite, $number, $instrument, $channel, $type, $date, $path, $row); $this_gralha_tiffs = findTiffinDiskFromGralha(basename($filedir), $this->restoration, $channel); // look for specific (Channel) Tiff data switch ($type) { case "XS": if ($channel == 1) { $gralhas_files[0] = "1"; } else { $gralhas_files[1] = "1"; } // Gralha CCD2XS present break; case "PAN": $gralhas_files[2] = "1"; // Gralha CCD2PAN present } if (count($this_gralha_tiffs) == 0) { $procPar = $this->g2tStart($filedir, $procPar, $satCod); } } else { if ($sensor == "ETM") { $filepan = str_replace("XS", "PAN", $filedir); $procPar = $this->g2tStart($filepan, $procPar, $satCod); } $procPar = $this->g2tStart($filedir, $procPar, $satCod); } } if ($sensor == "CCD") { for ($i = 0; $i < 3; $i++) { if ($gralhas_files[$i] != "1") { $gralha_name = str_replace("CCD1XS", $gralhas_files[$i], $file); // CCD1XS is the reference for Gralha in CbersScene decodeGralha($gralha_name, $satellite, $number, $instrument, $channel, $type, $date, $path, $row); $tiffs_found = findTiffinDiskFromGralha($gralha_name, $this->restoration, $channel); // look for specific (Channel) Tiff data if (count($tiffs_found) == 0) { $status = findDRDfromSceneId($this->sceneId, $drds, $tapeid, $tapepath, $skip); if ($status == 0) { if ($gralhas_files[$i] == "CCD1XS") { $index = 0; } else { $index = 1; } // Corresponds to DRD[1] (CCD2XS and CCD2PAN) $fulldrd = findDRDinDisk($drds[$index]); if (strlen($fulldrd) > 1) { $d2g = new d2g($drds[$index]); $d2g->createWorkOrder(); $d2g->start($procPar); $procPar = $this->g2tStart($gralha_name, $d2g->id(), $satCod); $gralhas_files[$i] = "1"; } else { $inproduction = false; } } else { $inproduction = false; } } else { $gralhas_files[$i] = "1"; } // Gralha not present but Tiffs are !!! That's what matters !!! } } } } else { if ($GLOBALS["stationDebug"]) { echo "<br> RequestClass - Gralhas not found, looking for DRD\n"; } $status = findDRDfromSceneId($this->sceneId, $drds, $tapeid, $tapepath, $skip); if ($GLOBALS["stationDebug"]) { echo "<br> RequestClass - Nome DRD = {$drds['0']} <br> \n"; } if ($status == 0) { if ($sensor == "CCD") { $limit = 2; } else { $limit = 1; } // Just one DRD to process if ($GLOBALS["stationDebug"]) { echo "<br> RequestClass - drd = {$drds} \n"; } for ($i = 0; $i < $limit; $i++) { $fulldrd = findDRDinDisk($drds[$i]); if (strlen($fulldrd) > 1) { if ($GLOBALS["stationDebug"]) { echo "<br> RequestClass - drd = {$drds} full = {$fulldrd} \n"; } if ($satCod == "T1" or $satCod == "A1") { $d2g = new c2h($fulldrd); } else { $d2g = new d2g($drds[$i]); $d2g->createWorkOrder(); } $d2g->start($procPar); if ($GLOBALS["stationDebug"]) { echo "<br> RequestClass - After D2G, creating g2t para " . $gralha . "\n"; } if ($satCod == "T1" or $satCod == "A1") { decodeDRD($drds[$i], $satellite, $number, $instrument, $year, $month, $day, $hour, $minute, $second, $channel); $datedir = $year . "_" . $month; $datepath = getGralhaDir($satellite . $number) . $datedir; $result = explode("_", $file); $hdfName = $result[0] . "." . "hdf"; $hdfFullName = $datepath . "/" . $drds[$i] . "/" . $hdfName; $arg = $hdfFullName; } else { $arg = $file; } if ($i == 1) { $arg = str_replace("CCD1XS", "CCD2XS", $file); $procPar = $this->g2tStart($arg, $d2g->id(), $satCod); $arg = str_replace("CCD1XS", "CCD2PAN", $file); $procPar = $this->g2tStart($arg, $procPar, $satCod); } else { $procPar = $this->g2tStart($arg, $d2g->id(), $satCod); } } else { /* # # Old code segment - proceedings have been improved. # if ($GLOBALS["stationDebug"]) echo "<br> RequestClass - DRD not found, looking for DRD on tape\n"; $targument = $tapeid.";".$tapepath.";;".$skip; // IMPORTANT if ($GLOBALS["stationDebug"]) echo "<br> RequestClass - Argument = " . $targument . "\n"; $m2d = new m2d ($targument); $m2d->setStatus ("OPERATOR"); if ($GLOBALS["stationDebug"]) echo "<br> RequestClass - Bd = Man " . $m2d->dbman . " Cat = " . $m2d->dbcat . "\n"; if ($GLOBALS["stationDebug"]) echo "<br> RequestClass - Bd = Man " . $GLOBALS["dbmanager"] . " Cat = " . $GLOBALS["dbcatalog"] . "\n"; $m2d->start (); if ($GLOBALS["stationDebug"]) echo "<br> RequestClass - After M2D, creating d2g para " . $drds . "\n"; $d2g = new d2g ($drds[$i]); $d2g->createWorkOrder(); $d2g->start ($m2d->id()); $procPar = $this->g2tStart($file, $d2g->id(),$satCod); # # # */ echo "<br> RequestClass - DRD data ({$drds[$i]}) not found ! <br>\n"; if ($sensor == "CCD") { if ($i > 0) { $arg = str_replace("CCD1XS", "CCD2XS", $argument); } $m2d_warning = new m2d("{$arg}"); $m2d_warning->setStatus("OPERATOR"); $m2d_warning->start(0, "<font color=#FF0000>WARNING ====> </font> DRD data ({$drds[$i]}) not found on proper directory ! "); } else { $inproduction = false; } } } } else { $inproduction = false; } } } // Setting up status if ($sensor == "CCD" and $inproduction == false) { if ($gralhas_files[0] != "1") { $arg = str_replace("CCD2XS", "CCD1XS", $argument); $msg = "Can\\'t Generate GRALHA CCD1XS Data !"; $p2u_warning = new p2u($arg); $p2u_warning->setStatus("OPERATOR"); $p2u_warning->start(0, "<font color=#FF0000>WARNING ====> </font>" . $msg); } if ($gralhas_files[1] != "1") { // Let's first check if CCD2XS Band 3 (that might be repeated due to CCD1XS) is the one that's lacking; if so, NO PROBLEMS ! if ($bands_all[1] != "1" or $bands_all[3] != "1") { $arg = str_replace("CCD1XS", "CCD2XS", $argument); $msg = "Can\\'t Generate GRALHA CCD2XS Data !"; $p2u_warning = new p2u($arg); $p2u_warning->setStatus("OPERATOR"); $p2u_warning->start(0, "<font color=#FF0000>WARNING ====> </font>" . $msg); } } if ($gralhas_files[2] != "1") { $msg = "Can\\'t Generate GRALHA CCD2PAN Data !"; $arg = str_replace("CCD1XS", "CCD2PAN", $argument); $p2u_warning = new p2u($arg); $p2u_warning->setStatus("OPERATOR"); $p2u_warning->start(0, "<font color=#FF0000>WARNING ====> </font>" . $msg); } $inproduction = true; // We previously know that we have at least one CCD - otherwise we would have been directed to the m2d operation above !!! } if ($this->status != 'Q') { $this->updateStatus($inproduction ? 'C' : 'Y'); } if ($inproduction == true) { if ($GLOBALS["stationDebug"]) { echo "RequestClass - Everything OK - let's start p2u with this dependence " . $procPar . "\n"; } if (trim($execClass) != "p2u") { if ($this->status != 'Q') { // This clause has been added to provide a previous execution of a "p2c" request for allowing Control Quality // assesment, before mailing product to user. // Comment this statement if this policy be changed. $p2u->setStatus("OPERATOR"); } } $p2u->start($procPar); } else { $p2u->sendErrorMail($file); $p2u->sendFirstMail(); $p2u->setStatus("OPERATOR"); switch ($satCod) { case "P6": $msg = "Tiff files no found !"; break; case "L5": case "L7": if ($sufix == "GLS") { $msg = "Tiff files no found !"; } else { $msg = "DRD data not found !"; } break; default: $msg = "DRD data not found !"; } $p2u->start(0, $msg); } }
function generateReqItem($parReqId, $parUserType) { $parDate = date("Y-m-d H:i:s"); $nM = searchMedia($this->bd, $matMedia, $this->media); $parStatus = 'B'; // $this->price = $this->price - $matMedia[0]->getPrice(); // trim media price (occasionally) embedded in image price // when evaluating cart item price. $userType = $parUserType; if (($this->price or $matMedia[0]->getPrice()) and $userType != 1) { $parStatus = 'Q'; } // Manager (UserType =1) // doesn't need allowance; // Q is the Request Item Status // correspondin to Quality Contro Test - priced items only $objReqI = new RequestItem($this->bd); $objReqI->fill($parReqId, $this->sceneId, $this->productId, $this->bands, $this->sceneShift, $this->corretion, $this->orientation, $this->resampling, $this->datum, $this->projection, $this->longOrigin, $this->latOrigin, $this->stdLat1, $this->stdLat2, $this->format, $this->inter, $this->media, $this->price, $parDate, $parStatus, $parDate, $this->restoration); if (!$objReqI->insert()) { //Deletar todos os pedidos e itens // Modificar o estado do pedido e dos demais itens do cart return false; } return true; }
break; } //Searching the scene $sql = "SELECT * FROM Scene WHERE SceneId='" . $objReq[0]->itens[$i]->sceneId . "'"; $dbcat->query($sql) or $dbcat->error($sql); $itens = $dbcat->numRows(); if ($itens == 0) { die("Erro nas Cenas"); } $row = $dbcat->fetchRow(); $dbcat->freeResult($results); # # Calculate item price (scene + media) # $media = $objReq[0]->itens[$i]->media; searchMedia($dbcat, $objMedia, $media); // $price = $objMedia[0]->getPrice($_SESSION['userLang']); // This is the media price $price += $objReq[0]->itens[$i]->price; // We now add scene price ... $total += $price; // ... and add to the total request price amount // Display details ?> <tr> <td align="center"><?php echo $i + 1; ?> </td> <td> <table class="">