所以我会尽可能地解释这个问题,如果我需要澄清任何问题,请随时提出问题。
我们通常每天销售约400~900张这样的产品,因此我们需要一张合并的PDF表格 生成/添加所有这些到单个可打印文档。这些是如何与昨天的订单隔离的 或今天的订单,或打印后的订单今天的订单无关紧要。它可能是最后的凭证 数字,或截止日期/时间,或其他什么。只要没有重复,它就可以忽略不计。
我希望看到的是用户在提交之前预览其凭据的能力 (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;