Ejemplo n.º 1
0
 function createComponentWeightTabella($name)
 {
     $grid = new Tabella(ProductWeightModel::getFluent()->toDataSource(), array('sorting' => 'asc', 'order' => 'weight_to', 'id_table' => 'id_product_weight', 'limit' => 50, "onSubmit" => function ($post) {
         //						print_r($post);exit;
         ProductWeightModel::edit($post, $post['id_product_weight']);
     }, "onDelete" => function ($id) {
         ProductWeightModel::delete($id);
     }));
     $el = NHtml::el("div");
     $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('addEmptyWeight!'))->addClass('addIcon ajax'));
     //$grid->addColumn($el, '', array('width'=>20,  'filter'=>NULL, "editable" => false ) );
     $grid->addColumn("Váha do", "weight_to", array("width" => 50, "editable" => true));
     $grid->addColumn("Cena poštovného", "weight_price", array("editable" => true));
     $grid->addColumn($el, "", array("width" => 30, 'filter' => NULL, "options" => '', "renderer" => function ($row) {
         $el = NHtml::el("td");
         $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deleteWeight!', array('id_product_weight' => $row->id_product_weight)))->addClass('deleteIcon ajax'));
         return $el;
     }));
     $this->addComponent($grid, $name);
 }
Ejemplo n.º 2
0
 static function getTotalPrice($products, $payment_method, $id_lang, $user)
 {
     $param = array('price' => 0, 'price_with_tax' => 0, 'weight' => 0, 'payment_price' => 0, 'delivery_price' => 0);
     foreach ($products as $id_product_param => $count) {
         $product = ProductModel::getProductIdentifyByParam($id_product_param, $id_lang, $user);
         $param['price'] += $product['price_array']['price'] * $count;
         $param['price_with_tax'] += $product['price_array']['price_with_tax'] * $count;
         $param['weight'] += $product['weight'] * $count;
     }
     ///$payment_method
     $param['payment_price'] = self::getPaymentPrice($payment_method, $param['price']);
     //		$delivery_price = ProductWeightModel::getPrice($weight);
     $param['delivery_price'] = ProductWeightModel::getPrice($param['weight']);
     $conf = NEnvironment::getContext()->parameters;
     if ($conf['DELIVERY_IS_WITH_TAX'] == 1) {
         $param['price'] += $param['delivery_price'] / (1 + $conf['DELIVERY_TAX'] / 100);
         $param['price_with_tax'] += $param['delivery_price'];
     } else {
         $param['price'] += $param['delivery_price'];
         $param['price_with_tax'] += $param['delivery_price'] * (1 + $conf['DELIVERY_TAX'] / 100);
     }
     return $param;
 }