protected function prepareMailData()
 {
     $product = Tree::find($this->getPreparedItem('id_catalog'));
     $occupation = Occupation::find($this->getPreparedItem('id_occupation'));
     $this->setMessageSubject('Заявка на услугу: ' . $product->title_ru);
     $this->appendMessageBody("<html><body>");
     $this->appendMessageBody("<p><b>Заявка на услугу:</b> " . $product->title_ru . "</p>");
     $this->appendMessageBody("<p><b>Фамилия:</b> " . $this->getPreparedItem('last_name') . "</p>");
     $this->appendMessageBody("<p><b>Имя:</b> " . $this->getPreparedItem('first_name') . "</p>");
     $this->appendMessageBody("<p><b>Отчество:</b> " . $this->getPreparedItem('patronymic_name') . "</p>");
     $this->appendMessageBody("<p><b>Занятость:</b> " . $occupation->title_ru . "</p>");
     $this->appendMessageBody("<p><b>Email:</b> " . $this->getPreparedItem('email') . "</p>");
     $this->appendMessageBody("<p><b>Контактный телефон:</b> " . $this->getPreparedItem('phone_number') . "</p>");
     $this->appendMessageBody("<p><b>Паспорт:</b> " . $this->getPreparedItem('passport') . "</p>");
     $this->appendMessageBody("<p><b>ИНН:</b> " . $this->getPreparedItem('inn') . "</p>");
     $this->appendMessageBody("<p><b>Клиент банка:</b> " . ($this->getPreparedItem('is_bank_client') ? 'Да' : 'Нет') . "</p>");
     if ($this->getPreparedItem('monthly_income')) {
         $this->appendMessageBody("<p><b>Ежемесячный доход:</b> " . $this->getPreparedItem('monthly_income') . "</p>");
     }
     if ($this->getPreparedItem('credit_amount')) {
         $this->appendMessageBody("<p><b>Сумма кредита:</b> " . $this->getPreparedItem('credit_amount') . "</p>");
     }
     if ($this->getPreparedItem('term')) {
         $this->appendMessageBody("<p><b>Срок кредита:</b> " . $this->getPreparedItem('term') . "</p>");
     }
     if ($this->getPreparedItem('is_insurance_loss_job')) {
         $this->appendMessageBody("<p><b>Страховка от временной потери работы:</b> Да</p>");
     }
     if ($this->getPreparedItem('is_insurance_accident')) {
         $this->appendMessageBody("<p><b>Страховка от несчастного случая:</b> Да</p>");
     }
     $this->appendMessageBody("<html><body>");
 }
 protected function prepareMailData()
 {
     $product = Tree::find($this->getPreparedItem('id_catalog'));
     $city = City::find($this->getPreparedItem('id_city'));
     if ($city) {
         $region = Region::find($city->id_region);
     }
     //$occupation = Occupation::find($this->getPreparedItem('id_occupation'));
     $this->setMessageSubject('Заявка на услугу: ' . $product->title_ru);
     $this->appendMessageBody("<html><body>");
     $this->appendMessageBody("<p><b>Заявка на услугу:</b> " . $product->title_ru . "</p>");
     $this->appendMessageBody("<p><b>Фамилия:</b> " . $this->getPreparedItem('last_name') . "</p>");
     $this->appendMessageBody("<p><b>Имя:</b> " . $this->getPreparedItem('first_name') . "</p>");
     $this->appendMessageBody("<p><b>Отчество:</b> " . $this->getPreparedItem('patronymic_name') . "</p>");
     //$this->appendMessageBody("<p><b>Занятость:</b> ". $occupation->title_ru ."</p>");
     $this->appendMessageBody("<p><b>Email:</b> " . $this->getPreparedItem('email') . "</p>");
     $this->appendMessageBody("<p><b>Контактный телефон:</b> " . $this->getPreparedItem('phone_number') . "</p>");
     if (isset($region) && $region) {
         $this->appendMessageBody("<p><b>Область:</b> " . $region->title_ru . "</p>");
     }
     $this->appendMessageBody("<p><b>Город:</b> " . $city->title_ru . "</p>");
     $this->appendMessageBody("<p><b>Клиент банка:</b> " . ($this->getPreparedItem('is_bank_client') ? 'Да' : 'Нет') . "</p>");
     if ($this->getPreparedItem('partner_code')) {
         $this->appendMessageBody("<p><b>Код партнера:</b> " . $this->getPreparedItem('partner_code') . "</p>");
     }
     $this->appendMessageBody("<html><body>");
 }
 public function onGetValue($formField, array &$row, &$postfix)
 {
     if ($row) {
         if ($formField->getFieldName() == 'id_catalog') {
             if ($row['id_catalog']) {
                 $product = Tree::find($row['id_catalog']);
                 return '<a href="' . geturl($product->getUrl()) . '" target="_blank">' . $product->title_ru . '</a>';
             }
         }
     }
 }
 protected function prepareMailData()
 {
     $product = Tree::find($this->getPreparedItem('id_catalog'));
     $occupation = Occupation::find($this->getPreparedItem('id_occupation'));
     $this->setMessageSubject('Заявка на услугу: ' . $product->title_ru);
     $this->appendMessageBody("<html><body>");
     $this->appendMessageBody("<p><b>Заявка на услугу:</b> " . $product->title_ru . "</p>");
     $this->appendMessageBody("<p><b>Фамилия:</b> " . $this->getPreparedItem('last_name') . "</p>");
     $this->appendMessageBody("<p><b>Имя:</b> " . $this->getPreparedItem('first_name') . "</p>");
     $this->appendMessageBody("<p><b>Отчество:</b> " . $this->getPreparedItem('patronymic_name') . "</p>");
     $this->appendMessageBody("<p><b>Занятость:</b> " . $occupation->title_ru . "</p>");
     $this->appendMessageBody("<p><b>Email:</b> " . $this->getPreparedItem('email') . "</p>");
     $this->appendMessageBody("<p><b>Контактный телефон:</b> " . $this->getPreparedItem('phone_number') . "</p>");
     $this->appendMessageBody("<p><b>Паспорт:</b> " . $this->getPreparedItem('passport') . "</p>");
     $this->appendMessageBody("<p><b>ИНН:</b> " . $this->getPreparedItem('inn') . "</p>");
     $this->appendMessageBody("<p><b>Клиент банка:</b> " . ($this->getPreparedItem('is_bank_client') ? 'Да' : 'Нет') . "</p>");
     if ($this->getPreparedItem('id_city')) {
         $city = City::find($this->getPreparedItem('id_city'));
         if (isset($city->title_ru)) {
             $this->appendMessageBody("<p><b>Город:</b> " . $city->title_ru . "</p>");
         }
     }
     if ($this->getPreparedItem('id_shop')) {
         $shop = Shop::find($this->getPreparedItem('id_shop'));
         if (isset($shop->title_ru)) {
             $this->appendMessageBody("<p><b>Магазин:</b> " . $shop->title_ru . "</p>");
         }
     }
     if ($this->getPreparedItem('id_product_type')) {
         $productType = Product::find($this->getPreparedItem('id_product_type'));
         if (isset($productType->title_ru)) {
             $this->appendMessageBody("<p><b>Тип товара:</b> " . $productType->title_ru . "</p>");
         }
     }
     if ($this->getPreparedItem('product_price')) {
         $this->appendMessageBody("<p><b>Стоимость товара:</b> " . $this->getPreparedItem('product_price') . "</p>");
     }
     if ($this->getPreparedItem('term')) {
         $this->appendMessageBody("<p><b>Срок кредита:</b> " . $this->getPreparedItem('term') . "</p>");
     }
     if ($this->getPreparedItem('is_insurance_loss_job')) {
         $this->appendMessageBody("<p><b>Страховка от временной потери работы:</b> Да</p>");
     }
     if ($this->getPreparedItem('is_insurance_accident')) {
         $this->appendMessageBody("<p><b>Страховка от несчастного случая:</b> Да</p>");
     }
     $this->appendMessageBody("<html><body>");
 }
 protected function prepareMailData()
 {
     $product = Tree::find($this->getPreparedItem('id_catalog'));
     $this->setMessageSubject('Заявка на услугу: ' . $product->title_ru);
     $this->appendMessageBody("<html><body>");
     $this->appendMessageBody("<p><b>Заявка на услугу:</b> " . $product->title_ru . "</p>");
     $this->appendMessageBody("<p><b>Фамилия:</b> " . $this->getPreparedItem('last_name') . "</p>");
     $this->appendMessageBody("<p><b>Имя:</b> " . $this->getPreparedItem('first_name') . "</p>");
     $this->appendMessageBody("<p><b>Отчество:</b> " . $this->getPreparedItem('patronymic_name') . "</p>");
     $this->appendMessageBody("<p><b>Контактный телефон:</b> " . $this->getPreparedItem('phone_number') . "</p>");
     $this->appendMessageBody("<p><b>Клиент банка:</b> " . ($this->getPreparedItem('is_bank_client') ? 'Да' : 'Нет') . "</p>");
     if ($this->getPreparedItem('deposit_amount')) {
         $this->appendMessageBody("<p><b>Сумма вклада:</b> " . $this->getPreparedItem('deposit_amount') . "</p>");
     }
     if ($this->getPreparedItem('term')) {
         $this->appendMessageBody("<p><b>Срок:</b> " . $this->getPreparedItem('term') . "</p>");
     }
     if ($this->getPreparedItem('monthly_installment')) {
         $this->appendMessageBody("<p><b>Ежемесячный взнос:</b> " . $this->getPreparedItem('monthly_installment') . "</p>");
     }
     if ($this->getPreparedItem('currency')) {
         $this->appendMessageBody("<p><b>Валюта:</b> " . $this->getPreparedItem('currency') . "</p>");
     }
     if ($this->getPreparedItem('interest_payment_percent')) {
         $this->appendMessageBody("<p><b>Выплата процентов (%):</b> " . $this->getPreparedItem('interest_payment_percent') . "</p>");
     }
     if ($this->getPreparedItem('interest_payment_type')) {
         if ($this->getPreparedItem('interest_payment_type') == 'end') {
             $type = 'в конце срока';
         } else {
             if ($this->getPreparedItem('interest_payment_type') == 'monthly') {
                 $type = 'ежемесячно';
             } else {
                 $type = 'капитализация';
             }
         }
         $this->appendMessageBody("<p><b>Выплата процентов:</b> " . $type . "</p>");
     }
     $this->appendMessageBody("<html><body>");
 }
 protected function prepareMailData()
 {
     $product = Tree::find($this->getPreparedItem('id_catalog'));
     $occupation = Occupation::find($this->getPreparedItem('id_occupation'));
     $this->setMessageSubject('Заявка на услугу: ' . $product->title_ru);
     $this->appendMessageBody("<html><body>");
     $this->appendMessageBody("<p><b>Заявка на услугу:</b> " . $product->title_ru . "</p>");
     $this->appendMessageBody("<p><b>Фамилия:</b> " . $this->getPreparedItem('last_name') . "</p>");
     $this->appendMessageBody("<p><b>Имя:</b> " . $this->getPreparedItem('first_name') . "</p>");
     $this->appendMessageBody("<p><b>Отчество:</b> " . $this->getPreparedItem('patronymic_name') . "</p>");
     $this->appendMessageBody("<p><b>Занятость:</b> " . $occupation->title_ru . "</p>");
     $this->appendMessageBody("<p><b>Email:</b> " . $this->getPreparedItem('email') . "</p>");
     $this->appendMessageBody("<p><b>Контактный телефон:</b> " . $this->getPreparedItem('phone_number') . "</p>");
     $this->appendMessageBody("<p><b>Паспорт:</b> " . $this->getPreparedItem('passport') . "</p>");
     $this->appendMessageBody("<p><b>ИНН:</b> " . $this->getPreparedItem('inn') . "</p>");
     $this->appendMessageBody("<p><b>Клиент банка:</b> " . ($this->getPreparedItem('is_bank_client') ? 'Да' : 'Нет') . "</p>");
     if ($this->getPreparedItem('monthly_fee')) {
         $this->appendMessageBody("<p><b>Ежемесячная плата:</b> " . $this->getPreparedItem('monthly_fee') . "</p>");
     }
     if ($this->getPreparedItem('left_to_repay_money')) {
         $this->appendMessageBody("<p><b>Осталось погашать:</b> " . $this->getPreparedItem('left_to_repay_money') . "</p>");
     }
     if ($this->getPreparedItem('credit_type')) {
         if ($this->getPreparedItem('credit_type') == 'simple') {
             $type = 'Кредит';
         } else {
             $type = 'Кредит на карте';
         }
         $this->appendMessageBody("<p><b>Тип кредита:</b> " . $type . "</p>");
     }
     if ($this->getPreparedItem('is_insurance_loss_job')) {
         $this->appendMessageBody("<p><b>Страховка от временной потери работы:</b> Да</p>");
     }
     if ($this->getPreparedItem('is_insurance_accident')) {
         $this->appendMessageBody("<p><b>Страховка от несчастного случая:</b> Да</p>");
     }
     $this->appendMessageBody("<html><body>");
 }
    $cities = Cache::tags('cities')->rememberForever('cities_' . App::getLocale(), function () {
        return City::active()->get();
    });
    $shops = Cache::tags('shops')->rememberForever('shops_' . App::getLocale(), function () {
        return Shop::active()->get();
    });
    $products = Cache::tags('products')->rememberForever('products_' . App::getLocale(), function () {
        return Product::active()->get();
    });
    $view->with('cities', $cities)->with('shops', $shops)->with('products', $products);
});
View::composer('partials.calculators.cards', function ($view) {
    $programs = Cache::tags('j_tree', 'cards_programs')->rememberForever('privates_cards_programs_' . App::getLocale(), function () {
        return CardProgram::active()->get();
    });
    $cards = Cache::tags('j_tree', 'cards')->rememberForever('privates_cards_' . App::getLocale(), function () {
        $cardsCatalog = Tree::find(Collector::get('idCardsCatalog'));
        return $cardsCatalog->immediateDescendants()->with('cardsPrograms')->active()->get();
    });
    $view->with('programs', $programs)->with('cards', $cards);
});
View::composer('partials.calculators.want_multiply', function ($view) {
    $calculatorDeposit = new DepositCalculator();
    $calculatorDeposit->setDepositAmount(Settings::get('deposit_amount_default', 100000));
    $calculatorDeposit->setTerm(Settings::get('term_default', 3));
    $calculatorDeposit->setMonthlyInstallment(0);
    $calculatorDeposit->setCurrency('uah');
    $calculatorDeposit->setIsMain(true);
    $calculations = $calculatorDeposit->calculate();
    $view->with('calculations', $calculations);
});
Ejemplo n.º 8
0
 private function getCategory($id)
 {
     $node = \Tree::find($id);
     $children = $node->descendants()->get(array("id", "title", "parent_id"))->toArray();
     $result = array();
     foreach ($children as $row) {
         $result[$row["parent_id"]][] = $row;
     }
     return $result;
 }
Ejemplo n.º 9
0
 /**
  * @param Node $node
  * @param mixed $uid
  * @return bool
  */
 protected static function checkUnique(Node $node, $uid)
 {
     $headNode = $node;
     do {
         $headNode = $node;
     } while ($node = $node->getParent());
     $tree = new Tree($headNode);
     return !$tree->find($uid);
 }
 public function testMoveRootNodeDown()
 {
     $expected = array(0 => array('Tree' => array('id' => '2', 'name' => '2', 'parent_id' => NULL, 'lft' => '1', 'rght' => '2', 'child_count' => '0', 'direct_child_count' => '0')), 1 => array('Tree' => array('id' => '1', 'name' => '1', 'parent_id' => NULL, 'lft' => '3', 'rght' => '16', 'child_count' => '6', 'direct_child_count' => '3')), 2 => array('Tree' => array('id' => '3', 'name' => '1.1', 'parent_id' => '1', 'lft' => '4', 'rght' => '11', 'child_count' => '3', 'direct_child_count' => '3')), 3 => array('Tree' => array('id' => '6', 'name' => '1.1.1', 'parent_id' => '3', 'lft' => '5', 'rght' => '6', 'child_count' => '0', 'direct_child_count' => '0')), 4 => array('Tree' => array('id' => '7', 'name' => '1.1.2', 'parent_id' => '3', 'lft' => '7', 'rght' => '8', 'child_count' => '0', 'direct_child_count' => '0')), 5 => array('Tree' => array('id' => '8', 'name' => '1.1.3', 'parent_id' => '3', 'lft' => '9', 'rght' => '10', 'child_count' => '0', 'direct_child_count' => '0')), 6 => array('Tree' => array('id' => '4', 'name' => '1.2', 'parent_id' => '1', 'lft' => '12', 'rght' => '13', 'child_count' => '0', 'direct_child_count' => '0')), 7 => array('Tree' => array('id' => '5', 'name' => '1.3', 'parent_id' => '1', 'lft' => '14', 'rght' => '15', 'child_count' => '0', 'direct_child_count' => '0')));
     $Tree = new Tree();
     $Tree->setOrder(1, 1);
     $results = $Tree->find('all', array('order' => 'lft'));
     $this->assertEqual($results, $expected);
 }
Ejemplo n.º 11
0
 public function testDetachAll()
 {
     $connection = m::mock('juicyORM\\Database\\DbConnection');
     $connection->shouldReceive('query')->with('SELECT * FROM "tree" WHERE "tree_id" = ?', array(1))->once()->andReturn(array($this->fake_tree_table[0]));
     $connection->shouldReceive('query')->with('DELETE FROM "leaf_tree" WHERE "tree_id" = ?', array(1), false)->once()->andReturn(true);
     $db = juicyORM\Database\DB::Instance($this->dbConfig, $connection, true);
     $tree = new Tree($db);
     $user_response = $tree->find(1)->leaves->detach_all();
     $this->assertEquals(gettype($user_response), 'boolean');
     $this->assertEquals($user_response, true);
     $this->assertEquals($db->runtime_info(), array(array('sql' => 'SELECT * FROM "tree" WHERE "tree_id" = ?', 'bindings' => array(1)), array('sql' => 'DELETE FROM "leaf_tree" WHERE "tree_id" = ?', 'bindings' => array(1))));
 }
Ejemplo n.º 12
0
 /**
  * Tree building from array
  *
  * @test
  */
 public function can_map_array()
 {
     Tree::mapArray([['children' => [['children' => [['children' => [['children' => []], ['children' => []]]], ['children' => []]]], ['children' => []]]], ['children' => []], ['children' => []]]);
     $this->assertEquals(3, Tree::getRoots()->count(), 'Expected numer of Roots');
     $this->assertEquals(7, Tree::find(1)->findDescendants()->count(), 'Expected numer of Descendants');
     $this->assertEquals(2, Tree::find(1)->children()->count(), 'Expected numer of Children');
     $this->assertEquals(4, Tree::find(5)->findAncestors()->count(), 'Expected numer of Ancestors');
     // Most nested
 }
 public function doDepositCalculation()
 {
     App::setLocale(Cookie::get('locale', 'ru'));
     $isMain = intval(Input::get('is_main'));
     $depositAmount = intval(trim(Input::get('deposit_amount')));
     $term = intval(trim(Input::get('term')));
     $monthlyInstallment = intval(trim(Input::get('monthly_installment')));
     $currency = trim(Input::get('currency'));
     $interestPaymentType = trim(Input::get('interest_payment_type'));
     $interestPaymentPercent = trim(Input::get('interest_payment_percent'));
     if (!$depositAmount || !$term || !$currency) {
         return Response::json(array('status' => false));
     }
     $calculator = new DepositCalculator();
     $calculator->setDepositAmount($depositAmount);
     $calculator->setTerm($term);
     $calculator->setMonthlyInstallment($monthlyInstallment);
     $calculator->setCurrency($currency);
     $viewTemplate = 'partials.calculators.partials.deposit_table_main';
     $sliderHtml = '';
     if (!$isMain) {
         $calculator->setInterestPaymentType($interestPaymentType);
         $calculator->setInterestPaymentPercent($interestPaymentPercent);
         $calculator->setIsMain(false);
         $viewTemplate = 'partials.calculators.partials.deposit_table';
     }
     $calculations = $calculator->calculate();
     if (!$isMain) {
         $depositsIds = Tree::getDepositsCompared();
         $depositsCatalog = Cache::tags('j_tree')->rememberForever('deposits_catalog_' . App::getLocale(), function () {
             return Tree::find(Collector::get('idDepositsCatalog'));
         });
         $deposits = Cache::tags('j_tree')->rememberForever('deposits_products_' . App::getLocale(), function () use($depositsCatalog) {
             return $depositsCatalog->children()->get();
         });
         $deposits = Tree::filterDepositsByIds($deposits, $depositsIds);
         $allDeposits = Cache::tags('deposits')->rememberForever('deposits_' . App::getLocale(), function () {
             return Deposit::all();
         });
         $depositOptionsGroups = Deposit::prepareData($allDeposits);
         $sliderHtml = View::make('private-persons.deposits.partials.deposits_slider', compact('deposits', 'depositOptionsGroups', 'calculations'))->render();
     }
     $html = View::make($viewTemplate, compact('result', 'currency', 'calculations'))->render();
     $firstDepositData = array();
     if ($calculations) {
         $firstDepositData = array_values($calculations)[0];
     }
     return Response::json(array('status' => true, 'html' => $html, 'slider_html' => $sliderHtml, 'currency' => isset($calculations['currency']) ? $calculations['currency'] : '', 'result' => isset($calculations['sum']) ? $calculations['sum'] : '', 'sum' => $firstDepositData['sum']));
 }