PHP number_format Examples

PHP number_format - 30 examples found. These are the top rated real world PHP examples of number_format extracted from open source projects. You can rate examples to help us improve the quality of examples.
 /**
  * @param $phone
  * @param $code
  * @return bool
  * send sms to register&runner phone
  */
 private function smsSend($phone, $code)
 {
     $account = "mt6724";
     $password = "le44n8";
     $time = microtime();
     $time = explode(" ", $time);
     $time = $time[1] + $time[0];
     $time = number_format($time * 1000, 0, ".", "");
     $timestamp = $time;
     $access_token = md5($timestamp . $password);
     $receive = $phone;
     $smscontent = "你的验证码为{$code},有效期10分钟";
     $str = "account={$account}&timestamp={$timestamp}&access_token={$access_token}&receiver={$receive}&smscontent={$smscontent}&extcode=0";
     $url = "http://121.42.11.93:8001/interface/sendSms";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 1);
     // post数据
     curl_setopt($ch, CURLOPT_POST, 1);
     // post的变量
     curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
     $output = curl_exec($ch);
     curl_close($ch);
     $res = json_decode($output, TRUE);
     if ($res['res_code'] == '0') {
         return true;
     } else {
         return false;
     }
 }
Example #2
0
 function example_output($content)
 {
     $content = trim($content);
     echo PHP_EOL . $content . PHP_EOL . PHP_EOL;
     echo '# Sir\'s template is rendered above (';
     echo number_format(strlen($content)) . ' bytes).' . PHP_EOL;
 }
Example #3
0
function pretty_number($n, $floor = true)
{
    if ($floor) {
        $n = floor($n);
    }
    return number_format($n, 0, ",", ".");
}
Example #4
0
 /**
  * @inheritdoc
  */
 public function getSummary()
 {
     $timings = $this->calculateTimings();
     $queryCount = count($timings);
     $queryTime = number_format($this->getTotalQueryTime($timings) * 1000) . ' ms';
     return Yii::$app->view->render('panels/db/summary', ['timings' => $this->calculateTimings(), 'panel' => $this, 'queryCount' => $queryCount, 'queryTime' => $queryTime]);
 }
Example #5
0
 /**
  * Measure time between two events
  *
  * First call should be to $key = Debug::timer() with no params, or provide your own key that's not already been used
  * Second call should pass the key given by the first call to get the time elapsed, i.e. $time = Debug::timer($key).
  * Note that you may make multiple calls back to Debug::timer() with the same key and it will continue returning the 
  * elapsed time since the original call. If you want to reset or remove the timer, call removeTimer or resetTimer.
  *
  * @param string $key 
  * 	Leave blank to start timer. 
  *	Specify existing key (string) to return timer. 
  *	Specify new made up key to start a named timer. 
  * @param bool $reset If the timer already exists, it will be reset when this is true. 
  * @return string|int
  *
  */
 public static function timer($key = '', $reset = false)
 {
     // returns number of seconds elapsed since first call
     if ($reset && $key) {
         self::removeTimer($key);
     }
     if (!$key || !isset(self::$timers[$key])) {
         // start new timer
         preg_match('/(\\.[0-9]+) ([0-9]+)/', microtime(), $time);
         $startTime = doubleval($time[1]) + doubleval($time[2]);
         if (!$key) {
             $key = $startTime;
             while (isset(self::$timers[$key])) {
                 $key .= ".";
             }
         }
         self::$timers[$key] = $startTime;
         $value = $key;
     } else {
         // return timer
         preg_match('/(\\.[0-9]*) ([0-9]*)/', microtime(), $time);
         $endTime = doubleval($time[1]) + doubleval($time[2]);
         $startTime = self::$timers[$key];
         $runTime = number_format($endTime - $startTime, 4);
         $value = $runTime;
     }
     return $value;
 }
Example #6
0
 /**
  * Verilen taksit
  *
  * @param float $fiyat
  * @param integer $taksitSayisi
  * @return float
  */
 public function taksitHesapla($fiyat, $taksitSayisi)
 {
     if (!isset($this->vadeFarklari[$taksitSayisi])) {
         return false;
     }
     return number_format(($this->vadeFarklari[$taksitSayisi] + 100) * $fiyat / 100, 2, '.', '');
 }
