Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.

Commit 11fb8b4

Browse files
Merge commit '86add2a83c3060c0dc0f5ebe2db827ceceace175'
2 parents f546011 + 86add2a commit 11fb8b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+205
-126
lines changed

api/webservice/POS/modules/IStorages/GetIStorages.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function get()
1515
{
1616
$records = [];
1717
$db = PearDatabase::getInstance();
18-
$query = 'SELECT * FROM u_yf_istorages
18+
$query = 'SELECT u_yf_istorages.* FROM u_yf_istorages
1919
INNER JOIN vtiger_crmentity ON u_yf_istorages.istorageid = vtiger_crmentity.crmid
2020
WHERE vtiger_crmentity.deleted = ?
2121
AND u_yf_istorages.pos LIKE ?
@@ -24,6 +24,7 @@ public function get()
2424
while ($storage = $db->getRow($results)) {
2525
$poses = explode(',', $storage['pos']);
2626
if (in_array($this->api->app['id'], $poses)) {
27+
unset($storage['pos']);
2728
$records[] = $storage;
2829
}
2930
}

api/webservice/POS/modules/Products/GetProducts.php

+31-18
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ class API_Products_GetProducts extends BaseAction
1010
{
1111

1212
protected $requestMethod = ['GET'];
13+
private $moduleName = 'Products';
14+
15+
private function getTemplate()
16+
{
17+
$moduleId = Vtiger_Functions::getModuleId($this->moduleName);
18+
$db = PearDatabase::getInstance();
19+
$query = 'SELECT templateid FROM vtiger_trees_templates WHERE module = ?';
20+
return $db->getSingleValue($db->pquery($query, [$moduleId]));
21+
}
1322

1423
private function getCategoryName($categoryId)
1524
{
@@ -18,43 +27,47 @@ private function getCategoryName($categoryId)
1827
return $categoryCache[$categoryId];
1928
}
2029
$db = PearDatabase::getInstance();
21-
$result = $db->pquery('SELECT name FROM vtiger_trees_templates_data WHERE templateid = ? AND tree = ?', [2, $categoryId]);
30+
$result = $db->pquery('SELECT name FROM vtiger_trees_templates_data WHERE templateid = ? AND tree = ?', [$this->getTemplate(), $categoryId]);
2231
$categoryName = $db->getSingleValue($result);
2332
$categoryCache[$categoryId] = $categoryName;
2433
return $categoryName;
2534
}
2635

27-
private function getInfo($recordId)
36+
private function getInfo($recordModel)
2837
{
29-
$recordModel = Vtiger_Record_Model::getInstanceById($recordId);
3038
$image = $recordModel->getImageDetails();
31-
$data = $recordModel->getData();
3239
$imagesUrl = '';
3340
foreach ($image as $img) {
3441
$imagesUrl[] = '/Products/GetImage/' . $img['id'];
3542
}
36-
$data['categoryName'] = $this->getCategoryName($data['pscategory']);
37-
$data['imageUrl'] = $imagesUrl;
38-
return $data;
43+
$recordModel->set('categoryName', $this->getCategoryName($recordModel->get('pscategory')));
44+
$recordModel->set('imageUrl', $imagesUrl);
3945
}
4046

41-
public function get($recordId = false)
47+
public function get()
4248
{
4349
$db = PearDatabase::getInstance();
44-
if ($recordId) {
45-
$records = $this->getInfo($recordId);
46-
} else {
47-
$query = 'SELECT vtiger_products.productid, vtiger_products.pos FROM vtiger_products
50+
$query = 'SELECT vtiger_products.productname,
51+
vtiger_crmentity.description,
52+
vtiger_products.pscategory,
53+
vtiger_products.productid,
54+
vtiger_products.pos,
55+
vtiger_products.unit_price
56+
FROM vtiger_products
4857
INNER JOIN vtiger_crmentity ON vtiger_products.productid = vtiger_crmentity.crmid
4958
WHERE vtiger_crmentity.deleted = ?
5059
AND vtiger_products.pos LIKE ?
5160
AND vtiger_products.discontinued = ?';
52-
$results = $db->pquery($query, [0, '%' . $this->api->app['id'] . '%', 1]);
53-
while ($products = $db->getRow($results)) {
54-
$poses = explode(',', $products['pos']);
55-
if (in_array($this->api->app['id'], $poses)) {
56-
$records[$products['productid']] = $this->getInfo($products['productid']);
57-
}
61+
$results = $db->pquery($query, [0, '%' . $this->api->app['id'] . '%', 1]);
62+
$records = [];
63+
while ($product = $db->getRow($results)) {
64+
$poses = explode(',', $product['pos']);
65+
if (in_array($this->api->app['id'], $poses)) {
66+
unset($product['pos']);
67+
$recordModel = Vtiger_Record_Model::getCleanInstance($this->moduleName);
68+
$recordModel->setData($product)->set('id', $product['productid']);
69+
$this->getInfo($recordModel);
70+
$records[$product['productid']] = $recordModel->getData();
5871
}
5972
}
6073
return $records;

api/webservice/POS/modules/SSingleOrders/SetSSingleOrders.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,23 @@ public function post()
5252
$defaultCurrency = Vtiger_Functions::getDefaultCurrencyInfo()['id'];
5353
$inventory = Vtiger_InventoryField_Model::getInstance($moduleName);
5454
$fields = $inventory->getColumns();
55+
$inventoryData = new Vtiger_Base_Model();
5556
foreach ($offer['items'] as $rowInInventory) {
5657
$countInventoryData++;
5758
foreach ($fields as $columnName) {
5859
if ($columnName == 'total' || $columnName == 'gross' || $columnName == 'net') {
59-
AppRequest::set($columnName . $countInventoryData, $rowInInventory['qty'] * $rowInInventory['price']);
60+
$inventoryData->set($columnName . $countInventoryData, $rowInInventory['qty'] * $rowInInventory['price']);
6061
} else {
6162
if (key_exists($columnName, $this->inventoryMapping)) {
62-
AppRequest::set($columnName . $countInventoryData, $rowInInventory[$this->inventoryMapping[$columnName]]);
63+
$inventoryData->set($columnName . $countInventoryData, $rowInInventory[$this->inventoryMapping[$columnName]]);
6364
}
6465
}
6566
}
66-
AppRequest::set('seq' . $countInventoryData, $countInventoryData);
67-
AppRequest::set('currency' . $countInventoryData, $defaultCurrency);
67+
$inventoryData->set('seq' . $countInventoryData, $countInventoryData);
68+
$inventoryData->set('currency' . $countInventoryData, $defaultCurrency);
6869
}
69-
AppRequest::set('inventoryItemsNo', $countInventoryData);
70+
$inventoryData->set('inventoryItemsNo', $countInventoryData);
71+
$recordModel->set('inventoryData', $inventoryData);
7072
$recordModel->save();
7173
$idsToReturn[$offer['id']] = $recordModel->getid();
7274
} else {

api/webservice/POS/modules/TreesManager/GetTree.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
*
4+
* Class to get category tree
55
* @package YetiForce.WebserviceAction
66
* @license licenses/License.html
77
* @author Tomasz Kur <[email protected]>

config/debug.php

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
// Display Smarty Debug Console
1818
'DISPLAY_DEBUG_VIEWER' => false,
1919

20+
'EXCEPTION_ERROR_HANDLER' => false,
21+
'EXCEPTION_ERROR_HANDLER_TO_FILE' => false,
22+
'EXCEPTION_ERROR_HANDLER_TO_SHOW' => false,
23+
2024
/* +***************************************************************
2125
* API
2226
* ************************************************************** */

config/version.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
* All Rights Reserved.
99
* Contributor(s): YetiForce.com
1010
* ****************************************************************************** */
11-
$patch_version = '20160517';
12-
$YetiForce_current_version = '3.0.153';
11+
$patch_version = '20160518';
12+
$YetiForce_current_version = '3.0.166';
1313
$_SESSION['yetiforce_version'] = $YetiForce_current_version;

include/http/Request.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -348,31 +348,31 @@ public static function get($key, $defvalue = '')
348348
return self::$request->get($key, $defvalue);
349349
}
350350

351-
public function has($key)
351+
public static function has($key)
352352
{
353353
if (!self::$request) {
354354
self::init();
355355
}
356356
return self::$request->has($key);
357357
}
358358

359-
public function getForSql($key, $skipEmtpy = true)
359+
public static function getForSql($key, $skipEmtpy = true)
360360
{
361361
if (!self::$request) {
362362
self::init();
363363
}
364364
return self::$request->getForSql($key, $skipEmtpy);
365365
}
366366

367-
public function set($key, $value)
367+
public static function set($key, $value)
368368
{
369369
if (!self::$request) {
370370
self::init();
371371
}
372372
return self::$request->set($key, $value);
373373
}
374374

375-
public function isEmpty($key)
375+
public static function isEmpty($key)
376376
{
377377
if (!self::$request) {
378378
self::init();

include/main/WebUI.php

+18
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,21 @@ function process(Vtiger_Request $request)
259259
}
260260
}
261261
}
262+
263+
if (AppConfig::debug('EXCEPTION_ERROR_HANDLER')) {
264+
265+
function exception_error_handler($errno, $errstr, $errfile, $errline)
266+
{
267+
$msg = $errno . ': ' . $errstr . ' in ' . $errfile . ', line ' . $errline;
268+
if (AppConfig::debug('EXCEPTION_ERROR_HANDLER_TO_FILE')) {
269+
$file = 'cache/logs/errors.log';
270+
$test = print_r($msg.PHP_EOL, true);
271+
file_put_contents($file, $test, FILE_APPEND);
272+
}
273+
if (AppConfig::debug('EXCEPTION_ERROR_HANDLER_TO_SHOW')) {
274+
Vtiger_Functions::throwNewException($msg, false);
275+
die();
276+
}
277+
}
278+
set_error_handler('exception_error_handler');
279+
}

include/runtime/BaseModel.php

+9
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,13 @@ public function isEmpty($key)
9595
{
9696
return (!isset($this->valueMap[$key]) || empty($this->valueMap[$key]));
9797
}
98+
99+
/**
100+
* Function to remove the value
101+
* @param type $key
102+
*/
103+
public function remove($key)
104+
{
105+
unset($this->valueMap[$key]);
106+
}
98107
}

include/utils/UserInfoUtil.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function isPermitted($module, $actionname, $record_id = '')
285285
}
286286

287287
//If no actionid, then allow action is vtiger_tab permission is available
288-
if ($actionid === '') {
288+
if ($actionid === '' || $actionid === null) {
289289
if ($profileTabsPermission[$tabid] == 0) {
290290
$permission = 'yes';
291291
} else {

0 commit comments

Comments
 (0)