public function actionAddAjax() { if (!isset(Yii::app()->user->storeID)) { $data['message'] = '<div class="alert alert-success">Store not found. </div>'; echo json_encode($data); exit; } $model = new Service(); if (isset($_POST['Service'])) { $model->attributes = $_POST['Service']; $data = array(); $mss = ''; if (count($data) == 0) { $model->pk_s_id = '-1'; $model->i_flag_sync = 1; $model->i_flag_deleted = 0; $model->i_disable = 0; if ($model->save()) { $model->pk_s_id = 'SV' . $model->id; if ($model->save()) { $data['option'] = '<option selected="selected" value ="' . $model->pk_s_id . '">' . $model->s_name . '</option>'; $data['message'] = '<div class="alert alert-success">Success! Account created. </div>'; } else { $model->delete(); $data['message'] = '<div class="alert alert-danger">Error! Please try again later.</div>'; } } else { $data['message'] = json_encode($model->errors); //'<div class="alert alert-danger">Error! Please try again later2.</div>'; } } echo json_encode($data); } }
function delete_list($id) { if ($id) { $rs = new Service($id); $rs->delete(); } }
public function delete() { ipRequest()->mustBePost(); $userId = ipRequest()->getPost('id'); if (!$userId) { throw new \Ip\Exception('Missing required parameters'); } if ($userId == ipAdminId()) { throw new \Ip\Exception("Can't delete yourself"); } Service::delete($userId); $data = array('status' => 'ok'); return new \Ip\Response\Json($data); }
/** * Тест каскадных удалений * */ public function testCascade() { $bt = new BillingTransaction(); // Создаем пользователя, услугу и транзакцию $user = $this->helper->makeUser(); $user->save(); $service = new Service(); $service->save(); $bt->setUserId($user->getId()); $bt->setServiceId($service->getId()); $bt->save(); // При удалении службы транзакция остается $service->delete(); $findBt = Doctrine::getTable('BillingTransaction')->find($bt->getId()); $this->assertType('BillingTransaction', $findBt); $this->assertEquals($findBt->getId(), $bt->getId()); // При удалении пользователя удаляется запись о транзакции $user->delete(); $findBt = Doctrine::getTable('BillingTransaction')->find($bt->getId()); $this->assertEquals($findBt, null); }
/** * @param \Nella\Models\IEntity * @return \Doctrine\ORM\EntityManager */ public function delete(\Nella\Models\IEntity $entity) { $class = get_class($entity); if ($class == 'Nella\Media\ImageEntity') { $path = $this->getContainer()->context->expand(static::CACHE_DIR); if (file_exists($path)) { $id = $entity->id; $files = \Nette\Utils\Finder::findFiles($id . ".jpg", $id . ".png", $id . ".gif")->from($path); foreach($files as $file) { if (file_exists($file->getRealPath())) { @unlink($file->getRealPath()); } } } return parent::delete($entity); } else { return parent::delete($entity); } }
private function _handleProgramSave() { // Update and/or create services on existing dates $dummy = new Service(); foreach ($this->_grouped_services as $date => $date_services) { foreach ($this->_congregations as $congid) { if (isset($date_services[$congid])) { // update the existing service $dummy->populate($date_services[$congid]['id'], $date_services[$congid]); if ($dummy->acquireLock()) { $this->_processServiceCell($congid, $date, $dummy); $dummy->save(); $dummy->releaseLock(); } else { trigger_error("Could not acquire lock on individual service for {$congid} on {$date} - didn't save"); } } else { if (!empty($_POST['topic_title'][$congid][$date]) || !empty($_POST['format_title'][$congid][$date]) || !empty($_POST['bible_ref0'][$congid][$date])) { // create a new service $service = new Service(); $service->setValue('date', $date); $service->setValue('congregationid', $congid); $this->_processServiceCell($congid, $date, $service); $service->create(); } } } } // Add services on new dates $i = 0; while (isset($_POST['new_service_date_d'][$i])) { foreach ($this->_congregations as $congid) { if (!empty($_POST['topic_title'][$congid]['new_' . $i]) || !empty($_POST['format_title'][$congid]['new_' . $i]) || !empty($_POST['bible_refs'][$congid]['new_' . $i][0]) || !empty($_POST['bible_refs'][$congid]['new_' . $i][1])) { // we need to create a service here $service = new Service(); $service->setValue('date', process_widget('new_service_date[' . $i . ']', array('type' => 'date'))); $service->setValue('congregationid', $congid); $this->_processServiceCell($congid, 'new_' . $i, $service); $service->create(); } } $i++; } $shifted = FALSE; // Process the "delete" commands if necessary if (!empty($_POST['delete_single'])) { $service = $GLOBALS['system']->getDBOBject('service', (int) $_POST['delete_single']); if ($service) { $service->delete(); if (!empty($_POST['shift_after_delete'])) { Service::shiftServices(array($service->getValue('congregationid')), $service->getValue('date'), '-7'); $shifted = TRUE; } } } if (!empty($_POST['delete_all_date'])) { $services = $GLOBALS['system']->getDBObjectData('service', array('date' => $_POST['delete_all_date'], 'congregationid' => $this->_congregations), 'AND'); $dummy = new Service(); foreach ($services as $id => $details) { $dummy->populate($id, $details); $dummy->delete(); $shifted = TRUE; } if (!empty($_POST['shift_after_delete'])) { Service::shiftServices($this->_congregations, $_POST['delete_all_date'], '-7'); $shifted = TRUE; } } // Process the "insert" commands if necessary if (!empty($_POST['insert_all_date'])) { Service::shiftServices($this->_congregations, $_POST['insert_all_date'], '7'); $shifted = TRUE; } if (!empty($_POST['insert_single_date'])) { foreach ($_POST['insert_single_date'] as $congid => $date) { Service::shiftServices(array($congid), $date, '7'); $shifted = TRUE; } } if (!$shifted) { foreach ($this->_congregations as $id) { $cong = $GLOBALS['system']->getDBObject('congregation', $id); $cong->releaseLock('services'); } add_message("Services saved"); redirect($_REQUEST['view'], array('editing' => NULL)); } $this->_loadServices(); }
/** * Deletes an invoice * @param Service $service */ public function delete(Service $service) { $service->delete($this); }
if ($_FILES['image']['tmp_name'] != "") { if (is_uploaded_file($_FILES['image']['tmp_name'])) { $_POST['image'] = resizer($_FILES['image']); } } else { $_POST['image'] = Service::selectImage($_POST['id'], $connect); } $service = new Service($_POST); try { $service->update($_POST['id'], $connect); $_SESSION['msg'] = "Serviço editado com sucesso."; } catch (PDOException $e) { $_SESSION['msg'] = "A edição desse serviço falhou."; } header('Location:../views/services.php'); } break; case 'delete': if (isset($_POST['id'])) { if (Service::delete($_POST['id'], $connect)) { $_SESSION['msg'] = "Serviço deletado."; header('Location:../views/services.php'); } } else { $_SESSION['msg'] = "Houve falha ao excluir esse serviço."; header('Location:../views/services.php'); } break; default: header('Location:logout.php'); }
<?php require DIR_CORE . 'services.php'; /** @var array $launch */ foreach ($launch as $s) { /** @var array $services */ if (isset($services[$s])) { _echo('Removing ' . $services[$s]); Service::delete($s); } else { _echo('Service ' . $s . ' not installed'); } }
public function beforeDelete($id) { Service::delete($id); }
public function delete_service($service_id = NULL) { if (is_null($service_id)) { add_error_flash_message('Služba sa nenašla.'); redirect(site_ur('services')); } $this->db->trans_begin(); $service = new Service(); $service->include_related_count('service_usage', 'service_usages_count'); $service->get_by_id((int) $service_id); if (!$service->exists()) { $this->db->trans_rollback(); add_error_flash_message('Služba sa nenašla.'); redirect(site_ur('services')); } if ((int) $service->service_usages_count > 0) { $this->db->trans_rollback(); add_error_flash_message('Nie je možné vymazať službu, ktorá bola už použitá v operáciách s LEDCOIN-om.'); redirect(site_url('services')); } $success_message = 'Služba <strong>' . $service->title . '</strong> s ID <strong>' . $service->id . '</strong> bola úspešne vymazaná.'; $error_message = 'Službu <strong>' . $service->title . '</strong> s ID <strong>' . $service->id . '</strong> sa nepodarilo vymazať.'; if ($service->delete() && $this->db->trans_status()) { $this->db->trans_commit(); add_success_flash_message($success_message); } else { $this->db->trans_rollback(); add_error_flash_message($error_message); } redirect(site_url('services')); }
public function deleteService(Service $service) { $service->delete(); //we can redirect using route also. return Redirect::route('service.list')->with('success', 'Service is deleted!'); }