/**
 * Get timestamp
 * @param String value
 * @param String dateFormat
 * @return String 
 */
function getTimeStamp($value, $dateFormat)
{
    $refinedDateFormat = getRefinedDateFormat($dateFormat);
    return strtotime(localdatetime2db($value, $refinedDateFormat));
}
Beispiel #2
0
 /**
  * Import data form a file to db
  * @param String filePath
  * @param Array &importData
  * @return Array
  */
 public function ImportFromFile($filePath, &$importData)
 {
     $fieldsData = $this->refineImportFielsData($importData["importFieldsData"]);
     $dateFormat = getRefinedDateFormat($this->getImportDateFormat($importData["dateFormat"]));
     if ($importData["CSV"]) {
         $metaData = $this->importFromCSV($filePath, $fieldsData, $importData["useHeadersLine"], $importData["delimiter"], $dateFormat);
     } else {
         $metaData = $this->importFromExcel($filePath, $fieldsData, $importData["useHeadersLine"], $dateFormat);
     }
     $resultData = array();
     $resultData["reportText"] = $this->getBasicReportText($metaData["totalRecords"], $metaData["addedRecords"], $metaData["updatedRecords"]);
     $resultData["unprocessedRecordsNumber"] = count($metaData["errorMessages"]);
     // prepare a report file
     $reportFileText = $this->getBasicReportText($metaData["totalRecords"], $metaData["addedRecords"], $metaData["updatedRecords"], false, "\r\n", $metaData["errorMessages"], $metaData["unprocessedData"]);
     $logFilePath = getabspath("templates_c/" . $this->getImportLogFileName() . ".txt");
     runner_save_file($logFilePath, $reportFileText);
     $resultData["logFilePath"] = $logFilePath;
     if (count($metaData["unprocessedData"])) {
         // prepare an unprocessed data log
         $unprocFilePath = getabspath("templates_c/" . $this->getUnprocessedDataFileName() . ".csv");
         $unprocContent = $this->getUnprocessedDataContent($metaData["unprocessedData"]);
         runner_save_file($unprocFilePath, $unprocContent);
         $resultData["unprocessedFilePath"] = $unprocFilePath;
     }
     return $resultData;
 }