Interface

Aus phynx application framework
Wechseln zu: Navigation, Suche

Das Interface-Plugin ist eine Interface-Klasse in PHP.
Sie können mit dieser Klasse open3A als Bibliothek verwenden
und von Ihrer Anwendung heraus Rechnungen und Lieferscheine erstellen lassen.
Es enthält Referenzimplementierung sowie Dokumentation.
Sie erhalten drei Jahre lang Updates für dieses Plugin.

Interface-Klasse

<?php
/*
 *  This file is part of open3A.

 *  open3A is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.

 *  open3A is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.

 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  2007, 2008, 2009, 2010, Rainer Furtmeier - Rainer@Furtmeier.de
 */

/**
 * This is a library class which you can use to create Rechnungen and Lieferscheine
 * as PDF with your own application.
 *
 * Please be aware that it will start a session if not already done so.
 * Afterwards the variables $_SESSION[S] and $_SESSION[messages] are required to be
 * unset. Else this class won't be initialized correctly and return an error.
 *
 * You can get the error numbers with getLastError() and translate it to text form
 * using getErrorMessage()
 *
 */
class ExtConnOpen3a extends ExtConn {
	function __construct($absolutePathToPhpAppFW);

	/**
	 * Loads or creates an Auftrag for the specified Adresse
	 *
	 * requires a user to be logged in
	 * requires that $AdresseID already exists
	 *
	 * @param int $AdresseID
	 *
	 * @return int AuftragID
	 */
	function loadOrCreateAuftrag($AdresseID);

	/**
	 * Sets the Kundennummer for an Auftrag
	 *
	 * Needs to be set only once as this value is stored with the Auftrag
	 *
	 * @param int $AuftragID
	 * @param string $kundennummer
	 */
	function setKundennummer($AuftragID, $kundennummer);

	/**
	 * Sets the UStIdNr or Steuernummer for an Auftrag
	 *
	 * Needs to be set only once as this value is stored with the Auftrag
	 *
	 * @param int $AuftragID
	 * @param string $UStIdNr
	 */
	function setUStIdNr($AuftragID, $UStIdNr);

	/**
	 * Creates a Rechnung, a Lieferschein, a Gutschrift
	 * or an Angebot for the given AuftragID
	 *
	 * The default Textbausteine will be used
	 *
	 * Valid types are
	 * R - Rechnung
	 * L - Lieferschein
	 * G - Gutschrift
	 * A - Angebot
	 *
	 * @param int $AuftragID
	 * @param string $type
	 *
	 * @return int GRLBMID
	 */
	function createGRLBM($AuftragID, $type);

	/**
	 * Adds an Artikel from the database to the given GRLBMID
	 * This method also uses the multiLanguage-Plugin and the Kundenpreis if Kundennummer is set
	 * You'll have to require_once the file plugins/multiLanguage/mMultiLanguageGUI.class.php
	 *
	 * @param int $GRLBMID
	 * @param int $ArtikelID
	 * @param int $kundennummer
	 * @param int $anzahl
	 *
	 * @return int PostenID
	 */
	function addArtikelToGRLBM($GRLBMID, $ArtikelID, $anzahl = 1, $kundennummer = null);

	/**
	 * Adds a Posten to the given GRLBMID
	 *
	 * @param int GRLBMID
	 * @param string artikelName
	 * @param string einheit
	 * @param float anzahl
	 * @param float preis
	 * @param float mwst
	 *
	 * @return int PostenID
	 */
	function addPostenToGRLBM($GRLBMID, $artikelName, $einheit, $anzahl, $preis, $mwst, $beschreibung = "", $isBrutto = false);

	/**
	 * Modifies the Textbaustein of an already created GRLBM
	 *
	 * Valid where-values are:
	 * - oben
	 * - unten
	 * - zahlungsbedingungen
	 *
	 * @param int $GRLBMID
	 * @param string $where
	 * @param string $text
	 *
	 * @return bool
	 */
	function setTextbaustein($GRLBMID, $where, $text);

