Provides access to sales statistics

@param  array $params
@param  \Smarty $smarty
@return string the value of the requested attribute
@throws \Exception
497472
public function statsAccess($params, $smarty)
    {
        if (false === array_key_exists("key", $params)) {
            throw new \InvalidArgumentException(sprintf("missing key attribute in stats access function"));
        }
        if (false === array_key_exists("startDate", $params) || $params['startDate'] === '') {
            throw new \InvalidArgumentException(sprintf("missing startDate attribute in stats access function"));
        }
        if (false === array_key_exists("endDate", $params) || $params['endDate'] === '') {
            throw new \InvalidArgumentException(sprintf("missing endDate attribute in stats access function"));
        }

        if (false !== array_key_exists("includeShipping", $params) && $params['includeShipping'] == 'false') {
            $includeShipping = false;
        } else {
            $includeShipping = true;
        }

        if (false !== array_key_exists("withTaxes", $params) && $params['withTaxes'] == 'false') {
            $withTaxes = false;
        } else {
            $withTaxes = true;
        }

        if ($params['startDate'] == 'today') {
            $startDate = new \DateTime();
            $startDate->setTime(0, 0, 0);
        } elseif ($params['startDate'] == 'yesterday') {
            $startDate = new \DateTime();
            $startDate->setTime(0, 0, 0);
            $startDate->modify('-1 day');
        } elseif ($params['startDate'] == 'this_month') {
            $startDate = new \DateTime();
            $startDate->modify('first day of this month');
            $startDate->setTime(0, 0, 0);
        } elseif ($params['startDate'] == 'last_month') {
            $startDate = new \DateTime();
            $startDate->modify('first day of last month');
            $startDate->setTime(0, 0, 0);
        } elseif ($params['startDate'] == 'this_year') {
            $startDate = new \DateTime();
            $startDate->modify('first day of January this year');
            $startDate->setTime(0, 0, 0);
        } elseif ($params['startDate'] == 'last_year') {
            $startDate = new \DateTime();
            $startDate->modify('first day of January last year');
            $startDate->setTime(0, 0, 0);
        } else {
            try {
                $startDate = new \DateTime($params['startDate']);
            } catch (\Exception $e) {
                throw new \InvalidArgumentException(
                    sprintf("invalid startDate attribute '%s' in stats access function", $params['startDate'])
                );
            }
        }

        if ($params['endDate'] == 'today') {
            $endDate = new \DateTime();
            $endDate->setTime(0, 0, 0);
        } elseif ($params['endDate'] == 'yesterday') {
            $endDate = new \DateTime();
            $endDate->setTime(0, 0, 0);
            $endDate->modify('-1 day');
        } elseif ($params['endDate'] == 'this_month') {
            $endDate = new \DateTime();
            $endDate->modify('last day of this month');
            $endDate->setTime(0, 0, 0);
        } elseif ($params['endDate'] == 'last_month') {
            $endDate = new \DateTime();
            $endDate->modify('last day of last month');
            $endDate->setTime(0, 0, 0);
        } elseif ($params['endDate'] == 'this_year') {
            $endDate = new \DateTime();
            $endDate->modify('last day of December this year');
            $endDate->setTime(0, 0, 0);
        } elseif ($params['endDate'] == 'last_year') {
            $endDate = new \DateTime();
            $endDate->modify('last day of December last year');
            $endDate->setTime(0, 0, 0);
        } else {
            try {
                $endDate = new \DateTime($params['endDate']);
            } catch (\Exception $e) {
                throw new \InvalidArgumentException(
                    sprintf("invalid endDate attribute '%s' in stats access function", $params['endDate'])
                );
            }
        }

        switch ($params['key']) {
            case 'sales':
                return OrderQuery::getSaleStats($startDate, $endDate, $includeShipping, $withTaxes);
                break;
            case 'orders':
                return OrderQuery::getOrderStats($startDate, $endDate, OrderStatusQuery::getPaidStatusIdList());
                break;
        }

        throw new \InvalidArgumentException(
            sprintf("invalid key attribute '%s' in stats access function", $params['key'])
        );
    }
