_props.php 1.87 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
45
<span class="inline_label"><label for="props">Характеристики</label></span>
<i class="br10"></i>
<table cellpadding="0" cellspacing="0" class="adminTable">
    <tr>
        <td>Название</td>
        <td>Значение</td>
    </tr>
    <?php
    $values = array();
    if(!$form->isNew()){
        $obj = $form->getObject();
        $values = Doctrine_Query::create()
            ->select("v.*")
            ->from("ProductPropValue v INDEXBY v.prop_id")
            ->where("v.product_id = ?", $obj->getId())
            ->fetchArray();
    }
    $props = Doctrine_Query::create()
        ->select("p.*, l.*, pt.*, lt.*")
        ->from("ProductProp p")
        ->leftJoin("p.ProductPropList l")
        ->leftJoin("p.Translation pt WITH pt.lang = 'ru'")
        ->leftJoin("l.Translation lt WITH lt.lang = 'ru'")
        ->fetchArray();
    if(count($props) > 0){
        foreach ($props as $prop){
            echo '<tr>';
            echo '<td width="150">' . $prop['Translation']['ru']['title'] . '</td>';
            echo '<td>';
            if($prop['isList']){
                echo '<select style="width:100%;" name="props[' . $prop['id'] . ']">';
                echo '<option value="">—</option>';
                foreach ($prop['ProductPropList'] as $list){
                    echo '<option ' . (isset($values[$prop['id']]) && (int)$values[$prop['id']]['value'] == $list['id'] ? 'selected="selected"' : '') . ' value="' . $list['id'] . '">' . $list['Translation']['ru']['variant'] . '</option>';
                }
                echo '</select>';
            }else{
                echo '<input autocomplete="off" size="8" maxlength="8" name="props['. $prop["id"] .']" value="' . (isset($values[$prop['id']]) ? $values[$prop['id']]['value'] : '') . '" id="props" type="text">';
            }
            echo '</td>';
            echo '</tr>';
        }
    }
    ?>
</table>