因此,我将尽我所能解释这一点,如果我需要澄清任何问题,请随时提出问题。
- 我们从 PDF 创建凭据。
- 背景图像已打印在一张纸上(A4:横向)
- 来自我们产品中的输入(自定义选项 > 名称和日期)和存储在我们数据库中的递增凭证号;我们将这些覆盖在我们的 A4 纸上的特定坐标处,以自己打印最终产品。
我们通常每天销售大约 400 到 900 个,因此我们需要一个组合的 PDF 表来生成/添加所有这些到单个可打印文档。这些如何与昨天的订单或今天的订单或打印今天的订单后的订单分开并不重要。它可以是 LAST 凭证号,也可以是截止日期/时间,或其他。只要没有重复,就可以忽略不计。
我希望看到的是用户能够在提交之前预览他们的凭证(JQuery 很可能符合要求,我设想从输入字段更新预览图像),使用过滤器数组或列表的能力(可能是一个平面文件?)所以我们可以删除被禁止的单词,最后我们可以纠正用户犯的错误,一种编辑 PDF 的方法,或者直接通过工具。
上周我一直在寻找一个插件或模块,我至少可以找到一个起点来做这件事。如果不是,这将需要从头开始创建。我通过 Zetaprints 简要查看了要打印的网页,但不仅安装过程复杂,而且每次使用的费用约为 1.70 美元,这将很快侵蚀我们的利润率。
我们现在做什么 这是我们与 OSCommerce 一起使用的旧版本,需要用 Magento 等价物替换。
具有编辑功能的旧版本:http: //pastebin.com/pafG0RLZ
未经编辑的新版本:http: //pastebin.com/b4a3kim1
这是需要某种集成的新版本的物理代码。请停止基于“理论概念”对我投反对票,因为这已经是一个需要集成的工作产品。
case "Ordination Credentials":
// hack -jd
include ('class.ezpdf.php');
$pdf =& new Cezpdf('LETTER','landscape');
$pdf->selectFont('./fonts/mtcorsva.afm');
$pdf->ezSetMargins(30,1,30,1);
extract($_GET);
$query = "
SELECT o.date_purchased,
fd.template_fn,
o.customers_name,
op.orders_id,
opa.orders_products_id,
products_name,
op.products_quantity,
field_name,
products_options_values
FROM orders_products AS op
JOIN orders AS o ON o.orders_id = op.orders_id
JOIN fulfillment_doc_products AS fdp ON fdp.product_id = op.products_id
JOIN fulfillment_docs AS fd ON fd.doc_id = fdp.doc_id
JOIN orders_products_attributes AS opa ON opa.orders_products_id = op.orders_products_id
RIGHT JOIN fulfillment_doc_fields AS fdf ON fdf.products_options_name = opa.products_options
AND fdf.doc_products_id = fdp.doc_products_id
WHERE op.orders_id
BETWEEN $in
AND $out
AND fd.doc_id = $doc_id
ORDER BY o.orders_id, products_name, opa.orders_products_id, field_name, products_options_values";
$result = mysql_query(trim($query)) or die("Broke the interwebs.");
while ($query_data = mysql_fetch_array($result)) {
//Standard db output filtering and processing into multi-dimensional array as seen above
$creds[$query_data['orders_products_id']][$query_data['field_name']] = sanitize_db_output($query_data['products_options_values']);
$creds[$query_data['orders_products_id']]['order_number'] = $query_data['orders_id'];
$creds[$query_data['orders_products_id']]['products_quantity'] = $query_data['products_quantity'];
}
$started = false;
foreach( $creds as $opt ) {
if($started) { $pdf->ezNewPage(); } //create new page
$started = true;
$name = ucwords(strtolower($opt['name']));
foreach (array('-', '\'',' Mc') as $delimiter) {
if (strpos($name, $delimiter) == true) {
$name = implode($delimiter, array_map('ucfirst', explode($delimiter, $name)));
}
}
//all caps
foreach (array('Ii', 'Iii') as $delimiter) {
if (strpos($name, $delimiter) == true) {
$name = implode($delimiter, array_map('strtoupper', explode($delimiter, $name)));
}
}
if(strpos($name, ',') !== false) {
foreach (array(', Jr', ', Sr') as $delimiter) {
if (strpos($name, $delimiter) == false) {
$name=implode(" ", array_reverse(explode(',', $name)));
}
}
}
$day = $opt["date-day"];
if (0<>$day) {
if (in_array($day% 100, range(11,13))) {
$day .= 'th';
} else {
switch ( $day % 10 ) {
case 1: $day .= 'st'; break;
case 2: $day .= 'nd'; break;
case 3: $day .= 'rd'; break;
default: $day .= 'th'; break;
}
}
}
$month = $opt["date-month"];
$year = $opt["date-year"];
$ordid = $opt["order_number"];
//create date
if (!isset($yname)) { $yname = "370"; }
if (!isset($ydate)) { $ydate = "289"; }
$pdf->ezSetY($yname); $pdf->ezText($name,28,array('left'=>-35, 'justification'=>'center'));
$pdf->ezSetY($ydate); $pdf->ezText($day,17,array('left'=>-220, 'justification'=>'center'));
$pdf->ezSetY($ydate); $pdf->ezText($month,17,array('left'=>40, 'justification'=>'center'));
$pdf->ezSetY($ydate); $pdf->ezText($year,17,array('left'=>375, 'justification'=>'center'));
$pdf->ezSetY(96); $pdf->ezText($ordid,12,array('left'=>505, 'justification'=>'center'));
}
$pdfcode = $pdf->output();
$file = './tmp/PDF_ordinations.pdf';
if (file_exists($fname)) { unlink($fname); } //start with new file
if (!file_exists($dir)) { mkdir ($dir,0777); } //dir create if not there
$fname = $file;
$fp = fopen($fname,'w');
fwrite($fp,$pdfcode);
fclose($fp);
header('Location:'.$fname);
break;