87992
public function fetchRequestToken(array $params = [])
    {
        $this->setAccessToken(null);
        $defaultParams = [
            'oauth_consumer_key' => $this->consumerKey,
            'oauth_callback' => $this->getReturnUrl(),
            //'xoauth_displayname' => Yii::$app->name,
        ];
        if (!empty($this->scope)) {
            $defaultParams['scope'] = $this->scope;
        }

        $request = $this->createRequest()
            ->setMethod($this->requestTokenMethod)
            ->setUrl($this->requestTokenUrl)
            ->setData(array_merge($defaultParams, $params));

        $this->signRequest($request);

        $response = $this->sendRequest($request);

        $token = $this->createToken([
            'params' => $response
        ]);
        $this->setState('requestToken', $token);

        return $token;
    }
1157065
public function getTransactionData($params)
    {
        $supportedParams = [
            'AllPayLogisticsID' => '',
            'PlatformID' => '',
        ];

        $this->sdk->Send = array_merge($this->sdk->Send, $supportedParams);

        $this->sdk->Send = array_replace(
            $this->sdk->Send,
            array_intersect_key($params, $this->sdk->Send)
        );

        return $this->sdk->QueryLogisticsInfo();
    }
826263
private function findOneRequest($soapArgs, $params) {

        $etiquetasReservadas = array();
        
        //Atribui a quantidade de etiquetas desejadas
        $soapArgs['qtdEtiquetas'] = $params->getQtdEtiquetas();

        $request = SoapClientFactory::getSoapClient()->solicitaEtiquetas($soapArgs);

        if($this->validAfterRequest($request)){

            $faixaEtiqueta = explode(',', $request->return);
            
            $numerosEtiqueta = $this->createNumberEtiquetasByRange($faixaEtiqueta[0], $faixaEtiqueta[1]);

            foreach ($numerosEtiqueta as $numeroEtiqueta){
                $etiqueta = new Etiqueta();
                $etiqueta->setEtiquetaSemDv($numeroEtiqueta);
                $etiquetasReservadas[] = $etiqueta;
            }

        }
        
        return $etiquetasReservadas;
        
    }
731625
public static function generateSign(array $params): string
    {
        $privateKey = self::$instance->private_key;

        if (is_null($privateKey)) {
            throw new InvalidConfigException('Missing Alipay Config -- [private_key]');
        }

        if (Str::endsWith($privateKey, '.pem')) {
            $privateKey = openssl_pkey_get_private($privateKey);
        } else {
            $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n".
                wordwrap($privateKey, 64, "\n", true).
                "\n-----END RSA PRIVATE KEY-----";
        }

        openssl_sign(self::getSignContent($params), $sign, $privateKey, OPENSSL_ALGO_SHA256);

        $sign = base64_encode($sign);

        Log::debug('Alipay Generate Sign', [$params, $sign]);

        return $sign;
    }
66333
public function getInsertID(string $sQuery, array $aParam = []) {
		if (!$this->_query($sQuery, $aParam, TRUE)) {
			return FALSE;
		}
		return (int)$this->_oPDO->lastInsertId();
	}