Example #7
0
 function call_order($lng, $para, $filename = 'order', $outHTML = null)
 {
     $para = $this->fun->array_getvalue($para);
     $lngpack = $lng ? $lng : $this->CON['is_lancode'];
     $lng = $lng == 'big5' ? $this->CON['is_lancode'] : $lng;
     include admin_ROOT . 'datacache/' . $lng . '_pack.php';
     $cartid = $this->fun->eccode($this->fun->accept('ecisp_order_list', 'C'), 'DECODE', db_pscode);
     $cartid = stripslashes(htmlspecialchars_decode($cartid));
     $uncartid = !empty($cartid) ? unserialize($cartid) : null;
     $total = $this->fun->eccode($this->fun->accept('ecisp_order_productmoney', 'C'), 'DECODE', db_pscode);
     $total = empty($total) ? 0 : $total;
     $buylink = $this->get_link('order', array(), $lngpack);
     $this->pagetemplate->assign('lngpack', $LANPACK);
     $this->pagetemplate->assign('buylink', $buylink);
     $this->pagetemplate->assign('ordertotal', number_format($total, 2));
     $this->pagetemplate->assign('total', $total);
     $this->pagetemplate->assign('uncartid', count($uncartid));
     $this->pagetemplate->assign('cartid', $cartid);
     if (!empty($outHTML)) {
         $output = $this->pagetemplate->fetch(null, null, $outHTML);
     } else {
         $output = $this->pagetemplate->fetch($lng . '/lib/' . $filename);
     }
     return $output;
 }
function TampilkanDaftarProgramStudi()
{
    global $Cari;
    $Max = 50;
    $arrcr = explode(',', $Cari);
    $arrwhr = array();
    if (!empty($arrcr[0])) {
        $arrwhr[] = "(Nama like '%" . TRIM($arrcr[0]) . "%') ";
    }
    $whr = implode(' and ', $arrwhr);
    // Hitung jumlah baris
    $Jml = GetaField('perguruantinggi', "{$whr} and NA", 'N', "count(PerguruanTinggiID)");
    if ($Jml > $Max) {
        $_Jml = number_format($Jml);
        echo "<p><b>Catatan:</b> Jumlah program studi yang Anda cari mencapai: <b>{$_Jml}</b>, tetapi sistem membatasi\r\n      jumlah program studi yang ditampilkan dan hanya menampilkan: <b>{$Max}</b>.\r\n      Gunakan Nama program studi dengan lebih spesifik untuk membatasi\r\n      jumlah program studi yang ditampilkan.</p>\r\n\r\n      <p><b>Format Pencarian:</b> NamaProgramStudi</p>";
    }
    // Tampilkan
    $s = "select ProdiDiktiID, Nama\r\n    from prodidikti\r\n    where {$whr} and NA='N'\r\n    order by Nama limit {$Max}";
    $r = _query($s);
    $n = 0;
    echo "<p><table class=box cellspacing=1 cellpadding=4 width=100%>\r\n    <tr><th class=ttl>#</th>\r\n    <th class=ttl>Kode Prodi</th>\r\n    <th class=ttl>Nama</th>\r\n    </tr>";
    while ($w = _fetch_array($r)) {
        $n++;
        echo "<tr><td class=ul>{$n}</td>\r\n    <td class=ul><a href='javascript:kembalikan(\"{$w['ProdiDiktiID']}\", \"{$w['Nama']}\")'>{$w['ProdiDiktiID']}</a></td>\r\n    <td class=ul>{$w['Nama']}&nbsp;</td>\r\n    </tr>";
    }
    echo "</table></p>";
}
Example #9
0
 public function getUrl()
 {
     $this->addField('CustomerID', $this->getConfigValue('customerID'));
     $this->addField('UserName', $this->getConfigValue('userName'));
     $this->addField('Amount', number_format($this->details->amount->get(), 2, '.', ''));
     $this->addField('Currency', $this->details->currency->get());
     // customer information
     $this->addField('CustomerEmail', $this->details->email->get());
     $this->addField('CustomerFirstName', $this->details->firstName->get());
     $this->addField('CustomerLastName', $this->details->lastName->get());
     $this->addField('CustomerAddress', $this->details->address->get());
     $this->addField('CustomerCity', $this->details->city->get());
     $this->addField('CustomerState', $this->details->state->get());
     $this->addField('CustomerPostcode', $this->details->postalCode->get());
     $this->addField('CustomerCountry', $this->details->country->get());
     $this->addField('MerchantOption1', $this->returnUrl);
     $this->addField('MerchantOption2', $this->details->currency->get());
     $this->addField('MerchantOption3', '');
     $this->addField('InvoiceDescription', $this->getConfigValue('invoiceDescription'));
     // order information
     $this->addField('MerchantReference', $this->details->invoiceID->get());
     $this->addField('CancelUrl', $this->siteUrl);
     $this->addField('ReturnUrl', $this->notifyUrl);
     preg_match('/URI>(.*)<\\/URI>/', $this->fetchUrl($this->getRequestUrl()), $match);
     return array_pop($match);
 }
