<?php foreach($products as $product):?>
<tr>
<td><?php echo $this->escapeHtml($product->getId())?></td>
<td><?php echo $this->escapeHtml($product->getName())?></td>
<td><?php echo $this->escapeHtml($product->getPrice())?></td>
<td>
<select class="form-control">
<?php foreach ($form as $element):?>
<option value="$element->get('id')" <?php if ($product->getCategoryId() == $element->getId()) { echo 'selected="selected"'}?> >
<?php echo $this->escapeHtml($element->getParentId())?>
</option>
<?php endforeach;?>
</select>
</td>
<td><?php echo $this->escapeHtml($product->getDescription())?></td>
<td><?php echo $this->escapeHtml($product->getImage())?></td>
<td>
<a class="btn btn-success" href="<?php $this->url('admin/products', array('action' => 'edit', 'id' => $product->getId()))?>"><span class="glyphicon glyphicon-pencil" ></span> Редактировать</a>
<a class="btn btn-danger" href="<?php $this->url('admin/products', array('action' => 'delete', 'id' => $product->getId()))?>" onclick="if(confirm(\'Удалить запись?\')) {document.location = this.href;} return false;"><span class="glyphicon glyphicon-remove"></span> Удалить</a>
</td>
</tr>
<?php endforeach;?>
try{
$sql = "UPDATE `users` SET ";
if($newPassword){
$sql .= "`password` = :newPassword, ";
}
$sql .= " `name` = :name,
`sec_name` = :sec_name,
`surname` = :surname,
`adress` = :adress,
`tel` = :tel
WHERE `email` = :email AND `password` = :curPassword LIMIT 1";
$stmt = $pdo -> prepare($sql);
$holders = array( ":name" => $name,
":sec_name" => $sec_name,
":surname" => $surname,
":adress" => $adress,
":tel" => $tel,
":email" => $email,
":password" => $curPasswordMD5['hash'],
);
if ($newPassword){
$holders[":newPassword"] = $newPassword['hash'];
}
$stmt->execute($holders);
return $stmt;
} catch (Exception $e) {
exit($e->getMessage());
}