392268
public function evtAddFile(ServiceManager $sm, array $params)
    {
        /** @var ZF3GotServices $gs */
        $gs         = $sm->get('graphic.object.templating.services');
        $ret        = [];
        /** @var ODDragNDrop $objet */
        $sessionObj = self::validateSession();
        /** @var ODDragNDrop $objet */
        $objet      = self::buildObject($params['id'], $sessionObj);

        $maxCountFile   = $objet->getMaxFileCount();
        $loadedFiles    = $objet->getLoadedFiles();

        if ($maxCountFile === 0 || sizeof($loadedFiles) < $maxCountFile) {
            $tempFolder = $objet->getTempFolder();
            $pathPublic = $_SERVER['DOCUMENT_ROOT'];
            /** si tempFolder vide, voir de créer un répertoire uploadFile dans public */
            if (empty($tempFolder)) {
                if (!file_exists($pathPublic.'/uploadedFiles')) {
                    $returnCall  = shell_exec('cd '.$pathPublic.' 2>&1');

                    $returnCall .= shell_exec('mkdir public/uploadedFiles 2>&1');
                    $returnCall .= shell_exec('chmod 777 public/uploadedFiles/ 2>&1');
                    if (!empty($returnCall)) { throw new Exception($returnCall); }
                }
                $tempFolder  = $pathPublic.'/uploadedFiles';
            }

            /**
             * traitement d'ajout d'un fichier
             */
            $fileName   = $params['name'];
            $fileExt    = pathinfo($fileName, PATHINFO_EXTENSION);
            $mimeType   = $this->getMimeString($fileExt);
            $imgSrc     = $params['file'];
            $imgFile    = base64_decode($imgSrc);
            $dest       = $tempFolder.'/'.$fileName;
            if ( $objet->addLoadedFile($params['name'], $dest) !== false ) {
                $file       = fopen($dest, 'wb');
                fwrite($file, $imgFile);
                fclose($file);

                $objet->setTempFolder($tempFolder);
                $objet->saveProperties();

                $mode   = 'addFile';
                $html   = ['name'=> $params['name'], 'mime'=> $mimeType];
                $ret[]  = $objet::formatRetour($objet->getId(), $objet->getId(), $mode, $html);
            } else {
                $alertMsg = 'alert("Nom de fichier '.$$params['name'].' existe dèjà, veuillez changer");';
                $ret[]  = $objet::formatRetour($objet->getId(), $objet->getId(), 'exec', $alertMsg);
            }
        } else if ($maxCountFile != 0) {
            $alertMsg = 'alert("Maximum de '.$maxCountFile.' fichier(s) atteint");';
            $ret[]  = $objet::formatRetour($objet->getId(), $objet->getId(), 'exec', $alertMsg);
        }

        return $ret;
    }
227056
public function getActualiteDetail($params = array())
	{
		$html = "";
		if (isset($this->variablesGet['archiIdActualite']) && $this->variablesGet['archiIdActualite']!='') {
			$req = "SELECT idActualite,  date, texte,  titre, sousTitre, urlFichier, fichierPdf FROM actualites WHERE idActualite='".$this->variablesGet['archiIdActualite']."'";
			$res = $this->connexionBdd->requete($req);
			if (mysql_num_rows($res)>0) {
				$fetch = mysql_fetch_assoc($res);

				$tab = new tableau();
				if ($fetch['fichierPdf']!='') {
					$tab->addValue("<div style='font-size:9px;'>"._("Pour un plus grand confort de lecture téléchargez la")." <a href='".$this->getUrlImage()."actualites/".$fetch['idActualite']."/".$fetch['fichierPdf']."' target='_blank'>"._("version PDF du texte.")."</a></div>");
				}
				$tab->addValue(stripslashes($fetch['titre']), "style='font-size:18px;font-weight:bold;'");
				$tab->addValue(stripslashes($fetch['sousTitre']), "style='font-size:14px;font-weight:bold;'");
				$html.=$tab->createHtmlTableFromArray(1, 'margin:0;padding:0;', '', '', " border=''");

				$html.="<br>";
				$html.=str_replace("###cheminImages###", $this->getUrlImage()."actualites/".$fetch['idActualite']."/", stripslashes($fetch['texte']));
			}
		}

		return $html;
	}
160066
protected function serializeParams(array $params)
    {
        $serialized = array();
        foreach ($params as $param) {
            $serialized[] = $this->serializer->serialize($param);
        }

        return $serialized;
    }
1164580
public function getCode($aParams, $oSmarty)
    {
        $oEmos = $this->getEmos();

        $this->_setControllerInfo($oEmos, $aParams, $oSmarty);

        $this->_setBasketActionsInfo($oEmos);

        return "\n" . $oEmos->toString();
    }
551625
public function QPayOrderQuery($params = array()){
        /*        //入参
                $params = array();
                $params["out_trade_no"] = "20160512161914_BBC";
                $params["sub_mch_id"] = "1900005911";*/
        if (empty($params["out_trade_no"])){
            throw new Exception('商户订单号参数不能缺少' ,'OUT_TRADE_NO_MUST_INPUT');
        }
        if (empty($params["sub_mch_id"])){
            throw new Exception('sub_mch_id不能缺少' ,'FEE_TYPE');
        }

        //api调用
        $qpayApi = new QpayMchAPI('https://qpay.qq.com/cgi-bin/pay/qpay_order_query.cgi', null, 10);
        $qpayApi->setMchId('1490434181');
        $qpayApi->setMchKey('8525638f86969d1de5c51ad0494f4f13');
        $ret = $qpayApi->reqQpay($params);
        return QpayMchUtil::xmlToArray($ret);
    }
