Skip to content

Commit

Permalink
Merge pull request #155 from leon-mbs/dev
Browse files Browse the repository at this point in the history
v5.1.0
  • Loading branch information
leon-mbs authored May 16, 2021
2 parents 778ea78 + cf833c4 commit 584ce89
Show file tree
Hide file tree
Showing 65 changed files with 3,193 additions and 1,792 deletions.
2,734 changes: 1,392 additions & 1,342 deletions db/db.sql

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion db/initdata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ INSERT INTO `customers` ( `customer_name`, `detail`, `email`, `phone`, `status`,

INSERT INTO `options` (`optname`, `optvalue`) VALUES('common', 'a:30:{s:9:"qtydigits";s:1:"0";s:8:"amdigits";s:1:"0";s:10:"dateformat";s:5:"d.m.Y";s:11:"partiontype";s:1:"1";s:4:"curr";s:2:"gr";s:6:"phonel";s:2:"10";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:8:"shopname";s:20:"Наша фирма";s:8:"ts_break";s:2:"60";s:8:"ts_start";s:5:"09:00";s:6:"ts_end";s:5:"18:00";s:11:"checkslogan";s:8:"Тест";s:11:"autoarticle";i:1;s:10:"usesnumber";i:0;s:10:"usescanner";i:0;s:9:"useimages";i:0;s:15:"showactiveusers";i:0;s:10:"usecattree";i:0;s:9:"usebranch";i:0;s:10:"noallowfiz";i:0;s:10:"allowminus";i:1;s:6:"useval";i:0;s:6:"capcha";i:0;s:9:"numberttn";i:0;s:11:"salesources";a:1:{i:1620576897;O:12:"App\\DataItem":2:{s:2:"id";i:1620576897;s:9:"\0*\0fields";a:1:{s:4:"name";s:31:"Основной магазин";}}}}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('api', 'a:3:{s:3:"exp";N;s:3:"key";N;s:5:"atype";s:1:"3";}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('printer', 'a:8:{s:6:"pwidth";s:4:"100%";s:9:"pricetype";s:6:"price1";s:11:"barcodetype";s:5:"EAN13";s:9:"pfontsize";s:2:"16";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('printer', 'a:8:{s:6:"pwidth";s:4:"100%";s:9:"pricetype";s:6:"price1";s:11:"barcodetype";s:4:"C128";s:9:"pfontsize";s:2:"16";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('shop', 'a:8:{s:7:"defcust";s:1:"2";s:12:"defpricetype";s:6:"price1";s:5:"email";s:0:"";s:8:"shopname";s:17:"Наш магаз";s:12:"currencyname";s:6:"грн";s:8:"uselogin";i:0;s:9:"usefilter";i:1;s:11:"usefeedback";i:1;}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('sms', 'a:7:{s:13:"turbosmstoken";s:0:"";s:12:"smssemytoken";s:0:"";s:12:"smssemydevid";s:0:"";s:11:"flysmslogin";s:0:"";s:10:"flysmspass";s:0:"";s:8:"flysmsan";s:0:"";s:7:"smstype";s:1:"0";}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('val', 'a:5:{s:6:"valuan";s:0:"";s:6:"valusd";s:2:"28";s:7:"valeuro";s:0:"";s:6:"valrub";s:0:"";s:8:"valprice";i:0;}');
Expand Down
2 changes: 1 addition & 1 deletion db/initdata_ua.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ INSERT INTO `customers` ( `customer_name`, `detail`, `email`, `phone`, `status`,

INSERT INTO `options` (`optname`, `optvalue`) VALUES('common', 'a:30:{s:9:"qtydigits";s:1:"0";s:8:"amdigits";s:1:"0";s:10:"dateformat";s:5:"d.m.Y";s:11:"partiontype";s:1:"1";s:4:"curr";s:2:"gr";s:6:"phonel";s:2:"10";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:8:"shopname";s:20:"Наша фирма";s:8:"ts_break";s:2:"60";s:8:"ts_start";s:5:"09:00";s:6:"ts_end";s:5:"18:00";s:11:"checkslogan";s:8:"Тест";s:11:"autoarticle";i:1;s:10:"usesnumber";i:0;s:10:"usescanner";i:0;s:9:"useimages";i:0;s:15:"showactiveusers";i:0;s:10:"usecattree";i:0;s:9:"usebranch";i:0;s:10:"noallowfiz";i:0;s:10:"allowminus";i:1;s:6:"useval";i:0;s:6:"capcha";i:0;s:9:"numberttn";i:0;s:11:"salesources";a:1:{i:1620576897;O:12:"App\\DataItem":2:{s:2:"id";i:1620576897;s:9:"\0*\0fields";a:1:{s:4:"name";s:31:"Основной магазин";}}}}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('api', 'a:3:{s:3:"exp";N;s:3:"key";N;s:5:"atype";s:1:"3";}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('printer', 'a:8:{s:6:"pwidth";s:4:"100%";s:9:"pricetype";s:6:"price1";s:11:"barcodetype";s:5:"EAN13";s:9:"pfontsize";s:2:"16";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('printer', 'a:8:{s:6:"pwidth";s:4:"100%";s:9:"pricetype";s:6:"price1";s:11:"barcodetype";s:4:"C128";s:9:"pfontsize";s:2:"16";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('shop', 'a:8:{s:7:"defcust";s:1:"2";s:12:"defpricetype";s:6:"price1";s:5:"email";s:0:"";s:8:"shopname";s:17:"Наш магаз";s:12:"currencyname";s:6:"грн";s:8:"uselogin";i:0;s:9:"usefilter";i:1;s:11:"usefeedback";i:1;}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('sms', 'a:7:{s:13:"turbosmstoken";s:0:"";s:12:"smssemytoken";s:0:"";s:12:"smssemydevid";s:0:"";s:11:"flysmslogin";s:0:"";s:10:"flysmspass";s:0:"";s:8:"flysmsan";s:0:"";s:7:"smstype";s:1:"0";}');
INSERT INTO `options` (`optname`, `optvalue`) VALUES('val', 'a:5:{s:6:"valuan";s:0:"";s:6:"valusd";s:2:"28";s:7:"valeuro";s:0:"";s:6:"valrub";s:0:"";s:8:"valprice";i:0;}');
Expand Down
83 changes: 22 additions & 61 deletions db/temp.sql
Original file line number Diff line number Diff line change
@@ -1,67 +1,28 @@

CREATE TABLE `custacc` (
`ca_id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) NOT NULL,
`document_id` int(11) DEFAULT NULL,
`optype` int(11) DEFAULT '0',

`amount` decimal(10,2) NOT NULL,
`createdon` date NOT NULL,
PRIMARY KEY (`ca_id`),
KEY `customer_id` (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



ALTER TABLE `timesheet` ADD `branch_id` INT NULL ;

alter VIEW `timesheet_view` AS
select
`t`.`time_id` AS `time_id`,
`t`.`emp_id` AS `emp_id`,
`t`.`description` AS `description`,
`t`.`t_start` AS `t_start`,
`t`.`t_end` AS `t_end`,
`t`.`t_type` AS `t_type`,
`t`.`t_break` AS `t_break`,
`e`.`emp_name` AS `emp_name`,
`b`.`branch_name` AS `branch_name`,
`e`.`disabled` AS `disabled`,
`t`.`branch_id` AS `branch_id`
from
`timesheet` `t` join `employees` `e` on `t`.`emp_id` = `e`.`employee_id`
left join branches b on t.branch_id = b.branch_id;

ALTER TABLE `customers` ADD `country` VARCHAR(255) NULL ;

ALTER VIEW `customers_view` AS
select
`customers`.`customer_id` AS `customer_id`,
`customers`.`customer_name` AS `customer_name`,
`customers`.`detail` AS `detail`,
`customers`.`email` AS `email`,
`customers`.`phone` AS `phone`,
`customers`.`status` AS `status`,
`customers`.`city` AS `city`,
`customers`.`leadsource` AS `leadsource`,
`customers`.`leadstatus` AS `leadstatus`,
`customers`.`country` AS `country`,
(
CREATE VIEW `custacc_view` AS
select
count(0)
from
`messages` `m`
where
((`m`.`item_id` = `customers`.`customer_id`) and (`m`.`item_type` = 2))) AS `mcnt`,(
select
count(0)
from
`files` `f`
where
((`f`.`item_id` = `customers`.`customer_id`) and (`f`.`item_type` = 2))) AS `fcnt`,(
select
count(0)
from
`eventlist` `e`
where
((`e`.`customer_id` = `customers`.`customer_id`) and (`e`.`eventdate` >= now()))) AS `ecnt`
`c`.`ca_id` AS `ca_id`,
`c`.`customer_id` AS `customer_id`,
`c`.`document_id` AS `document_id`,
`c`.`optype` AS `optype`,

`c`.`amount` AS `amount`,
`d`.`document_number` AS `document_number`,
`c`.`createdon` AS `createdon`
from
`customers`;







(`custacc` `c` join `documents` `d` on((`d`.`document_id` = `c`.`document_id`)));

/*

Expand Down
59 changes: 59 additions & 0 deletions db/update500to510.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@


ALTER TABLE `customers` ADD `country` VARCHAR(255) NULL ;
ALTER TABLE `timesheet` ADD `branch_id` INT NULL ;


alter VIEW `timesheet_view` AS
select
`t`.`time_id` AS `time_id`,
`t`.`emp_id` AS `emp_id`,
`t`.`description` AS `description`,
`t`.`t_start` AS `t_start`,
`t`.`t_end` AS `t_end`,
`t`.`t_type` AS `t_type`,
`t`.`t_break` AS `t_break`,
`e`.`emp_name` AS `emp_name`,
`b`.`branch_name` AS `branch_name`,
`e`.`disabled` AS `disabled`,
`t`.`branch_id` AS `branch_id`
from
`timesheet` `t` join `employees` `e` on `t`.`emp_id` = `e`.`employee_id`
left join branches b on t.branch_id = b.branch_id;


ALTER VIEW `customers_view` AS
select
`customers`.`customer_id` AS `customer_id`,
`customers`.`customer_name` AS `customer_name`,
`customers`.`detail` AS `detail`,
`customers`.`email` AS `email`,
`customers`.`phone` AS `phone`,
`customers`.`status` AS `status`,
`customers`.`city` AS `city`,
`customers`.`leadsource` AS `leadsource`,
`customers`.`leadstatus` AS `leadstatus`,
`customers`.`country` AS `country`,
(
select
count(0)
from
`messages` `m`
where
((`m`.`item_id` = `customers`.`customer_id`) and (`m`.`item_type` = 2))) AS `mcnt`,(
select
count(0)
from
`files` `f`
where
((`f`.`item_id` = `customers`.`customer_id`) and (`f`.`item_type` = 2))) AS `fcnt`,(
select
count(0)
from
`eventlist` `e`
where
((`e`.`customer_id` = `customers`.`customer_id`) and (`e`.`eventdate` >= now()))) AS `ecnt`
from
`customers`;


1 change: 1 addition & 0 deletions www/app/api/customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function list() {
'phone' => $cust->phone,
'email' => $cust->email,
'city' => $cust->city,
'country' => $cust->country,
'address' => $cust->address,
'description' => base64_encode($cust->comment)
);
Expand Down
2 changes: 2 additions & 0 deletions www/app/api/docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,6 @@ public function createprodissue($args) {
return $doc->document_number;
}



}
27 changes: 24 additions & 3 deletions www/app/api/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public function storelist() {
}
return $list;
}
//список типов ТМЦ
public function typelist() {
return Item::getTypes();
}

// список артикулов
public function articlelist() {
Expand Down Expand Up @@ -56,21 +60,37 @@ public function itemlist() {
if ($args['cat'] > 0) {
$w .= " and cat_id=" . $args['cat'];
}
if ($args['item_type'] > 0) {
$w .= " and item_type=" . $args['item_type'];
}
if (strlen($args['item_code']) > 0) {
$w .= " and item_code=" . Item::qstr($args['item_code']);
}
if (strlen($args['bar_code']) > 0) {
$w .= " and bar_code=" . Item::qstr($args['bar_code']);
}

foreach (Item::find($w, 'itemname') as $item) {
$plist = array();

$it = $it = array(
$it = array(
'item_code' => $item->item_code,
'bar_code' => $item->bar_code,
'itemname' => $item->itemname,
'description' => base64_encode($item->description),
'measure' => $item->msr,
'item_type' => $item->item_type,
'manufacturer' => $item->manufacturer,
'cat_name' => $item->cat_name,
'cat_id' => $item->cat_id
);


$it = array_merge($it,$item->getData()) ;

unset($it['detail']);
unset($it['disabled']);


if (strlen($item->price1) > 0) {
$it['price1'] = $item->price1;
}
Expand Down Expand Up @@ -131,10 +151,11 @@ public function save($args) {
$item->item_code = $args['item_code'];
$item->bar_code = $args['bar_code'];
$item->itemname = $args['itemname'];
$item->measure = $args['measure'];
$item->msr = $args['measure'];
$item->manufacturer = $args['manufacturer'];
$item->description = @base64_decode($args['description']);
$item->cat_id = $args['cat_id'];
$item->item_type = $args['item_type'];

if ($args['price1'] > 0) {
$item->price1 = $args['price1'];
Expand Down
4 changes: 3 additions & 1 deletion www/app/entity/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function getChildren(&$clist = null) {
}

//список с тмц
public static function getList($fullname = false) {
public static function getList($fullname = false ) {
if ($fullname == false) {
return Category::findArray("cat_name", "cat_id in (select cat_id from items where disabled <>1 )", "cat_name");
}
Expand All @@ -138,5 +138,7 @@ public static function getList($fullname = false) {
}
return $ret;
}



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

namespace App\Entity;

/**
* Клас-сущность лицевой счет контрагента
*
* @table=custacc
* @view=custacc_view
* @keyfield=ca_id
*/
class CustAcc extends \ZCL\DB\Entity
{
const TYPE_PAYMENT = 0;
const TYPE_BONUS = 1;

protected function init() {
$this->customer_id = 0;
$this->optype = 0;

}
protected function afterLoad() {
$this->document_date = strtotime($this->document_date);
}

public static function addEntry($customer_id,$amount,$document_id,$optype=0){
$custacc = new CustAcc();
$custacc->customer_id = $customer_id;
$custacc->optype = $optype;
$custacc->document_id = $document_id;
$custacc->createdon=time() ;

$custacc->save();
}
}
17 changes: 9 additions & 8 deletions www/app/entity/doc/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ private function packData() {
$this->content = "<doc><header>";

foreach ($this->headerdata as $key => $value) {
if ($key > 0) {
continue;
}


if (strpos($value, '[CDATA[') !== false) {
\App\System::setWarnMsg('CDATA в поле обьекта');
Expand Down Expand Up @@ -169,7 +167,13 @@ private function unpackData() {
return;
}
foreach ($xml->header->children() as $child) {
$this->headerdata[(string)$child->getName()] = (string)$child;
/* $ch = (string)$child;
if(is_numeric($ch)) {
if(ctype_digit($ch)) $ch = intval($ch);
else $ch = doubleval($ch) ;
}
*/
$this->headerdata[(string)$child->getName()] =$ch ;
}
$this->detaildata = array();

Expand Down Expand Up @@ -367,10 +371,7 @@ public function updateStatus($state) {
if ($oldstate != $state) {
$doc = $this->cast();
$doc->onState($state);





\App\Entity\Subscribe::onDocumentState($doc->document_id, $state);
}

Expand Down
2 changes: 1 addition & 1 deletion www/app/entity/doc/goodsissue.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function Execute() {
foreach ($listst as $st) {
$sc = new Entry($this->document_id, 0 - $st->quantity * $st->partion, 0 - $st->quantity);
$sc->setStock($st->stock_id);
$sc->setExtCode($item->price * $k - $st->partion); //Для АВС
// $sc->setExtCode($item->price * $k - $st->partion); //Для АВС
$sc->setOutPrice($item->price * $k);
$sc->save();
$amount += $item->price * $k * $st->quantity;
Expand Down
2 changes: 1 addition & 1 deletion www/app/entity/doc/goodsreceipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function Execute() {

$sc = new Entry($this->document_id, $item->price * $item->quantity, $item->quantity);
$sc->setStock($stock->stock_id);
$sc->setExtCode($item->price); //Для АВС
// $sc->setExtCode($item->price); //Для АВС
$sc->setOutPrice($item->price);

$sc->save();
Expand Down
2 changes: 1 addition & 1 deletion www/app/entity/doc/orderfood.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function Execute() {
foreach ($listst as $st) {
$sc = new Entry($this->document_id, 0 - $st->quantity * $st->partion, 0 - $st->quantity);
$sc->setStock($st->stock_id);
$sc->setExtCode($item->price * $k - $st->partion); //Для АВС
// $sc->setExtCode($item->price * $k - $st->partion); //Для АВС
$sc->setOutPrice($item->price * $k);
$sc->save();
}
Expand Down
4 changes: 2 additions & 2 deletions www/app/entity/doc/poscheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function Execute() {
foreach ($listst as $st) {
$sc = new Entry($this->document_id, 0 - $st->quantity * $st->partion, 0 - $st->quantity);
$sc->setStock($st->stock_id);
$sc->setExtCode($item->price * $k - $st->partion); //Для АВС
// $sc->setExtCode($item->price * $k - $st->partion); //Для АВС
$sc->setOutPrice($item->price * $k);
$sc->save();
}
Expand Down Expand Up @@ -214,7 +214,7 @@ public function Execute() {

$sc = new Entry($this->document_id, 0 - ($ser->price * $k * $ser->quantity), 0);
$sc->setService($ser->service_id);
$sc->setExtCode(0 - ($ser->price * $k)); //Для АВС
// $sc->setExtCode(0 - ($ser->price * $k)); //Для АВС
$sc->setOutPrice(0 - $item->price * $k);

$sc->save();
Expand Down
2 changes: 1 addition & 1 deletion www/app/entity/doc/retcustissue.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function Execute() {
foreach ($listst as $st) {
$sc = new Entry($this->document_id, 0 - $st->quantity * $item->price, 0 - $st->quantity);
$sc->setStock($st->stock_id);
$sc->setExtCode($item->price - $st->partion); //Для АВС
// $sc->setExtCode($item->price - $st->partion); //Для АВС
$sc->setOutPrice($item->price);
$sc->save();
}
Expand Down
Loading

0 comments on commit 584ce89

Please sign in to comment.