Skip to content

Commit

Permalink
Merge pull request #123 from leon-mbs/dev
Browse files Browse the repository at this point in the history
4.8.2
  • Loading branch information
leon-mbs authored Jan 17, 2021
2 parents 072c251 + df97fd5 commit 97b93f0
Show file tree
Hide file tree
Showing 205 changed files with 8,764 additions and 4,827 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ www/cron.cmd
www/.idea/


www/logs/
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
CHANGELOG
=========

### v4.8.1 (2021-01-10)
### v4.8.2 (2021-01-10)
* Исправление ошибок
* Печать накладной на узком принтере


Для обновления версии обновить папки app, templates, templates_ua
* Внешнее API в модуле автозапчастей
* Добавлен документ Товарно-транспортная накладная. Доставка теперь будет через него а не Расходную накладную.
* Оприходование на склад расширено до возможностей Авансового отчета .
* Оплаты непосредственно в заказе.

Для обновления версии обновить папки app, templates, templates_ua, выполнить update480to482.sql


### v4.8.0 (2020-12-19)
* Добавлен модуль програмного РРО для отправки чеков в налоговую (Украина). Описание модуля
Expand Down
119 changes: 60 additions & 59 deletions db/initdata.sql

Large diffs are not rendered by default.

126 changes: 63 additions & 63 deletions db/initdata_ua.sql

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions db/update480to482.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

