Skip to content

Commit

Permalink
Merge pull request #89 from leon-mbs/dev
Browse files Browse the repository at this point in the history
v4.4.0
  • Loading branch information
leon-mbs authored Jun 8, 2020
2 parents 42d465d + d097da5 commit b1e40c0
Show file tree
Hide file tree
Showing 96 changed files with 2,239 additions and 240 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
CHANGELOG
=========

### v4.4.0 (2020-06-03)
* Добавлена возможность работать в разрезе нескольких компаний.
* Справочник договоров.
* Импорт клиентов с опенкарта в справочник контрагентов.
* Уведомление о выходе новой версии на странице логина.
* Добавлена капча на форму логина.

Для обновления выполнить update430to440.sql обновить папки app, templates, templates_ua. Обновить библиотеки согласно composer.json

### v4.3.0 (2020-05-25)
* добавлены роли пользователей. Теперь разделение доступа и оперативное меню настраивается на уровне роли.
Для обновления выполнить update421to430.sql обновить папки app, templates, templates_ua
Expand Down Expand Up @@ -56,8 +65,7 @@ CHANGELOG
* Добавлена возможность работы с филиалами (например торговыми точками). Доступ к данным
системы определеяется разрешенными пользователю филиалами.
* Печать квитанций и этикеток на узкий принтер.
* Мастер миграции - переноса данных при переходе на новую версию.


Новая версия требует PHP7.2

