Skip to content

Commit

Permalink
Merge pull request #103 from leon-mbs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
leon-mbs authored Aug 10, 2020
2 parents 3f08052 + 1684ea0 commit bddd516
Show file tree
Hide file tree
Showing 53 changed files with 1,985 additions and 191 deletions.
61 changes: 60 additions & 1 deletion www/app/acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,27 @@ public static function checkEditRef($ref, $showerror = true) {
}
if ($showerror == true) {
System::setErrorMsg(H::l( 'aclnoaccesseditref', self::$_metasdesc[$ref]));
App::RedirectHome();

}
return false;
}
//проверка на доступ к удалению из справочника
public static function checkDelRef($ref, $showerror = true) {
if (System::getUser()->rolename == 'admins') {
return true;
}

self::load();

$meta_id = self::$_metas['4_' . $ref];
$acldelete = explode(',', System::getUser()->acldelete);

if (in_array($meta_id, $acldelete)) {
return true;
}
if ($showerror == true) {
System::setErrorMsg(H::l( 'aclnoaccessdelref', self::$_metasdesc[$ref]));

}
return false;
}
Expand Down Expand Up @@ -191,6 +211,45 @@ public static function checkEditDoc($doc, $inreg = false, $showerror = true) {

return false;
}
//проверка на доступ к удалению документа
public static function checkDelDoc($doc, $inreg = false, $showerror = true) {
$user = System::getUser();
if ($user->rolename == 'admins') {
return true;
}

self::load();


if ($user->onlymy == 1 && $doc->document_id > 0) {
if ($user->user_id != $doc->user_id) {

System::setErrorMsg( H::l('aclnoaccessdeldoc' , self::$_metasdesc[ $doc->meta_name]));

if ($inreg == false) {
App::RedirectHome();
}
return false;
}
}


$acldelete = explode(',', $user->acldelete);

if (in_array($doc->meta_id, $acldelete)) {
return true;
}

if ($showerror == true) {

System::setErrorMsg( H::l('aclnoaccessdeldoc' , self::$_metasdesc[ $doc->meta_name]));
if ($inreg == false) {
App::RedirectHome();
}
}

return false;
}

