Beispiel #1
0
 protected function setUp()
 {
     parent::setUp();
     $this->_object = RUtils::dt();
     $this->_date = '1988-01-01 6:40:34';
     $this->_defaultParams = array('date' => $this->_date, 'timezone' => 'UTC');
 }
Beispiel #2
0
<?php

namespace php_rutils\doc\examples;

use php_rutils\RUtils;
require '_begin.php';
//Translify
echo RUtils::translit()->translify('Муха - это маленькая птичка'), PHP_EOL;
//Result: Muxa - e`to malen`kaya ptichka
//Detranslify
echo RUtils::translit()->detranslify("Muxa - e`to malen`kaya ptichka"), PHP_EOL;
//Result: Муха - это маленькая птичка
//Prepare to use in URLs or file/dir name
echo RUtils::translit()->slugify('Муха — это маленькая птичка'), PHP_EOL;
//Result: muha-eto-malenkaya-ptichka
require '_end.php';
Beispiel #3
0
 protected function setUp()
 {
     parent::setUp();
     $this->_object = RUtils::translit();
 }
Beispiel #4
0
 private function _createDistanceData(\DateInterval $interval)
 {
     $distanceData = array();
     //table of word representations
     $numeral = RUtils::numeral();
     $years = $interval->y;
     if ($years) {
         $distanceData['y'] = $numeral->getPlural($years, self::$_YEAR_VARIANTS);
     }
     $months = $interval->m;
     if ($months) {
         $distanceData['m'] = $numeral->getPlural($months, self::$_MONTH_VARIANTS);
     }
     $days = $interval->d;
     if ($days) {
         $distanceData['d'] = $numeral->getPlural($days, self::$_DAY_VARIANTS);
     }
     $hours = $interval->h;
     if ($hours) {
         $distanceData['h'] = $numeral->getPlural($hours, self::$_HOUR_VARIANTS);
     }
     $minutes = $interval->i;
     if ($minutes) {
         $distanceData['i'] = $numeral->getPlural($minutes, self::$_MINUTE_VARIANTS);
     }
     return $distanceData;
 }
Beispiel #5
0
 protected function setUp()
 {
     parent::setUp();
     $this->_object = RUtils::numeral();
 }
Beispiel #6
0
$toTime = new \DateTime('05-06-1945');
//Unix timestamp and string also available
echo RUtils::dt()->distanceOfTimeInWords($toTime), PHP_EOL;
//Result: 68 лет назад
$toTime = strtotime('05-06-1945');
$fromTime = null;
//now
$accuracy = RUtils::ACCURACY_MINUTE;
//years, months, days, hours, minutes
echo RUtils::dt()->distanceOfTimeInWords($toTime, $fromTime, $accuracy), PHP_EOL;
//Result: 68 лет, 4 месяца, 21 день, 19 часов, 12 минут назад
//Time distance from fixed date in past to date in future
$fromTime = '1988-01-01 11:40';
$toTime = '2088-01-01 12:35';
$accuracy = RUtils::ACCURACY_MINUTE;
//years, months, days, hours, minutes
echo RUtils::dt()->distanceOfTimeInWords($toTime, $fromTime, $accuracy), PHP_EOL;
//Result: через 100 лет, 55 минут
//Get age by date
$birthDate = strtotime('today - 25 years');
echo RUtils::dt()->getAge($birthDate), PHP_EOL;
//Result: 25
//Custom prefix in
Dt::$PREFIX_IN = 'опосля';
$fromTime = '1988-01-01 11:40';
$toTime = '2088-01-01 12:35';
$accuracy = RUtils::ACCURACY_MINUTE;
//years, months, days, hours, minutes
echo RUtils::dt()->distanceOfTimeInWords($toTime, $fromTime, $accuracy), PHP_EOL;
//Result: опосля 100 лет, 55 минут
require '_end.php';
Beispiel #7
0
namespace php_rutils\doc\examples;