### v3.1.3 (2019-12-06)
Expand Down
71 changes: 62 additions & 9 deletions db/db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,35 @@ CREATE TABLE `branches` (
PRIMARY KEY (`branch_id`)
) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `contracts`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `contracts` (
`contract_id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) DEFAULT '0',
`firm_id` int(11) DEFAULT '0',
`createdon` date NOT NULL,
`contract_number` varchar(64) NOT NULL,
`disabled` tinyint(1) DEFAULT '0',
`details` longtext NOT NULL,
PRIMARY KEY (`contract_id`)
) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `contracts_view`;
/*!50001 DROP VIEW IF EXISTS `contracts_view`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `contracts_view` AS SELECT
1 AS `contract_id`,
1 AS `customer_id`,
1 AS `firm_id`,
1 AS `createdon`,
1 AS `contract_number`,
1 AS `disabled`,
1 AS `details`,
1 AS `customer_name`,
1 AS `firm_name`*/;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `customers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
Expand All @@ -32,7 +61,7 @@ CREATE TABLE `customers` (
`status` smallint(4) NOT NULL DEFAULT '0',
`city` varchar(255) DEFAULT NULL,
PRIMARY KEY (`customer_id`)
) AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `customers_view`;
/*!50001 DROP VIEW IF EXISTS `customers_view`*/;
Expand Down Expand Up @@ -62,7 +91,7 @@ CREATE TABLE `docstatelog` (
`hostname` varchar(64) NOT NULL,
PRIMARY KEY (`log_id`),
KEY `document_id` (`document_id`)
) AUTO_INCREMENT=998 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=1022 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `docstatelog_view`;
/*!50001 DROP VIEW IF EXISTS `docstatelog_view`*/;
Expand Down Expand Up @@ -103,7 +132,7 @@ CREATE TABLE `documents` (
KEY `customer_id` (`customer_id`),
KEY `user_id` (`user_id`),
KEY `branch_id` (`branch_id`)
) AUTO_INCREMENT=262 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=272 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `documents_view`;
/*!50001 DROP VIEW IF EXISTS `documents_view`*/;
Expand Down Expand Up @@ -157,7 +186,7 @@ CREATE TABLE `entrylist` (
PRIMARY KEY (`entry_id`),
KEY `document_id` (`document_id`),
KEY `stock_id` (`stock_id`)
) AUTO_INCREMENT=740 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=742 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
Expand Down Expand Up @@ -278,7 +307,7 @@ CREATE TABLE `files` (
`mime` varchar(16) DEFAULT NULL,
PRIMARY KEY (`file_id`),
KEY `item_id` (`item_id`)
) AUTO_INCREMENT=26 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=27 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `filesdata`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
Expand All @@ -289,6 +318,17 @@ CREATE TABLE `filesdata` (
UNIQUE KEY `file_id` (`file_id`)
) DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `firms`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `firms` (
`firm_id` int(11) NOT NULL AUTO_INCREMENT,
`firm_name` varchar(255) NOT NULL,
`details` longtext NOT NULL,
`disabled` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`firm_id`)
) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `images`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
Expand Down Expand Up @@ -513,7 +553,7 @@ CREATE TABLE `metadata` (
`menugroup` varchar(255) DEFAULT NULL,
`disabled` tinyint(4) NOT NULL,
PRIMARY KEY (`meta_id`)
) AUTO_INCREMENT=79 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=82 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mfund`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
Expand Down Expand Up @@ -621,7 +661,7 @@ CREATE TABLE `notifies` (
`sender_name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`notify_id`),
KEY `user_id` (`user_id`)
) AUTO_INCREMENT=64 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=69 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `options`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
Expand Down Expand Up @@ -655,7 +695,7 @@ CREATE TABLE `paylist` (
`paytype` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`pl_id`),
KEY `document_id` (`document_id`)
) AUTO_INCREMENT=249 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=251 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `paylist_view`;
/*!50001 DROP VIEW IF EXISTS `paylist_view`*/;
Expand Down Expand Up @@ -924,7 +964,7 @@ CREATE TABLE `users` (
`role_id` int(11) DEFAULT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `userlogin` (`userlogin`)
) AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
) AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `users_view`;
/*!50001 DROP VIEW IF EXISTS `users_view`*/;
Expand All @@ -945,6 +985,19 @@ SET character_set_client = utf8;
1 AS `employee_id`,
1 AS `username`*/;
SET character_set_client = @saved_cs_client;
/*!50001 DROP VIEW IF EXISTS `contracts_view`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = latin1 */;
/*!50001 SET character_set_results = latin1 */;
/*!50001 SET collation_connection = latin1_swedish_ci */;
/*!50001 CREATE */
/*!50013 */
/*!50001 VIEW `contracts_view` AS select `co`.`contract_id` AS `contract_id`,`co`.`customer_id` AS `customer_id`,`co`.`firm_id` AS `firm_id`,`co`.`createdon` AS `createdon`,`co`.`contract_number` AS `contract_number`,`co`.`disabled` AS `disabled`,`co`.`details` AS `details`,`cu`.`customer_name` AS `customer_name`,`f`.`firm_name` AS `firm_name` from ((`contracts` `co` join `customers` `cu` on((`co`.`customer_id` = `cu`.`customer_id`))) left join `firms` `f` on((`co`.`firm_id` = `f`.`firm_id`))) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP VIEW IF EXISTS `customers_view`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
Expand Down
6 changes: 4 additions & 2 deletions db/initdata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SET NAMES 'utf8';


INSERT INTO `users` ( `userlogin`, `userpass`, `createdon`, `email`, `acl`, `disabled`, `options`) VALUES( 'admin', '$2y$10$GsjC.thVpQAPMQMO6b4Ma.olbIFr2KMGFz12l5/wnmxI1PEqRDQf.', '2017-01-01', '[email protected]', 'a:8:{s:7:"acltype";i:0;s:6:"onlymy";i:0;s:7:"aclview";N;s:7:"acledit";N;s:6:"aclexe";N;s:9:"aclbranch";N;s:7:"widgets";N;s:7:"modules";N;}', 0, 'a:4:{s:9:"smartmenu";s:3:"7,8";s:8:"defstore";s:2:"19";s:5:"defmf";s:1:"2";s:8:"pagesize";s:2:"15";}');
INSERT INTO `roles` ( `rolename`, `acl`) VALUES ( 'admins', NULL);
INSERT INTO `roles` ( `rolename`, `acl`) VALUES( 'admins', 'a:7:{s:7:"aclview";N;s:7:"acledit";N;s:6:"aclexe";N;s:9:"aclcancel";N;s:7:"widgets";N;s:7:"modules";N;s:9:"smartmenu";s:1:"8";}');
UPDATE users set role_id=(select role_id from roles where rolename='admins' limit 0,1 ) where userlogin='admin' ;


Expand All @@ -12,7 +12,7 @@ INSERT INTO `mfund` (`mf_id`, `mf_name`, `description`) VALUES(2, 'Касса',

INSERT INTO `options` (`optname`, `optvalue`) VALUES('common', 'a:16:{s:9:"qtydigits";s:1:"0";s:8:"amdigits";s:1:"0";s:11:"partiontype";s:1:"1";s:4:"lang";s:2:"ru";s:6:"price1";s:18:"Розничная";s:6:"price2";s:14:"Оптовая";s:6:"price3";s:0:"";s:6:"price4";s:0:"";s:6:"price5";s:0:"";s:8:"defprice";s:2:"10";s:11:"autoarticle";i:1;s:6:"useset";i:0;s:10:"usesnumber";i:0;s:10:"usescanner";i:0;s:9:"useimages";i:0;s:9:"usebranch";i:0;}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('shop', 'N;');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('firm', 'a:5:{s:8:"firmname";s:20:"Наша фирма";s:8:"shopname";s:14:"Магазин";s:5:"phone";s:0:"";s:7:"address";s:0:"";s:3:"inn";s:0:"";}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('firm', 'a:5:{s:9:"firm_name";s:20:"Наша фирма";s:8:"shopname";s:14:"Магазин";s:5:"phone";s:0:"";s:7:"address";s:0:"";s:3:"inn";s:0:"";}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('printer', 'a:7:{s:6:"pwidth";s:0:"";s:9:"pricetype";s:6:"price1";s:11:"barcodetype";s:5:"EAN13";s:5:"pname";i:1;s:5:"pcode";i:0;s:8:"pbarcode";i:1;s:6:"pprice";i:0;}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('modules', 'a:11:{s:6:"ocsite";s:20:"http://local.ostore3";s:9:"ocapiname";s:5:"admin";s:5:"ockey";s:256:"Bf81dB8fY2waVxlhych4fFprGfxF2tULlSlHiwEXZqf45E6HDBoA6XjocGcziRsfCQsRovzzDAvMBImmrlzXqEJcMByQpkfeLYfZBDoYstDVuA0Qvx86YkeXVwQ6I2v8xEXS2ZL6ioH1l8qinySGZdRrO5mgFCFWKhgKxIfkNOYpvzIZdR2MdqkHKSzHGSfoDVmbts8slGNFqYzvkXQSP0VaHcw0fYmBZLo0HEvLb2EiBZ5A8EcGDZWWtndg2wlY";s:13:"occustomer_id";s:1:"8";s:11:"ocpricetype";s:6:"price1";s:6:"wcsite";s:15:"http://local.wp";s:6:"wckeyc";s:43:"ck_a36c9d5d8ef70a34001b6a44bc245a7665ca77e7";s:6:"wckeys";s:43:"cs_12b03012d9db469b45b1fc82e329a3bc995f3e36";s:5:"wcapi";s:2:"v3";s:13:"wccustomer_id";s:1:"8";s:11:"wcpricetype";s:6:"price1";}');

Expand Down Expand Up @@ -73,4 +73,6 @@ INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `men
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(76, 1, 'Выплата зарплаты', 'OutSalary', 'Платежи', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(77, 2, 'Отчет по зарплате', 'SalaryRep', 'Платежи', 0);
INSERT INTO `metadata` (`meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 2, 'Движение по контрагентам', 'CustActivity', 'Платежи', 0);
INSERT INTO `metadata` (`meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 4, 'Договора', 'ContractList', '', 0);


1 change: 1 addition & 0 deletions db/initdata_ua.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `men
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(76, 1, 'Виплата зарплати', 'OutSalary', 'Платежі', 0);
INSERT INTO `metadata` (`meta_id`, `meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES(77, 2, 'Звіт по зарплаті', 'SalaryRep', 'Платежі', 0);
INSERT INTO `metadata` (`meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 2, 'Рух по контрагентах', 'CustActivity', 'Платежі', 0);
INSERT INTO `metadata` (`meta_type`, `description`, `meta_name`, `menugroup`, `disabled`) VALUES( 4, 'Контракти', 'ContractList', '', 0);
37 changes: 37 additions & 0 deletions db/update430to440.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
CREATE TABLE `firms` (
`firm_id` int(11) NOT NULL AUTO_INCREMENT,
`firm_name` varchar(255) NOT NULL,
`details` longtext ,
`disabled` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`firm_id`)
) ENGINE=MyISAM CHARSET=utf8;




CREATE TABLE `contracts` (
`contract_id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) DEFAULT '0',
`firm_id` int(11) DEFAULT '0',
`createdon` date NOT NULL,
`contract_number` varchar(64) NOT NULL,
`disabled` tinyint(1) DEFAULT '0',
`details` longtext NOT NULL,
PRIMARY KEY (`contract_id`)
) DEFAULT CHARSET=utf8;


CREATE VIEW `contracts_view` AS
select
`co`.`contract_id` AS `contract_id`,
`co`.`customer_id` AS `customer_id`,
`co`.`firm_id` AS `firm_id`,
`co`.`createdon` AS `createdon`,
`co`.`contract_number` AS `contract_number`,
`co`.`disabled` AS `disabled`,
`co`.`details` AS `details`,
`cu`.`customer_name` AS `customer_name`,
`f`.`firm_name` AS `firm_name`
from
((`contracts` `co` join `customers` `cu` on((`co`.`customer_id` = `cu`.`customer_id`))) left join `firms` `f` on((`co`.`firm_id` = `f`.`firm_id`)));

20 changes: 8 additions & 12 deletions www/app/acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,17 @@ public static function checkShowSer($ser, $showerror = true) {
* возвращает ограничение для ресурсов по филиалам
* @param mixed $nul включая те у которых филиал не задан
*/
public static function getBranchConstraint($nul = false) {
public static function getBranchConstraint( ) {
$options = \App\System::getOptions('common');
if ($options['usebranch'] != 1) {
return '';
}

$id = \App\System::getBranch(); //если выбран конкретный
if ($id > 0) {
if ($nul == true) {
return "branch_id in (0,{$id})";
} else {
return "branch_id in ({$id})";
}

return "branch_id in (0,{$id})";

}


Expand All @@ -295,14 +293,12 @@ public static function getBranchConstraint($nul = false) {
}

if (strlen($user->aclbranch) == 0) {
return '1=2';
return "branch_id in (0 )";
} //нет доступа ни к одному филиалу

if ($nul == true) {
return "branch_id in (0,{$user->aclbranch})";
} else {
return "branch_id in ({$user->aclbranch})";
}

return "branch_id in (0,{$user->aclbranch})";



}
Expand Down
71 changes: 71 additions & 0 deletions www/app/entity/contract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace App\Entity;

/**
* Клас-сущность договор
*
* @table=contracts
* @view=contracts_view
* @keyfield=contract_id
*/
class Contract extends \ZCL\DB\Entity
{

protected function init() {
$this->contract_id = 0;
$this->createdon = time();
}

protected function afterLoad() {

$this->createdon = strtotime($this->createdon);

$xml = @simplexml_load_string($this->details);

$this->shortdesc = (string)($xml->shortdesc[0]);
$this->payname = (string)($xml->payname[0]);
$this->pay = (int)($xml->pay[0]);
$this->file_id = (int)($xml->file_id[0]);

parent::afterLoad();
}

protected function beforeSave() {
parent::beforeSave();
$this->details = "<details>";
//упаковываем данные
$this->details .= "<shortdesc><![CDATA[{$this->shortdesc}]]></shortdesc>";
$this->details .= "<payname><![CDATA[{$this->payname}]]></payname>";
$this->details .= "<pay>{$this->pay}</pay>";
$this->details .= "<file_id>{$this->file_id}</file_id>";
$this->details .= "</details>";

return true;
}

public static function PayList(){
return array(
1=>\App\Helper::l('cnal'),
2=>\App\Helper::l('cbeznal'),
3=>\App\Helper::l('ckredit'),
4=>\App\Helper::l('creal')
);
}
public static function getList($c,$f=0){

$ar = array();
if(strlen($f)==0)$f=0;
if($c>0 ) {
$where="disabled <> 1 and customer_id={$c} and coalesce(firm_id,0) = {$f} " ;

$res = Contract::find($where,'contract_number');
foreach($res as $k=>$v) {
$ar[$k] = $v->contract_number .' '. $v->shortdesc ;
}

}

return $ar;
}
}
2 changes: 2 additions & 0 deletions www/app/entity/customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ protected function beforeSave() {
$this->detail .= "<bonus>{$this->bonus}</bonus>";
$this->detail .= "<type>{$this->type}</type>";
$this->detail .= "<jurid>{$this->jurid}</jurid>";
$this->detail .= "<shopcust_id>{$this->shopcust_id}</shopcust_id>";
$this->detail .= "<address><![CDATA[{$this->address}]]></address>";
$this->detail .= "<comment><![CDATA[{$this->comment}]]></comment>";
$this->detail .= "</detail>";
Expand All @@ -49,6 +50,7 @@ protected function afterLoad() {
$this->bonus = (int)($xml->bonus[0]);
$this->type = (int)($xml->type[0]);
$this->jurid = (int)($xml->jurid[0]);
$this->shopcust_id = (int)($xml->shopcust_id[0]);
$this->address = (string)($xml->address[0]);
$this->comment = (string)($xml->comment[0]);

Expand Down
5 changes: 3 additions & 2 deletions www/app/entity/doc/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,12 @@ public static function create($classname, $branch_id = 0) {
$doc = new $fullclassname();
$doc->meta_id = $meta['meta_id'];


$doc->branch_id = $branch_id;
if ($branch_id == 0) {
if ($branch_id == 0 ) {
$doc->branch_id = \App\Acl::checkCurrentBranch();
}

return $doc;
}

Expand Down
Loading

0 comments on commit b1e40c0

Please sign in to comment.