我有这个(PHP)脚本,它运行良好。现在我想扩展他。我创建并将PDF文件保存到文件夹中。 PDF文件名来自:
orderNumber_ customerName_totalAmount.pdf
示例=> 10503_David_195.pdf(大卫订货号为10503已售价195美元)
订单号是唯一的,并分配给客户。仅限购买金额变更。以下是文件夹中列出的PDF文件的示例。
10503_David_195.pdf => (David with the order number 10503 has Shopped for $195)
10504_Katja_220.pdf => (Katja with the order number 10504 has Shopped for $220)
10505_Alex_15.pdf => (Alex with the order number 10505 has Shopped for $15)
现在我要在保存之前检查:如果订单号和客户名称匹配,则总金额不同,将PDF文件保存到/ modified /文件夹。
实施例: David已在此文件夹中包含一个PDF文件,名称为:10504_David_195.pdf
现在我想再次为David创建一个PDF文件(名称和订单号匹配),现在只有总金额不同。
10503_David_330.pdf => (David with the order number 10503 has Shopped for $330)
我希望此PDF文件现在存储在/ modified /文件夹中。
总金额变化的原因:如果客户想从他的订单(10503)取消某些文章(例如:David)。取消后,订单号和客户名称相同,仅限总金额变化。
你有想法吗? 提前谢谢!
/** Create PDF Files **/
$orderSum = $getTotalSum();
$pdfOrderSum = (int)$orderSum;
$sFilename = $orderNumber."_".$customerName()."_".$pdfOrderSum.".pdf";
$path = '/demosite/';
$date = date("d/M/Y");
list($day, $month, $year) = split('[/.-]', $date);
$checkSubPath = $path."subfolder/$year/$month/$day/";
if (!file_exists($checkSubPath) ) {
mkdir($path."subfolder/$year/", 0777, TRUE);
mkdir($path."subfolder/$year/$month/", 0777, TRUE);
mkdir($path."subfolder/$year/$month/$day/", 0777, TRUE);
}
$PDFdir = $path."subfolder/$year/$month/$day/";
foreach(glob($PDFdir."*.pdf") as $pathPDF) {
basename($pathPDF);
}
$PDFs = basename($pathPDF,".pdf");
$allFile = isset($PDFs) ? $PDFs : null;
$checkPDFListTotal = strpos($allFile, $sFilename);
$checkOrderNumber = strpos($allFile, $pdfCount); /* if ONLY total amount is different */
if ($checkPDFListTotal !== false) {
return "";
} elseif ($checkOrderNumber !== false) { /* if order number and customer name match ONLY the total amount is different save PDF file to /modified/ folder. */
$checkModifiedPath = $path."subfolder/$year/$month/$day/modified/";
if (!file_exists($checkModifiedPath ) ) {
mkdir($path."subfolder/$year/$month/$day/modified/", 0777, TRUE);
}
$folderPatch = "subfolder/$year/$month/$day/modified/";
$pathFull = $path.$folderPatch.$sFilename;
} else {
$folderPatch = "subfolder/$year/$month/$day/";
$pathFull = $path.$folderPatch.$sFilename;
}