Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix #828

Merged
merged 12 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion db/update/temp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ ALTER TABLE promocodes ADD dateto DATE DEFAULT NULL ;
ALTER TABLE note_topics ADD ispublic tinyint(1) DEFAULT 0;
ALTER TABLE note_topicnode ADD islink tinyint(1) DEFAULT 0;
//ALTER TABLE note_nodes ADD detail text DEFAULT NULL,;
ALTER TABLE documents DROP INDEX `unuqnumber`;


delete from options where optname='version' ;
insert into options (optname,optvalue) values('version','6.12.0');

ALTER TABLE documents DROP INDEX `unuqnumber`;
2 changes: 1 addition & 1 deletion www/app/entity/crontask.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static function do(): void {
\App\Helper::setKeyVal('lastcronm', time()) ;

//очищаем статистику
$dt = $conn->DBDate(strtotime('-1 month', time())) ;
$dt = $conn->DBDate(strtotime('-12 month', time())) ;
$conn->Execute("delete from stats where category in (1,2,3,5,6) and dt < ". $dt) ;
$conn->Execute(" OPTIMIZE TABLE stats " ) ;

Expand Down
85 changes: 57 additions & 28 deletions www/app/entity/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ protected function afterLoad() {
$this->country = (string)$xml->country[0];
$this->notes = (string)$xml->notes[0];
$reclist = (string)$xml->reclist[0];
$this->cflist = (string)$xml->cflist[0];

if(strlen($reclist) >0) {
$this->reclist = @unserialize(@base64_decode($reclist)) ;
Expand Down Expand Up @@ -172,6 +173,7 @@ protected function beforeSave() {
$this->detail .= "<url>{$this->url}</url>";
$this->detail .= "<foodstate>{$this->foodstate}</foodstate>";
$this->detail .= "<state>{$this->state}</state>";
$this->detail .= "<cflist>{$this->cflist}</cflist>";

//упаковываем цены по филиалам
$brprice = serialize($this->brprice);
Expand Down Expand Up @@ -868,26 +870,11 @@ public function getID() {
* @param mixed $item_id
*/
public static function packStBC($price,$qty,$item_id) {
$common = \App\System::getOptions("common");

if($common['amdigits'] == 1) {
$price= $price *100 ;
}

$price=doubleval(\App\Helper::fa($price));
$qty=doubleval(\App\Helper::fqty($qty));

if($common['qtydigits'] ==1) {
$qty= $qty *10;
}
if($common['qtydigits'] ==2) {
$qty= $qty *100;
}
if($common['qtydigits'] ==3) {
$qty= $qty *1000 ;
}
//убираем нули
$price= intval($price) ;
$qty= intval($qty) ;

$barcode = strlen($price) . $price .strlen($qty) . $qty . $item_id;
$barcode = "".$price.'-'.$qty. '-' . $item_id;

return $barcode;
}
Expand All @@ -898,20 +885,62 @@ public static function packStBC($price,$qty,$item_id) {
* @param mixed $barcode
*/
public static function unpackStBC($barcode) {
$common = \App\System::getOptions("common");
$lprice= substr($barcode,0,1);
$price= substr($barcode,1,$lprice);
$lqty= substr($barcode,$lprice+1,1);
$qty= substr($barcode,$lprice+2,$lqty);
$id= substr($barcode,$lprice+2+$lqty);


$item= Item::load(trim($id));
$s=explode('-',$barcode) ;

$item= Item::load(trim($s[2]));
if($item != null) {

$item->price = \App\Helper::fa($price);
$item->quantity =\App\Helper::fqty($qty);
$item->price = \App\Helper::fa($s[0]);
$item->quantity =\App\Helper::fqty($s[1]);

}
return $item;
}

/**
* сохранить значения кастомных полей
*
* @param mixed $cf код=>значение
*/
public function savecf($cf){
if(!is_array($cf)) {
$cf=[];
}
$this->cflist = serialize($cf);
}
/**
* вернуть значения кастомных полей
*
*/
public function getcf(){
$cfv = [] ;
if(strlen($this->cflist)>0) {
$cfv=unserialize($this->cflist) ;
}
$options = \App\System::getOptions('common');
$cflist = $options['cflist'];
$i=1;
$ret=[];
foreach($cflist as $cf=>$f) {

$it = new \App\DataItem() ;
$it->id= $i++;
$it->code= $f->code;
$it->name= $f->name;
$it->val='';
foreach($cfv as $cv=>$v) {
if($f->code==$cv) {
$it->val= $v;
}
}
$ret[]=$it;


}

return $ret;
}

}
31 changes: 25 additions & 6 deletions www/app/entity/subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Subscribe extends \ZCL\DB\Entity
public const RSV_WH = 4;
public const RSV_SYSTEM = 5;
public const RSV_DOCRESP = 6;
public const RSV_TG = 7;

protected function init() {
$this->sub_id = 0;
Expand All @@ -47,6 +48,7 @@ protected function afterLoad() {
$this->doctypename = (string)($xml->doctypename[0]);
$this->msgsubject = (string)($xml->msgsubject[0]);
$this->url = (string)($xml->url[0]);
$this->chat_id = (string)($xml->chat_id[0]);
$this->username = (string)($xml->username[0]);
$this->user_id = (int)($xml->user_id[0]);
$this->state = (int)($xml->state[0]);
Expand Down Expand Up @@ -75,6 +77,7 @@ protected function beforeSave() {
$this->detail .= "<username>{$this->username}</username>";
$this->detail .= "<msgsubject>{$this->msgsubject}</msgsubject>";
$this->detail .= "<url>{$this->url}</url>";
$this->detail .= "<chat_id>{$this->chat_id}</chat_id>";

$this->detail .= "</detail>";

Expand Down Expand Up @@ -108,8 +111,9 @@ public static function getMsgTypeList($rt=0) {
}

if(strlen(\App\System::getOption("common", 'tbtoken'))>0) {
$list[self::MSG_BOT] = "Телеграм бот";
$list[self::MSG_BOT] = "Телеграм";
}


if($rt==self::RSV_CUSTOMER) {
unset($list[self::MSG_NOTIFY]) ;
Expand All @@ -121,6 +125,15 @@ public static function getMsgTypeList($rt=0) {
unset($list[self::MSG_BOT]) ;
unset($list[self::MSG_SMS]) ;
}

if($rt==self::RSV_TG ) {
unset($list[self::MSG_EMAIL]) ;
unset($list[self::MSG_VIBER]) ;

unset($list[self::MSG_SMS]) ;
unset($list[self::MSG_NOTIFY]) ;
}



return $list;
Expand All @@ -139,6 +152,7 @@ public static function getRecieverList($et=0) {
$list[self::RSV_SYSTEM] = "Системний лог";
$list[self::RSV_USER] = "Користувач системи";
$list[self::RSV_WH] = "Web Hook";
$list[self::RSV_TG] = "Телеграм";

return $list;
}
Expand Down Expand Up @@ -183,9 +197,7 @@ public static function onDocumentState($doc_id, $state) {
}

}
if($c==null && $u== null){
continue;
}


if ($c != null ) {
$options['phone'] = $c->phone;
Expand All @@ -201,6 +213,9 @@ public static function onDocumentState($doc_id, $state) {
$options['chat_id'] = $u->chat_id;
$options['notifyuser'] = $u->user_id;
}
if ($sub->reciever_type == self::RSV_TG) {
$options['chat_id'] = $sub->chat_id;;
}

$options['doc'] = $doc;

Expand Down Expand Up @@ -250,7 +265,10 @@ public static function onNewCustomer($customer_id) {
$options['chat_id'] = $u->chat_id;
$options['notifyuser'] = $u->user_id;
}
// $options['c'] = $c;
//
if ($sub->reciever_type == self::RSV_TG) {
$options['chat_id'] = $sub->chat_id;;
}

$text = $sub->getTextCust($c);

Expand Down Expand Up @@ -303,6 +321,7 @@ private function sendmsg($text, $options=[]){
if(strlen($options['chat_id'])>0 && $this->msg_type == self::MSG_BOT) {
$ret = self::sendBot($options['chat_id'], $text, $this->attach==1 ? $options['doc'] : null,$this->html==1) ;
}

if($this->reciever_type == self::RSV_WH) {
$ret = self::sendHook($this->url, $text) ;
}
Expand Down Expand Up @@ -376,7 +395,7 @@ private function getTextDoc($doc) {
$header['payed'] = '';
$header['credit'] = '';
$header['payurl'] = '';
$header['botname'] = $common['tbname'] ??'';
// $header['botname'] = $common['tbname'] ??'';
$header['device'] = $doc->headerdata['device'] ??'';
$header['ttnnp'] = $doc->headerdata['ship_number'] ??'';
if (strlen($doc->headerdata['device']) > 0 && strlen($doc->headerdata['devsn']) > 0) {
Expand Down
Loading