794323
public function transactionData($params)
    {
        Util::verifyKeys(
                self::$_transactionSignature,
                $params
                );
        $params["kind"] = TransparentRedirect::CREATE_TRANSACTION;
        $transactionType = isset($params['transaction']['type']) ?
            $params['transaction']['type'] :
            null;
        if ($transactionType != Transaction::SALE && $transactionType != Transaction::CREDIT) {
           throw new InvalidArgumentException(
                   'expected transaction[type] of sale or credit, was: ' .
                   $transactionType
                   );
        }

        return $this->_data($params);
    }
308006
private static function getCacheKeyForCall(array $params)
    {
        static $domainLevel = null;

        $params += $_GET;
        $keyStr = '';
        foreach ($params as $param) {
            $keyStr .= serialize($param);
        }

        $keyStr .= Request::domainPrefix(
            $domainLevel ?? $domainLevel = count(explode('.', Config::application('domain')))
        );

        return md5($keyStr);
    }
550199
public function contentDataAccess($params, &$smarty)
    {
        $contentId = $this->getRequest()->get('content_id');

        if ($contentId !== null) {
            return $this->dataAccessWithI18n(
                "Content",
                $params,
                ContentQuery::create()->filterByPrimaryKey($contentId)
            );
        }

        return '';
    }
367086
public static function getModelEquation(array $params): string
    {
        return sprintf('y = %fx + %f', $params[self::$M], $params[self::$B]);
    }
723047
public function to_smarty_php()
    {
        $code = '';
        for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
            if ($key + 2 < $cnt) {
                if ($this->subtrees[$key] instanceof _smarty_linebreak && $this->subtrees[$key + 1] instanceof _smarty_tag && $this->subtrees[$key + 1]->data == '' && $this->subtrees[$key + 2] instanceof _smarty_linebreak) {
                    $key = $key + 1;
                    continue;
                }
                if (substr($this->subtrees[$key]->data, -1) == '<' && $this->subtrees[$key + 1]->data == '' && substr($this->subtrees[$key + 2]->data, -1) == '?') {
                    $key = $key + 2;
                    continue;
                }
            }
            if (substr($code, -1) == '<') {
                $subtree = $this->subtrees[$key]->to_smarty_php();
                if (substr($subtree, 0, 1) == '?') {
                    $code = substr($code, 0, strlen($code) - 1) . '<<?php ?>?' . substr($subtree, 1);
                } elseif ($this->parser->asp_tags && substr($subtree, 0, 1) == '%') {
                    $code = substr($code, 0, strlen($code) - 1) . '<<?php ?>%' . substr($subtree, 1);
                } else {
                    $code .= $subtree;
                }
                continue;
            }
            if ($this->parser->asp_tags && substr($code, -1) == '%') {
                $subtree = $this->subtrees[$key]->to_smarty_php();
                if (substr($subtree, 0, 1) == '>') {
                    $code = substr($code, 0, strlen($code) - 1) . '%<?php ?>>' . substr($subtree, 1);
                } else {
                    $code .= $subtree;
                }
                continue;
            }
            if (substr($code, -1) == '?') {
                $subtree = $this->subtrees[$key]->to_smarty_php();
                if (substr($subtree, 0, 1) == '>') {
                    $code = substr($code, 0, strlen($code) - 1) . '?<?php ?>>' . substr($subtree, 1);
                } else {
                    $code .= $subtree;
                }
                continue;
            }
            $code .= $this->subtrees[$key]->to_smarty_php();
        }

        return $code;
    }
454670
public function formCollectionCount($params, \Smarty_Internal_Template $template)
    {
        /**
         * Get parameters
         */
        $form = $this->getInstanceFromParams($params);
        $row = $this->getSymfonyFormFromParams($params, "row");
        $collection = $this->resolveCollection($this->getParam($params, "collection"), $form);

        $hash = $this->initializeCollection($form, $collection, $row);

        return $this->formCollectionCount[$hash]["total_count"];
    }