Table of contents
Stationery overload
If further information is required for the stationery, such as, for example, the weight or height of an article, you can create your own letterhead for loading.
The file that should load the stationery must be called class.stationery_custom.php. This file has to be uploaded in the Xentral folder to www/lib/documents and is then valid for all documents.
Hint: You can get the source code from the file in the Open source version.
In the following example, the weight as well as the height, width, length, and region of origin of the item are to be added to the item description of an item.
There is no custom stationery yet, so for the time being the stationery look is set in the default settings:
The first thing to do is to create the class.stationery_custom.php file. The basic structure for the custom stationery looks like this:
?php
include_once "class.stationery.php";
class StationeryCustom extends Stationery {
function __construct(&$app) { $this->app = $app; parent::__construct($app); }
} ?>
Next, open the file class.stationery.php, which is currently responsible for the layout of the stationery and pick out the function that is to be loaded, copy and paste it under the function "construct". In this case, the function renderItems is to be copied, since this is responsible for the rendering of the item positions. Since the function renderItems function is quite long, this example only shows how the code of class.stationery_custom.php then looks like.
?php
include_once "class.stationery.php";
class StationeryCustom extends Stationery {
function __construct(&$app) { $this->app = $app; parent::__construct($app); }
public function renderItems() {$posWidth = $this->app->erp->company_data("width_position"); $amWidth = $this->app->erp->company_data("width_amount"); $itemNoWidth = $this->app->erp->company_data("width_number"); ... ... ...
}
} ?>
Below
if($item['ean']!="" && $item['ean']!="0"){
if($item['desc']!=""){
$item['desc']=$item['desc']."\r\n".$this->app->erp->label("document_ean").": ".$item['ean'];
}else{
$item['desc']=$this->app->erp->label("document_ean").": ".$item['ean'];
}
}
the size, height, width, length, and region of origin of the item will be added to the variable $item['desc'], because this variable contains the description text to which further values are added.
The finished section will look like this:
if($item['ean']!="" && $item['ean']!="0"){
if($item['desc']!=""){
$item['desc']=$item['desc']."\r\n".$this->app->erp->label("document_ean").": ".$item['ean'];
}else{
$item['desc']=$this->app->erp->label("document_ean").": ".$item['ean'];
}
}
$data = $this->app->DB->SelectArr("SELECT weight, length, width, height, region of origin FROM article WHERE id = '".$item['article']."');
$data = reset($data);
if($item['desc'] != ""){
if($data['weight'] != "" AND $data['weight'] > 0){
$item['desc'] = $item['desc']."\r\n". "weight: ".$data['weight']." kg";
}
}else{
if($data['weight'] != "" AND $data['weight'] > 0){
$item['desc'] = $item['desc']."Weight: ".$data['weight']." kg";
}
}
if($item['desc'] != ""){
if($data['length'] != "" AND $data['length'] > 0){
$item['desc'] = $item['desc']. "length: ".$data['length']." cm";
}
}else{
if($data['length'] != "" AND $data['length'] > 0){
$item['desc'] = $item['desc']. "Length: ".$data['length']." cm";
}
}
if($item['desc'] != ""){
if($data['width'] != "" AND $data['width'] > 0){
$item['desc'] = $item['desc']. "width: ".$data['width']." cm";
}
}else{
if($data['width'] != "" AND $data['width'] > 0){
$item['desc'] = $item['desc']. "Width: ".$data['width']." cm";
}
}
if($item['desc'] != ""){
if($data['height'] != "" AND $data['height'] > 0){
$item['desc'] = $item['desc']. "height: ".$data['height']." cm";
}
}else{
if($data['height'] != "" AND $data['height' > 0]){
$item['desc'] = $item['desc']. "Height: ".$data['height']." cm";
}
}
$origin region = "";
switch($data['origin region']){
case "01":
$origin region = "Schleswig-Holstein";
break;
case "02":
$origin region = "Hamburg";
break;
case "03":
$origin region = "Lower Saxony";
break;
case "04":
$origin region = "Bremen";
break;
case "05":
$origin region = "North Rhine-Westphalia";
break;
case "06":
$origin region = "Hesse";
break;
case "07":
$origin region = "Rhineland-Palatinate";
break;
case "08":
$origin region = "Baden-Württemberg";
break;
case "09":
$origin region = "Bavaria";
break;
case "10":
$origin region = "Saarland";
break;
case "11":
$origin region = "Berlin";
break;
case "12":
$origin region = "Brandenburg";
break;
case "13":
$origin region = "Mecklenburg-Vorpommern";
break;
case "14":
$origin region = "Saxony";
break;
case "15":
$origin region = "Saxony-Anhalt";
break;
case "16":
$origin region = "Thuringia";
break;
case "99":
$origin region = "foreign origin";
break;
}
if($item['desc'] != ""){
if($item['desc'] != ""){
$item['desc'] = $item['desc']. "region of origin: ".$region of origin;
}
}else{
if($item['desc'] != ""){
$item['desc'] = $item['desc']. "region of origin: ".$region of origin;
}
}
The result now looks like this:
Only one document type loaded
Furthermore, there is the possibility to load only certain documents. In the following example, the next, i.e. smallest, best-before date from the warehouse for an item is to be added to the item description, expiration date from the warehouse for this article is to be displayed on a picking. For this purpose, the delivery bill must be loaded, because the pick note is also created with the class.lieferschein.php. To load the class.lieferschein.php file, a file named class.lieferschein_custom.php has to be created and put it into the xentralsordner after www/lib/dokumente. Up to now, there is no class.delivery_note_custom.php file, so the picking note looks like this:
The basic structure of the file looks like this:
?php
if(!class_exists('StationeryCustom'))
{
class StationeryCustom extends Stationery
{
}
}
class DeliveryNotePDFCustom extends StationeryCustom {
public $doctype;
function __construct($app,$project="")
{
$this->app=&$app;
//parent::stationery();
$this->doctype="delivery bill";
$this->doctypeOrig="delivery bill";
parent::__construct($this->app,$project);
}
}
?>
Next, find the appropriate function to load in class.lieferschein.php. In this case, it is the function GetDeliveryNote. This function is copied and pasted under the constructor "construct". Because the GetLieferschein function is quite long, we will only show here what the file currently looks like:
?php
if(!class_exists('StationeryCustom'))
{
class StationeryCustom extends Stationery
{
}
}
class DeliveryNotePDFCustom extends StationeryCustom {
public $doctype;
function __construct($app,$project="")
{
$this->app=&$app;
//parent::stationery();
$this->doctype="delivery bill";
$this->doctypeOrig="delivery bill";
parent::__construct($this->app,$project);
}
function GetDeliveryNote($id,$info="",$extrafreitext="")
{
$this->doctypeid = $id;
if(method_exists($this->app->erp,'CalculateDeliveryNumber'))$this->app->erp->CalculateDeliveryNumber($id);
$letter_paper_processor_hide = $this->app->erp->Company_data('letter_paper_processor_hide');
$letter_paper_sales_hide = $this->app->erp->company_data('letter_paper_distribution_hide');
$address = $this->app->DB->Select("SELECT address FROM delivery_note WHERE id='$id' LIMIT 1");
...
...
...
}
}
?>
Now the adjustments are made in the code. If these would now simply be added these would be valid for delivery bills and picking bills. However, here only the picking slips are to be adjusted, which is why it is checked beforehand with an if statement, whether it is a pick ticket or not. The changes are made under
/*
if(!empty($chargen)){
foreach($chargen as $chargen=>$charge){
$chargelist = $chargelist.$charge['charge'].";";
}
$chargelist=substr($chargelist, 0, -1);
$value['charge'] = $this->app->DB->Select("SELECT charge management FROM article WHERE id='".$value[article]."' LIMIT 1");
if($value['chargen']=="0"){
$value['description'] = $value['description'];
}else{
$value['description'] = $value['description']."\r\n".$this->app->erp->label("document_charge").": ". $chargelist;
}
}
*/
added. The whole thing will look like this:
if($info == "pick ticket"){ if($value['freefield1'] != ""){ //$value['description'] .= "\r\n". "Please select the following MHD: ".$value['freefield1']; }else{ $mhd = $this->app->DB->Select("SELECT MIN(mhddatum) FROM stock_minimum_expiration_date WHERE item= '".$value['article']."' AND mhdate > CURDATE()"); $value['description'] .= ["description" ]."Smallest MHD in the warehouse: ".$mhd; } }