	/**
	 * Modifies the Lieferdatum of an already created GRLBM
	 *
	 * The date has to be given in german format such as 1.3.2008
	 *
	 * @param int $GRLBMID
	 * @param string $datum
	 *
	 * @return bool
	 */
	function setLieferdatum($GRLBMID, $datum);

	/**
	 * Sets the Versandkosten for a Rechnung
	 *
	 * @param int $GRLBM
	 * @param float $kosten
	 * @param float $mwst
	 *
	 * @return bool
	 */
	function setVersandkostenNetto($GRLBMID, $kosten, $mwst);

	/**
	 * Sets the Rabatt in percent for a Posten
	 * You may only use this Method if you have the customizer
	 * CustomizerRabatt.class.php
	 * You will also have to require_once the class-file
	 *
	 * @param int $PostenID
	 * @param float $rabatt
	 */
	function setPostenRabatt($PostenID, $rabatt);

	/**
	 * Sets the Mehrwertsteuer (VAT) in percent for a Posten
	 *
	 * @param int $PostenID
	 * @param float $mwst
	 */
	function setPostenMwSt($PostenID, $mwst);

	/**
	 * Sets the Vorlage of the copy you want to use to create the PDF
	 *
	 * Be aware that this setting is stored persistently!
	 *
	 * @param string $name
	 */
	function setCopyVorlage($name);

	/**
	 * If you don't want to display "Kopie" on the copy-PDF
	 * call this function with false
	 *
	 * Be aware that this setting is stored persistently!
	 *
	 * @param bool $label
	 */
	function showCopyLabelOnPDF($label);

	/**
	 * You may use this method to send the Rechnung directly to your customer
	 * The following actions are available:
	 *
	 * 0: do nothing
	 * 1: Mail (on paper via PixelLetter-Plugin)
	 * 2: E-Mail
	 * 3: Signed E-Mail via PixelLetter or signaturportal (requires Plugin)
	 *
	 * @param int $AuftragID
	 * @param int $GRLBMID
	 * @param int $action
	 */
	function doDefaultRechnungsversand($AuftragID, $GRLBMID, $action);

	/**
	 * Creates the PDF-file and stores it
	 *
	 * @param int $AuftragID
	 * @param int $GRLBMID
	 * @param bool istKopie
	 * @param string $dateiname
	 *
	 * @return $filename if $dateiname == ""
	 */
	function getPDF($AuftragID, $GRLBMID, $istKopie, $dateiname = "");

	/**
	 * Returns the overall total of a Rechnung or Gutschrift
	 *
	 * @param int $GRLBMID
	 * @return float
	 */
	function getTotal($GRLBMID);

	function getErrorMessage($number);

	/**
	 * loads or creates an Adresse with an initial AuftragID = -1
	 * If you use this Adresse in an Auftrag, it will be copied and the old one deleted
	 *
	 * Be advised that open3A will not create Kundendaten (including a Kundennummer) for this Adresse,
	 * but the Adresse will show up in the Adressen-Tab
	 *
	 * @param string $firma
	 * @param string $vorname
	 * @param string $nachname
	 * @param string $strasse
	 * @param string $nr
	 * @param string $plz
	 * @param string $ort
	 * @param string $land
	 * @param string $email
	 *
	 * @return int AdresseID
	 */
	function loadOrCreateAdresse($firma, $vorname, $nachname, $strasse, $nr, $plz, $ort, $land = "", $email = "");

	/**
	 * Returns the AdresseID to a Kundennummer
	 * Returns false if Kundennummer does not exist
	 *
	 * If you use the AdresseID from this method with loadOrCreateAuftrag
	 * you will always get a new Auftrag and never reuse an Auftrag
	 *
	 * @param int $KundenNr
	 *
	 * @return int AdresseID
	 */
	public function getAdresseIDFromKundennummer($KundenNr);