/**
* проверка на доступ к утверждению и выполнению документа.
Expand Down
2 changes: 1 addition & 1 deletion www/app/entity/doc/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function beforeSave() {


if (false == $this->checkUniqueNumber()) {
System::setWarnMsg('Не уникальный номер документа ');
System::setWarnMsg(\App\Helper::l('nouniquedocnumber') );
}

if ($this->parent_id > 0) {
Expand Down
28 changes: 15 additions & 13 deletions www/app/entity/doc/goodsreceipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,28 @@ public function Execute() {
$types = array();
$common = \App\System::getOptions("common");
if ($this->amount == 0) {
return;
// return;
}
//аналитика
foreach ($this->unpackDetails('detaildata') as $item) {


$total = $this->amount;

if ($this->headerdata["disc"] > 0) {
$total = $total - $this->headerdata["disc"];
}
if ($this->headerdata["nds"] > 0) {
$total = $total + $this->headerdata["nds"];
if($total>0){
if ($this->headerdata["disc"] > 0) {
$total = $total - $this->headerdata["disc"];
}
if ($this->headerdata["nds"] > 0) {
$total = $total + $this->headerdata["nds"];
}
if (($this->headerdata["rate"] != 0) && ($this->headerdata["rate"] != 1)) {
$total = $total * $this->headerdata["rate"];
}
$k = $total / $this->amount;
$item->price = H::fa($item->price * $k); //пересчитываем учетную цену
}else {
$item->price = 0;
}
if (($this->headerdata["rate"] != 0) && ($this->headerdata["rate"] != 1)) {
$total = $total * $this->headerdata["rate"];
}
$k = $total / $this->amount;
$item->price = H::fa($item->price * $k); //пересчитываем учетную цену

$item->amount = $item->price * $item->quantity;
$stock = \App\Entity\Stock::getStock($this->headerdata['store'], $item->item_id, $item->price, $item->snumber, $item->sdate, true);

Expand Down
1 change: 1 addition & 0 deletions www/app/entity/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ protected function afterLoad() {
$this->aclexe = $acl['aclexe'];
$this->aclcancel = $acl['aclcancel'];
$this->aclstate = $acl['aclstate'];
$this->acldelete = $acl['acldelete'];

$this->widgets = $acl['widgets'];
$this->modules = $acl['modules'];
Expand Down
2 changes: 2 additions & 0 deletions www/app/entity/userrole.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected function afterLoad() {
$this->aclexe = $acl['aclexe'];
$this->aclcancel = $acl['aclcancel'];
$this->aclstate = $acl['aclstate'];
$this->acldelete = $acl['acldelete'];

$this->widgets = $acl['widgets'];
$this->modules = $acl['modules'];
Expand All @@ -64,6 +65,7 @@ protected function beforeSave() {
$acl['aclexe'] = $this->aclexe;
$acl['aclcancel'] = $this->aclcancel;
$acl['aclstate'] = $this->aclstate;
$acl['acldelete'] = $this->acldelete;

$acl['widgets'] = $this->widgets;
$acl['modules'] = $this->modules;
Expand Down
1 change: 1 addition & 0 deletions www/app/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ public static function getDefFirm() {
return $user->deffirm;
}
$st = \App\Entity\Firm::getList();

if (count($st) == 1) {
$keys = array_keys($st);
return $keys[0];
Expand Down
12 changes: 8 additions & 4 deletions www/app/modules/ocstore/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Modules\OCStore;



/**
* Вспомагательный класс
*/
Expand All @@ -14,15 +16,17 @@ class Helper
* @param mixed $url адрес API например <youropencartsite>/index.php?route=api/login'
* @param mixed $params параметры например array('username' => $apiname,'key' => $key );
*/
public static function do_curl_request($url, $params = array()) {
public static function do_curl_request($url, $ssl, $params = array()) {


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, _ROOT . 'upload/apicookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, _ROOT . 'upload/apicookie.txt');
if( strpos($url,'https')!==false){
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $ssl==1);



$params_string = '';
Expand Down
18 changes: 9 additions & 9 deletions www/app/modules/ocstore/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function filterOnSubmit($sender) {
$modules = System::getOptions("modules");

$url = $modules['ocsite'] . '/index.php?route=api/zstore/articles&' . System::getSession()->octoken;
$json = Helper::do_curl_request($url);
$json = Helper::do_curl_request($url,$modules['ocssl']);
if ($json === false) {
return;
}
Expand Down Expand Up @@ -141,15 +141,15 @@ public function exportOnSubmit($sender) {
);

$url = $modules['ocsite'] . '/index.php?route=api/zstore/addproducts&' . System::getSession()->octoken;
$json = Helper::do_curl_request($url, $fields);
$json = Helper::do_curl_request($url,$modules['ocssl'], $fields);
if ($json === false) {
return;
}
$data = json_decode($json, true);


if ($data['error'] != "") {
$this->setErrorTop($data['error']);
$this->setError($data['error']);
return;
}
$this->setSuccess('exported_items', count($elist));
Expand Down Expand Up @@ -179,14 +179,14 @@ public function onUpdateQty($sender) {
'data' => $data
);
$url = $modules['ocsite'] . '/index.php?route=api/zstore/updatequantity&' . System::getSession()->octoken;
$json = Helper::do_curl_request($url, $fields);
$json = Helper::do_curl_request($url,$modules['ocssl'], $fields);
if ($json === false) {
return;
}
$data = json_decode($json, true);

if ($data['error'] != "") {
$this->setErrorTop($data['error']);
$this->setError($data['error']);
return;
}
$this->setSuccess('refreshed');
Expand All @@ -211,14 +211,14 @@ public function onUpdatePrice($sender) {
'data' => $data
);
$url = $modules['ocsite'] . '/index.php?route=api/zstore/updateprice&' . System::getSession()->octoken;
$json = Helper::do_curl_request($url, $fields);
$json = Helper::do_curl_request($url,$modules['ocssl'], $fields);
if ($json === false) {
return;
}
$data = json_decode($json, true);

if ($data['error'] != "") {
$this->setErrorTop($data['error']);
$this->setError($data['error']);
return;
}
$this->setSuccess('refreshed');
Expand All @@ -232,14 +232,14 @@ public function onGetItems($sender) {
$elist = array();

$url = $modules['ocsite'] . '/index.php?route=api/zstore/getproducts&' . System::getSession()->octoken;
$json = Helper::do_curl_request($url);
$json = Helper::do_curl_request($url,$modules['ocssl']);
if ($json === false) {
return;
}
$data = json_decode($json, true);

if ($data['error'] != "") {
$this->setErrorTop($data['error']);
$this->setError($data['error']);
return;
}
// $this->setInfo($json);
Expand Down
21 changes: 12 additions & 9 deletions www/app/modules/ocstore/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __construct() {
$form = $this->add(new Form("cform"));
$form->add(new TextInput('site', $modules['ocsite']));
$form->add(new TextInput('apiname', $modules['ocapiname']));
$form->add(new CheckBox('ssl', $modules['ocssl']));
$form->add(new CheckBox('outcome', $modules['ocoutcome']));
$form->add(new CheckBox('insertcust', $modules['ocinsertcust']));
$form->add(new TextArea('key', $modules['ockey']));
Expand All @@ -44,6 +45,7 @@ public function checkOnClick($sender) {
$apiname = $this->cform->apiname->getText();
$key = $this->cform->key->getText();
$site = trim($site, '/');
$ssl = $this->cform->ssl->isChecked() ? 1 : 0;

$url = $site . '/index.php?route=api/login';

Expand All @@ -52,15 +54,15 @@ public function checkOnClick($sender) {
'key' => $key
);

$json = Helper::do_curl_request($url, $fields);
$json = Helper::do_curl_request($url,$ssl, $fields);
if ($json === false) {

return;
}

$data = json_decode($json, true);
if ($data == null) {
$this->setErrorTop($json);
$this->setError($json);
return;
}
if (is_array($data) && count($data) == 0) {
Expand All @@ -70,10 +72,10 @@ public function checkOnClick($sender) {
}

if (is_array($data['error'])) {
$this->setErrorTop(implode(' ', $data['error']));
$this->setError(implode(' ', $data['error']));
} else {
if (strlen($data['error']) > 0) {
$this->setErrorTop($data['error']);
$this->setError($data['error']);
}
}

Expand All @@ -91,22 +93,22 @@ public function checkOnClick($sender) {

//загружаем список статусов
$url = $site . '/index.php?route=api/zstore/statuses&' . System::getSession()->octoken;
$json = Helper::do_curl_request($url, array());
$json = Helper::do_curl_request($url,$ssl, array());
$data = json_decode($json, true);

if ($data['error'] != "") {
$this->setErrorTop($data['error']);
$this->setError($data['error']);
} else {

System::getSession()->statuses = $data['statuses'];
}
//загружаем список категорий
$url = $site . '/index.php?route=api/zstore/cats&' . System::getSession()->octoken;
$json = Helper::do_curl_request($url, array());
$json = Helper::do_curl_request($url,$ssl, array());
$data = json_decode($json, true);

if ($data['error'] != "") {
$this->setErrorTop($data['error']);
$this->setError($data['error']);
} else {

System::getSession()->cats = $data['cats'];
Expand All @@ -121,6 +123,7 @@ public function saveOnClick($sender) {
$customer_id = $this->cform->defcust->getValue();
$pricetype = $this->cform->defpricetype->getValue();
$outcome = $this->cform->outcome->isChecked() ? 1 : 0;
$ssl = $this->cform->ssl->isChecked() ? 1 : 0;
$insertcust = $this->cform->insertcust->isChecked() ? 1 : 0;
if ($customer_id == 0) {

Expand All @@ -142,7 +145,7 @@ public function saveOnClick($sender) {
$modules['ockey'] = $key;
$modules['occustomer_id'] = $customer_id;
$modules['ocpricetype'] = $pricetype;
$modules['ocoutcome'] = $outcome;
$modules['ocssl'] = $ssl;
$modules['ocinsertcust'] = $insertcust;

System::setOptions("modules", $modules);
Expand Down
Loading

0 comments on commit bddd516

Please sign in to comment.