commit 232fb3c9e9da88d7dcd135b14e25e223c361c806 Author: Dennis Eichhorn Date: Sun Nov 29 21:57:18 2015 +0100 Init diff --git a/Admin/Install/ItemReference.php b/Admin/Install/ItemReference.php new file mode 100644 index 0000000..1ac3101 --- /dev/null +++ b/Admin/Install/ItemReference.php @@ -0,0 +1,51 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Billing\Admin\Install; + +use phpOMS\DataStorage\Database\DatabaseType; +use phpOMS\DataStorage\Database\Pool; + +/** + * Media addition class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class ItemReference +{ + + /** + * {@inheritdoc} + */ + public static function install(Pool $dbPool, array $info) + { + + switch ($dbPool->get('core')->getType()) { + case DatabaseType::MYSQL: + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'billing_invoice_element` + ADD KEY `billing_invoice_element_article` (`billing_invoice_element_article`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'billing_invoice_element_ibfk_2` FOREIGN KEY (`billing_invoice_element_article`) REFERENCES `' . $dbPool->get('core')->prefix . 'itemreference` (`itemreference_id`);' + )->execute(); + break; + } + } +} diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php new file mode 100644 index 0000000..84112c4 --- /dev/null +++ b/Admin/Install/Navigation.php @@ -0,0 +1,38 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Billing\Admin\Install; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Navigation +{ + public static function install($dbPool) + { + $navData = json_decode(file_get_contents(__DIR__ . '/nav.install.json'), true); + + $class = '\\Modules\\Navigation\\Admin\\Installer'; + $class::installExternal($dbPool, $navData); + } +} diff --git a/Admin/Install/nav.install.json b/Admin/Install/nav.install.json new file mode 100644 index 0000000..ebee021 --- /dev/null +++ b/Admin/Install/nav.install.json @@ -0,0 +1,64 @@ +[ + { + "id": 1005104001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Billing", + "uri": "/{/lang}/backend/sales/invoice/list", + "target": "self", + "icon": null, + "order": 5, + "from": "Billing", + "permission": null, + "parent": 1001601001, + "children": [ + { + "id": 1005104101, + "pid": "722ef87be24d036db431dd65c0418e5502a6eb89", + "type": 3, + "subtype": 1, + "name": "List", + "uri": "/{/lang}/backend/sales/invoice/list", + "target": "self", + "icon": null, + "order": 1, + "from": "Billing", + "permission": null, + "parent": 1005104001, + "children": [ + { + "id": 1005104201, + "pid": "420c091bd6d9f5cd16b1d62569189feb707d6652", + "type": 3, + "subtype": 1, + "name": "Invoice", + "uri": "/{/lang}/backend/sales/invoice/single", + "target": "self", + "icon": null, + "order": 1, + "from": "Billing", + "permission": null, + "parent": 1005104101, + "children": [] + } + ] + }, + { + "id": 1005104301, + "pid": "722ef87be24d036db431dd65c0418e5502a6eb89", + "type": 3, + "subtype": 1, + "name": "Create", + "uri": "/{/lang}/backend/sales/invoice/create", + "target": "self", + "icon": null, + "order": 5, + "from": "Billing", + "permission": null, + "parent": 1005104001, + "children": [] + } + ] + } +] diff --git a/Admin/Installer.php b/Admin/Installer.php new file mode 100644 index 0000000..529165f --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,116 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Billing\Admin; + +use phpOMS\DataStorage\Database\DatabaseType; +use phpOMS\DataStorage\Database\Pool; +use phpOMS\Module\InstallerAbstract; + +/** + * Billing install class. + * + * @category Modules + * @package Modules\Billing + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Installer extends InstallerAbstract +{ + + /** + * {@inheritdoc} + */ + public static function install(Pool $dbPool, array $info) + { + parent::install($dbPool, $info); + + switch ($dbPool->get('core')->getType()) { + case DatabaseType::MYSQL: + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'billing_invoice` ( + `billing_invoice_id` int(11) NOT NULL AUTO_INCREMENT, + `billing_invoice_status` tinyint(2) DEFAULT NULL, + `billing_invoice_shipTo` varchar(50) DEFAULT NULL, + `billing_invoice_shipFAO` varchar(30) DEFAULT NULL, + `billing_invoice_shipAddr` varchar(50) DEFAULT NULL, + `billing_invoice_shipCity` varchar(20) DEFAULT NULL, + `billing_invoice_shipZip` varchar(20) DEFAULT NULL, + `billing_invoice_shipCountry` varchar(30) DEFAULT NULL, + `billing_invoice_billTo` varchar(50) DEFAULT NULL, + `billing_invoice_billFAO` varchar(30) DEFAULT NULL, + `billing_invoice_billAddr` varchar(50) DEFAULT NULL, + `billing_invoice_billCity` varchar(20) DEFAULT NULL, + `billing_invoice_billZip` varchar(20) DEFAULT NULL, + `billing_invoice_billCountry` varchar(30) DEFAULT NULL, + `billing_invoice_type` tinyint(2) DEFAULT NULL, + `billing_invoice_created` datetime DEFAULT NULL, + `billing_invoice_shippdate` datetime DEFAULT NULL, + `billing_invoice_printed` datetime DEFAULT NULL, + `billing_invoice_price` decimal(9,2) DEFAULT NULL, + `billing_invoice_currency` varchar(3) DEFAULT NULL, + `billing_invoice_freightage` decimal(9,2) DEFAULT NULL, + `billing_invoice_info` text DEFAULT NULL, + `billing_invoice_voucher` int(11) DEFAULT NULL, + `billing_invoice_promotion` int(11) DEFAULT NULL, + `billing_invoice_creator` int(11) NOT NULL, + `billing_invoice_client` int(11) NOT NULL, + `billing_invoice_referer` int(11) DEFAULT NULL, + `billing_invoice_reference` int(11) DEFAULT NULL, + PRIMARY KEY (`billing_invoice_id`), + KEY `billing_invoice_creator` (`billing_invoice_creator`), + KEY `billing_invoice_client` (`billing_invoice_client`), + KEY `billing_invoice_referer` (`billing_invoice_referer`), + KEY `billing_invoice_reference` (`billing_invoice_reference`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'billing_invoice` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'billing_invoice_ibfk_1` FOREIGN KEY (`billing_invoice_creator`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'billing_invoice_ibfk_2` FOREIGN KEY (`billing_invoice_client`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'billing_invoice_ibfk_3` FOREIGN KEY (`billing_invoice_referer`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'billing_invoice_ibfk_4` FOREIGN KEY (`billing_invoice_reference`) REFERENCES `' . $dbPool->get('core')->prefix . 'billing_invoice` (`billing_invoice_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'billing_invoice_element` ( + `billing_invoice_element_id` int(11) NOT NULL AUTO_INCREMENT, + `billing_invoice_element_position` smallint(5) NOT NULL, + `billing_invoice_element_article` int(11) NOT NULL, + `billing_invoice_element_name` varchar(30) NOT NULL, + `billing_invoice_element_desc` text NOT NULL, + `billing_invoice_element_quantity` int(11) NOT NULL, + `billing_invoice_element_price` decimal(11,2) NOT NULL, + `billing_invoice_element_tax` decimal(5,2) NOT NULL, + `billing_invoice_element_discountp` decimal(5,2) NOT NULL, + `billing_invoice_element_discount` decimal(11,2) NOT NULL, + `billing_invoice_element_invoice` int(11) NOT NULL, + PRIMARY KEY (`billing_invoice_element_id`), + KEY `billing_invoice_element_invoice` (`billing_invoice_element_invoice`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'billing_invoice_element` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'billing_invoice_element_ibfk_1` FOREIGN KEY (`billing_invoice_element_invoice`) REFERENCES `' . $dbPool->get('core')->prefix . 'billing_invoice` (`billing_invoice_id`);' + )->execute(); + break; + } + } +} diff --git a/Controller.php b/Controller.php new file mode 100644 index 0000000..11fcac0 --- /dev/null +++ b/Controller.php @@ -0,0 +1,152 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Billing; + +use Modules\Navigation\Models\Navigation; +use Modules\Navigation\Views\NavigationView; +use phpOMS\Contract\RenderableInterface; +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\RequestDestination; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\WebInterface; +use phpOMS\Views\View; +use phpOMS\Views\ViewLayout; + +/** + * Billing class. + * + * @category Modules + * @package Modules\Billing + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Controller extends ModuleAbstract implements WebInterface +{ + + /** + * Module name. + * + * @var \string + * @since 1.0.0 + */ + protected static $module = 'Billing'; + + /** + * Localization files. + * + * @var \string + * @since 1.0.0 + */ + protected static $localization = [ + RequestDestination::BACKEND => ['backend'], + ]; + + /** + * Providing. + * + * @var \string + * @since 1.0.0 + */ + protected static $providing = [ + 'Content', + ]; + + /** + * Dependencies. + * + * @var \string + * @since 1.0.0 + */ + protected static $dependencies = []; + + /** + * Routing elements. + * + * @var array + * @since 1.0.0 + */ + protected static $routes = [ + '^.*/backend/sales/invoice/create.*$' => [['dest' => '\Modules\Billing\Controller:viewBillingInvoiceCreate', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/sales/invoice/list.*$' => [['dest' => '\Modules\Billing\Controller:viewBillingInvoiceList', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + + '^.*/backend/purchase/invoice/create.*$' => [['dest' => '\Modules\Billing\Controller:viewBillingPurchaseInvoiceCreate', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/purchase/invoice/list.*$' => [['dest' => '\Modules\Billing\Controller:viewBillingPurchaInvoiceList', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + ]; + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewBillingInvoiceList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Billing/Theme/backend/invoice-list'); + $view->addData('nav', $this->createNavigation(1005104001, $request, $response)); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewBillingInvoiceCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Billing/Theme/backend/invoice-create'); + $view->addData('nav', $this->createNavigation(1005104001, $request, $response)); + + return $view; + } + + /** + * @param int $pageId Page/parent Id for navigation + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private function createNavigation(\int $pageId, RequestAbstract $request, ResponseAbstract $response) + { + $nav = Navigation::getInstance($request, $this->app->dbPool); + $navView = new NavigationView($this->app, $request, $response); + $navView->setTemplate('/Modules/Navigation/Theme/backend/mid'); + $navView->setNav($nav->getNav()); + $navView->setLanguage($request->getL11n()->language); + $navView->setParent($pageId); + + return $navView; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..f5e456e --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Billing + +Sample invoices as selection for offers promotions etc. + +credit note by selecting invoice(s) via checkbox \ No newline at end of file diff --git a/Theme/backend/invoice-archive.tpl.php b/Theme/backend/invoice-archive.tpl.php new file mode 100644 index 0000000..9dd9c79 --- /dev/null +++ b/Theme/backend/invoice-archive.tpl.php @@ -0,0 +1,19 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ +echo $this->getData('nav')->render(); ?> diff --git a/Theme/backend/invoice-create.tpl.php b/Theme/backend/invoice-create.tpl.php new file mode 100644 index 0000000..5ca7dd2 --- /dev/null +++ b/Theme/backend/invoice-create.tpl.php @@ -0,0 +1,153 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +echo $this->getData('nav')->render(); ?> + +
+
+ +
+
+ +
+
+

l11n->lang['Billing']['Invoice'] ?>

+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+

l11n->lang['Billing']['Invoice'] ?>

+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+

l11n->lang['Billing']['Delivery'] ?>

+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ + + + + + + + +
l11n->lang['Billing']['Invoice'] ?>
+ l11n->lang['Billing']['Item']; ?> + l11n->lang['Billing']['Variation']; ?> + l11n->lang['Billing']['Name']; ?> + l11n->lang['Billing']['Quantity']; ?> + l11n->lang['Billing']['Discount']; ?> + l11n->lang['Billing']['DiscountP']; ?> + l11n->lang['Billing']['Bonus']; ?> + l11n->lang['Billing']['Tax']; ?> + l11n->lang['Billing']['Net']; ?> +
+ l11n->lang['Billing']['Freightage']; ?>: 0.00 - + l11n->lang['Billing']['Net']; ?>: 0.00 - + l11n->lang['Billing']['Tax']; ?>: 0.00 - + l11n->lang['Billing']['Total']; ?>: 0.00 +
+ + + + + + + + + +
+
+
+
+
diff --git a/Theme/backend/invoice-list.tpl.php b/Theme/backend/invoice-list.tpl.php new file mode 100644 index 0000000..ee631d9 --- /dev/null +++ b/Theme/backend/invoice-list.tpl.php @@ -0,0 +1,47 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ + +$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response); +$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); +$footerView->setPages(20); +$footerView->setPage(1); + +echo $this->getData('nav')->render(); ?> + +
+ + + + + + + + $value) : $count++; ?> + + +
l11n->lang['Billing']['Invoices'] ?>
l11n->lang[0]['ID']; ?> + l11n->lang['Billing']['Type']; ?> + l11n->lang['Billing']['ClientID']; ?> + l11n->lang['Billing']['Client']; ?> + l11n->lang['Billing']['Net']; ?> + l11n->lang['Billing']['Gross']; ?> + l11n->lang['Billing']['Created']; ?> + l11n->lang['Billing']['Due']; ?> +
render(); ?> +
l11n->lang[0]['Empty']; ?> + +
+
diff --git a/Theme/backend/invoice-single.tpl.php b/Theme/backend/invoice-single.tpl.php new file mode 100644 index 0000000..9dd9c79 --- /dev/null +++ b/Theme/backend/invoice-single.tpl.php @@ -0,0 +1,19 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ +echo $this->getData('nav')->render(); ?> diff --git a/Theme/lang/backend.en.lang.php b/Theme/lang/backend.en.lang.php new file mode 100644 index 0000000..dbea19f --- /dev/null +++ b/Theme/lang/backend.en.lang.php @@ -0,0 +1,51 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +$MODLANG['Billing'] = [ + 'Address' => 'Address', + 'Addresses' => 'Addresses', + 'Bonus' => 'Bonus', + 'City' => 'City', + 'Client' => 'Client', + 'ClientID' => 'Client ID', + 'Confirmation' => 'Confirmation', + 'Country' => 'Country', + 'Created' => 'Created', + 'CreditNote' => 'Credit Note', + 'Delivery' => 'Delivery', + 'DeliveryNote' => 'Delivery Note', + 'Discount' => 'Discount', + 'DiscountP' => 'Discount %', + 'Due' => 'Due', + 'Freightage' => 'Freightage', + 'Gross' => 'Gross', + 'Invoice' => 'Invoice', + 'Invoices' => 'Invoices', + 'Item' => 'Item', + 'Items' => 'Items', + 'Name' => 'Name', + 'Net' => 'Net', + 'Offer' => 'Offer', + 'Price' => 'Price', + 'Quantity' => 'Quantity', + 'Recipient' => 'Recipient', + 'Shipment' => 'Shipment', + 'Source' => 'Source', + 'Tax' => 'Tax', + 'Total' => 'Total', + 'Type' => 'Type', + 'Variation' => 'Variation', + 'Zip' => 'Zip', +]; diff --git a/Theme/lang/nav.backend.en.lang.php b/Theme/lang/nav.backend.en.lang.php new file mode 100644 index 0000000..2a1e052 --- /dev/null +++ b/Theme/lang/nav.backend.en.lang.php @@ -0,0 +1,18 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +$MODLANG['Navigation'] = [ + 'Billing' => 'Billing', +]; diff --git a/info.json b/info.json new file mode 100644 index 0000000..89fcf34 --- /dev/null +++ b/info.json @@ -0,0 +1,53 @@ +{ + "name": { + "id": 1005100000, + "internal": "Billing", + "external": "OMS Accounts Receivable" + }, + "version": "1.0.0", + "requirements": { + "phpOMS": "1.0.0", + "phpOMS-db": "1.0.0" + }, + "creator": { + "name": "Orange Management", + "website": "www.spl1nes.com" + }, + "description": "Accounting module.", + "directory": "Billing", + "dependencies": {}, + "providing": { + "Navigation": "*" + }, + "load": [ + { + "pid": [ + "722ef87be24d036db431dd65c0418e5502a6eb89", + "475124021da7877ef311983bb9eb769b1bd94f22" + ], + "type": 4, + "for": 0, + "from": "Billing", + "file": "Billing" + }, + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 5, + "from": "Billing", + "for": "Navigation", + "file": "nav.backend" + }, + { + "pid": [ + "722ef87be24d036db431dd65c0418e5502a6eb89", + "475124021da7877ef311983bb9eb769b1bd94f22" + ], + "type": 5, + "for": "Content", + "file": "backend", + "from": "Billing" + } + ] +}