Skip to content

Commit

Permalink
Merge pull request #141 from leon-mbs/dev
Browse files Browse the repository at this point in the history
4.8.5
  • Loading branch information
leon-mbs authored Mar 12, 2021
2 parents 28a8627 + 874b115 commit c692a9d
Show file tree
Hide file tree
Showing 58 changed files with 17,891 additions and 17,113 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
CHANGELOG
=========
### v4.8.5 (2021-03-12)
* В справочник контрагентов добавлена возможность работы с лидами
* Обновление календаря в нарядах и табеле

Для обновления версии обновить папки assets, app, templates, templates_ua,
vendor (или выполнить Composer обновив composer.json), выполнить update484to485.sql

### v4.8.4 (2021-03-05)
* Интеграция с Новой Почтой (Украина)
* Настройка подписки на события и уведомлений
Expand Down
3 changes: 2 additions & 1 deletion db/temp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ CREATE TABLE `prodproc` (



*/
*/

38 changes: 38 additions & 0 deletions db/update484to485.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
ALTER TABLE `customers`
ADD `createdon` Date ,
ADD `leadstatus` VARCHAR(255) NULL ,
ADD `leadsource` 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`.`createdon` AS `createdon`,
(
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`;
121 changes: 76 additions & 45 deletions www/app/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

namespace App;

class Calendar extends \Zippy\Html\HtmlComponent implements \Zippy\Interfaces\Requestable
class Calendar extends \Zippy\Html\HtmlComponent implements \Zippy\Interfaces\Requestable,\Zippy\Interfaces\AjaxRender
{

private $event = null;
private $data = array();
private $view = 'month';
private $view = 'dayGridMonth';


public function __construct($id,$view='month') {
public function __construct($id ) {
parent::__construct($id);
$this->view = $view;
$this->view = 'dayGridMonth' ;

}


Expand All @@ -23,70 +25,85 @@ public final function RenderImpl() {
if ($_config['common']['lang'] == 'ua') {
$lang = 'ua';
}

if (count($this->data) > 0) {
$ev = ",events: [";
foreach ($this->data as $dt) {
$ev .= " { id : '{$dt->id}',title : '{$dt->title}', start : '{$dt->start}' , end : '{$dt->end}' , color : '{$dt->color}'},";

$ev .= " { id : '{$dt->id}',
title : '{$dt->title}',
start : {$dt->start} ,
end : {$dt->end} ,
backgroundColor: '{$dt->color}',
allDay : false },";
}
$ev = rtrim($ev, ',');
$ev .= "]";
}

$js = <<<EOT
$("#{$id}").fullCalendar({
var calendarEl = document.getElementById('{$id}');
var Calendar = FullCalendar.Calendar;
var calendar = new Calendar(calendarEl, {
header: {
left: '',
headerToolbar: {
left : 'prev,next today',
center: 'title',
right: ' prev,next'
},
defaultView: '{$this->view}',
eventTextColor:'white',
minTime: '08:00:00',
maxTime: '20:00:00',
eventClick: function(calEvent, jsEvent, view) {
var url ='{$url}:' + 'click:'+ calEvent.id ;
right : 'dayGridMonth,timeGridWeek,timeGridDay'
},
initialView: '{$this->view}' ,
themeSystem: 'bootstrap' ,
editable: true,
droppable: true,
eventClick: function(info) {
var url ='{$url}:' + 'click:'+ info.event.id ;
window.location= url;
},
dayClick: function(date, jsEvent, view) {
var dt =date.toISOString();
var url ='{$url}:' + 'add:'+ dt;
dateClick: function(info) {
var url ='{$url}:' + 'add:'+ info.dateStr;
window.location= url;
},
editable: true,
eventResize: function(event, delta, revertFunc) {
},
eventResize: function(info) {
var url ='{$url}:' + 'resize:'+ event.id +':' +delta;
window.location= url;
var url ='{$url}:' + 'resize:'+ info.event.id +':' + info.startDelta.milliseconds + ':' + info.endDelta.milliseconds +'&ajax=true' ;
// window.location= url;
getUpdate(url) ;
} ,
eventDrop: function(event, delta, revertFunc) {
eventDrop: function(info) {
var url ='{$url}:' + 'move:'+ event.id +':' +delta;
window.location= url;
var url ='{$url}:' + 'move:'+ info.event.id +':' + info.delta.years+':' + info.delta.months+':' + info.delta.days+':' + info.delta.milliseconds +'&ajax=true' ;
// window.location= url;
getUpdate(url) ;
} ,
} ,
locale: '{$lang}'
{$ev}
{$ev}
});
});
calendar.render();
EOT;

Application::$app->getResponse()->addJavaScript($js, true);
Expand All @@ -98,18 +115,27 @@ public final function RequestHandle() {

$action['action'] = $params[0];
$action['id'] = $params[1];
$action['delta'] = $params[2];
$action['startdelta'] = $params[2];
$action['enddelta'] = $params[3];
$action['years'] = $params[2];
$action['months'] = $params[3];
$action['days'] = $params[4];
$action['ms'] = $params[5];


if ($action['action'] == 'add') {
$dt = $params[1] . ':' . $params[2] . ':' . $params[3];
$action['date'] = strtotime($dt);
}
if ($action['action'] == 'resize') {
$action['delta'] = $action['delta'] / 1000;
$action['startdelta'] = $action['startdelta'] / 1000;
$action['enddelta'] = $action['enddelta'] / 1000;
}
if ($action['action'] == 'move') {
$action['delta'] = $action['delta'] / 1000;
$action['years'] = $action['years'] ;
$action['month'] = $action['month'] ;
$action['days'] = $action['days'] ;
$action['ms'] = $action['ms']/1000 ;
}

if ($this->event != null) {
Expand All @@ -125,7 +151,10 @@ public function setEvent(\Zippy\Interfaces\EventReceiver $receiver, $handler) {
public function setData($data) {
$this->data = $data;
}
public function AjaxAnswer() {

return '';
}
}

class CEvent
Expand All @@ -136,9 +165,11 @@ class CEvent
public function __construct($id, $title, $start, $end, $color) {
$this->id = $id;
$this->title = $title;
$this->start = date("Y-m-d H:i", $start);
$this->end = date("Y-m-d H:i", $end);
$this->start = "new Date(".date("Y", $start).", ".( date("m", $start) -1).", ".date("d", $start).",".date("H", $start).",".date("i", $start).")" ;
$this->end = "new Date(".date("Y", $end).", ".( date("m", $end) -1).", ".date("d", $end).",".date("H", $end).",".date("i", $end).")" ;
// $this->end = date("Y-m-dTH:i", $end);
$this->color = $color;
}

}

51 changes: 45 additions & 6 deletions www/app/entity/customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ class Customer extends \ZCL\DB\Entity

const STATUS_ACTUAL = 0; //актуальный
const STATUS_DISABLED = 1; //не используется
const STATUS_WAIT = 2; //потенциальный
const STATUS_LEAD = 2; //лид


const TYPE_BAYER = 1; //покупатель
const TYPE_SELLER = 2; //поставщик




protected function init() {
$this->customer_id = 0;
$this->customer_name = '';
$this->status = 0;
$this->fromlead = 0;
$this->createdon = time();
}

protected function beforeSave() {
Expand All @@ -33,14 +37,15 @@ protected function beforeSave() {
$this->detail .= "<discount>{$this->discount}</discount>";
$this->detail .= "<bonus>{$this->bonus}</bonus>";
$this->detail .= "<type>{$this->type}</type>";
$this->detail .= "<fromlead>{$this->fromlead}</fromlead>";
$this->detail .= "<jurid>{$this->jurid}</jurid>";
$this->detail .= "<shopcust_id>{$this->shopcust_id}</shopcust_id>";
$this->detail .= "<isholding>{$this->isholding}</isholding>";
$this->detail .= "<holding>{$this->holding}</holding>";
$this->detail .= "<viber>{$this->viber}</viber>";
$this->detail .= "<created>{$this->created}</created>";

$this->detail .= "<user_id>{$this->user_id}</user_id>";

$this->detail .= "<holding_name><![CDATA[{$this->holding_name}]]></holding_name>";
$this->detail .= "<address><![CDATA[{$this->address}]]></address>";
$this->detail .= "<comment><![CDATA[{$this->comment}]]></comment>";
Expand All @@ -60,13 +65,16 @@ protected function afterLoad() {
$this->shopcust_id = (int)($xml->shopcust_id[0]);
$this->isholding = (int)($xml->isholding[0]);
$this->user_id = (int)($xml->user_id[0]);
$this->created = (int)($xml->created[0]);
$this->fromlead = (int)($xml->fromlead[0]);

$this->holding = (int)($xml->holding[0]);
$this->holding_name = (string)($xml->holding_name[0]);
$this->address = (string)($xml->address[0]);
$this->comment = (string)($xml->comment[0]);
$this->viber = (string)($xml->viber[0]);


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

parent::afterLoad();
}

Expand Down Expand Up @@ -142,5 +150,36 @@ public static function getHoldList($type = 0) {
return Customer::findArray("customer_name", $where, "customer_name");
}

public static function getLeadSources(){
$options = \App\System::getOptions('common' ) ;

if(is_array($options['leadsources'])==false)$options['leadsources'] = array();

$list = array();
foreach($options['leadsources'] as $item){
if(strlen($item->name)==0) continue;
$list[$item->name] = $item->name;
}


return $list;
}

public static function getLeadStatuses(){
$options = \App\System::getOptions('common' ) ;

if(is_array($options['leadstatuses'])==false)$options['leadstatuses'] = array();

$list = array();
foreach($options['leadstatuses'] as $item){
if(strlen($item->name)==0) continue;
$list[$item->name] = $item->name;
}


return $list;

}


}
1 change: 1 addition & 0 deletions www/app/entity/doc/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function generateReport() {
"_detail" => $detail,
"customer_name" => $this->customer_name,
"firm_name" => $firm['firm_name'],
"firm_address" => $firm['address'],
"logo" => _BASEURL . $firm['logo'],
"islogo" => strlen($firm['logo']) > 0,
"stamp" => _BASEURL . $firm['stamp'],
Expand Down
21 changes: 21 additions & 0 deletions www/app/entity/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,5 +435,26 @@ public static function getTypes() {
return $list;
}

/**
* себестоимость для готовой продукции
*
*/
public function getProdprice(){
$price = 0;
if ($this->zarp > 0) {
$price += $this->zarp;
}
$ilist = \App\Entity\ItemSet::find("pitem_id=" . $this->item_id);

if (count($ilist) > 0) {
foreach ($ilist as $iset) {
$it = \App\Entity\Item::load($iset->item_id);
$pr = $it->getLastPartion(0);
$price += ($iset->qty * $pr);
}
}


return $price;
}
}
Loading

0 comments on commit c692a9d

Please sign in to comment.