	/**
	 * sets the Lieferadresse displayed on a Lieferschein
	 * Only works for Lieferscheine
	 *
	 * @param int $GRLBMID
	 * @param int $AdresseID
	 *
	 * @return bool
	 */
	function setLieferadresse($GRLBMID, $AdresseID);

	/**
	 * Changes the prefix of the given GRLBM
	 * Overwrites the default prefix set in the Stammdaten
	 *
	 * @param int $GRLBMID
	 * @param string $newPrefix
	 *
	 * @return bool
	 */
	function setPrefix($GRLBMID, $newPrefix);
}
?>

Referenzimplementierung

<?php
error_reporting(E_ALL);
/**
 * The folder that contains the dirs applications, classes, images, plugins, system...
 */
$absolutePathToPhpAppFW = "/srv/www/dev/phpApplicationFW/";

require_once $absolutePathToPhpAppFW."classes/frontend/ExtConn.class.php";
require_once $absolutePathToPhpAppFW."open3A/ExtConn/ExtConnOpen3A.class.php";

$e = new ExtConnOpen3A($absolutePathToPhpAppFW);

$e->setMySQLData("localhost","open3A","zjTWWa87yvfnMn2.","open3ADev");


if(!$e->login("test","test"))
	die($e->getErrorMessage($e->getLastError()));
	
$AdresseID = $e->loadOrCreateAdresse("ExtConn Testfirma", "Max", "Mustermann", "Musterstraße", "8", "12345", "Musterhausen");
echo "Adress-ID: $AdresseID\n";

$AuftragID = $e->loadOrCreateAuftrag($AdresseID);
echo "Auftrags-ID: $AuftragID\n";

/**
 * If you have set your own Rechnungsnummer-Template in the Stammdaten,
 * you need to require_once the .class.php-file before creating a new GRLBM
 * 
 * require_once $absolutePathToPhpAppFW."specifics/myReNrTemplate.class.php";
 */

require_once $absolutePathToPhpAppFW."specifics/Jahr5Nummer.class.php";
$GRLBMID = $e->createGRLBM($AuftragID, "R");
echo "GRLBM-ID: $GRLBMID\n";

$PostenID = $e->addPostenToGRLBM($GRLBMID, "Testartikel", "Stunden", 1, 11.813, 19, "Beschreibung\n2te Zeile");
echo "Posten-ID: $PostenID\n";

/**
 * Path to the Vorlage you want to use
 * Please do not "require_once" it earlier as there are further dependencies
 * which are loaded in the constructor of ExtConnOpen3A()
 * 
 * require_once $absolutePathToPhpAppFW."specifics/HSBriefkopf.class.php";
 */

/*
require_once $absolutePathToPhpAppFW."specifics/HSBriefkopf.class.php";
$e->setCopyVorlage("HSBriefkopf");
*/

#$e->showCopyLabelOnPDF(false);
#$e->setTextbaustein($GRLBMID, "unten","Unberechtigt abgezogene Skontobeträge werden nachgefordert.\nDie Ware bleibt bis zur vollständigen Bezahlung unser Eigentum.");
$e->setLieferdatum($GRLBMID, "1.2.2008");
$e->setVersandkostenNetto($GRLBMID, 15.20, 19);
$e->setKundennummer($AuftragID,"10000");
$e->getPDF($AuftragID, $GRLBMID, false, "/srv/www/dev/extC/Rechnung.pdf");

/**
 * This is important or you will get error messages like:
 * 
 * Fatal error: ExtConn::login() function.ExtConn-login:
 * The script tried to execute a method or access a property of an incomplete object.
 * Please ensure that the class definition "Session" of the object you are trying to
 * operate on was loaded _before_ unserialize() gets called or provide a __autoload()
 * function to load the class definition in...
 */
$e->cleanUp();

?>