Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-mbs committed Dec 27, 2024
1 parent f6a9709 commit 01c82f3
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
33 changes: 24 additions & 9 deletions www/app/modules/np/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class Helper



public function __construct() {
public function __construct($throwErrors = false) {


$modules = \App\System::getOptions("modules");

// parent::__construct($modules['npapikey']);

// $this->throwErrors = $throwErrors;
$this->throwErrors = $throwErrors;
$this
->setKey($modules['npapikey'])
// ->setLanguage($language)
Expand Down Expand Up @@ -230,6 +230,8 @@ private function request($model, $method, $params = null)
? self::API_URI.'/xml/'
: self::API_URI.'/json/';

// $url = "https://api-cdn.novaposhta.ua/api-warehouses/api2/generated-cache/warehouses/warehouses.json";

$data = array(
'apiKey' => $this->key,
'modelName' => $model,
Expand All @@ -253,6 +255,19 @@ private function request($model, $method, $params = null)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);

if (curl_errno($ch) > 0) {
$msg = "sign server error: ".curl_error($ch);
$msg = str_replace("'", "\"", $msg) ;
$result = array('success' => false, 'errors' => $msg);
}
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status_code !== 200) {


$result = array('success' => false, 'errors' => "Код ".$status_code);

}
curl_close($ch);

} else {
Expand Down Expand Up @@ -1211,9 +1226,6 @@ public function getPointListCache($cityref,$pm=false) {
//обновление кеща списков
public function updatetCache() {

@unlink(_ROOT . "upload/arealist.dat");
@unlink(_ROOT . "upload/citylist.dat");
@unlink(_ROOT . "upload/pointlist.dat");

@mkdir(_ROOT . "upload") ;

Expand Down Expand Up @@ -1241,7 +1253,8 @@ public function updatetCache() {
}

$d = serialize($areas);

@unlink(_ROOT . "upload/arealist.dat");

file_put_contents(_ROOT . "upload/arealist.dat", $d);
unset($d);

Expand All @@ -1255,12 +1268,13 @@ public function updatetCache() {
}

$d = serialize($cities);

@unlink(_ROOT . "upload/citylist.dat");

file_put_contents(_ROOT . "upload/citylist.dat", $d);
unset($tmplist);
unset($cities);
unset($d);
gc_collect_cycles() ;
// gc_collect_cycles() ;

$wlist = array();
$tmplist = $this->getWarehouses('');
Expand All @@ -1269,7 +1283,8 @@ public function updatetCache() {
$wlist[] = array('Ref' => $a['Ref'], 'City' => $a['CityRef'], 'Description' => trim($a['Description']) );
}
unset($tmplist) ;
gc_collect_cycles() ;
// gc_collect_cycles() ;
@unlink(_ROOT . "upload/pointlist.dat");

$d = serialize($wlist);
file_put_contents(_ROOT . "upload/pointlist.dat", $d);
Expand Down
10 changes: 6 additions & 4 deletions www/app/modules/np/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function savecacheOnClick($sender) {

try {

$api = new Helper();
$api = new Helper(true);

$ret = $api->updatetCache() ;

Expand All @@ -158,15 +158,17 @@ public function savecacheOnClick($sender) {
if(strlen($ret['warn'] ??'')>0 ) {
$this->setWarn($ret['warn']);
}

$this->setSuccess('Збережено');
$this->updateData();

} catch(\Exception $ee) {
$msg = $ee->getMessage();
$this->setError($msg);
}

$this->updateData();


$this->setSuccess('Збережено');

}

public function gabListOnRow( $row) {
Expand Down
9 changes: 6 additions & 3 deletions www/app/pages/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,12 @@ public function beforeRender() {
$this->_tvars['alerterror'] = "";
if (strlen(System::getErrorMsgTopPage() ?? '') > 0) {
$this->_tvars['alerterror'] = System::getErrorMsgTopPage();

$this->goAnkor('topankor');


}
$this->_tvars['alertinfo'] = "";
if (strlen(System::getInfoMsgTopPage() ?? '') > 0) {
$this->_tvars['alertinfo'] = System::getInfoMsgTopPage();
$this->goAnkor('topankor');
}
}

Expand All @@ -390,6 +392,7 @@ protected function afterRender() {

$this->setError('');
$this->setErrorTopPage('');
$this->setInfoTopPage('');

$this->setSuccess('');
$this->setInfo('');
Expand Down
2 changes: 1 addition & 1 deletion www/app/pages/doc/goodsissue.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function __construct($docid = 0, $basedocid = 0) {
$order = $basedoc->cast();

if($order->getNotSendedItem() == 0){
. $this->setWarn('Позиції по цьому замовленню вже відправлені') ;
$this->setWarn('Позиції по цьому замовленню вже відправлені') ;
}

$this->docform->total->setText(H::fa($order->amount));
Expand Down
6 changes: 6 additions & 0 deletions www/templates/pages/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,12 @@
</div>
{{/alerterror}}

{{#alertinfo}}
<div class="alert alert-info" role="alert">
{{{alertinfo}}}
</div>
{{/alertinfo}}

</div>
</div>
<div class="row">
Expand Down

0 comments on commit 01c82f3

Please sign in to comment.