Table of contents
- Secure: Communication via GET and POST
- DB: Access to the database
- Tpl: The template system
- erp: The core library for ERP functions
- Add new menu item
- Write values to LogFile with LogFile()
- Tables exist/create with CheckTable()
- Columns present/create with CheckColumn()
- Add purchase price with AddPurchasePrice()
- Add sales price with AddSalesPrice()
- Create/update article with InsertUpdateArticle()
- Create/update address with InsertUpdateAddress()
- Assign roles with AddRoleToAddress()
- Get free article number with GetNextArtikelnummer()
- Get free customer number with GetNextKundeennummer()
- Get free supplier number with GetNextSupplierNumber()
- Get free employee number with GetNextEmployeeNumber()
- Create offer with CreateAngebot()
- Create order with CreateOrder()
- Create delivery bill with CreateDeliveryNote()
- Create invoice with CreateInvoice()
- Get country names with ISO via GetSelectLaenderliste()
- Get English country names with ISO via GetSelectLaenderlisteEN()
- YUI: For jQuery and Javascript widgets
- Notifications
- Deposit own source texts/changes in update server
- Image import
Secure: Communication via GET and POST
Access via GetPOST()
Fetches the value via POST from a form. Inside () specify the name of the form element e.g.
$name = $this->app->Secure->GetPOST('name');
Access via GetGET()
Fetches the value from the URL via GET. Inside () specify the name of the variable from of the URL e.g.
$id = $this->app->Secure->GetGET('id');
DB: Access to the database
Used to work with the data from the database. For modules in Xentral only these functions should be used.
Access via Update()
Inside the brackets specify the SQL update statement to execute e.g.
$id = $this->app->Secure->GetGET('id'); $this->app->DB->Update("UPDATE address SET name ='Mayer Antonia' WHERE id = "$id"");
result with a value with Select()
Inside the brackets specify the SQL query statement to execute e.g.
$id = 4; $name = $this->app->DB->Select("SELECT name FROM address WHERE id = "$id"");
Result with multiple values with SelectArr()
Used when you want values from several columns of the database. The return is stored in an array with associative indices e.g.
$person data = $this->app->DB->SelectArr("SELECT name, street, loc, plz, country FROM address WHERE id = 5");
Insert via Insert()
Inside the brackets specify the SQL insert statement to execute e.g.
$this->app->DB->Insert("INSERT INTO address (name, street, city, plz, country) VALUES ('Klein Christian', 'Musterstrasse 10', 'Musterort', '12345', 'DE')");
Delete via Delete()
Inside the brackets specify the SQL delete statement to execute e.g.
$this->app->DB->Delete("DELETE FROM address WHERE id = 10");
Last assigned ID via GetInsertID()
Returns the last ID inserted into the database, e.g.
$adressid = $this->app->DB->GetInsertID();
Tpl: The template system
Used to work with the template.
Insert/replace values with Set()
Adds a new string to the template field area. Attention: Set() overwrites the contents of the previous template field range. The first parameter stands for the template field range (always capitalized!) and the second parameter is the string that should overwrite this template field area. Example:
$this->app->Tpl->Set("FIRSTNAME", "Marie");
Insert values with Add()
Adds a new string to the template field area. First parameter is the field area of the template, the second parameter is the string that should be should be inserted, e.g.
$this->app->Tpl->Add("TABLE", "FirstNameLastName");
Select template file with Parse()
Ensures that the template file specified in () is used to render the HTML code. Example:
$this->app->Tpl->Parse("PAGE", "example_module_list.tpl");
erp: The core library for ERP functions
These functions can be found in the file class.erpapi.php.
Add new menu item
Adds a new menu item to the navigation. The first parameter is the link of the module in which the new menu item should be added. Parameter 2 is the label of the menu item. Example:
$this->app->erp->MenuEntry("index.php?module=modulename&action=list", "Overview");
Write values to LogFile with LogFile()
Writes to the LogFile the contents of the (), viewable in the database table logfile. Example: $this->app->erp->LogFile("Error 1: No name available");
tables present/create with CheckTable()
Checks if the table exists in the database. If it does not exist it will be created. Example: $this->app->erp->CheckTable("address");
Columns present/create with CheckColumn()
Checks if the column exists in the specified table. If not it will be created. Meaning of the parameters CheckColumn(Column name, data type, table name, default value). Example: $this->app->erp->CheckColumn("id", "int(10)", "address", "NOT NULL AUTO_INCREMENT");
Add purchase price with AddPurchasePrice()
Adds a new purchase price to the specified item. Meaning of the parameters AddPurchasePrice(ItemID, FromQuantity, IDSupplier, OrderNo, NameSupplier, PurchasePrice). Example: $this->app->erp->AddPurchasePrice(23, 1, 57, "14456", "Joghurt und Eis GmbH", 1.80);
Add sales price with AddSalesPrice()
Adds a new sales price to the specified item. Meaning of the parameters AddSalePrice(ItemID, FromQuantity, AddressID for which group the price applies, SalesPrice). 0 as the third parameter means that this sales price applies to all, i.e. for no particular group. Example: $this->app->erp->AddSalePrice(23, 1, 0, 2.00);
Create/update article with InsertUpdateArticle()
Adds a new article or updates an existing article. Parameter must be an array. If the article is to be updated, this must be passed, otherwise the article will be created. The indices of the array must be named like the columns of the article table. Example: $articledata = array(); $article_data['name_en'] = "Apple"; $article_data['anabregs_text'] = "A red apple"; $article_data['producer'] = "Apple farm";
$this->app->erp->InsertUpdateArticle($articleData);
Create/update address with InsertUpdateAddress()
Adds a new address or updates an existing address. Parameter must be an array. If the address is to be updated, the ID and - depending on the role of the address - the employee-, or customer-, or supplier number must be specified, otherwise the address will be recreated. The indices of the array must be named like the columns of the address table. Example: $addressdata = array(); $addressdata['name'] = "Max Mustermann"; $addressdata['street'] = "Musterstraße 1"; $adressdaten['plz'] = "00000"; $adressdaten['ort'] = "Musterort"; $addressdata['country'] = "DE";
$this->app->erp->InsertUpdateAddress($addressdata);
Assign roles with AddRoleToAddress()
Adds a role to an already existing address. There are the roles Employee, Customer, and Supplier. The roles can be assigned to specific objects, such as "Project" or "Group". Meaning of the parameters AddRoleToAddress(AddressID, role, optional predicate, optional object, optional parameterID). If the role is generally valid, only the first two parameters can be used, if you want to assign it to specific objects, the last parameter must be filled with the respective project or group ID. In the following example, the role Customer is added to an address for a specific project. Example: $this->app->erp->AddRoleToAddress(145, "Customer", "From", "Project", 2);
Get free article number with GetNextArtikelnummer()
Returns the next free article number from the number range. Example: $freearticlenr = $this->app->erp->GetNextArticleNumber();
Get free customer number with GetNextKundennummer()
Returns the next free customer number from the number range. Example: $freecustomernumber = $this->app->erp->GetNextCustomerNumber();
Get free supplier number with GetNextSupplierNumber()
Returns the next free supplier number from the number range. Example: $freevendornr = $this->app->erp->GetNextVendorNumber();
Get free employee number with GetNextEmployeeNumber()
Returns the next free employee number from the number range. Example: $freeemployeenr = $this->app->erp->GetNextEmployeeNumber();
Create offer with CreateAngebot()
Creates a new quote for the AddressID specified in (). Returns the ID of the created offer. Example: $offerid = $this->app->erp->CreateOffer(22);
Create order with CreateOrder()
Creates a new job for the AddressID specified in (). Returns the ID of the created order. Example: $auftragid = $this->app->erp->CreateAuftrag(34);
Create delivery bill with CreateDeliveryNote()
Creates a new delivery bill for the addressID specified in (). Returns the ID from the created delivery bill. Example: $deliverynoteid = $this->app->erp->CreateDeliveryNote(12);
Create invoice with CreateInvoice()
Creates a new invoice for the AddressID specified in (). Returns the ID of of the created invoice. Example: $invoiceid = $this->app->erp->CreateInvoice(23);
Get country names with ISO via GetSelectLaenderliste()
Returns an array filled with country names and their two-character ISO code. If the parameter is set to true, the key of the array is the country name and the value is the ISO code. If false it is the other way around. Example: $country = $this->app->erp->GetSelectLaenderliste(true);
Get English country names with ISO via GetSelectLaenderlisteEN()
Returns an array filled with English country names and their two-character ISO code is returned. If the parameter is set to true, the key of the array is the English country name and the value is the ISO code. If false it is the other way around. Example: $laenderEN = $this->app->erp->GetSelectLaenderlisteEN(false);
YUI: For jQuery and Javascript widgets
These functions can be found in the class.yui.php file.
Select LiveTable with TableSearch()
Determines which template is used to display the LiveTable. The first parameter specifies in which template field area the LiveTable is to be displayed. The second parameter specifies which LiveTable is to be used. Example: $this->app->YUI->TableSearch('TAB1','example_module_list', "show","",basename(FILE), CLASS);
Preselection for text fields via AutoComplete()
Creates a preselection of matching entries while typing. Already existing pre-selections can be found in the ajax.php file in the AjaxFilter() function. Meaning of the parameters AutoComplete(TextfieldID, Filter, Only_Number). Only_Number can be omitted or set to 1. If the parameter is set to 1, only the number is inserted into the text field, instead of number and label. Example: $this->app->YUI->AutoComplete("selectitem", "itemnumber", 1);
Create DatePicker with DatePicker()
Creates a small calendar by clicking in the text field specified in () where you can click on the desired date. You can see the graphical interface under Widgets. Example: $this->app->YUI->DatePicker("date_from");
Create TimePicker with TimePicker()
Creates a window with two sliders when you click in the text field specified in () for time selection. You can see the graphical interface here under Widgets. Example: $this->app->YUI->TimePicker("time_from");
Extended Textarea with CkEditor()
Adds some formatting options to a normal HTML textarea using buttons. As first parameter the Id of the textarea must be entered. The second parameter is the type of formatting options, such as basic, occupy or all. You can see the different graphical interfaces here under Widgets. Example: $this->app->YUI->CkEditor("textarea", "basic");
Notifications
$this->app->erp->InternalEvent($this->app->User->GetID(), "text", "type",1);
- Parameter is the UserID, must be present
- Parameter is the text you want to output
- Parameter is the type of message (see listing below)
- Parameters whether the notification should appear with sound or without sound
Valid types for the message
- default
- notice
- success
- warning
- error
- push
Deposit own source code/changes in update server
Many PHP files can be overloaded with individual files. To do this copy the body of an original file e.g. class.invoice.php and name this class.invoice_custom.php. In this file, there must be the class with the appendix Custom. e.g. Class RechnungCustom Extends invoice now the methods in the file can be overloaded individually. The new file class.invoice_custom.php will not be overwritten by the update server. You can get an FTP account for the update server on request. The adjustments will automatically update with transferred. files, which are identical with the open source version which is delivered unencrypted.
Overloadable files
- Modules from www/pages
- Documents from lib/documents
- Class.erpapi.php → class.erpapi_custom.php
- Class.printer.php → class.printer_custom.php
Source files
The general source code can be found in the .src.php file Example class.erpapi_custom.php
Example class.remote_custom.php
Image import
Information about importing images can be found in this article.