INSERT INTO `metadata` ( `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 1, 'Òîâàðíî-òðàíñïîðòíàÿ íàêëàäíàÿ', 'TTN', 'Ïðîäàæè', 0);

CREATE TABLE `shop_images` (
`image_id` int(11) NOT NULL AUTO_INCREMENT,
`content` longblob NOT NULL,
`mime` varchar(16) DEFAULT NULL,
`thumb` longblob,
PRIMARY KEY (`image_id`)
) DEFAULT CHARSET=utf8;



4 changes: 4 additions & 0 deletions db/update480to490.sql → db/update482to483.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

/*
CREATE TABLE `empacc` (
`ea_id` int(11) NOT NULL AUTO_INCREMENT,
`emp_id` int(11) NOT NULL,
`document_id` int(11) DEFAULT NULL,
`acctype` int(11) DEFAULT NULL,
`createdon` date NOT NULL,
`notes` varchar(255) DEFAULT NULL,
`income` decimal(10,2) NOT NULL,
Expand All @@ -11,6 +13,8 @@ CREATE TABLE `empacc` (
KEY `emp_id` (`emp_id`)
) DEFAULT CHARSET=utf8;



CREATE TABLE `prodproc` (
`pp_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
Expand Down
37 changes: 37 additions & 0 deletions www/app/api/common.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\API;

class common extends JsonRPC
{

public function login($user, $password) {


$api = \App\System::getOptions('api');

$user = \App\Helper::login($user, $password);

if ($user instanceof \App\Entity\User) {
$key = strlen($api['key']) > 0 ? $api['key'] : "defkey";
$exp = strlen($api['exp']) > 0 ? $api['exp'] : 60;

$token = array(
"user_id" => $user->user_id,
"iat" => time(),
"exp" => time() + $exp * 60
);

$jwt = \Firebase\JWT\JWT::encode($token, $key);


} else {
throw new \Exception('Неверный логин', 1000);
}

return $jwt;

}


}
35 changes: 35 additions & 0 deletions www/app/api/help.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\API;
/**
* возвращает описание API
*/
class help
{
function __construct() {

global $_config;


$path = '';
$name = ltrim($name, '\\');

$lang = $_config['common']['lang'];

if (strlen($_GET['lang']) > 0) {
$lang = $_GET['lang'];
}

$templatepath = 'templates/';

if (strlen($lang) > 0 && $lang != 'ru') {
$templatepath = 'templates_' . $lang . '/';
}
$path = _ROOT . strtolower($templatepath) . "apihelp.html";


$template = @file_get_contents($path);
echo $template;
die;
}
}
38 changes: 38 additions & 0 deletions www/app/api/items.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\API;

class items extends JsonRPC
{
/**
* список категорий
*
*/
public function catlist($args) {


$list = array();
foreach (\App\Entity\Category::find('', 'cat_name') as $cat) {
$list[] = array('id' => $cat->cat_id, 'name' => $cat->cat_name);

}
return $list;
}

public function itemlist($args) {

$list = array();
$w = '';

if ($args['cat'] > 0) {
$w = "cat_id=" . $args['cat'];
}
\App\Helper::log($w);
foreach (\App\Entity\Item::find($w, 'itemname') as $item) {
$list[] = array('code' => $item->item_code, 'name' => $item->itemame);

}
return $list;
}

}
62 changes: 58 additions & 4 deletions www/app/jsonrpc.php → www/app/api/jsonrpc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App;
namespace App\API;

/**
* Base class for Json RPC
Expand All @@ -25,10 +25,57 @@ public function Execute() {


if ($response != null) {
echo json_encode($response);
echo json_encode($response, JSON_UNESCAPED_UNICODE);
} else {
http_response_code(200);
}
}


protected function checkAcess() {
$api = \App\System::getOptions('api');
$user = null;

//Bearer
if ($api['atype'] == 1) {

$jwt = "";
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
if ($header == "Authorization") {
$jwt = str_replace("Bearer ", "", $value);
$jwt = trim($jwt);
break;
}
}

$key = strlen($api['key']) > 0 ? $api['key'] : "defkey";


$decoded = \Firebase\JWT\JWT::decode($jwt, $key, array('HS256'));

$user = \App\Entity\User::load($decoded->user_id);
}
//Basic
if ($api['atype'] == 2) {
$user = \App\Helper::login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);

}
//без авторризации
if ($api['atype'] == 3) {
$user = \App\Entity\User::getByLogin('admin');
}
if ($user == null) {
throw new \Exception('Пользователь не найден', 1001);
}
\App\System::setUser($user);


return true;

}


/**
* Processes the user input, and prepares a response (if necessary).
*
Expand Down Expand Up @@ -160,11 +207,17 @@ private function processRequest($request) {
*/
private function processQuery($id, $method, $arguments) {


if (method_exists($this, $method) == false) {
return self::error($id, -32601, "Method '{$method}' not found");
}

$result = @call_user_func_array(array($this, $method), $arguments);
try {

$result = @call_user_func_array(array($this, $method), array('args' => $arguments));
} catch(\Exception $e) {
return self::error($id, $e->getCode(), $e->getMessage());
}

if ($result != false) {
return self::response($id, $result);
Expand Down Expand Up @@ -232,7 +285,7 @@ private static function requestError($id = null) {
* @return array
* Returns an error object.
*/
private static function error($id, $code, $message, $data = null) {
protected static function error($id, $code, $message, $data = null) {
$error = array(
'code' => $code,
'message' => $message
Expand Down Expand Up @@ -270,4 +323,5 @@ private static function response($id, $result) {
);
}


}
17 changes: 0 additions & 17 deletions www/app/api/orders.php

This file was deleted.

20 changes: 0 additions & 20 deletions www/app/api/pos.php

This file was deleted.

51 changes: 0 additions & 51 deletions www/app/api/price.php

This file was deleted.

2 changes: 1 addition & 1 deletion www/app/restful.php → www/app/api/restful.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App;
namespace App\API;

/**
* Base class for RESTFul
Expand Down
20 changes: 20 additions & 0 deletions www/app/api/testclass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\API;

/**
* Пример использования произвольного кастомного класса в API
* пример вызова /api/TestClass/Hello/1
*/
class TestClass
{

public function Hello($p) {

//если POST
$request = file_get_contents('php://input');

echo "Hi";
}

}
Loading

0 comments on commit 97b93f0

Please sign in to comment.