Go to the documentation of this file.
18 parent::__construct($oConfig);
20 $this->_oConfig = &$oConfig;
25 $this->
query(
"INSERT IGNORE INTO `" . $this->_sPrefix .
"modules` (`uri`) VALUES('" . $aData[
'uri'] .
"')");
30 $this->
query(
"DELETE FROM `" . $this->_sPrefix .
"modules` WHERE `uri`='" . $aData[
'uri'] .
"' LIMIT 1");
39 `tp`.`id` AS `provider_id`,
40 `tp`.`name` AS `provider_name`,
41 `tp`.`caption` AS `provider_caption`,
42 `tp`.`description` AS `provider_description`,
43 `tp`.`option_prefix` AS `provider_option_prefix`,
45 `tpo`.`name` AS `name`,
46 `tpo`.`type` AS `type`,
47 `tpo`.`caption` AS `caption`,
48 `tpo`.`description` AS `description`,
49 `tpo`.`extra` AS `extra`,
50 `tpo`.`check_type` AS `check_type`,
51 `tpo`.`check_params` AS `check_params`,
52 `tpo`.`check_error` AS `check_error`
53 FROM `" . $this->_sPrefix .
"providers` AS `tp`
54 LEFT JOIN `" . $this->_sPrefix .
"providers_options` AS `tpo` ON `tp`.`id`=`tpo`.`provider_id`
55 ORDER BY `tp`.`id` ASC, `tpo`.`order` ASC";
57 return $this->
getAll($sSql);
62 `tuv`.`option_id` AS `option_id`,
63 `tuv`.`value` AS `value`
64 FROM `" . $this->_sPrefix .
"user_values` AS `tuv`
65 WHERE `tuv`.`user_id`= ?";
71 $sSql =
"REPLACE INTO `" . $this->_sPrefix .
"user_values` SET `user_id`='" . $iUserId .
"', `option_id`='" . $iOptionId .
"', `value`='" . $sValue .
"'";
72 return $this->
query($sSql);
80 return $this->
getOne(
"SELECT `items` FROM `" . $this->_sPrefix .
"cart` WHERE `client_id`='" .
$iId .
"' LIMIT 1");
84 $sItems = trim($sItems,
":");
86 $sSql =
"DELETE FROM `" . $this->_sPrefix .
"cart` WHERE `client_id`='" .
$iId .
"' LIMIT 1";
88 $sSql =
"REPLACE INTO `" . $this->_sPrefix .
"cart` SET `client_id`='" .
$iId .
"', `items`='" . $sItems .
"'";
90 return $this->
query($sSql);
97 return (
int)$this->
getOne(
"SELECT `ID` FROM `Profiles` WHERE `NickName`='" . $sUsername .
"' LIMIT 1");
101 $sCurrencyCode = $this->_oConfig->getCurrencyCode();
102 $sCurrencySign = $this->_oConfig->getCurrencySign();
108 'profile_name' =>
getParam(
'site_title'),
109 'profile_icon' =>
$GLOBALS[
'oFunctions']->getMemberThumbnail(0,
'none',
false,
'site',
true,
'small'),
110 'profile_url' => CH_WSB_URL_ROOT,
111 'status' =>
'Active',
112 'currency_code' => $sCurrencyCode,
113 'currency_sign' => $sCurrencySign
118 `tp`.`NickName` AS `username`,
119 '' AS `profile_name`,
121 `tp`.`Status` AS `status`,
122 '" . $sCurrencyCode .
"' AS `currency_code`,
123 '" . $sCurrencySign .
"' AS `currency_sign`
124 FROM `Profiles` AS `tp`
129 if(!
empty($aVendor)) {
130 $aVendor[
'profile_name'] =
getNickName($aVendor[
'id']);
142 if(!
empty($sProvider)) {
146 if(isset($aOptions[$aProvider[
'option_prefix'] .
'active']) && $aOptions[$aProvider[
'option_prefix'] .
'active'][
'value'] ==
'on') {
147 $aProvider[
'options'] = $aOptions;
156 foreach($aProviders
as $aProvider)
157 if(isset($aOptions[$aProvider[
'option_prefix'] .
'active']) && $aOptions[$aProvider[
'option_prefix'] .
'active'][
'value'] ==
'on') {
158 foreach($aOptions
as $sName => $aOption)
159 if(strpos(
$sName, $aProvider[
'option_prefix']) !==
false)
160 $aProvider[
'options'][
$sName] = $aOption;
169 return (
int)$this->
getOne(
"SELECT `ID` FROM `Profiles` WHERE `Role`&" .
CH_WSB_ROLE_ADMIN .
" AND `Status`='Active' ORDER BY `ID` ASC LIMIT 1");
173 return $this->
getColumn(
"SELECT `ID` FROM `Profiles` WHERE `Role`&" .
CH_WSB_ROLE_ADMIN .
" AND `Status`='Active' ORDER BY `ID` ASC");
184 $sWhereClause =
"`tp`.`name`= ?";
190 `tp`.`name` AS `name`,
191 `tp`.`caption` AS `caption`,
192 `tp`.`description` AS `description`,
193 `tp`.`option_prefix` AS `option_prefix`,
194 `tp`.`for_visitor` AS `for_visitor`,
195 `tp`.`class_name` AS `class_name`,
196 `tp`.`class_file` AS `class_file`
197 FROM `" . $this->_sPrefix .
"providers` AS `tp`
198 WHERE " . $sWhereClause;
204 return $this->
getAll(
"SELECT `id`, `name`, `type` FROM `" . $this->_sPrefix .
"providers_options`");
208 if (!
empty($iProviderId)) {
209 $sWhereAddon =
" AND `tpo`.`provider_id`= ? ";
210 $aBindings[] = $iProviderId;
212 $aBindings[] = $iUserId;
215 `tpo`.`name` AS `name`,
216 `tuv`.`value` AS `value`
217 FROM `" . $this->_sPrefix .
"providers_options` AS `tpo`
218 LEFT JOIN `" . $this->_sPrefix .
"user_values` AS `tuv` ON `tpo`.`id`=`tuv`.`option_id`
219 WHERE 1" . $sWhereAddon .
" AND `tuv`.`user_id`= ?";
226 $sDateFormat = $this->_oConfig->getDateFormat(
'orders');
228 $sMethodName =
'getRow';
230 switch($aParams[
'type']) {
232 $sWhereClause =
" AND `id`= ? ";
233 $aBindings[] = $aParams[
'id'];
247 DATE_FORMAT(FROM_UNIXTIME(`date`), '" . $sDateFormat .
"') AS `date_uf`,
250 FROM `" . $this->_sPrefix .
"transactions_pending`
251 WHERE 1 " . $sWhereClause .
"
253 return $this->$sMethodName($sSql, $aBindings);
259 foreach($aCartInfo[
'items']
as $aItem)
260 $sItems .= $aCartInfo[
'vendor_id'] .
'_' . $aItem[
'module_id'] .
'_' . $aItem[
'id'] .
'_' . $aItem[
'quantity'] .
':';
262 $sSql =
"INSERT INTO `" . $this->_sPrefix .
"transactions_pending` SET
263 `client_id`='" . $iClientId .
"',
264 `seller_id`='" . $aCartInfo[
'vendor_id'] .
"',
265 `items`='" . trim($sItems,
':') .
"',
266 `amount`='" . $aCartInfo[
'items_price'] .
"',
267 `provider`='" . $sProviderName .
"',
268 `date`=UNIX_TIMESTAMP()";
270 return (
int)$this->
query($sSql) > 0 ? $this->
lastId() : 0;
275 foreach($aValues
as $sName => $sValue)
276 $sUpdateClause .=
"`" .
$sName .
"`='" . $sValue .
"', ";
278 $sSql =
"UPDATE `" . $this->_sPrefix .
"transactions_pending`
279 SET " . $sUpdateClause .
"`reported`='0'
280 WHERE `id`='" .
$iId .
"'";
281 return (
int)$this->
query($sSql) > 0;
287 $sSetClause .=
"`" . $sKey .
"`='" . $sValue .
"', ";
289 return $this->
query(
"INSERT INTO `" . $this->_sPrefix .
"transactions` SET " . $sSetClause .
"`date`=UNIX_TIMESTAMP(), `reported`='0'");
294 foreach($aValues
as $sName => $sValue)
295 $sUpdateClause .=
"`" .
$sName .
"`='" . $sValue .
"', ";
296 $sUpdateClause = substr($sUpdateClause, 0, -2);
298 $sSql =
"UPDATE `" . $this->_sPrefix .
"transactions`
299 SET " . $sUpdateClause .
"
300 WHERE `id`='" .
$iId .
"'";
301 return (
int)$this->
query($sSql) > 0;
305 $sDateFormat = $this->_oConfig->getDateFormat(
'orders');
307 $sMethodName =
'getRow';
309 switch($aParams[
'type']) {
311 $sWhereClause =
" AND `tt`.`id`='" . $aParams[
'id'] .
"'";
314 $sMethodName =
'getAll';
315 $sWhereClause =
" AND `tt`.`order_id`='" . $aParams[
'order_id'] .
"'";
318 $sMethodName =
'getAll';
319 foreach($aParams[
'conditions']
as $sKey => $sValue)
320 $sWhereClause .=
" AND `tt`.`" . $sKey .
"`='" . $sValue .
"'";
325 `tt`.`order_id` AS `order_id`,
326 `tt`.`client_id` AS `client_id`,
327 `tt`.`seller_id` AS `seller_id`,
328 `tt`.`module_id` AS `module_id`,
329 `tt`.`item_id` AS `item_id`,
330 `tt`.`item_count` AS `item_count`,
331 `tt`.`amount` AS `amount`,
332 `tt`.`date` AS `date`,
333 DATE_FORMAT(FROM_UNIXTIME(`tt`.`date`), '" . $sDateFormat .
"') AS `date_uf`,
334 `ttp`.`order` AS `order`,
335 `ttp`.`error_msg` AS `error_msg`,
336 `ttp`.`provider` AS `provider`
337 FROM `" . $this->_sPrefix .
"transactions` AS `tt`
338 LEFT JOIN `" . $this->_sPrefix .
"transactions_pending` AS `ttp` ON `tt`.`pending_id`=`ttp`.`id`
339 WHERE 1" . $sWhereClause;
341 return $this->$sMethodName($sSql);
350 $iId = (int)$this->
getOne(
"SELECT `ID` FROM `Profiles` WHERE `NickName`='" .
$sName .
"' LIMIT 1");
357 `tsm`.`uri` AS `uri`,
358 `tsm`.`title` AS `title`
359 FROM `" . $this->_sPrefix .
"modules` AS `tm`
360 LEFT JOIN `sys_modules` AS `tsm` ON `tm`.`uri`=`tsm`.`uri`
361 ORDER BY `tsm`.`date`";
363 return $this->
getAll($sSql);
367 $sDateFormat = $this->_oConfig->getDateFormat(
'orders');
370 if(!
empty($aParams[
'filter']))
371 $sFilterAddon =
" AND (DATE_FORMAT(FROM_UNIXTIME(`ttp`.`date`), '" . $sDateFormat .
"') LIKE '%" . $aParams[
'filter'] .
"%' OR `tp`.`NickName` LIKE '%" . $aParams[
'filter'] .
"%' OR `ttp`.`order` LIKE '%" . $aParams[
'filter'] .
"%')";
375 `ttp`.`order` AS `order`,
376 `ttp`.`amount` AS `amount`,
378 `ttp`.`items` AS `items`,
379 `ttp`.`date` AS `date`,
380 DATE_FORMAT(FROM_UNIXTIME(`ttp`.`date`), '" . $sDateFormat .
"') AS `date_uf`,
381 `ttp`.`client_id` AS `user_id`,
382 `tp`.`NickName` AS `user_name`
383 FROM `" . $this->_sPrefix .
"transactions_pending` AS `ttp`
384 LEFT JOIN `Profiles` AS `tp` ON `ttp`.`client_id`=`tp`.`ID`
385 WHERE `ttp`.`seller_id`='" . $aParams[
'seller_id'] .
"' AND (ISNULL(`ttp`.`order`) OR (NOT ISNULL(`ttp`.`order`) AND `ttp`.`error_code` NOT IN ('0' ,'1'))) " . $sFilterAddon .
"
386 ORDER BY `ttp`.`date` DESC
387 LIMIT " . $aParams[
'start'] .
", " . $aParams[
'per_page'];
388 $aOrders = $this->
getAll($sSql);
390 foreach($aOrders
as $iKey => $aOrder) {
392 $aOrders[$iKey][
'products'] = count($aProducts);
395 foreach($aProducts
as $aProduct)
396 $iItems += (int)$aProduct[
'item_count'];
397 $aOrders[$iKey][
'items'] = $iItems;
403 $sDateFormat = $this->_oConfig->getDateFormat(
'orders');
406 if(!
empty($aParams[
'filter']))
407 $sFilterAddon =
" AND (DATE_FORMAT(FROM_UNIXTIME(`ttp`.`date`), '" . $sDateFormat .
"') LIKE '%" . $aParams[
'filter'] .
"%' OR `tp`.`NickName` LIKE '%" . $aParams[
'filter'] .
"%' OR `ttp`.`order` LIKE '%" . $aParams[
'filter'] .
"%')";
411 FROM `" . $this->_sPrefix .
"transactions_pending` AS `ttp`
412 LEFT JOIN `Profiles` AS `tp` ON `ttp`.`client_id`=`tp`.`ID`
413 WHERE `ttp`.`seller_id`='" . $aParams[
'seller_id'] .
"' AND (ISNULL(`ttp`.`order`) OR (NOT ISNULL(`ttp`.`order`) AND `ttp`.`error_code`<>'1')) " . $sFilterAddon .
"
415 return (
int)$this->
getOne($sSql);
419 $sDateFormat = $this->_oConfig->getDateFormat(
'orders');
422 if(!
empty($aParams[
'filter']))
423 $sFilterAddon =
" AND (DATE_FORMAT(FROM_UNIXTIME(`tt`.`date`), '" . $sDateFormat .
"') LIKE '%" . $aParams[
'filter'] .
"%' OR `tt`.`order_id` LIKE '%" . $aParams[
'filter'] .
"%' OR `tp`.`NickName` LIKE '%" . $aParams[
'filter'] .
"%' OR `ttp`.`order` LIKE '%" . $aParams[
'filter'] .
"%')";
427 `ttp`.`order` AS `order`,
428 `tt`.`amount` AS `amount`,
429 `tt`.`order_id` AS `license`,
430 `tt`.`date` AS `date`,
431 DATE_FORMAT(FROM_UNIXTIME(`tt`.`date`), '" . $sDateFormat .
"') AS `date_uf`,
433 `tt`.`item_count` AS `items`,
434 `tt`.`client_id` AS `user_id`,
435 `tp`.`NickName` AS `user_name`
436 FROM `" . $this->_sPrefix .
"transactions` AS `tt`
437 LEFT JOIN `" . $this->_sPrefix .
"transactions_pending` AS `ttp` ON `tt`.`pending_id`=`ttp`.`id`
438 LEFT JOIN `Profiles` AS `tp` ON `tt`.`client_id`=`tp`.`ID`
439 WHERE `tt`.`seller_id`='" . $aParams[
'seller_id'] .
"' " . $sFilterAddon .
"
440 ORDER BY `tt`.`date` DESC
441 LIMIT " . $aParams[
'start'] .
", " . $aParams[
'per_page'];
443 return $this->
getAll($sSql);
447 $sDateFormat = $this->_oConfig->getDateFormat(
'orders');
450 if(!
empty($aParams[
'filter']))
451 $sFilterAddon =
" AND (DATE_FORMAT(FROM_UNIXTIME(`tt`.`date`), '" . $sDateFormat .
"') LIKE '%" . $aParams[
'filter'] .
"%' OR `tt`.`order_id` LIKE '%" . $aParams[
'filter'] .
"%' OR `tp`.`NickName` LIKE '%" . $aParams[
'filter'] .
"%' OR `ttp`.`order` LIKE '%" . $aParams[
'filter'] .
"%')";
455 FROM `" . $this->_sPrefix .
"transactions` AS `tt`
456 LEFT JOIN `" . $this->_sPrefix .
"transactions_pending` AS `ttp` ON `tt`.`pending_id`=`ttp`.`id`
457 LEFT JOIN `Profiles` AS `tp` ON `tt`.`client_id`=`tp`.`ID`
458 WHERE `tt`.`seller_id`='" . $aParams[
'seller_id'] .
"' " . $sFilterAddon .
"
461 return (
int)$this->
getOne($sSql);
465 $sDateFormat = $this->_oConfig->getDateFormat(
'orders');
468 if(!
empty($aParams[
'filter']))
469 $sFilterAddon =
" AND (DATE_FORMAT(FROM_UNIXTIME(`tt`.`date`), '" . $sDateFormat .
"') LIKE '%" . $aParams[
'filter'] .
"%' OR `tt`.`order_id` LIKE '%" . $aParams[
'filter'] .
"%' OR `tp`.`NickName` LIKE '%" . $aParams[
'filter'] .
"%' OR `ttp`.`order` LIKE '%" . $aParams[
'filter'] .
"%')";
473 `ttp`.`order` AS `order`,
474 `tt`.`amount` AS `amount`,
475 `tt`.`order_id` AS `license`,
476 `tt`.`date` AS `date`,
477 DATE_FORMAT(FROM_UNIXTIME(`tt`.`date`), '" . $sDateFormat .
"') AS `date_uf`,
479 `tt`.`item_count` AS `items`,
480 `tp`.`ID` AS `user_id`,
481 `tp`.`NickName` AS `user_name`
482 FROM `" . $this->_sPrefix .
"transactions` AS `tt`
483 LEFT JOIN `" . $this->_sPrefix .
"transactions_pending` AS `ttp` ON `tt`.`pending_id`=`ttp`.`id`
484 LEFT JOIN `Profiles` AS `tp` ON `tt`.`seller_id`=`tp`.`ID`
485 WHERE `tt`.`client_id`='" . $aParams[
'user_id'] .
"' " . $sFilterAddon .
"
486 ORDER BY `tt`.`date` DESC
487 LIMIT " . $aParams[
'start'] .
", " . $aParams[
'per_page'];
489 return $this->
getAll($sSql);
493 $sDateFormat = $this->_oConfig->getDateFormat(
'orders');
495 $sFilterAddon = !
empty($aParams[
'seller_id']) ?
" AND `tt`.`seller_id`='" . $aParams[
'seller_id'] .
"'" :
" AND `tt`.`seller_id`<>'-1'";
496 if(!
empty($aParams[
'filter']))
497 $sFilterAddon =
" AND (DATE_FORMAT(FROM_UNIXTIME(`tt`.`date`), '" . $sDateFormat .
"') LIKE '%" . $aParams[
'filter'] .
"%' OR `tt`.`order_id` LIKE '%" . $aParams[
'filter'] .
"%' OR `tp`.`NickName` LIKE '%" . $aParams[
'filter'] .
"%' OR `ttp`.`order` LIKE '%" . $aParams[
'filter'] .
"%')";
501 FROM `" . $this->_sPrefix .
"transactions` AS `tt`
502 LEFT JOIN `" . $this->_sPrefix .
"transactions_pending` AS `ttp` ON `tt`.`pending_id`=`ttp`.`id`
503 LEFT JOIN `Profiles` AS `tp` ON `tt`.`seller_id`=`tp`.`ID`
504 WHERE `tt`.`client_id`='" . $aParams[
'user_id'] .
"' " . $sFilterAddon .
"
507 return (
int)$this->
getOne($sSql);
511 $mixedResult = $this->
query(
"UPDATE `" . $this->_sPrefix .
"transactions_pending` SET `reported`=`reported`+'1' WHERE `id` IN ('" . implode(
"','", $aOrders) .
"')");
512 return (
int)$mixedResult > 0;
516 $mixedResult = $this->
query(
"UPDATE `" . $this->_sPrefix .
"transactions` SET `reported`=`reported`+'1' WHERE `id` IN ('" . implode(
"','", $aOrders) .
"')");
517 return (
int)$mixedResult > 0;
521 $mixedResult = $this->
query(
"DELETE FROM `" . $this->_sPrefix .
"transactions_pending` WHERE `id` IN ('" . implode(
"','", $aOrders) .
"')");
522 return (
int)$mixedResult > 0;
526 $mixedResult = $this->
query(
"DELETE FROM `" . $this->_sPrefix .
"transactions` WHERE `id` IN ('" . implode(
"','", $aOrders) .
"')");
527 return (
int)$mixedResult > 0;
531 $this->
query(
"DELETE FROM `ch_pmt_cart` WHERE `client_id`='" .
$iId .
"'");
532 $this->
query(
"DELETE FROM `ch_pmt_user_values` WHERE `user_id`='" .
$iId .
"'");
getParam($sName, $bCache=true)
const CH_PMT_ADMINISTRATOR_ID
cancelPendingOrders($aOrders)
get_member_icon($ID, $float='none', $bGenProfLink=false)
updatePending($iId, $aValues)
reportProcessedOrders($aOrders)
ch_import($sClassName, $aModule=array())
cancelProcessedOrders($aOrders)
getHistoryOrders($aParams)
updateOption($iUserId, $iOptionId, $sValue)
insertPending($iClientId, $sProviderName, $aCartInfo)
getProcessedOrdersCount($aParams)
getAll($sQuery, $aBindings=[], $iFetchType=PDO::FETCH_ASSOC)
reportPendingOrders($aOrders)
setCartItems($iId, $sItems)
getVendorInfoProviders($iId, $sProvider='')
getPendingOrdersCount($aParams)
getRow($sQuery, $aBindings=[], $iFetchStyle=PDO::FETCH_ASSOC)
getVendorInfoProfile($iId)
query($sQuery, $aBindings=[])
insertTransaction($aInfo)
getOne($sQuery, $aBindings=[], $iIndex=0)
getProfileLink( $iID, $sLinkAdd='')
getProcessedOrders($aParams)
const CH_PMT_ADMINISTRATOR_USERNAME
updateTransaction($iId, $aValues)
getHistoryOrdersCount($aParams)
getOptions($iUserId=CH_PMT_EMPTY_ID, $iProviderId=0)
getPendingOrders($aParams)
Attr AllowedRel this is empty
getAllWithKey($sQuery, $sFieldKey, $aBindings=[], $iFetchType=PDO::FETCH_ASSOC)
getColumn($sQuery, $aBindings=[])
static items2array($mixed)