use php_rutils\RUtils;
use php_rutils\TypoRules;
require '_begin.php';
$text = <<<TEXT
...Когда В. И. Пупкин увидел в газете ( это была "Сермяжная правда" № 45) рубрику Weather Forecast (r),
он не поверил своим глазам - температуру обещали +-451F.
TEXT;
//Standard rules
echo RUtils::typo()->typography($text), PHP_EOL;
/**
 * Result:
 * ...Когда В. И. Пупкин увидел в газете (это была «Сермяжная правда» №45) рубрику Weather Forecast®,
 * он не поверил своим глазам — температуру обещали ±451°F.
 */
//Extended rules
echo RUtils::typo()->typography($text, TypoRules::$EXTENDED_RULES), PHP_EOL;
/**
 * Result:
 * …Когда В. И. Пупкин увидел в газете (это была «Сермяжная правда» №45) рубрику Weather Forecast®,
 * он не поверил своим глазам — температуру обещали ±451 °F.
 */
//Custom rules
echo RUtils::typo()->typography($text, array(TypoRules::DASHES, TypoRules::CLEAN_SPACES)), PHP_EOL;
/**
 * Result:
 * ...Когда В. И. Пупкин увидел в газете (это была "Сермяжная правда" № 45) рубрику Weather Forecast (r),
 * он не поверил своим глазам — температуру обещали +-451F.
 */
require '_end.php';
Beispiel #8
-1
function plural($num, $arg, $type = '1')
{
    if ($type == 1) {
        return RUtils::numeral()->getPlural($num, $arg);
    }
    if ($type == 2) {
        return RUtils::numeral()->choosePlural($num, $arg);
    }
}
 public function wizardAction($step, Request $request)
 {
     $stepData = $request->getSession()->get('stepData', []);
     $form = $this->createForm(new InvoiceWizard($step));
     $form->handleRequest($request);
     if ($request->isMethod('GET') && isset($stepData['pbl'])) {
         $form->get('pbl')->setData($stepData['pbl']);
     }
     if ($step == 1) {
         $request->getSession()->set('stepData', null);
         $stepData = [];
     }
     if (isset($request->get('sportmaster_wizard')['previous'])) {
         return $this->redirect($this->generateUrl('sportmaster_invoice_number'));
     }
     $shipmentData = [];
     if (isset($stepData['shipment'])) {
         $shipmentData = $stepData['shipment'];
     }
     if ($step == 3) {
         $report = new InvoicingReport($this->container, $shipmentData);
         $report->export();
     }
     if ($request->isMethod('POST')) {
         if ($form->isValid()) {
             $data = $form->getData();
             if ($step == 1) {
                 $env = $this->container->getParameter("kernel.environment");
                 $host = $env == 'prod' ? 'mowtools.europe.panorg.com' : 'localhost';
                 $url = 'http://' . $host . '/sportmaster/jsonSO.php';
                 $client = new GuzzleHttp\Client(['timeout' => 0, 'allow_redirects' => false]);
                 $response = $client->post($url, ['form_params' => ['PBL' => $data['pbl']]]);
                 $result = json_decode((string) $response->getBody(), true);
                 if ($result) {
                     if (!isset($result['error'])) {
                         $stepData = ['pbl' => $data['pbl'], 'shipment' => current($result)];
                         $ref =& $stepData['shipment'];
                         $ref['VendorName'] = RUtils::translit()->detranslify($ref['VendorName']);
                         $ref['POL'] = isset($ref['POL'][0]) ? $ref['POL'][0] : 'empty';
                         $ref['percent'] = $ref['ContainerVolume'] != 0 ? round($ref['Volume'] / $ref['ContainerVolume'] * 100, 2) : 'cant calculate';
                         $ref['currency'] = $this->getDoctrine()->getManager()->getRepository('CoreBundle:CurrencyRate')->getRateByCodeAndDate('USD', new \DateTime('now'));
                         $request->getSession()->set('stepData', $stepData);
                         return $this->redirect($this->generateUrl('sportmaster_invoice_number', ['step' => ++$step]));
                     } else {
                         $form->addError(new FormError($result['error']));
                     }
                 } else {
                     $form->addError(new FormError("Shipment data PBL = {$data['pbl']} was not found"));
                 }
             }
         }
     }
     return $this->render('SportmasterBundle:Default:wizard.html.twig', ['form' => $form->createView(), 'step' => $step, 'stepData' => $stepData, 'shipmentData' => $shipmentData]);
 }
 protected function getServiceRuName($serviceName)
 {
     $map = ['OceanFreight' => 'О/Ф {pol} – {pod}', 'POMF' => 'СБОР ЗА УПРАВЛЕНИЕ ЗАКАЗОМ', 'Scan' => 'СКАНИРОВАНИЕ', 'Consolidation' => 'КОНСОЛИДАЦИЯ ГРУЗА', 'TelexRelease' => 'ТЕЛЕКС РЕЛИЗ', 'CFSCharges' => 'ПОГРУЗО-РАЗГРУЗОЧНЫЕ РАБОТЫ', 'OTHC' => 'ТЕРМИНАЛЬНАЯ ОБРАБОТКА ГРУЗА В ПОРТУ НАЗНАЧЕНИЯ ({pod})'];
     if (isset($map[$serviceName])) {
         $serviceName = $map[$serviceName];
         $serviceName = str_replace('{pol}', RUtils::translit()->detranslify($this->shipmentData['POL']), $serviceName);
         $serviceName = str_replace('{pod}', RUtils::translit()->detranslify($this->shipmentData['POD']), $serviceName);
         return $serviceName;
     }
     return 'unknown';
 }
