/** * Import movies */ public function actionImport() { if ($movies = CHttpRequest::getPost('movies', false)) { foreach (explode("\n", $movies) as $key => $movie) { if (!ImportLog::model()->find('import_name=:movie', array(':movie' => $movie))) { if (substr($movie, -2) == 02) { continue; } // 2nd part $search = SearchController::search(str_replace(array('-', '01'), ' ', $movie)); $log = new ImportLog(); $log->import_name = $movie; $log->search_id = $search->id; $log->save(); } } } $this->render('import', array('imported_movies' => ImportLog::model()->findAll())); }
//display sushi outstanding approval queue case 'getOutstandingSushiImports': $sushiImport = new ImportLog(); $sushiArray = array(); $sushiArray = $sushiImport->getSushiImports(); if (count($sushiArray) > 0) { echo "<table class='dataTable' style='width:830px; max-width:830px;'>"; echo "<tr>"; echo "<th style='padding:3px;'>Platform/Publisher</th>"; echo "<th style='padding:3px;'>Import Run Date</th>"; echo "<th style='padding:3px;'>Details</th>"; echo "<th style='padding:3px;'> </th>"; echo "<th style='padding:3px;'> </th>"; echo "</tr>"; foreach ($sushiArray as $sushi) { $imp = new ImportLog(new NamedArguments(array('primaryKey' => $sushi['importLogID']))); $platforms = $imp->getPlatforms(); foreach ($platforms as $platform) { if ($platform['platformID'] > 0) { $urlstring = "platformID=" . $platform['platformID']; $obj = new Platform(new NamedArguments(array('primaryKey' => $platform['platformID']))); } else { $urlstring = "publisherPlatformID=" . $sushi['publisherPlatformID']; $obj = new PublisherPlatform(new NamedArguments(array('primaryKey' => $sushi['publisherPlatformID']))); } } echo "<tr>"; echo "<td {$classAdd} style='padding:3px;'><a href='publisherPlatform.php?" . $urlstring . "'>" . $obj->name . "</a></td>"; echo "<td {$classAdd} style='padding:3px;'>" . format_date($sushi['importDateTime']) . "</td>"; echo "<td {$classAdd} style='padding:3px;'>" . nl2br($sushi['details']) . "</td>"; echo "<td {$classAdd} style='padding:3px;'><a href='uploadConfirmation.php?importLogID=" . $sushi['importLogID'] . "'>view to process</a></td>";
} else { $user = new User(); } $user->loginID = $_GET['loginID']; $user->firstName = $_GET['firstName']; $user->lastName = $_GET['lastName']; $user->privilegeID = $_GET['privilegeID']; try { $user->save(); } catch (Exception $e) { echo $e->getMessage(); } break; case 'deleteImportLog': $importLogID = $_GET['importLogID']; $importLog = new ImportLog(new NamedArguments(array('primaryKey' => $importLogID))); echo "<font color='red'>"; try { $importLog->delete(); } catch (Exception $e) { echo $e->getMessage(); } echo "</font>"; break; case 'deleteUser': $loginID = $_GET['loginID']; $user = new User(new NamedArguments(array('primaryKey' => $loginID))); echo "<font color='red'>"; try { $user->delete(); } catch (Exception $e) {
public function saveLogAndExit($reportLayout = NULL, $txtFile = NULL, $success = FALSE) { //First, delete any preexisting Failured records, these shouldn't be needed/interesting after this. $this->log("Cleaning up prior failed import logs...."); $this->getPublisherOrPlatform->removeFailedSushiImports; if (!$txtFile) { $txtFile = strtotime("now") . '.txt'; } $logFileLocation = 'logs/' . $txtFile; $this->log("Log File Name: {$logFileLocation}"); if ($success) { $this->logStatus("Finished processing " . $this->getServiceProvider . ": {$reportLayout}."); } //save the actual log file $fp = fopen(BASE_DIR . $logFileLocation, 'w'); fwrite($fp, implode("\n", $this->detailLog)); fclose($fp); //save to import log!! $importLog = new ImportLog(); $importLog->loginID = "sushi"; $importLog->layoutCode = $reportLayout; $importLog->fileName = 'archive/' . $txtFile; $importLog->archiveFileURL = 'archive/' . $txtFile; $importLog->logFileURL = $logFileLocation; $importLog->details = implode("<br />", $this->statusLog); try { $importLog->save(); $importLogID = $importLog->primaryKey; } catch (Exception $e) { echo $e->getMessage(); } $importLogPlatformLink = new ImportLogPlatformLink(); $importLogPlatformLink->importLogID = $importLogID; $importLogPlatformLink->platformID = $this->platformID; try { $importLogPlatformLink->save(); } catch (Exception $e) { echo $e->getMessage(); } if (!$success) { throw new Exception(implode("\n", $this->detailLog)); } }
} } if ($multYear) { $logSummary .= date("F Y", mktime(0, 0, 0, $startMonth, 10, $startYear)) . " - " . date("F Y", mktime(0, 0, 0, $holdEndMonth, 10, $endYear)); } else { $logSummary .= date("F Y", mktime(0, 0, 0, $startMonth, 10, $startYear)) . " - " . date("F Y", mktime(0, 0, 0, $endMonth, 10, $startYear)); } include 'templates/header.php'; //Log import in database if ($importLogID != "") { $importLog = new ImportLog(new NamedArguments(array('primaryKey' => $importLogID))); $importLog->fileName = $importLog->fileName; $importLog->archiveFileURL = $importLog->fileName; $importLog->details = $importLog->details . "\n" . $rownumber . _(" titles processed.") . $logSummary; } else { $importLog = new ImportLog(); $importLog->importLogID = ''; $importLog->fileName = $orgFileName; $importLog->archiveFileURL = 'archive/' . $uploadedFilename; $importLog->details = $rownumber . _(" titles processed.") . $logSummary; } $importLog->loginID = $user->loginID; $importLog->layoutCode = $layoutCode; $importLog->logFileURL = $logfile; try { $importLog->save(); $importLogID = $importLog->primaryKey; } catch (Exception $e) { echo $e->getMessage(); } //only get unique platforms