Example #10
0
 public function getLoveHistory($page, $justUser = false)
 {
     $front = Frontend::getInstance();
     $page--;
     $l = $this->getLimit() * $page;
     $where = '';
     $sql = "SELECT count(*) " . "FROM " . LOVE_LOVE;
     $res = mysql_query($sql);
     $row = mysql_fetch_row($res);
     $loves = $row[0];
     $sql = "SELECT count(*) " . "FROM " . LOVE_LOVE . " " . "WHERE " . LOVE_LOVE . ".receiver = '" . $front->getUser()->getUsername() . "' " . "OR " . LOVE_LOVE . ".giver = '" . $front->getUser()->getUsername() . "' " . ($sql .= $justUser ? '' : "OR " . LOVE_LOVE . ".company_id = '" . $front->getUser()->getCompany_id() . "' ");
     $sql .= $where . " " . "ORDER BY id DESC";
     $res = mysql_query($sql);
     $row = mysql_fetch_row($res);
     $count = $row[0];
     $cPages = ceil($count / $this->getLimit());
     $sql = "SELECT id,giver,receiver,why,private,TIMESTAMPDIFF(SECOND,at,NOW()) as delta " . "FROM " . LOVE_LOVE . " " . "WHERE " . LOVE_LOVE . ".receiver = '" . $front->getUser()->getUsername() . "' " . "OR " . LOVE_LOVE . ".giver = '" . $front->getUser()->getUsername() . "' ";
     $sql .= $justUser ? '' : "OR " . LOVE_LOVE . ".company_id = '" . $front->getUser()->getCompany_id() . "' ";
     $sql .= $where . " " . "ORDER BY id DESC " . "LIMIT " . $l . "," . $this->getLimit();
     $res = mysql_query($sql);
     // Construct json for history
     $this->pages = array(array($page, $cPages, number_format($loves)));
     for ($i = 1; $row = mysql_fetch_assoc($res); $i++) {
         $givernickname = getNickName($row['giver']);
         $givernickname = !empty($givernickname) ? $givernickname : $row['giver'];
         $receivernickname = getNickName($row['receiver']);
         $receivernickname = !empty($receivernickname) ? $receivernickname : $row['receiver'];
         $why = $row['why'];
         if ($row['private']) {
             $why .= " (love sent quietly)";
         }
         $history[] = array("id" => $row['id'], "giver" => $row['giver'], "giverNickname" => $givernickname, "receiver" => $row['receiver'], "receiverNickname" => $receivernickname, "why" => $why, "delta" => Utils::relativeTime($row['delta']));
     }
     return $history;
 }
Example #11
0
function bjtable($res, $frame_caption)
{
    $htmlout = '';
    $htmlout .= begin_frame($frame_caption, true);
    $htmlout .= begin_table();
    $htmlout .= "<tr>\r\n\t<td class='colhead'>Rank</td>\r\n\t<td class='colhead' align='left'>User</td>\r\n\t<td class='colhead' align='right'>Wins</td>\r\n\t<td class='colhead' align='right'>Losses</td>\r\n\t<td class='colhead' align='right'>Games</td>\r\n\t<td class='colhead' align='right'>Percentage</td>\r\n\t<td class='colhead' align='right'>Win/Loss</td>\r\n\t</tr>";
    $num = 0;
    while ($a = mysqli_fetch_assoc($res)) {
        ++$num;
        //==Calculate Win %
        $win_perc = number_format($a['wins'] / $a['games'] * 100, 1);
        //==Add a user's +/- statistic
        $plus_minus = $a['wins'] - $a['losses'];
        if ($plus_minus >= 0) {
            $plus_minus = mksize(($a['wins'] - $a['losses']) * 100 * 1024 * 1024);
        } else {
            $plus_minus = "-";
            $plus_minus .= mksize(($a['losses'] - $a['wins']) * 100 * 1024 * 1024);
        }
        $htmlout .= "<tr><td>{$num}</td><td align='left'>" . "<b><a href='userdetails.php?id=" . $a['id'] . "'>" . $a['username'] . "</a></b></td>" . "<td align='right'>" . number_format($a['wins'], 0) . "</td>" . "<td align='right'>" . number_format($a['losses'], 0) . "</td>" . "<td align='right'>" . number_format($a['games'], 0) . "</td>" . "<td align='right'>{$win_perc}</td>" . "<td align='right'>{$plus_minus}</td>" . "</tr>\n";
    }
    $htmlout .= end_table();
    $htmlout .= end_frame();
    return $htmlout;
}
Example #12
0
 /**
  * Run
  */
 public function run()
 {
     // Authenticate
     $this->authenticate();
     // Failed to get account details
     if (!($account = $this->api->getAccount())) {
         $this->abort('Unable to fetch account');
     }
     // Get last workspace
     $workspace = $account->getLastWorkspace();
     // Get summary report for all hours
     $summary = $this->api->getMemberTimesheetReport($workspace, $account);
     // Account
     $this->line();
     $this->line('Account:');
     $this->line('   %-15s: %s', 'Id', $account->getId());
     $this->line('   %-15s: %s', 'Created', date('Y-m-d H:i', $account->getCreatedTime()));
     $this->line('   %-15s: %s', 'Last workspace', $account->getLastWorkspaceId());
     $this->line('   %-15s: %s', 'Company', $workspace->getCompanyName());
     $this->line('   %-15s: %s', 'First Name', $account->getFirstName());
     $this->line('   %-15s: %s', 'Last Name', $account->getLastName());
     $this->line('   %-15s: %s', 'Email', $account->getEmailAddress());
     $this->line();
     // Hours summary
     $this->line('Hours:');
     $this->line('   %-15s: %s', 'Expected', number_format($summary->getRequiredHours(), 2));
     $this->line('   %-15s: %s', 'Logged', number_format($summary->getLoggedHours(), 2));
     $this->line('   %-15s: %s', 'Unlogged', number_format($summary->getUnloggedHours(), 2));
     $this->line('   %-15s: %s', 'Summed', number_format($summary->getTotalHours(), 2));
     $this->line('   %-15s: %s', 'Offset', ($summary->getOffsetHours() > 0 ? '+' : '') . number_format($summary->getOffsetHours(), 2));
     $this->line();
 }
Example #13
0
 function sendVariables($path_url, $pp_vals)
 {
     $this->_POST1 = array();
     $this->_POST1['instId'] = $pp_vals['wp_instId'];
     $this->_POST1['item_number'] = time() . rand(0, 1000);
     if (isset($_POST['force_inv_no'])) {
         $this->_POST1['item_number'] = $_POST['force_inv_no'];
     }
     $this->_POST1['cartId'] = $this->_POST1['item_number'];
     $this->_POST1['amount'] = number_format($_POST['gross_amount'], 2);
     $this->_POST1['currency'] = $pp_vals['wp_currency'];
     $this->_POST1['desc'] = $_POST['desc'];
     if ($this->demo_mode) {
         $this->_POST1['testMode'] = 100;
     }
     $this->_POST1['M_pp'] = "WorldPay";
     $this->_POST1['M_item_no'] = $this->_POST1['item_number'];
     $this->_POST1['name'] = $_POST['name'];
     $this->_POST1['tel'] = $_POST['telephone'];
     $this->_POST1['address'] = $_POST['address'];
     $this->_POST1['city'] = $_POST['city'];
     $this->_POST1['state'] = $_POST['state'];
     $this->_POST1['postcode'] = $_POST['zip'];
     $this->_POST1['country'] = $_POST['country'];
     $this->_POST1['email'] = $_POST['email'];
 }
Example #14
0
 /**
  * Returns the given amount as a formatted string according to the
  * given currency.
  * IMPORTANT NOTE:
  * The amount must always be the smallest unit passed as a string
  * or int! It is a very bad idea to use float for monetary
  * calculations if you need exact values, therefore
  * this method won't accept float values.
  * Examples:
  *      format (500, 'EUR');      --> '5,00 EUR'
  *      format (4.23, 'EUR');     --> FALSE
  *      format ('872331', 'EUR'); --> '8.723,31 EUR'.
  *
  * @param int|string $amount Amount to be formatted. Must be the smalles unit
  * @param string $currencyKey ISO 3 letter code of the currency
  * @param bool $withSymbol If set the currency symbol will be rendered
  *
  * @return string|bool String representation of the amount including currency
  *      symbol(s) or FALSE if $amount was of the type float
  */
 public static function format($amount, $currencyKey, $withSymbol = true)
 {
     if (is_float($amount)) {
         return false;
     }
     /**
      * Currency repository.
      *
      * @var CurrencyRepository
      */
     $currencyRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\CurrencyRepository');
     $currency = $currencyRepository->findByIso3($currencyKey);
     if (empty($currency)) {
         return false;
     }
     $formattedAmount = number_format($amount / $currency['cu_sub_divisor'], $currency['cu_decimal_digits'], $currency['cu_decimal_point'], $currency['cu_thousands_point']);
     if ($withSymbol) {
         $wholeString = $formattedAmount;
         if (!empty($currency['cu_symbol_left'])) {
             $wholeString = $currency['cu_symbol_left'] . ' ' . $wholeString;
         }
         if (!empty($currency['cu_symbol_right'])) {
             $wholeString .= ' ' . $currency['cu_symbol_right'];
         }
     } else {
         $wholeString = $formattedAmount;
     }
     return $wholeString;
 }
 function json_encode($data)
 {
     if (is_array($data)) {
         $ret = array();
         // OBJECT
         if (array_keys($data) !== range(0, count($data) - 1)) {
             foreach ($data as $key => $val) {
                 $ret[] = kcfinder_json_string_encode($key) . ':' . json_encode($val);
             }
             return "{" . implode(",", $ret) . "}";
             // ARRAY
         } else {
             foreach ($data as $val) {
                 $ret[] = json_encode($val);
             }
             return "[" . implode(",", $ret) . "]";
         }
         // BOOLEAN OR NULL
     } elseif (is_bool($data) || $data === null) {
         return $data === null ? "null" : ($data ? "true" : "false");
     } elseif (is_float($data)) {
         return rtrim(rtrim(number_format($data, 14, ".", ""), "0"), ".");
     } elseif (is_int($data)) {
         return $data;
     }
     // STRING
     return kcfinder_json_string_encode($data);
 }
Example #16
0
 public function getTatraPayURL($amount, $returnUrl, $variableSymbol = "", $specificSymbol = "", $constantSymbol = "", $paymentReference = "")
 {
     $url = "https://moja.tatrabanka.sk/cgi-bin/e-commerce/start/e-commerce.jsp";
     $query = "?PT=TatraPay&MID=" . config('tatrabanka.merchant-id');
     $query .= "&AMT=" . number_format($amount, 2, '.', '');
     $query .= "&CURR=978";
     $signature = config('tatrabanka.merchant-id') . number_format($amount, 2, '.', '') . '978';
     if ($variableSymbol !== "") {
         $query .= "&VS=" . $variableSymbol;
         $query .= "&SS=" . $specificSymbol;
         $query .= "&CS=" . $constantSymbol;
         $signature .= $variableSymbol . $specificSymbol . $constantSymbol;
     } else {
         $query .= "&REF=" . $paymentReference;
         $signature .= $paymentReference;
     }
     $query .= "&RURL=" . $returnUrl;
     $signature .= $returnUrl;
     $signature = $this->getSignature($signature);
     $query .= "&SIGN=" . $signature;
     if (config('tatrabanka.notification-number')) {
         $query .= '&RSMS=' . config('tatrabanka.notification-number');
     }
     if (config('tatrabanka.notification-email')) {
         $query .= '&REM=' . config('tatrabanka.notification-email');
     }
     return $url . $query;
 }
 function afterFind(&$results)
 {
     foreach ($results as $key => &$value) {
         $value['SalaryRange']['range'] = number_format($value['SalaryRange']['range']);
     }
     return $results;
 }
Example #18
0
function percent($a, $t)
{
    $count1 = $a / $t;
    $count2 = $count1 * 100;
    $count = number_format($count2, 0);
    return $count;
}
Example #19
0
 protected function initContent()
 {
     $this->setTitle('Client');
     $error = $this->getAction()->getError();
     $data = $this->getAction()->getData();
     $html = '';
     if ($error) {
         $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']);
     }
     if (!isset($data['info'])) {
         return $html;
     }
     $info = $data['info'];
     $displayInfo = $info['uaData']['displayInfo'];
     $this->setSubTitle('#' . $info['id']);
     $html .= '<h3>Information</h3>' . '<div class="row">' . '<div class="span2">' . BrowserInfo::buildIconHtml($displayInfo) . '</div>' . '<div class="span10">' . '<table class="table table-striped">' . '<tbody>' . '<tr><th>Name</th><td>' . html_tag('a', array('href' => $info['viewUrl']), $info['name']) . '</td></tr>' . '<tr><th>UA ID</th><td>' . '<code>' . htmlspecialchars($info['uaID']) . '</code>' . '<tr><th>User-Agent</th><td>' . '<tt>' . htmlspecialchars($info['uaRaw']) . '</tt>' . '</td></tr>' . '<tr><th>Session age</th><td>' . number_format(intval($info['sessionAge'])) . 's' . '</td></tr>' . '<tr><th>Connected</th><td>' . self::getPrettyDateHtml($info, 'connected') . '</td></tr>' . '<tr><th>Last ping</th><td>' . self::getPrettyDateHtml($info, 'pinged') . '</td></tr>' . '</tbody></table>' . '</div>' . '</div>';
     $html .= '<h3>Log</h3>';
     if (!$data['results']) {
         $html .= '<div class="alert alert-info">Client has no run log.</div>';
     } else {
         $html .= '<table class="table table-striped">' . '<thead><tr><th>Result</th><th>Project</th></th><th>Run</th><th>Status</th>' . '<tbody>';
         foreach ($data['results'] as $run) {
             $html .= '<tr>' . '<td>' . html_tag('a', array('href' => $run['viewUrl']), '#' . $run['id']) . '</td>' . '<td>' . ($run['project'] ? html_tag('a', array('href' => $run['project']['viewUrl']), $run['project']['display_title']) : '-') . '</td>' . '<td>' . ($run['job'] && $run['run'] ? html_tag('a', array('href' => $run['job']['viewUrl']), $run['job']['nameText'] . ' / ' . $run['run']['name']) : '<em>Job has been deleted</em>') . '</td>' . JobPage::getJobStatusHtmlCell($run['status']) . '</tr>';
         }
         $html .= '</tbody></table>';
     }
     return $html;
 }
	function get_cart_summ()
	{
		$cart =& cart :: instance();
		$locale = locale :: instance();
		
		return number_format($cart->get_total_summ(), $locale->fract_digits, $locale->decimal_symbol, $locale->thousand_separator);
	}
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     $chunksCollected = 0;
     $entitiesCollected = 0;
     $tilesCollected = 0;
     $memory = memory_get_usage();
     foreach ($sender->getServer()->getLevels() as $level) {
         $diff = [count($level->getChunks()), count($level->getEntities()), count($level->getTiles())];
         $level->doChunkGarbageCollection();
         $level->unloadChunks(true);
         $chunksCollected += $diff[0] - count($level->getChunks());
         $entitiesCollected += $diff[1] - count($level->getEntities());
         $tilesCollected += $diff[2] - count($level->getTiles());
         $level->clearCache(true);
     }
     $cyclesCollected = $sender->getServer()->getMemoryManager()->triggerGarbageCollector();
     $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "Garbage collection result" . TextFormat::GREEN . " ----");
     $sender->sendMessage(TextFormat::GOLD . "Chunks: " . TextFormat::RED . number_format($chunksCollected));
     $sender->sendMessage(TextFormat::GOLD . "Entities: " . TextFormat::RED . number_format($entitiesCollected));
     $sender->sendMessage(TextFormat::GOLD . "Tiles: " . TextFormat::RED . number_format($tilesCollected));
     $sender->sendMessage(TextFormat::GOLD . "Cycles: " . TextFormat::RED . number_format($cyclesCollected));
     $sender->sendMessage(TextFormat::GOLD . "Memory freed: " . TextFormat::RED . number_format(round(($memory - memory_get_usage()) / 1024 / 1024, 2)) . " MB");
     return true;
 }
