Skip to content
Code-Schnipsel Gruppen Projekte
Commit 209ebc0c erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

refactor: Grundgerüst

Übergeordneter fd63a5b1
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!2Dev,!1Dev
<?php
/**
* This file contains package_quiqqer_bill_ajax_invoices_list
*/
/**
* Returns invoices list for a grid
*
* @param string $params - JSON query params
*
* @return array
*/
QUI::$Ajax->registerFunction(
'package_quiqqer_bill_ajax_invoices_list',
function ($params) {
$Invoices = QUI\ERP\Accounting\Invoice\Handler::getInstance();
$Grid = new QUI\Utils\Grid();
$data = $Invoices->search(
$Grid->parseDBParams(json_decode($params, true))
);
return $Grid->parseResult($data, $Invoices->count());
},
array('params'),
'Permission::checkAdminUser'
);
define('package/quiqqer/bill/bin/Invoices', [
'package/quiqqer/bill/bin/backend/classes/Invoices'
], function (Invoices) {
"use strict";
return new Invoices();
});
/**
*
*/
define('package/quiqqer/bill/bin/backend/classes/Invoices', [
'qui/QUI',
'qui/classes/QDOM',
'Ajax'
], function (QUI, QDOM, QUIAjax) {
"use strict";
return new Class({
Extends: QDOM,
Type: '',
initialize: function (options) {
this.parent(options);
},
/**
* Return the data from a bill
*
* @param {Number} billId
* @returns {Promise}
*/
get: function (billId) {
return new Promise(function (resolve) {
});
},
/**
* Return invoices for a grid
*
* @param {Object} params - Grid params
* @returns {Promise}
*/
getList: function (params) {
return new Promise(function (resolve) {
QUIAjax.get('');
resolve();
});
}
});
});
define('', [
'qui/QUI',
'qui/controls/desktop/Panel'
], function (QUI, QUIPanel) {
"use strict";
return new Class({
Extends: QUIPanel,
Type: '',
options: {
invoiceId: false
},
initialize: function (options) {
this.setAttributes({
icon: 'fa fa-money'
});
this.parent(options);
}
});
});
\ No newline at end of file
/**
* @module package/quiqqer/bill/bin/backend/controls/InvoicesPanel
*
* @require qui/QUI
* @require qui/controls/desktop/Panel
* @require controls/grid/Grid
*/
define('package/quiqqer/bill/bin/backend/controls/InvoicesPanel', [
'qui/QUI',
'qui/controls/desktop/Panel',
'controls/grid/Grid',
'package/quiqqer/bill/bin/Invoices'
], function (QUI, QUIPanel, Grid, Invoices) {
"use strict";
return new Class({
Extends: QUIPanel,
Type: 'package/quiqqer/bill/bin/backend/controls/InvoicesPanel',
initialize: function (options) {
this.setAttributes({
icon: 'fa fa-money'
});
this.parent(options);
this.$Grid = null;
this.addEvents({
onCreate: this.$onCreate,
onResize: this.$onResize
});
},
refresh: function () {
this.Loader.show();
Invoices.getList().then(function (result) {
this.$Grid.setData(result);
}.bind(this));
},
/**
* event : on create
*/
$onCreate: function () {
// Buttons
// Grid
var Container = new Element('div').inject(
this.getContent()
);
this.$Grid = new Grid(Container, {
columnModel: [{}]
});
},
/**
* event : on resize
*/
$onResize: function () {
if (!this.$Grid) {
return;
}
var Body = this.getContent();
if (!Body) {
return;
}
var size = Body.getSize();
this.$Grid.setHeight(size.y - 40);
this.$Grid.setWidth(size.x - 40);
}
});
});
\ No newline at end of file
{
"name": "quiqqer\/bill",
"type": "quiqqer-module",
"description": "",
"version": "dev-master",
"license": "",
"authors": [
{
"name": "Henning Leutz",
"email": "leutz@pcsg.de",
"homepage": "http:\/\/www.pcsg.de",
"role": "Developer"
}
],
"support": {
"email": "support@pcsg.de",
"url": "http:\/\/www.pcsg.de"
},
"require": {
"php": ">=5.6",
"quiqqer\/quiqqer": "1.*|dev-master|dev-dev"
},
"autoload": {
"psr-4": {
"QUI\\ERP\\": "src\/QUI\/ERP"
}
}
}
\ No newline at end of file
{"name":"quiqqer\/bill","type":"quiqqer-module","description":"","version":"dev-dev","license":"","authors":[{"name":"Henning Leutz","email":"leutz@pcsg.de","homepage":"http:\/\/www.pcsg.de","role":"Developer"}],"support":{"email":"support@pcsg.de","url":"http:\/\/www.pcsg.de"},"require":{"php":">=5.6","quiqqer\/quiqqer":"1.*|dev-master|dev-dev"},"autoload":{"psr-4":{"QUI\\ERP\\":"src\/QUI\/ERP"}}}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<database>
<global>
<table name="invoice">
<field type="INT(11) NOT NULL">id</field>
<field type="INT(11) NOT NULL">customer_id</field>
<field type="int(11) NULL">order_id</field> <!-- wird normal nicht gebraucht, muss in data -->
<!--<field type="int(11) NOT NULL">contract_id</field>--> <!-- wird normal nicht gebraucht, muss in data -->
<field type="varchar(250) NOT NULL">hash</field>
<field type="timestamp NULL DEFAULT CURRENT_TIMESTAMP">date</field>
<field type="varchar(200) NOT NULL">payment</field>
<field type="text NULL">payment_data</field> <!-- muss verschlüsselt sein -->
<field type="datetime NULL">payment_time</field>
<field type="text NULL">payment_address</field>
<field type="text NULL">delivery_address</field>
<field type="int(3) NULL">time_for_payment</field>
<field type="int(2) NOT NULL">paid_status</field>
<field type="timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'">paid_date</field>
<field type="text NULL">paid_data</field>
<field type="int(1) DEFAULT 0">canceled</field> <!-- storno -->
<field type="int(11) NOT NULL">c_user</field>
<field type="text NULL">data</field>
<field type="text NOT NULL">products</field>
<!--<field type="text NULL">comments</field>--> <!-- als Modul auslagern -->
<field type="text NULL">history</field>
<field type="text NULL">customer_data</field>
<field type="float NOT NULL">isbrutto</field>
<field type="text NOT NULL">currency_data</field>
<field type="float NOT NULL">nettosum</field>
<field type="float NOT NULL">subsum</field>
<field type="float NOT NULL">sum</field>
<field type="text NOT NULL">vat_data</field>
<!--<field type="text NOT NULL">shipping</field>--> <!-- auslagern -> eigenes modul -->
<!--<field type="int(2) NOT NULL">dunning_level</field>--> <!-- eigenes modul -->
<!--<field type="int(11) NOT NULL">dunning_time</field>--> <!-- eigenes modul -->
<primary>id</primary>
<index>uid</index>
<index>payment</index>
<index>date</index>
<index>hash</index>
<auto_increment>id</auto_increment>
</table>
<table name="invoice_temporary">
<field type="INT(11) NOT NULL">id</field>
<field type="INT(11) NOT NULL">customer_id</field>
<field type="int(11) NULL">order_id</field>
<field type="varchar(250) NOT NULL">hash</field>
<field type="varchar(200) NOT NULL">payment</field>
<field type="text NULL">payment_data</field> <!-- muss verschlüsselt sein -->
<field type="datetime NULL">payment_time</field>
<field type="text NULL">payment_address</field>
<field type="text NULL">delivery_address</field>
<field type="int(3) NULL">time_for_payment</field>
<field type="int(2) NOT NULL">paid_status</field>
<field type="timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'">paid_date</field>
<field type="text NULL">paid_data</field>
<field type="int(1) DEFAULT 0">canceled</field> <!-- storno -->
<field type="timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP">date</field>
<field type="int(11) NOT NULL">c_user</field>
<field type="text NULL">data</field>
<field type="text NOT NULL">products</field>
<field type="text NULL">history</field>
<field type="text NULL">customer_data</field>
<field type="float NOT NULL">isbrutto</field>
<field type="text NOT NULL">currency_data</field>
<field type="float NOT NULL">nettosum</field>
<field type="float NOT NULL">subsum</field>
<field type="float NOT NULL">sum</field>
<field type="text NOT NULL">vat_data</field>
<field type="int(5) NOT NULL">processing_status</field> <!-- variable machen, prozess status verwaltung -->
</table>
</global>
</database>
\ No newline at end of file
<?php
/**
* This file contains QUI\ERP\Accounting\Invoice\Exception
*/
namespace QUI\ERP\Accounting\Invoice;
use QUI;
/**
* Class Exception
* @package QUI\ERP\Accounting\Invoice
*/
class Exception extends QUI\Exception
{
}
<?php
namespace QUI\ERP\Accounting\Invoice;
use QUI;
/**
* Class Factory
* - Creates Temporary invoices
*
* @package QUI\ERP\Accounting\Bill
*/
class Factory
{
/**
* @var null
*/
protected static $Instance = null;
/**
* @return null|Factory
*/
public static function getInstance()
{
if (self::$Instance === null) {
self::$Instance = new self();
}
return self::$Instance;
}
/**
* Create a non posted invoice
*
* @return TemporaryInvoice
*/
public function createTemporaryBill()
{
$Handler = Handler::getInstance();
$Database = QUI::getDataBase();
$Database->insert(
$Handler->temporaryInvoiceTable(),
array()
);
$newId = $Database->getPDO()->lastInsertId();
return $Handler->getTemporaryInvoice($newId);
}
}
\ No newline at end of file
<?php
namespace QUI\ERP\Accounting\Invoice;
use QUI;
/**
* Class Handler
* - Maintains invoices
* - Returns invoices
*
* @package QUI\ERP\Accounting\Bill
*/
class Handler
{
/**
* @var string
*/
const TABLE_INVOICE = 'invoice';
/**
* @var string
*/
const TABLE_TEMPORARY_INVOICE = 'invoice_temporary';
/**
* @var null
*/
protected static $Instance = null;
/**
* @return null|Handler
*/
public static function getInstance()
{
if (self::$Instance === null) {
self::$Instance = new self();
}
return self::$Instance;
}
/**
* Tables
*/
/**
* Return the invoice table name
*
* @return string
*/
public function invoiceTable()
{
return QUI::getDBTableName(self::TABLE_INVOICE);
}
/**
* Return the temporary invoice table name
*
* @return string
*/
public function temporaryInvoiceTable()
{
return QUI::getDBTableName(self::TABLE_TEMPORARY_INVOICE);
}
/**
* GET methods
*/
/**
* Search for invoices
*
* @param array $params - search params
* @return array
*/
public function search($params = array())
{
$query = array(
'from' => $this->invoiceTable(),
'limit' => 20
);
if (isset($params['where'])) {
$query['where'] = $params['where'];
}
if (isset($params['where_or'])) {
$query['where_or'] = $params['where_or'];
}
if (isset($params['limit'])) {
$query['limit'] = $params['limit'];
}
if (isset($params['order'])) {
$query['order'] = $params['order'];
}
return QUI::getDataBase()->fetch($query);
}
/**
* Count the invoices
*
* @param array $queryParams - optional
* @return int
*/
public function count($queryParams = array())
{
$query = array(
'from' => $this->invoiceTable(),
'count' => array(
'select' => 'id',
'as' => 'count'
)
);
if (isset($queryParams['where'])) {
$query['where'] = $queryParams['where'];
}
if (isset($queryParams['where_or'])) {
$query['where_or'] = $queryParams['where_or'];
}
$data = QUI::getDataBase()->fetch($query);
if (isset($data[0]) && isset($data[0]['count'])) {
return (int)$data[0]['count'];
}
return 0;
}
/**
* Search for temporary invoices
*
* @param array $params - search params
* @return array
*/
public function searchTemporaryInvoices($params = array())
{
$query = array(
'from' => $this->temporaryInvoiceTable(),
'limit' => 20
);
if (isset($params['where'])) {
$query['where'] = $params['where'];
}
if (isset($params['where_or'])) {
$query['where_or'] = $params['where_or'];
}
if (isset($params['limit'])) {
$query['limit'] = $params['limit'];
}
if (isset($params['order'])) {
$query['order'] = $params['order'];
}
return QUI::getDataBase()->fetch($query);
}
/**
* Count the invoices
*
* @param array $queryParams - optional
* @return int
*/
public function countTemporaryInvoices($queryParams = array())
{
$query = array(
'from' => $this->temporaryInvoiceTable(),
'count' => array(
'select' => 'id',
'as' => 'count'
)
);
if (isset($queryParams['where'])) {
$query['where'] = $queryParams['where'];
}
if (isset($queryParams['where_or'])) {
$query['where_or'] = $queryParams['where_or'];
}
$data = QUI::getDataBase()->fetch($query);
if (isset($data[0]) && isset($data[0]['count'])) {
return (int)$data[0]['count'];
}
return 0;
}
/**
* Return an Invoice or an TemporaryInvoice
*
* @param string $id - ID of the Invoice or TemporaryInvoice
* @return TemporaryInvoice|Invoice
*
* @throws Exception
*/
public function get($id)
{
if (strpos($id, 'ti-') === 0) {
return $this->getTemporaryInvoice($id);
}
return $this->getInvoice($id);
}
/**
* Return an Invoice
*
* @param string $id - ID of the Invoice
* @return Invoice
*
* @throw Exception
*/
public function getInvoice($id)
{
return new Invoice($id, $this);
}
/**
* Return the data from an invoice
*
* @param string $id
* @return array
* @throws Exception
*/
public function getInvoiceData($id)
{
$result = QUI::getDataBase()->fetch(array(
'from' => self::invoiceTable(),
'where' => array(
'id' => $id
),
'limit' => 1
));
if (!isset($result[0])) {
throw new Exception(
array('quiqqer/bill', 'exception.invoice.not.found'),
404
);
}
return $result[0];
}
/**
* Return a temporary invoice
*
* @param string $id - ID of the Invoice
* @return TemporaryInvoice
*
* @throws Exception
*/
public function getTemporaryInvoice($id)
{
return new TemporaryInvoice($id, $this);
}
/**
* Return the data from a temporary invoice
*
* @param string $id
* @return array
* @throws Exception
*/
public function getTemporaryInvoiceData($id)
{
$result = QUI::getDataBase()->fetch(array(
'from' => self::temporaryInvoiceTable(),
'where' => array(
'id' => $id
),
'limit' => 1
));
if (!isset($result[0])) {
throw new Exception(
array('quiqqer/bill', 'exception.temporary.invoice.not.found'),
404
);
}
return $result[0];
}
}
<?php
namespace QUI\ERP\Accounting\Invoice;
use QUI;
/**
* Class Invoice
* - Bill class
*
* @package QUI\ERP\Accounting\Invoice
*/
class Invoice extends QUI\QDOM
{
/**
* Invoice constructor.
*
* @param $id
* @param Handler $Handler
*/
public function __construct($id, Handler $Handler)
{
$this->setAttributes($Handler->getInvoiceData($id));
}
/**
* Storno
*/
public function cancel()
{
// @todo wenn umgesetzt wird, vorher mor fragen
// -> Gutschrift erzeugen
}
}
<?php
namespace QUI\ERP\Accounting\Invoice;
use QUI;
/**
* Class TemporaryInvoice
* - Temporary Bill / Invoice class
* - A temporary invoice is a non posted bill, it is not a real invoice
* - To create a correct invoice from the temporary invoice, the post method must be used
*
* @package QUI\ERP\Accounting\Invoice
*/
class TemporaryInvoice extends QUI\QDOM
{
/**
* Invoice constructor.
*
* @param $id
* @param Handler $Handler
*/
public function __construct($id, Handler $Handler)
{
$this->setAttributes($Handler->getTemporaryInvoiceData($id));
}
/**
* Creates a bill from the temporary invoice
*
* @throws Exception
*/
public function post()
{
}
/**
* SAve te current temporary invoice data to the database
*/
public function save()
{
}
}
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren