Enhances PDFLabel (and some parts of label-controller/model) to custom-papertypes. UNTESTED
这个提交包含在:
父节点
d76e7e74d5
当前提交
ed6ca09b67
共有 4 个文件被更改,包括 37 次插入 和 21 次删除
|
|
@ -157,8 +157,10 @@ class Labels extends CI_Controller {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($label) {
|
if ($label) {
|
||||||
|
$ptype=$this->labels_model->getPaperType($label->paper_type); // fetch papersize out of paper-table
|
||||||
|
var_dump($ptype);
|
||||||
$pdf = new PDF_Label(array(
|
$pdf = new PDF_Label(array(
|
||||||
'paper-size' => $label->paper_type,
|
'paper-size' => 'custom', // $label->paper_type, // The only Type left is "custom" because A4 and so on are also defined at paper_types
|
||||||
'metric' => $label->metric,
|
'metric' => $label->metric,
|
||||||
'marginLeft' => $label->marginleft,
|
'marginLeft' => $label->marginleft,
|
||||||
'marginTop' => $label->margintop,
|
'marginTop' => $label->margintop,
|
||||||
|
|
@ -168,7 +170,9 @@ class Labels extends CI_Controller {
|
||||||
'SpaceY' => $label->spacey,
|
'SpaceY' => $label->spacey,
|
||||||
'width' => $label->width,
|
'width' => $label->width,
|
||||||
'height' => $label->height,
|
'height' => $label->height,
|
||||||
'font-size' => $label->font_size
|
'font-size' => $label->font_size,
|
||||||
|
'pgX' => $ptype->width,
|
||||||
|
'pgY' => $ptype->height
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
if ($jscall) {
|
if ($jscall) {
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,14 @@ class Labels_model extends CI_Model {
|
||||||
return $query->row();
|
return $query->row();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPaperType($ptype) {
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
|
$this->db->where('id',$ptype);
|
||||||
|
$query = $this->db->get('paper_types');
|
||||||
|
|
||||||
|
return $query->row();
|
||||||
|
}
|
||||||
|
|
||||||
function saveDefaultLabel($id) {
|
function saveDefaultLabel($id) {
|
||||||
$sql = 'update label_types set useforprint = 0 where user_id = ' . $this->session->userdata('user_id');
|
$sql = 'update label_types set useforprint = 0 where user_id = ' . $this->session->userdata('user_id');
|
||||||
$this->db->query($sql);
|
$this->db->query($sql);
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,10 @@ class PDF_Label extends tfpdf {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
function __construct($format, $unit='mm', $posX=1, $posY=1) {
|
function __construct($format, $unit='mm', $posX=1, $posY=1, $pgX=0,$pgY=0) {
|
||||||
if (is_array($format)) {
|
if (is_array($format)) {
|
||||||
// Custom format
|
// Custom format
|
||||||
|
var_dump("X".$pgX);
|
||||||
$Tformat = $format;
|
$Tformat = $format;
|
||||||
} else {
|
} else {
|
||||||
// Built-in format
|
// Built-in format
|
||||||
|
|
@ -80,7 +81,7 @@ class PDF_Label extends tfpdf {
|
||||||
$Tformat = $this->_Avery_Labels[$format];
|
$Tformat = $this->_Avery_Labels[$format];
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct('P', $unit, $Tformat['paper-size']);
|
parent::__construct('P', $unit, $Tformat['paper-size'],$Tformat['pgX'],$Tformat['pgY']);
|
||||||
$this->_Metric_Doc = $unit;
|
$this->_Metric_Doc = $unit;
|
||||||
$this->_Set_Format($Tformat);
|
$this->_Set_Format($Tformat);
|
||||||
$this->SetFont('Arial');
|
$this->SetFont('Arial');
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ protected $PDFVersion; // PDF version number
|
||||||
* Public methods *
|
* Public methods *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
function __construct($orientation='P', $unit='mm', $size='A4')
|
function __construct($orientation='P', $unit='mm', $size='A4',$pgX = 0,$pgY =0)
|
||||||
{
|
{
|
||||||
// Some checks
|
// Some checks
|
||||||
$this->_dochecks();
|
$this->_dochecks();
|
||||||
|
|
@ -131,6 +131,9 @@ function __construct($orientation='P', $unit='mm', $size='A4')
|
||||||
// Page sizes
|
// Page sizes
|
||||||
$this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
|
$this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
|
||||||
'letter'=>array(612,792), 'legal'=>array(612,1008));
|
'letter'=>array(612,792), 'legal'=>array(612,1008));
|
||||||
|
if ($size == 'custom') {
|
||||||
|
$size=array($pgX,$pgY);
|
||||||
|
}
|
||||||
$size = $this->_getpagesize($size);
|
$size = $this->_getpagesize($size);
|
||||||
$this->DefPageSize = $size;
|
$this->DefPageSize = $size;
|
||||||
$this->CurPageSize = $size;
|
$this->CurPageSize = $size;
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用