public function EditAction() { $id = intval(Request::GetPart(3)); $contact = ContactsModel::GetObj()->where('id = ? AND company_id = ?', [0 => $id, 1 => $this->company->id]); if (Request::isposted('name')) { $contact->name = Request::post('name'); $contact->status = Request::post('status'); $contact->email = Request::post('email'); $contact->phone = Request::post('phone'); $contact->mob = Request::post('mob'); $contact->skype = Request::post('skype'); $contact->company_id = $this->company->id; if ($contact->name != '') { if ($contact->id == 0) { Site::Message('Контакт успешно создан'); } else { Site::Message('Контакт успешно отредактирован'); } $contact->save(); $this->IndexAction(); } else { Site::Message('Имя контакта обязательно для заполнения'); $this->Render('edit', ['contact' => $contact, 'company' => $this->company]); } } else { Site::Message('Видимость контактов профиля можно изменить в настройках'); $this->Render('edit', ['contact' => $contact, 'company' => $this->company]); } }
public function EditAction() { $id = intval(Request::GetPart(3)); $product = ProductModel::GetObj()->where('id = ? AND company_id = ?', [0 => $id, 1 => $this->company->id]); if (Request::isposted('name')) { $product->name = Request::post('name'); $product->about = Request::post('about'); $product->company_id = $this->company->id; $file = new File('pic', 7); if ($file->isLoaded()) { if (!$file->checktype(['jpg', 'jpeg', 'bmp', 'gif', 'png'])) { Site::Error('Неверный тип файла'); } else { $new_name = $file->getnewname(); $file->SaveResizedImage($new_name, 200, 0); $file->SaveResizedImage('s_' . $new_name, 100, 0); //Если файл лого уже существует if ($product->pic != '') { if (file_exists(ROOT . '/web/files/' . $product->pic)) { unlink(ROOT . '/web/files/' . $product->pic); } if (file_exists(ROOT . '/web/files/s_' . $product->pic)) { unlink(ROOT . '/web/files/s_' . $product->pic); } } $product->pic = $new_name; } } if ($product->name != '') { if ($product->id == 0) { Site::Message('Продукция успешно добавлена в каталог'); } else { Site::Message('Продукция успешно отредактирована'); } $product->save(); $this->IndexAction(); } else { Site::Message('Наименование продукции обязательно для заполения'); $this->Render('edit', ['product' => $product, 'company' => $this->company]); } } else { $this->Render('edit', ['product' => $product, 'company' => $this->company]); } }