83 lines
3.5 KiB
PHP
83 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace BRSystems\Core\Cms\cmsOrders;
|
|
|
|
use BRSystems\Core\Cms\cmsOrders\inc\cmsOrdersController;
|
|
use BRSystems\Core\Cms\cmsOrders\inc\cmsOrdersExport;
|
|
use BRSystems\Core\Library\cJSON\cJSON;
|
|
|
|
/**
|
|
* cmsOrders
|
|
*
|
|
* @category cmsOrders
|
|
* @author Mareks Keišs <keiss.mareks@gmail.com>
|
|
* @since Version 3.0
|
|
*/
|
|
class cmsOrders
|
|
{
|
|
public cmsOrdersController $controller;
|
|
|
|
/**
|
|
* Class constructor
|
|
*/
|
|
public function __construct($uriData)
|
|
{
|
|
$DIR = __DIR__ ?: dirname(__FILE__);
|
|
$this->controller = new cmsOrdersController($uriData, $DIR, basename($DIR));
|
|
}
|
|
|
|
public function run()
|
|
{
|
|
switch (getV('action')) {
|
|
case 'edit':
|
|
$this->controller->run(true);
|
|
break;
|
|
case 'filter_table':
|
|
cJSON::sendok($this->controller->createCmsTable(getP('page'), getP('filter'), getP('headers')));
|
|
case 'selfLoad':
|
|
if ($this->controller->oUser->chkPermission('CMS_APP_ORDER_RECEIPTS_EDIT')) {
|
|
cJSON::sendok($this->controller->editCmsTableRecord(getV('id')));
|
|
}
|
|
cJSON::senderror(['data' => $this->controller->gM("No access rights to edit")]);
|
|
case 'cloneBlank':
|
|
if ($this->controller->oUser->chkPermission('CMS_APP_ORDER_RECEIPTS_ADD_NEW')) {
|
|
cJSON::sendok($this->controller->editCmsTableRecord(getV('id'), true));
|
|
}
|
|
cJSON::senderror(['data' => $this->controller->gM("No access rights to add new")]);
|
|
case 'selfSave':
|
|
if (getV('id')) {
|
|
if ($this->controller->oUser->chkPermission('CMS_APP_ORDER_RECEIPTS_EDIT', false, false)) {
|
|
cJSON::sendok($this->controller->saveRecordData(getV('id'), getP('fields')));
|
|
}
|
|
cJSON::senderror(['data' => $this->controller->gM("No access rights to edit")]);
|
|
} else {
|
|
if ($this->controller->oUser->chkPermission('CMS_APP_ORDER_RECEIPTS_ADD_NEW', false, false)) {
|
|
cJSON::sendok($this->controller->saveRecordData(getV('id'), getP('fields')));
|
|
}
|
|
cJSON::senderror(['data' => $this->controller->gM("No access rights to add new")]);
|
|
}
|
|
case 'deleteRecords':
|
|
if ($this->controller->oUser->chkPermission('CMS_APP_ORDER_RECEIPTS_DELETE')) {
|
|
cJSON::sendok($this->controller->delete(getP('fields')));
|
|
}
|
|
cJSON::senderror(['data' => $this->controller->gM("No access rights to delete")]);
|
|
case 'changeRecordsStatus':
|
|
if ($this->controller->oUser->chkPermission('CMS_APP_ORDER_RECEIPTS_EDIT')) {
|
|
cJSON::sendok($this->controller->changeEnumFields(getP('baseField'), getP('fields')));
|
|
}
|
|
cJSON::senderror(['data' => $this->controller->gM("No access rights to edit")]);
|
|
case 'export_excel':
|
|
(new cmsOrdersExport($this->controller))->saveExcelDoc(getV('data'));
|
|
die();
|
|
case 'export_pdf':
|
|
(new cmsOrdersExport($this->controller))->savePdfDoc(getV('data'));
|
|
die();
|
|
case 'sum2words':
|
|
cJSON::sendok($this->controller->getSumInWords(getV('sum')));
|
|
default:
|
|
$this->controller->run();
|
|
break;
|
|
}
|
|
}
|
|
}
|