Example #22
0
 /**
  * Perform a search and return a JSON response.
  *
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function searchAction(Request $request)
 {
     $queryString = $request->query->get('q');
     $category = $request->query->get('category', null);
     $locale = $request->query->get('locale', null);
     $page = $this->listRestHelper->getPage();
     $limit = $this->listRestHelper->getLimit();
     $aggregateHits = [];
     $startTime = microtime(true);
     $categories = $category ? [$category] : $this->searchManager->getCategoryNames();
     foreach ($categories as $category) {
         $query = $this->searchManager->createSearch($queryString);
         if ($locale) {
             $query->locale($locale);
         }
         if ($category) {
             $query->category($category);
         }
         foreach ($query->execute() as $hit) {
             $aggregateHits[] = $hit;
         }
     }
     $time = microtime(true) - $startTime;
     $adapter = new ArrayAdapter($aggregateHits);
     $pager = new Pagerfanta($adapter);
     $pager->setMaxPerPage($limit);
     $pager->setCurrentPage($page);
     $representation = new SearchResultRepresentation(new CollectionRepresentation($pager->getCurrentPageResults(), 'result'), 'sulu_search_search', ['locale' => $locale, 'query' => $query, 'category' => $category], (int) $page, (int) $limit, $pager->getNbPages(), 'page', 'limit', false, count($aggregateHits), $this->getCategoryTotals($aggregateHits), number_format($time, 8));
     $view = View::create($representation);
     $context = SerializationContext::create();
     $context->enableMaxDepthChecks();
     $context->setSerializeNull(true);
     $view->setSerializationContext($context);
     return $this->viewHandler->handle($view);
 }
Example #23
0
 public function afterFind()
 {
     $this->cost = number_format($this->cost / 100, 2, '.', ',');
     $this->timestamp = gmdate('dS-M-Y', $this->timestamp);
     $this->service_status = $this->service_status === '1' ? "Active" : "Inactive";
     return parent::afterFind();
 }
Example #24
0
 public function getData()
 {
     $data = array();
     $data['items'] = array();
     $data['thd'] = array('Concepto', 'Cantidad', 'Nro. de Identificacion', 'Nombre y Descripcion de los Elementos', 'Incorporacion Bs.', 'Desincorporacion Bs.');
     $data['twf'] = array(13, 45, 14, 130, 27, 27);
     $data['taf'] = array('C', 'C', 'C', 'C', 'R', 'R');
     $data['tdf'] = array('', 'TOTAL', 0, '', 0, 0);
     $data['tdf'][2] = 0;
     //cantidad
     $data['tdf'][4] = 0;
     //incorporacion
     $data['tdf'][5] = 0;
     //desincorporacion
     $items = $this->getMovimientos();
     $i = 0;
     $data['thw'] = array(13, 15, 15, 15, 14, 30, 100, 27, 27);
     $data['ta'] = array('C', 'C', 'C', 'C', 'C', 'C', 'L', 'R', 'R');
     foreach ($items as $item) {
         $data['tdf'][2] += $item['cantidad'];
         $data['tdf'][4] += $item['incorporacion'];
         $data['tdf'][5] += $item['desincorporacion'];
         $data['items'][$i] = array($item['grupo'], $item['subgrupo'], $item['seccion'], $item['concepto'], $item['cantidad'], $item['codigo'], $item['descripcion'], number_format($item['incorporacion'], 2, ',', '.'), number_format($item['desincorporacion'], 2, ',', '.'));
         $i++;
     }
     $data['tdf'][4] = number_format($data['tdf'][4], 2, ',', '.');
     $data['tdf'][5] = number_format($data['tdf'][5], 2, ',', '.');
     return $data;
 }
Example #25
0
 public static function valorMonetario($valor)
 {
     if (empty($valor)) {
         $valor = 0;
     }
     return number_format($valor, 2, ',', '.');
 }
Example #26
0
function get_user_paid_expenses_test($userid_array)
{
    if (is_array($userid_array)) {
        $userids = implode(",", $userid_array);
    } else {
        $userids = $userid_array;
    }
    $sql = "SELECT user_id as userid, expense_id as exid, group_id, amount, UNIX_TIMESTAMP(expense_date) AS expensedate, \n            description FROM expenses WHERE user_id in ({$userids})";
    if (!($result = mysql_query($sql))) {
        return false;
    } else {
        $total = 0;
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['amount'] = $row['amount'];
            $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['expense_date'] = date("j M Y", $row['expensedate']);
            $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['description'] = $row['description'];
            $paid['users'][$row['userid']]['groups'][$row['group_id']]['group_total'] += $row['amount'];
            $paid['users'][$row['userid']]['user_total'] += $row['amount'];
            $total += $row['amount'];
            // format totals with two decimals
            $paid['users'][$row['userid']]['groups'][$row['group_id']]['total'] = number_format($paid['users'][$row['userid']]['groups'][$row['group_id']]['total'], DECIMALS, DSEP, TSEP);
            $paid['users'][$row['userid']]['total'] = number_format($paid['users'][$row['userid']]['total'], DECIMALS, DSEP, TSEP);
            $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['running_total'] += $row['amount'] + $last_running[$row['userid']][$row['group_id']];
            $last_running[$row['userid']][$row['group_id']] = $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['running_total'];
        }
        $paid['total'] = number_format($total, DECIMALS, DSEP, TSEP);
    }
    // array structure: ['users'][$userid]['groups'][$groupid][$expenseid]['amount|expense_date|description']
    return $paid;
}
Example #27
0
function SSL_COMPRA_FACTURA($transaccion, $salida = 'enlinea')
{
    $c = sprintf('SELECT procon.`codigo_producto`, procon.`titulo` AS "titulo_contenedor", provar.`descripcion` AS "titulo_variedad", provar.foto, comcon.`codigo_compra`, comcon.`codigo_usuario`, comcon.`codigo_variedad`, FORMAT(comcon.`precio_grabado`,2) AS precio_grabado, FORMAT(comcon.`precio_envio`,2) AS precio_envio, comcon.`direccion_entrega`, comcon.`fecha_entrega`, comcon.`tarjeta_de`, comcon.`tarjeta_para`, comcon.`tarjeta_cuerpo`, comcon.`usuario_notas`, comcon.`transaccion`, comcon.`fecha`, `estado`, `correo_contacto`, `telefono_remitente`, `usuario_notas`, `nombre_t_credito`,`estado_notas` FROM `flores_SSL_compra_contenedor` AS comcon LEFT JOIN `flores_producto_variedad` AS provar USING(codigo_variedad) LEFT JOIN `flores_producto_contenedor` AS procon USING(codigo_producto)  WHERE transaccion="%s"', db_codex($transaccion));
    $r = db_consultar($c);
    if (!mysql_num_rows($r)) {
        echo '<p>Lo sentimos, tal factura no existe</p>';
        return;
    }
    $f = mysql_fetch_assoc($r);
    $buffer = '<style>';
    $buffer .= 'table {border-collapse:collapse;}';
    $buffer .= 'table th{border-top:thin solid #c0c0c0;border-left:thin solid #c0c0c0;border-right:thin solid #c0c0c0;background-color:#eee;}';
    $buffer .= 'table td{border-top:thin solid #c0c0c0;border:1px solid #c0c0c0;}';
    $buffer .= '</style>';
    $buffer .= '<table style="width:100%">';
    $campo = array('Factura' => $f['transaccion'], 'F360' => $f['codigo_producto'] . ':' . $f['codigo_variedad'], 'Producto' => $f['titulo_contenedor'], 'Variedad' => $f['titulo_variedad'], 'Precio' => '$' . $f['precio_grabado'], 'Recargo de envio' => '$' . $f['precio_envio'], 'Total' => '$' . number_format($f['precio_grabado'] + $f['precio_envio'], 2, '.', ','), 'Remitente' => $f['tarjeta_de'], 'Destinatario' => $f['tarjeta_para'], 'Tarjeta' => $f['tarjeta_cuerpo'], 'Enviar a' => $f['direccion_entrega'], 'Fecha pedido' => date('d/m/Y'), 'Fecha de entrega' => date('d/m/Y', strtotime($f['fecha_entrega'])), 'Correo contacto' => $f['correo_contacto'], 'Teléfono remitente' => $f['telefono_remitente'], 'Notas adicionales del comprador' => $f['usuario_notas'] ? $f['usuario_notas'] : '[No especificó nada en especial]');
    foreach ($campo as $clave => $valor) {
        $buffer .= sprintf('<tr><td>%s</td><td style="font-weight:bold">%s</td></tr>', $clave, $valor);
    }
    $buffer .= '</table>';
    switch ($salida) {
        case 'enlinea':
            return array($buffer, $f);
            break;
        case 'pdf':
            $buffer = '<html><body>' . $buffer . '</body></html>';
            require_once 'PHP/dompdf/dompdf_config.inc.php';
            $dompdf = new DOMPDF();
            $dompdf->load_html($buffer);
            //$dompdf->render();
            //$dompdf->stream("factura-$transaccion.pdf");
    }
}
Example #28
0
 /**
  * {@inheritdoc}
  */
 public function filterValue($value)
 {
     $precision = $this->getOption('precision');
     $roundmode = $this->getOption('round_mode');
     $decimals = $this->getOption('decimals');
     $decPoint = $this->getOption('dec_point');
     $thousands = $this->getOption('thousands_sep');
     $currencyField = $this->getOption('currency_field');
     $currencyValue = $this->getOption('currency');
     $mappingFields = $this->getOption('field_mapping');
     $currencySeparator = $this->getOption('value_currency_separator');
     if (!isset($currencyField) && !isset($currencyValue)) {
         throw new DataGridColumnException(sprintf('At least one option from "currency" and "currency_field" must be defined in "%s" field.', $this->getName()));
     }
     $currency = $currencyValue;
     if (isset($currencyField)) {
         if (!in_array($currencyField, $mappingFields)) {
             throw new DataGridColumnException(sprintf('There is no field with name "%s".', $currencyField));
         }
         $currency = $value[$currencyField];
         unset($value[$currencyField]);
     }
     foreach ($value as $fieldName => &$val) {
         if (empty($val)) {
             continue;
         }
         $val = round($val, $precision, $roundmode);
         $val = number_format($val, $decimals, $decPoint, $thousands);
         $val = $val . $currencySeparator . $currency;
     }
     return $value;
 }