Beispiel #11
-1
                <td><?php 
echo \php_rutils\RUtils::formatNumber($order->amount, 2);
?>
</td>
            </tr>
            <tr>
                <td colspan="5">Без налога (НДС)</td>
                <td>&mdash;</td>
            </tr>
        </tfoot>
    </table>

    <p>
        Всего наименований <?php 
echo count($items);
?>
, на сумму <?php 
echo \php_rutils\RUtils::formatNumber($order->amount, 2);
?>
 RUB <br/>
        <strong><?php 
echo \App\Utils\Strings::ucfirst($numeral->getRubles($order->amount, true, true));
?>
</strong>
    </p>

    <img src="<?php 
$_($this->pixie->config->get('parameters.receipt.facsimile', ''));
?>
" alt="" style="width: 100%;"/>
</div>
Beispiel #12
-1
namespace php_rutils\doc\examples;

use php_rutils\RUtils;
require '_begin.php';
//Word forms
$variants = array('гвоздь', 'гвоздя', 'гвоздей');
//Choose plural (variant only)
$amount = 15;
echo $amount, ' ', RUtils::numeral()->choosePlural($amount, $variants), PHP_EOL;
//Result: 15 гвоздей
//Get plural (amount and variant):
$amount = 2;
echo RUtils::numeral()->getPlural($amount, $variants), PHP_EOL;
//Result: 2 гвоздя
//Sum string in words
$amount = 1234;
$gender = RUtils::MALE;
echo RUtils::numeral()->sumString($amount, $gender, $variants), PHP_EOL;
//Result: одна тысяча двести тридцать четыре гвоздя
//Numeral in words
$numeral = RUtils::numeral();
echo $numeral->getInWordsInt(100), PHP_EOL;
//Result: сто
echo $numeral->getInWordsFloat(100.025), PHP_EOL;
//Result: сто целых двадцать пять тысячных
echo $numeral->getInWords(100.0), PHP_EOL;
//Result: сто
//Get string for money (RUB)
echo RUtils::numeral()->getRubles(100.25), PHP_EOL;
//Result: сто рублей двадцать пять копеек
require '_end.php';