Merge pull request #9014 from atm-john/NEW_PDF_DOCUMENT_COLUMN_new_files
Experimental new pdf documents using new column system
This commit is contained in:
commit
fecb6e49c6
@ -823,4 +823,229 @@ abstract class CommonDocGenerator
|
|||||||
if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
|
if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
|
||||||
$pdf->line($x, $y+$h, $x, $y);
|
$pdf->line($x, $y+$h, $x, $y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uasort callback function to Sort colums fields
|
||||||
|
*
|
||||||
|
* @param array $a PDF lines array fields configs
|
||||||
|
* @param array $b PDF lines array fields configs
|
||||||
|
* @return int Return compare result
|
||||||
|
*/
|
||||||
|
function columnSort($a, $b) {
|
||||||
|
|
||||||
|
if(empty($a['rank'])){ $a['rank'] = 0; }
|
||||||
|
if(empty($b['rank'])){ $b['rank'] = 0; }
|
||||||
|
if ($a['rank'] == $b['rank']) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ($a['rank'] > $b['rank']) ? -1 : 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare Array Column Field
|
||||||
|
*
|
||||||
|
* @param object $object common object
|
||||||
|
* @param outputlangs $outputlangs langs
|
||||||
|
* @param int $hidedetails Do not show line details
|
||||||
|
* @param int $hidedesc Do not show desc
|
||||||
|
* @param int $hideref Do not show ref
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
function prepareArrayColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0){
|
||||||
|
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$this->defineColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
|
||||||
|
|
||||||
|
|
||||||
|
// Sorting
|
||||||
|
uasort ( $this->cols, array( $this, 'columnSort' ) );
|
||||||
|
|
||||||
|
// Positionning
|
||||||
|
$curX = $this->page_largeur-$this->marge_droite; // start from right
|
||||||
|
|
||||||
|
// Array witdh
|
||||||
|
$arrayWidth = $this->page_largeur-$this->marge_droite-$this->marge_gauche;
|
||||||
|
|
||||||
|
// Count flexible column
|
||||||
|
$totalDefinedColWidth = 0;
|
||||||
|
$countFlexCol = 0;
|
||||||
|
foreach ($this->cols as $colKey =>& $colDef)
|
||||||
|
{
|
||||||
|
if(!$this->getColumnStatus($colKey)) continue; // continue if desable
|
||||||
|
|
||||||
|
if(!empty($colDef['scale'])){
|
||||||
|
// In case of column widht is defined by percentage
|
||||||
|
$colDef['width'] = abs($arrayWidth * $colDef['scale'] / 100 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty($colDef['width'])){
|
||||||
|
$countFlexCol++;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$totalDefinedColWidth += $colDef['width'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->cols as $colKey =>& $colDef)
|
||||||
|
{
|
||||||
|
// setting empty conf with default
|
||||||
|
if(!empty($colDef['title'])){
|
||||||
|
$colDef['title'] = array_replace($this->defaultTitlesFieldsStyle, $colDef['title']);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$colDef['title'] = $this->defaultTitlesFieldsStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
// setting empty conf with default
|
||||||
|
if(!empty($colDef['content'])){
|
||||||
|
$colDef['content'] = array_replace($this->defaultContentsFieldsStyle, $colDef['content']);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$colDef['content'] = $this->defaultContentsFieldsStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getColumnStatus($colKey))
|
||||||
|
{
|
||||||
|
// In case of flexible column
|
||||||
|
if(empty($colDef['width'])){
|
||||||
|
$colDef['width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set positions
|
||||||
|
$lastX = $curX;
|
||||||
|
$curX = $lastX - $colDef['width'];
|
||||||
|
$colDef['xStartPos'] = $curX;
|
||||||
|
$colDef['xEndPos'] = $lastX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get column content width from column key
|
||||||
|
*
|
||||||
|
* @param string $colKey the column key
|
||||||
|
* @return float width in mm
|
||||||
|
*/
|
||||||
|
function getColumnContentWidth($colKey)
|
||||||
|
{
|
||||||
|
$colDef = $this->cols[$colKey];
|
||||||
|
return $colDef['width'] - $colDef['content']['padding'][3] - $colDef['content']['padding'][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get column content X (abscissa) left position from column key
|
||||||
|
*
|
||||||
|
* @param string $colKey the column key
|
||||||
|
* @return float X position in mm
|
||||||
|
*/
|
||||||
|
function getColumnContentXStart($colKey)
|
||||||
|
{
|
||||||
|
$colDef = $this->cols[$colKey];
|
||||||
|
return $colDef['xStartPos'] + $colDef['content']['padding'][3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get column position rank from column key
|
||||||
|
*
|
||||||
|
* @param string $colKey the column key
|
||||||
|
* @return int rank on success and -1 on error
|
||||||
|
*/
|
||||||
|
function getColumnRank($colKey)
|
||||||
|
{
|
||||||
|
if(!isset($this->cols[$colKey]['rank'])) return -1;
|
||||||
|
return $this->cols[$colKey]['rank'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get column position rank from column key
|
||||||
|
*
|
||||||
|
* @param string $newColKey the new column key
|
||||||
|
* @param array $defArray a single column definition array
|
||||||
|
* @param string $targetCol target column used to place the new column beside
|
||||||
|
* @param bool $insertAfterTarget insert before or after target column ?
|
||||||
|
* @return int new rank on success and -1 on error
|
||||||
|
*/
|
||||||
|
function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false)
|
||||||
|
{
|
||||||
|
// prepare wanted rank
|
||||||
|
$rank = -1;
|
||||||
|
|
||||||
|
// try to get rank from target column
|
||||||
|
if(!empty($targetCol)){
|
||||||
|
$rank = $this->getColumnRank($targetCol);
|
||||||
|
if($rank>=0 && $insertAfterTarget){ $rank++; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// get rank from new column definition
|
||||||
|
if($rank<0 && !empty($defArray['rank'])){
|
||||||
|
$rank = $defArray['rank'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// error: no rank
|
||||||
|
if($rank<0){ return -1; }
|
||||||
|
|
||||||
|
foreach ($this->cols as $colKey =>& $colDef)
|
||||||
|
{
|
||||||
|
if( $rank <= $colDef['rank'])
|
||||||
|
{
|
||||||
|
$colDef['rank'] = $colDef['rank'] + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$defArray['rank'] = $rank;
|
||||||
|
$this->cols[$newColKey] = $defArray; // array_replace is used to preserve keys
|
||||||
|
|
||||||
|
return $rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print standard column content
|
||||||
|
*
|
||||||
|
* @param PDF $pdf pdf object
|
||||||
|
* @param float $curY curent Y position
|
||||||
|
* @param string $colKey the column key
|
||||||
|
* @param string $columnText column text
|
||||||
|
* @return int new rank on success and -1 on error
|
||||||
|
*/
|
||||||
|
function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '')
|
||||||
|
{
|
||||||
|
global $hookmanager;
|
||||||
|
|
||||||
|
$parameters=array(
|
||||||
|
'object' => $object,
|
||||||
|
'curY' =>& $curY,
|
||||||
|
'columnText' => $columnText,
|
||||||
|
'colKey' => $colKey
|
||||||
|
);
|
||||||
|
$reshook=$hookmanager->executeHooks('printStdColumnContent',$parameters,$this); // Note that $action and $object may have been modified by hook
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error,$hookmanager->errors,'errors');
|
||||||
|
if (!$reshook)
|
||||||
|
{
|
||||||
|
if(empty($columnText)) return;
|
||||||
|
$pdf->SetXY($this->getColumnContentXStart($colKey),$curY); // Set curent position
|
||||||
|
$colDef = $this->cols[$colKey];
|
||||||
|
$pdf->MultiCell( $this->getColumnContentWidth($colKey),2, $columnText,'',$colDef['content']['align']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get column status from column key
|
||||||
|
*
|
||||||
|
* @param string $colKey the column key
|
||||||
|
* @return float width in mm
|
||||||
|
*/
|
||||||
|
function getColumnStatus($colKey)
|
||||||
|
{
|
||||||
|
if( !empty($this->cols[$colKey]['status'])){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1675
htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
Normal file
1675
htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
Normal file
File diff suppressed because it is too large
Load Diff
2030
htdocs/core/modules/facture/doc/pdf_sponge.modules.php
Normal file
2030
htdocs/core/modules/facture/doc/pdf_sponge.modules.php
Normal file
File diff suppressed because it is too large
Load Diff
1891
htdocs/core/modules/propale/doc/pdf_cyan.modules.php
Normal file
1891
htdocs/core/modules/propale/doc/pdf_cyan.modules.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -491,6 +491,7 @@ YouMustCreateInvoiceFromThird=This option is only available when creating invoic
|
|||||||
YouMustCreateInvoiceFromSupplierThird=This option is only available when creating invoices from tab "supplier" of third party
|
YouMustCreateInvoiceFromSupplierThird=This option is only available when creating invoices from tab "supplier" of third party
|
||||||
YouMustCreateStandardInvoiceFirstDesc=You have to create a standard invoice first and convert it to "template" to create a new template invoice
|
YouMustCreateStandardInvoiceFirstDesc=You have to create a standard invoice first and convert it to "template" to create a new template invoice
|
||||||
PDFCrabeDescription=Invoice PDF template Crabe. A complete invoice template (recommended Template)
|
PDFCrabeDescription=Invoice PDF template Crabe. A complete invoice template (recommended Template)
|
||||||
|
PDFSpongeDescription=Invoice PDF template Sponge. A complete invoice template
|
||||||
PDFCrevetteDescription=Invoice PDF template Crevette. A complete invoice template for situation invoices
|
PDFCrevetteDescription=Invoice PDF template Crevette. A complete invoice template for situation invoices
|
||||||
TerreNumRefModelDesc1=Return number with format %syymm-nnnn for standard invoices and %syymm-nnnn for credit notes where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
|
TerreNumRefModelDesc1=Return number with format %syymm-nnnn for standard invoices and %syymm-nnnn for credit notes where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
|
||||||
MarsNumRefModelDesc1=Return number with format %syymm-nnnn for standard invoices, %syymm-nnnn for replacement invoices, %syymm-nnnn for down payment invoices and %syymm-nnnn for credit notes where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
|
MarsNumRefModelDesc1=Return number with format %syymm-nnnn for standard invoices, %syymm-nnnn for replacement invoices, %syymm-nnnn for down payment invoices and %syymm-nnnn for credit notes where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
|
||||||
|
|||||||
@ -141,6 +141,7 @@ OrderByWWW=Online
|
|||||||
OrderByPhone=Phone
|
OrderByPhone=Phone
|
||||||
# Documents models
|
# Documents models
|
||||||
PDFEinsteinDescription=A complete order model (logo...)
|
PDFEinsteinDescription=A complete order model (logo...)
|
||||||
|
PDFEratostheneDescription=A complete order model (logo...)
|
||||||
PDFEdisonDescription=A simple order model
|
PDFEdisonDescription=A simple order model
|
||||||
PDFProformaDescription=A complete proforma invoice (logo…)
|
PDFProformaDescription=A complete proforma invoice (logo…)
|
||||||
CreateInvoiceForThisCustomer=Bill orders
|
CreateInvoiceForThisCustomer=Bill orders
|
||||||
|
|||||||
@ -78,6 +78,7 @@ TypeContact_propal_external_CUSTOMER=Customer contact following-up proposal
|
|||||||
TypeContact_propal_external_SHIPPING=Customer contact for delivery
|
TypeContact_propal_external_SHIPPING=Customer contact for delivery
|
||||||
# Document models
|
# Document models
|
||||||
DocModelAzurDescription=A complete proposal model (logo...)
|
DocModelAzurDescription=A complete proposal model (logo...)
|
||||||
|
DocModelCyanDescription=A complete proposal model (logo...)
|
||||||
DefaultModelPropalCreate=Default model creation
|
DefaultModelPropalCreate=Default model creation
|
||||||
DefaultModelPropalToBill=Default template when closing a business proposal (to be invoiced)
|
DefaultModelPropalToBill=Default template when closing a business proposal (to be invoiced)
|
||||||
DefaultModelPropalClosed=Default template when closing a business proposal (unbilled)
|
DefaultModelPropalClosed=Default template when closing a business proposal (unbilled)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user