Example #29
0
function twitter_time($time)
{
    // Get the number of seconds elapsed since this date
    $delta = time() - strtotime($time);
    if ($delta < 60) {
        return 'minder dan een minuut geleden';
    } else {
        if ($delta < 120) {
            return 'ongeveer een minuut geleden';
        } else {
            if ($delta < 60 * 60) {
                return floor($delta / 60) . ' minuten geleden';
            } else {
                if ($delta < 120 * 60) {
                    return 'ongeveer een uur geleden';
                } else {
                    if ($delta < 24 * 60 * 60) {
                        return floor($delta / 3600) . ' uren geleden';
                    } else {
                        if ($delta < 48 * 60 * 60) {
                            return 'gisteren';
                        } else {
                            return number_format(floor($delta / 86400)) . ' dagen geleden';
                        }
                    }
                }
            }
        }
    }
}
 function makeButton()
 {
     global $sabnzbd_ip;
     global $sabnzbd_port;
     global $sabnzbd_api;
     $sabnzbdXML = simplexml_load_file('http://' . $sabnzbd_ip . ':' . $sabnzbd_port . '/api?mode=qstatus&output=xml&apikey=' . $sabnzbd_api);
     if ($sabnzbdXML->state == 'Downloading') {
         $speed = $sabnzbdXML->speed;
         if (strpbrk($speed, 'K')) {
             // This converts the speed from KBps or MBps to Mbps
             $convertedSpeed = number_format(substr($speed, 0, strlen($speed) - 2) * 8 / 1024, 1);
         } else {
             $convertedSpeed = number_format(substr($speed, 0, strlen($speed) - 2) * 8, 0);
         }
         $icon = '<i class="icon-' . ($this->status ? 'download-alt' : 'remove') . ' icon-white"></i>';
         $txt = $this->status ? $convertedSpeed . 'Mb' : 'Offline';
     } else {
         $icon = '<i class="icon-' . ($this->status ? 'ok' : 'remove') . ' icon-white"></i>';
         $txt = $this->status ? 'Online' : 'Offline';
     }
     $btn = $this->status ? 'success' : 'warning';
     $prefix = $this->url == "" ? '<button style="width:62px" class="btn btn-xs btn-' . $btn . ' disabled">' : '<a href="' . $this->url . '" style="width:62px" class="btn btn-xs btn-' . $btn . '">';
     $suffix = $this->url == "" ? '</button>' : '</a>';
     return $prefix . $icon . " " . $txt . $suffix;
 }