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 {
|
||||
if ($label) {
|
||||
$ptype=$this->labels_model->getPaperType($label->paper_type); // fetch papersize out of paper-table
|
||||
var_dump($ptype);
|
||||
$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,
|
||||
'marginLeft' => $label->marginleft,
|
||||
'marginTop' => $label->margintop,
|
||||
|
|
@ -168,7 +170,9 @@ class Labels extends CI_Controller {
|
|||
'SpaceY' => $label->spacey,
|
||||
'width' => $label->width,
|
||||
'height' => $label->height,
|
||||
'font-size' => $label->font_size
|
||||
'font-size' => $label->font_size,
|
||||
'pgX' => $ptype->width,
|
||||
'pgY' => $ptype->height
|
||||
));
|
||||
} else {
|
||||
if ($jscall) {
|
||||
|
|
|
|||
|
|
@ -117,6 +117,14 @@ class Labels_model extends CI_Model {
|
|||
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) {
|
||||
$sql = 'update label_types set useforprint = 0 where user_id = ' . $this->session->userdata('user_id');
|
||||
$this->db->query($sql);
|
||||
|
|
|
|||
|
|
@ -69,25 +69,26 @@ class PDF_Label extends tfpdf {
|
|||
);
|
||||
|
||||
// Constructor
|
||||
function __construct($format, $unit='mm', $posX=1, $posY=1) {
|
||||
if (is_array($format)) {
|
||||
// Custom format
|
||||
$Tformat = $format;
|
||||
} else {
|
||||
// Built-in format
|
||||
if (!isset($this->_Avery_Labels[$format]))
|
||||
$this->Error('Unknown label format: '.$format);
|
||||
$Tformat = $this->_Avery_Labels[$format];
|
||||
}
|
||||
function __construct($format, $unit='mm', $posX=1, $posY=1, $pgX=0,$pgY=0) {
|
||||
if (is_array($format)) {
|
||||
// Custom format
|
||||
var_dump("X".$pgX);
|
||||
$Tformat = $format;
|
||||
} else {
|
||||
// Built-in format
|
||||
if (!isset($this->_Avery_Labels[$format]))
|
||||
$this->Error('Unknown label format: '.$format);
|
||||
$Tformat = $this->_Avery_Labels[$format];
|
||||
}
|
||||
|
||||
parent::__construct('P', $unit, $Tformat['paper-size']);
|
||||
$this->_Metric_Doc = $unit;
|
||||
$this->_Set_Format($Tformat);
|
||||
$this->SetFont('Arial');
|
||||
$this->SetMargins(0,0);
|
||||
$this->SetAutoPageBreak(false);
|
||||
$this->_COUNTX = $posX-2;
|
||||
$this->_COUNTY = $posY-1;
|
||||
parent::__construct('P', $unit, $Tformat['paper-size'],$Tformat['pgX'],$Tformat['pgY']);
|
||||
$this->_Metric_Doc = $unit;
|
||||
$this->_Set_Format($Tformat);
|
||||
$this->SetFont('Arial');
|
||||
$this->SetMargins(0,0);
|
||||
$this->SetAutoPageBreak(false);
|
||||
$this->_COUNTX = $posX-2;
|
||||
$this->_COUNTY = $posY-1;
|
||||
}
|
||||
|
||||
function _Set_Format($format) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ protected $PDFVersion; // PDF version number
|
|||
* Public methods *
|
||||
*******************************************************************************/
|
||||
|
||||
function __construct($orientation='P', $unit='mm', $size='A4')
|
||||
function __construct($orientation='P', $unit='mm', $size='A4',$pgX = 0,$pgY =0)
|
||||
{
|
||||
// Some checks
|
||||
$this->_dochecks();
|
||||
|
|
@ -131,6 +131,9 @@ function __construct($orientation='P', $unit='mm', $size='A4')
|
|||
// Page sizes
|
||||
$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));
|
||||
if ($size == 'custom') {
|
||||
$size=array($pgX,$pgY);
|
||||
}
|
||||
$size = $this->_getpagesize($size);
|
||||
$this->DefPageSize = $size;
|
||||
$this->CurPageSize = $size;
|
||||
|
|
|
|||
正在加载…
在新工单中引用