/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Service(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Service'])) { $model->attributes = $_POST['Service']; if ($model->save()) { if (!empty($_POST['yt1'])) { Yii::app()->user->setFlash('service-created', "¡El servicio <b><i>"{$model->name}"</i></b> fue creado exitosamente!"); $this->redirect(array('create')); } else { $this->redirect(array('view', 'id' => $model->id)); } } } if (ServiceType::model()->count('active = 1') > 0) { $this->render('create', array('model' => $model)); } else { throw new CHttpException('', 'Primero debe ' . CHtml::link('crear un Tipo de Servicio', array('servicetype/create')) . '.'); } }
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); } }
/** * Updates or inserts a contact * @param Service $service * @return self * @throws NotValidException */ public function save(Service $service) { if (!$this->validate()) { throw new NotValidException('Unable to validate contact'); } return $this->reload($service->save($this)); }
public function create($permalink = null) { $event = self::load_event($permalink); $service = new Service(); if ($this->post) { $service->event_id = $event->id; $service->cost = UnMoney($_POST['cost']); $service->capacity = $_POST['capacity']; $service->participant = $_POST['participant']; $service->hidden = $_POST['hidden']; $service->name = $_POST['name']; $service->description = $_POST['description']; $service->advanced = $_POST['advanced']; $service->question = $_POST['question']; $service->max_per_signup = $_POST['max_per_signup']; $service->discountable = $this->PostData("discountable"); if ($service->save()) { Site::Flash("notice", "The service has been added"); Redirect("admin/events/{$event->permalink}/services"); } } $this->assign("event", $event); $this->assign("service", $service); $this->title = "Add Service"; $this->render("service/create.tpl"); }
public function update_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->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')); } build_validator_from_form($this->get_form()); if ($this->form_validation->run()) { $service_data = $this->input->post('service'); $service->from_array($service_data, array('title', 'price')); if ($service->save() && $this->db->trans_status()) { $this->db->trans_commit(); add_success_flash_message('Služba s ID <strong>' . $service->id . '</strong> bola úspešne upravená.'); redirect(site_url('services')); } else { $this->db->trans_rollback(); add_error_flash_message('Službu s ID <strong>' . $service->id . '</strong> sa nepodarilo upraviť.'); redirect(site_url('services/edit_service/' . (int) $service->id)); } } else { $this->db->trans_rollback(); $this->edit_service($service->id); } }
function save($id = FALSE) { if ($_POST) { $category = new Category($id); $_POST['module'] = "services"; $_POST['name'] = lang_encode($_POST['name']); $category->from_array($_POST); $category->save(); if ($_POST['title']['th']) { foreach ($_POST['title']['th'] as $key => $item) { $service = new Service(@$_POST['sub_id'][$key]); if ($item) { $title = array('th' => $_POST['title']['th'][$key], 'en' => $_POST['title']['en'][$key]); $service->title = lang_encode($title); $service->category_id = $category->id; $service->save(); } } // exit; } set_notify('success', lang('save_data_complete')); } // redirect($_POST['referer']); // redirect($_SERVER['HTTP_REFERER']); redirect('services/admin/services'); }
/** * SetUp */ protected function _start() { $this->table = Doctrine::getTable('OperationNotification'); // Создать услугу с захардкоженным ID $service = new Service(); $service->setKeyword(Service::SERVICE_SMS); $service->save(); }
/** * Store a newly created resource in storage. * POST /services * * @return Response */ public function store() { $service = new Service(); $service->service = Input::get('service'); $service->save(); Flash::message('Service Added!'); return Redirect::route('add_service'); }
/** * Тест /services/index * */ public function testIndex() { $user = $this->helper->makeUser(); $this->authenticateUser($user); $user->save(); $service = new Service(); $service->price = 100; $service->name = "Уникальное имя услуги " . uniqid(); $service->save(); $this->browser->get($this->generateUrl('services'))->with('response')->begin()->isStatusCode(200)->matches('/(' . $service->name . ')/i')->end(); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('cs_service_types')->delete(); $services = array("Theme", "Project", "Fix Bug"); foreach ($services as $service) { $sv = new Service(); $sv->name = $service; $sv->description = "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"; $sv->save(); } }
public function storeService() { $advisor = Auth::user(); // If form validation passes: $service = new Service(); $service->name = Input::get('name'); if (Input::get('notes')) { $service->notes = Input::get('notes'); } $service->save(); $advisor->services()->save($service); return Redirect::intended('advisor.dashboard'); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Service(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Service'])) { $model->attributes = $_POST['Service']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function submit() { $facility1 = $this->input->post('spoint'); $service = $this->input->post('facility'); $u = new Service(); $u->facility_id = $service; $u->service_point = $facility1; $u->save(); $data['title'] = "Service Points"; $data['content_view'] = "facility_service"; $data['banner_text'] = "Service Points"; $data['quick_link'] = "facility_service"; $this->load->view("template", $data); }
/** install($name) Method that installs the relevant plugin. $name just sends the plugin name. Useful for schema adding. */ public function install($name) { $sql = "CREATE TABLE capone\n (cID INTEGER NOT NULL AUTO_INCREMENT,\n cImageID INTEGER NOT NULL,\n cOSID INTEGER NOT NULL,\n cKey VARCHAR(250) NOT NULL,\n PRIMARY KEY(cID),\n INDEX new_index (cImageID),\n INDEX new_index2 (cKey))\n ENGINE = MyISAM"; if ($this->DB->query($sql)) { $CaponeDMI = new Service(array('name' => 'FOG_PLUGIN_CAPONE_DMI', 'description' => 'This setting is used for the capone module to set the DMI field used.', 'value' => '', 'category' => 'Plugin: ' . $name)); $CaponeDMI->save(); $CaponeRegEx = new Service(array('name' => 'FOG_PLUGIN_CAPONE_REGEX', 'description' => 'This setting is used for the capone module to set the reg ex used.', 'value' => '', 'category' => 'Plugin: ' . $name)); $CaponeRegEx->save(); $CaponeShutdown = new Service(array('name' => 'FOG_PLUGIN_CAPONE_SHUTDOWN', 'description' => 'This setting is used for the capone module to set the shutdown after imaging.', 'value' => '', 'category' => 'Plugin: ' . $name)); $CaponeShutdown->save(); return true; } return false; }
/** * Creates a new service and returns the service Object. * @return [type] [description] */ public function createService($name, $notes, $duration, $id = null) { $advisor = Advisor::find($id); $service = new Service(); $service->name = $name; $service->duration = $duration; $service->notes = $notes; $service->save(); if ($id == null) { return $service; } $advisor->services()->attach($service); return $service; }
public function saveService() { $service = ['name' => Input::get('name')]; $rules = ['name' => 'required']; $valid = Validator::make($service, $rules); if ($valid->passes()) { $service = new Service($service); $service->save(); if (!empty(Input::get('pets'))) { $service->pets()->sync(Input::get('pets')); } return Redirect::to('/services')->with('success', 'Service is saved!'); } else { return Redirect::back()->withErrors($valid)->withInput(); } }
public function run() { DB::statement("TRUNCATE TABLE services"); $adminId = User::select('id')->where('username', 'dungho')->first()->id; $services = array('Xông hơi thảo dược', 'Waxing nách', 'Mặt nạ cao bí đao'); foreach ($services as $service) { $sv = new Service(); $sv->name = $service; // $sv->admin_id = $adminId; $sv->outlet_id = rand(1, 4); $sv->status = 'active'; $sv->created_at = new DateTime(); $sv->updated_at = new DateTime(); $sv->save(); } }
/** * 录入 * */ public function actionCreate() { parent::_acl(); $model = new Service(); if (isset($_POST['Service'])) { $image = XUpload::upload($_FILES['image']); $model->attributes = $_POST['Service']; if (is_array($image)) { $model->image = $image['pathname']; } if ($model->save()) { AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入海外服务,ID:' . $model->id)); $this->redirect(array('index')); } } $this->render('create', array('model' => $model)); }
/** * [saveModel - saves ou model info to the DB] * @param boolean $service [description] * @return [Eloquent model] [service eloquent model] */ protected function saveModel($service = false) { if (Input::get('id')) { $service = Service::find(Input::get('id')); } if (!$service) { $service = new Service(); } $load_company_model = $service->companies; $service->name = Input::get('name'); $service->category_id = Input::get('category_id'); $service->status_id = Input::get('status_id'); $service->invoice_periods_id = Input::get('invoice_periods_id'); $service->default_monthly_costs = Input::get('default_monthly_costs'); $service->comment = Input::get('comment'); $service->save(); return $service; }
public static function store() { $params = $_POST; $employees = Employee::all(); $attributes = array('name' => $params['name'], 'price' => $params['price'], 'description' => $params['description']); $service = new Service($attributes); $errors = $service->errors(); if (count($errors) == 0) { $service->save(); foreach ($employees as $emp) { if (isset($_POST[$emp->id])) { OfferedServicesController::create($emp->id, $service->id); } } Redirect::to('/palvelut/' . $service->id, array('message' => 'Uusi palvelu luotu!')); } else { View::make('service/new.html', array('errors' => $errors, 'attributes' => $attributes, 'employees' => $employees)); } }
public static function create() { $params = $_POST; $service = new Service(array('name' => $params['name'], 'reservation_unit' => $params['reservation_unit'], 'rate' => $params['rate'], 'opens_at' => $params['opens_at'], 'closes_at' => $params['closes_at'])); $errors = $service->errors(); $error = false; $message = ''; if (count($errors) > 0) { $error = true; $message = 'Virheelliset tiedot!'; Redirect::to(\Slim\Slim::getInstance()->urlFor('service_add'), array('message' => $message, 'error' => $error, 'errors' => $errors, 'service' => $service)); } else { try { $service->save(); Redirect::to(\Slim\Slim::getInstance()->urlFor('services_index'), array('message' => 'Palvelu luotu!')); } catch (Exception $e) { Redirect::to(\Slim\Slim::getInstance()->urlFor('services_index'), array('message' => 'Virhe tallennettaessa palvelua!', 'error' => true)); } } }
public function save() { $app = Yii::app(); $transaction = $app->db->beginTransaction(); try { if ($this->validate() == false) { throw new CDbException('参数出错', 0, []); } preg_match('/^(.*)@/', $this->username, $match); $password = CPasswordHelper::hashPassword($this->password); $result = Fraudmetrix::register($this->username, $this->username, $password); if ($result['success'] == true && $result['final_decision'] == 'Reject') { throw new CDbException('注册用户失败', 100, []); } $user = new User(); $user->attributes = ['username' => $this->username, 'realname' => isset($match[1]) ? $match[1] : '无', 'nickname' => isset($match[1]) ? $match[1] : '无', 'email' => $this->username, 'password' => $password, 'sign_up_time' => time(), 'sign_up_ip' => Yii::app()->request->getUserHostAddress(), 'approved' => 5, 'state' => 0]; if ($user->save() === false) { throw new CDbException('注册用户失败', 10, $user->getErrors()); } $user->uuid = $app->getSecurityManager()->generateUUID($user->id . $user->password); if ($user->save() === false) { throw new CDbException('注册用户失败', 10, $user->getErrors()); } //写入service $service = new Service(); $service->attributes = ['uid' => $user->id, 'email' => $user->username, 'status' => 1, 'traffic' => 100 * 100]; if ($service->save()) { Queue::apiCreate($user->id); } $transaction->commit(); } catch (CDbException $e) { $transaction->rollback(); $this->addErrors($e->errorInfo); return false; } $email = $app->getComponent('email'); if (!empty($email)) { $email->quickSend($this->username, '欢迎您注册夸父', "请妥善保管好您的登录密码:" . $this->password); } return true; }
/** * Тест каскадных удалений * */ 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); }
public function services_post() { if (Request::ajax()) { $data['response'] = 'validation_failed'; $service_name = Input::get('service_name'); $rules = array('service_name' => 'required|unique:services,name'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { $data['errors'] = $validator->getMessageBag()->toArray(); $data['message'] = "Oops there was an error."; } else { $service = new Service(); $service->name = strip_tags(ucwords($service_name)); $service->save(); $data['response'] = "ok"; $data['message'] = "Service was successfully saved."; } $response = Response::make(json_encode($data), 200); $response->header('Content-Type', 'text/json'); return $response; } }
/** * Авторизоваться * Проверяем 2 ситуации: * - У пользователя есть подписка на услугу iphone, и она просрочена * - У пользователя есть действующая подписка */ public function testAuthentificatedAndSubscribed() { $plan = array(array('subscribed_till' => date('Y-m-d', strtotime('- 2 days')), 'status_code' => 402, 'element' => array('selector' => 'response error', 'contents' => 'Payment required'), 'is_authenticated' => false), array('subscribed_till' => date('Y-m-d', strtotime('+ 2 days')), 'status_code' => 200, 'element' => array('selector' => 'response message', 'contents' => 'Authentificated'), 'is_authenticated' => true)); $expected = array('user_name' => "Name", 'user_login' => "Login", 'password' => "ValidPassword"); $user = $this->helper->makeUser($expected); $service = new Service(); $service->keyword = Service::SERVICE_IPHONE; $service->price = 100; $service->name = "Уникальное имя услуги " . uniqid(); $service->save(); foreach ($plan as $case) { if (!isset($subscription)) { $subscription = new ServiceSubscription(); $subscription->service_id = $service->id; $subscription->user_id = $user->getId(); } $subscription->subscribed_till = $case['subscribed_till']; $subscription->save(); $requestParams = array('login' => $expected['user_login'], 'password' => $expected['password']); $this->browser->post($this->generateUrl("auth"), $requestParams)->with("request")->begin()->isParameter("module", "myAuth")->isParameter("action", "login")->end()->with("response")->begin()->isStatusCode($case['status_code'])->checkElement($case['element']['selector'], $case['element']['contents'])->end()->with("user")->isAuthenticated($case['is_authenticated']); } }
protected function envService() { $service2 = new Service(); $service2->title = 'Caretaker'; $service2->description = 'I helped take care of kids at our church on sundays.'; $service2->template_id = 2; $service2->save(); $service21 = new Service(); $service21->title = 'Raise awareness'; $service21->description = 'I helped rise awareness for cancer'; $service21->template_id = 2; $service21->save(); $service22 = new Service(); $service22->title = 'Babysitting'; $service22->description = "Every weekend i'd go over to my friends house to watch their kids."; $service22->template_id = 2; $service22->save(); $service3 = new Service(); $service3->title = 'My Project'; $service3->description = 'Its pretty awesome'; $service3->template_id = 3; $service3->save(); }
/** * 公司信息保存 */ public function actionSaveserviceorgan() { $OrganID = Yii::app()->user->getOrganID(); $Organ = Yii::app()->request->getParam("Organ"); $arr = Yii::app()->request->getParam("telPhone"); $TelPhone = ""; foreach ($arr as $key => $val) { if (empty($val)) { continue; } $TelPhone .= $val . ","; } $model = Organ::model()->findByPK($OrganID); if (empty($model)) { $model = new Organ(); } //保存organ数据 $model->attributes = $Organ; $model->TelPhone = trim($TelPhone, ','); //判断基本信息是否为空,为空则不提交 if ($Organ) { //接收删除图片的地址 $photoId = Yii::app()->request->getParam("photoId"); //判断是否删除图片 if (!empty($photoId)) { $imageids = explode(',', $photoId); foreach ($imageids as $imageid) { $picture = OrganPhoto::model()->find('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID)); //判断该图片路径是否存在数据库中 if (empty($picture)) { $ftp = new Ftp(); $res = $ftp->delete_file($imageid); $ftp->close(); } else { OrganPhoto::model()->deleteAll('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID)); $ftp = new Ftp(); $res = $ftp->delete_file($picture->Path); $ftp->close(); } } } //接收上传图片地址 $goodsImages = Yii::app()->request->getParam("goodsImages"); //判断是否有上传图片 if (!empty($goodsImages)) { $imglegth = count($goodsImages); for ($i = 0; $i < $imglegth; $i++) { $goodsImg = new OrganPhoto(); $goodsImg->OrganID = $OrganID; $goodsImg->Path = $goodsImages[$i]; $goodsImg->save(); } } //判断是否上传营业执照 $BLPoto = Yii::app()->request->getParam("BLPoto"); if ($model->BLPoto != $BLPoto) { if (!empty($model->BLPoto)) { $ftp = new Ftp(); $res = $ftp->delete_file($model->BLPoto); $ftp->close(); } $model->BLPoto = $BLPoto; } //接收service数据 $service = Yii::app()->request->getParam("Service"); $opentime = Yii::app()->request->getParam("OpenTime"); //保存service数据 $servicemodel = Service::model()->find("OrganID=:organid", array(":organid" => $OrganID)); if (empty($servicemodel)) { //判断是否第一次添加 $servicemodel = new Service(); $servicemodel->OrganID = $OrganID; } $servicemodel->PositionCount = $service['PositionCount']; $servicemodel->TechnicianCount = $service['TechnicianCount']; $servicemodel->ParkingDigits = $service['ParkingDigits']; $servicemodel->ReservationMode = $service['ReservationMode']; $servicemodel->ShopArea = $service['ShopArea']; $servicemodel->OpenTime = $opentime[0] . ',' . $opentime[1] . ',' . $opentime[2] . ',' . $opentime[3]; //$model->attributes = $Organ; if ($servicemodel->save() && $model->save()) { //保存成功 //$file->saveAs(Yii::app()->params['uploadPath'].$model->Logo, true); $this->redirect(array('index')); } else { var_dump($goodsImg->errors); die; } } }
/** * @return Service */ private function getService() { if (is_null($this->_service)) { $service = new Service(); $service->price = 100; $service->save(); $this->_service = $service; } return $this->_service; }
public function actionSaveorgan() { $userId = Commonmodel::getOrganID(); //执行添加或修改操作 if ($_POST['Service']) { $userId = Commonmodel::getOrganID(); $service = $_POST['Service']; //获取营业时间、经营区域、地址 $openTime = $_POST['startWeek'] . "," . $_POST['endWeek'] . "," . $_POST['startTime'] . "," . $_POST['endTime']; $service['serviceOpenTime'] = $openTime; $service['serviceProvince'] = $_POST['serviceProvince']; $service['serviceCity'] = $_POST['serviceCity']; $service['serviceArea'] = $_POST['serviceArea']; $service['serviceRegionProvince'] = $_POST['serviceRegionProvince']; $service['serviceRegionCity'] = $_POST['serviceRegionCity']; $service['serviceRegionArea'] = $_POST['serviceRegionArea']; $rsType == false; // 添加机构照片 if ($_POST['organImages']) { $organImages = $_POST['organImages']; $imglegth = count($organImages); for ($i = 0; $i < $imglegth; $i++) { $organImg = new ServicePhoto(); $organImg->userId = $userId; $organImg->addTime = date("Y-m-d", time()); $organImg->photoName = $organImages[$i]; $organImg->save(); } $rsType = true; } else { $rsType = true; } // 删除机构照片 if (!empty($_POST['photoName'])) { $photoName = $_POST['photoName']; //该处传过来的其实是图片名称 $imagenames = explode(',', $photoName); foreach ($imagenames as $imagename) { $myfileurl = Yii::app()->params['uploadPath'] . $imagename; $oldpic = ServicePhoto::model()->find("photoName=:name", array(":name" => $imagename)); if ($oldpic) { //存入数据库后删除 $bools = ServicePhoto::model()->deleteAll("photoName=:name", array(":name" => $imagename)); if ($bools) { if (file_exists($myfileurl)) { unlink($myfileurl); } } } else { //添加时删除(未存入数据库) if (file_exists($myfileurl)) { unlink($myfileurl); } } } $rsType = true; } else { $rsType = true; } //判断机构信息是否存在,存在则修改,不存在则添加 $model = Service::model()->find("userId=:userId", array(":userId" => $userId)); if (!empty($service)) { if (empty($model)) { $model = new Service(); $model->userId = $userId; $model->attributes = $service; if ($model->save()) { $user = User::model()->findByPk($userId); $user->OrganID = $userId; $user->save(); } $rsType = true; } $model->attributes = $service; if ($model->updateByPk($userId, $service)) { $rsType = true; } } else { $rsType = true; } if ($rsType) { echo json_encode('OK'); } else { echo json_encode('NoOk'); } } }
protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); // create connection to import database $this->logSection('connection', 'creating connection to import source'); $source = Propel::getConnection($options['source'] ? $options['source'] : null); // create static counties and offices $this->logSection('static', 'creating static counties and offices'); $connection->beginTransaction(); try { OfficePeer::doDeleteAll($connection); $o1 = new Office(); $o1->setName('Plattsburgh'); $o1->save($connection); $o1 = new Office(); $o1->setName('Rouses Point'); $o1->save($connection); CountyPeer::doDeleteAll($connection); $c1 = new County(); $c1->setName('Clinton'); $c1->save($connection); $c1 = new County(); $c1->setName('Essex'); $c1->save($connection); $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // read in and create objects for district, frequency, icd9, job, services tables // DISTRICT $query = 'SELECT * FROM %s'; $query = sprintf($query, 'tbl_district'); $statement = $source->prepare($query); $statement->execute(); $districts = $statement->fetchAll(); $connection->beginTransaction(); try { DistrictPeer::doDeleteAll($connection); foreach ($districts as $district) { $this->logSection('district', 'creating district ' . $district['district_name']); $d1 = new District(); $d1->setName($district['district_name']); $d1->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // FREQUENCY $query = 'SELECT * FROM %s'; $query = sprintf($query, 'tbl_frequency'); $statement = $source->prepare($query); $statement->execute(); $frequencies = $statement->fetchAll(); $connection->beginTransaction(); try { FrequencyPeer::doDeleteAll($connection); foreach ($frequencies as $freq) { $this->logSection('freq', 'reading frequency ' . $freq['freq_title']); $f1 = new Frequency(); $f1->setName($freq['freq_title']); $f1->setDescription($freq['freq_description']); $f1->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // ICD9 $query = 'SELECT * FROM %s'; $query = sprintf($query, 'tbl_icd9'); $statement = $source->prepare($query); $statement->execute(); $icd9s = $statement->fetchAll(); $connection->beginTransaction(); try { Icd9Peer::doDeleteAll($connection); foreach ($icd9s as $icd9) { $this->logSection('icd9', 'reading icd9 ' . $icd9['icd9_value']); $i1 = new Icd9(); $i1->setName($icd9['icd9_value']); $i1->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // JOB $query = 'SELECT * FROM %s'; $query = sprintf($query, 'tbl_job'); $statement = $source->prepare($query); $statement->execute(); $jobs = $statement->fetchAll(); $connection->beginTransaction(); try { JobPeer::doDeleteAll($connection); foreach ($jobs as $job) { $this->logSection('job', 'reading job ' . $job['job_title']); $j1 = new Job(); $j1->setName($job['job_title']); $j1->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // SERVICES $query = 'SELECT * FROM %s'; $query = sprintf($query, 'tbl_services'); $statement = $source->prepare($query); $statement->execute(); $services = $statement->fetchAll(); $connection->beginTransaction(); try { ServicePeer::doDeleteAll($connection); foreach ($services as $service) { $this->logSection('service', 'reading service ' . $service['service_title']); $s1 = new Service(); $s1->setName($service['service_title']); $s1->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // EMPLOYEES $query = 'SELECT * FROM %s LEFT JOIN (%s) ON (%s.emp_job_title = %s.job_id)'; $query = sprintf($query, 'tbl_employee', 'tbl_job', 'tbl_employee', 'tbl_job'); $statement = $source->prepare($query); $statement->execute(); $employees = $statement->fetchAll(); $connection->beginTransaction(); try { EmployeePeer::doDeleteAll($connection); foreach ($employees as $employee) { $this->logSection('employee', 'reading employee ' . $employee['emp_id']); $emp = new Employee(); $emp_fields = array('clearance' => $employee['emp_scr_clearance'], 'first_name' => $employee['emp_fn'], 'middle' => $employee['emp_mi'], 'last_name' => $employee['emp_ln'], 'address' => $employee['emp_address'], 'address_2' => $employee['emp_address2'], 'city' => $employee['emp_city'], 'state' => $employee['emp_state'], 'zip' => $employee['emp_zip'], 'home_phone' => $employee['emp_phone'], 'cell_phone' => $employee['emp_cell'], 'company_email' => $employee['emp_email'], 'personal_email' => $employee['emp_p_email'], 'license_number' => $employee['emp_license_number'], 'license_expiration' => $employee['emp_license_exp'], 'dob' => $employee['emp_dob'], 'doh' => $employee['emp_hire_date'], 'dof' => $employee['emp_end_date'], 'ssn' => $employee['emp_ssn'], 'health_insurance' => $employee['emp_health'], 'retirement_plan' => $employee['emp_401k'], 'suplimental_health' => $employee['emp_health_sup'], 'health_type' => $employee['emp_health_type'], 'tb_date' => $employee['emp_tb'], 'osha_date' => $employee['emp_osha'], 'cpr_date' => $employee['emp_cpr'], 'finger_prints' => $employee['emp_fp'], 'finger_print_notes' => $employee['emp_fp_n'], 'notes' => $employee['emp_notes']); $emp->fromArray($emp_fields, BasePeer::TYPE_FIELDNAME); // find the job - check for errors $emp->setJob(JobPeer::getByName($employee['job_title'])); // if physical has a date then create a new physical object for employee if ($employee['emp_physical']) { $this->logSection('physical', 'employee ' . $employee['emp_fn'] . ' had a physical on ' . $employee['emp_physical']); $ph1 = new Physical(); $ph1->setEmployee($emp); $ph1->setDateGiven($employee['emp_physical']); $ph1->save($connection); } $emp->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // read in and create client objects - linking to employee // CLIENTS $query = 'SELECT * FROM %s LEFT JOIN (%s) ON (%s.client_district = %s.district_id)'; $query = sprintf($query, 'tbl_client', 'tbl_district', 'tbl_client', 'tbl_district'); $statement = $source->prepare($query); $statement->execute(); $clients = $statement->fetchAll(); $connection->beginTransaction(); try { ClientPeer::doDeleteAll($connection); foreach ($clients as $client) { $this->logSection('client', 'reading client ' . $client['client_ln']); $cl = new Client(); $client_fields = array('first_name' => $client['client_fn'], 'last_name' => $client['client_ln'], 'dob' => $client['client_dob'], 'parent_first' => $client['client_parent_fn'], 'parent_last' => $client['client_parent_ln'], 'address' => $client['client_address'], 'address_2' => $client['client_address2'], 'city' => $client['client_city'], 'state' => $client['client_state'], 'zip' => $client['client_zip'], 'home_phone' => $client['home_phone'], 'work_phone' => $client['work_phone'], 'cell_phone' => $client['cell_phone'], 'blue_card' => $client['blue_card'], 'physical_exp' => $client['physical_exp_date'], 'immunizations' => $client['immunizations'], 'waiting_list' => $client['waiting_list']); // county $cl->setCounty(CountyPeer::getByName($client['client_county'])); // district $cl->setDistrict(DistrictPeer::getByName($client['district_name'])); $cl->fromArray($client_fields, BasePeer::TYPE_FIELDNAME); $cl->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // CLIENT SERVICES // CLASSROOM $query = 'SELECT * FROM tbl_classroom LEFT JOIN (tbl_client) ON (tbl_classroom.class_client_id = tbl_client.client_id) LEFT JOIN (tbl_employee) ON (tbl_classroom.class_provider_id = tbl_employee.emp_id) LEFT JOIN (tbl_services) ON (tbl_classroom.class_service_id = tbl_services.service_id) LEFT JOIN (tbl_frequency) ON (tbl_classroom.class_freq_id = tbl_frequency.freq_id)'; $statement = $source->prepare($query); $statement->execute(); $classrooms = $statement->fetchAll(); $connection->beginTransaction(); $c = new Criteria(); $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_CLASSROOM); try { ClientServicePeer::doDelete($c, $connection); foreach ($classrooms as $classroom) { $this->logSection('classroom', 'reading service ' . $classroom['class_id']); $cr_cl = new Classroom(); $cr_cl->setStartDate($classroom['class_start_date']); $cr_cl->setEndDate($classroom['class_exp_date']); $cr_cl->setChangeDate($classroom['class_chng_date']); $cr_cl->setNotes($classroom['class_notes']); // client $cr_cl->setClient(ClientPeer::getByFullName($classroom['client_fn'], $classroom['client_ln'])); // employee $cr_cl->setEmployee(EmployeePeer::getByFullName($classroom['emp_fn'], $classroom['emp_ln'])); // service $cr_cl->setService(ServicePeer::getByName($classroom['service_title'])); // frequency $cr_cl->setFrequency(FrequencyPeer::getByName($classroom['freq_title'])); // office $cr_cl->setOffice(OfficePeer::getByName($classroom['class_location'])); $cr_cl->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // EI $query = 'SELECT * FROM tbl_ei LEFT JOIN (tbl_client) ON (tbl_ei.ei_client_id = tbl_client.client_id) LEFT JOIN (tbl_employee) ON (tbl_ei.ei_provider_id = tbl_employee.emp_id) LEFT JOIN (tbl_services) ON (tbl_ei.ei_service_id = tbl_services.service_id) LEFT JOIN (tbl_frequency) ON (tbl_ei.ei_freq_id = tbl_frequency.freq_id) LEFT JOIN (tbl_icd9) ON (tbl_ei.ei_icd9_id = tbl_icd9.icd9_id)'; $statement = $source->prepare($query); $statement->execute(); $eis = $statement->fetchAll(); $connection->beginTransaction(); $c = new Criteria(); $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_EI); try { ClientServicePeer::doDelete($c, $connection); foreach ($eis as $ei) { $this->logSection('ei', 'reading service ' . $ei['ei_id']); $ei_cl = new Ei(); $ei_cl->setStartDate($ei['ei_start_date']); $ei_cl->setEndDate($ei['ei_exp_date']); $ei_cl->setChangeDate($ei['ei_chng_date']); $ei_cl->setNotes($ei['ei_serv_notes']); $ei_cl->setAuthorization($ei['ei_auth']); $ei_cl->setPhysiciansOrder($ei['ei_p_order']); // client $ei_cl->setClient(ClientPeer::getByFullName($ei['client_fn'], $ei['client_ln'])); // employee $ei_cl->setEmployee(EmployeePeer::getByFullName($ei['emp_fn'], $ei['emp_ln'])); // service $ei_cl->setService(ServicePeer::getByName($ei['service_title'])); // frequency $ei_cl->setFrequency(FrequencyPeer::getByName($ei['freq_title'])); // office $ei_cl->setIcd9(Icd9Peer::getByName($ei['icd9_value'])); $ei_cl->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // PRESCHOOL $query = 'SELECT * FROM tbl_preschool LEFT JOIN (tbl_client) ON (tbl_preschool.pre_client_id = tbl_client.client_id) LEFT JOIN (tbl_employee) ON (tbl_preschool.pre_provider_id = tbl_employee.emp_id) LEFT JOIN (tbl_services) ON (tbl_preschool.pre_service_id = tbl_services.service_id) LEFT JOIN (tbl_frequency) ON (tbl_preschool.pre_freq_id = tbl_frequency.freq_id)'; $statement = $source->prepare($query); $statement->execute(); $preschools = $statement->fetchAll(); $connection->beginTransaction(); $c = new Criteria(); $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_PRESCHOOL); try { ClientServicePeer::doDelete($c, $connection); foreach ($preschools as $preschool) { $this->logSection('preschool', 'reading service ' . $preschool['pre_id']); $pr_cl = new Preschool(); $pr_cl->setStartDate($preschool['pre_start_date']); $pr_cl->setEndDate($preschool['pre_exp_date']); $pr_cl->setChangeDate($preschool['pre_chng_date']); // client $pr_cl->setClient(ClientPeer::getByFullName($preschool['client_fn'], $preschool['client_ln'])); // employee $pr_cl->setEmployee(EmployeePeer::getByFullName($preschool['emp_fn'], $preschool['emp_ln'])); // service $pr_cl->setService(ServicePeer::getByName($preschool['service_title'])); // frequency $pr_cl->setFrequency(FrequencyPeer::getByName($preschool['freq_title'])); $pr_cl->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // SEIT $query = 'SELECT * FROM tbl_seit LEFT JOIN (tbl_client) ON (tbl_seit.seit_client_id = tbl_client.client_id) LEFT JOIN (tbl_employee) ON (tbl_seit.seit_provider_id = tbl_employee.emp_id) LEFT JOIN (tbl_services) ON (tbl_seit.seit_service_id = tbl_services.service_id) LEFT JOIN (tbl_frequency) ON (tbl_seit.seit_freq_id = tbl_frequency.freq_id)'; $statement = $source->prepare($query); $statement->execute(); $seits = $statement->fetchAll(); $connection->beginTransaction(); $c = new Criteria(); $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_SEIT); try { ClientServicePeer::doDelete($c, $connection); foreach ($seits as $seit) { $this->logSection('seit', 'reading service ' . $seit['seit_id']); $seit_cl = new Seit(); $seit_cl->setStartDate($seit['seit_start_date']); $seit_cl->setEndDate($seit['seit_exp_date']); $seit_cl->setChangeDate($seit['seit_chng_date']); $seit_cl->setNotes($seit['seit_notes']); // client $seit_cl->setClient(ClientPeer::getByFullName($seit['client_fn'], $seit['client_ln'])); // employee $seit_cl->setEmployee(EmployeePeer::getByFullName($seit['emp_fn'], $seit['emp_ln'])); // service $seit_cl->setService(ServicePeer::getByName($seit['service_title'])); // frequency $seit_cl->setFrequency(FrequencyPeer::getByName($seit['freq_title'])); $seit_cl->save($connection); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } }