Offer.class.php 1.37 KB
Newer Older
Яков's avatar
first  
Яков committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

/**
 * Offer
 * 
 * This class has been auto-generated by the Doctrine ORM Framework
 * 
 * @package    sf
 * @subpackage model
 * @author     Atma
 * @version    SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
 */
class Offer extends BaseOffer
{
    static public $quantity_type_select_values = array('m2' => 'м²', 'sheet' => 'лист', 'piece' => 'шт.');
    public function save(Doctrine_Connection $conn = null)
    {
        if($this->getQuantityType()){
            $this->setQuantityType(mb_strtolower($this->getQuantityType()));
        }

        parent::save($conn);

        $offer_count = Doctrine_Query::create()
            ->from("Offer")
            ->where("product_id = ?", $this->getProductId())
            ->andWhere("is_delete = 0")
            ->count();

        Doctrine_Query::create()
            ->update("Product")
            ->set("offer_count", $offer_count)
            ->where("id = ?", $this->getProductId())
            ->execute();
    }
    public function getQuantityTypeValue($culture)
    {
        $quantity_type = $this['Translation'][$culture]['quantity_type'];
        if ($this['quantity_type_select']) {
            $quantity_type = (isset(Offer::$quantity_type_select_values[$this['quantity_type_select']]) ? Offer::$quantity_type_select_values[$this['quantity_type_select']] : '');
        }
        return $quantity_type;
    }
}