/** * Run the database seeds. * * @return void */ public function run() { DB::table('cs_status')->delete(); $status = array("Open", "In Progress", "Close", "Cancel"); foreach ($status as $stt) { $status = new Status(); $status->name = $stt; $status->description = "Lorem Ipsum has been the dummy text ever since the 1500s"; $status->save(); } }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aOfferVoucher1 !== null) { if ($this->aOfferVoucher1->isModified() || $this->aOfferVoucher1->isNew()) { $affectedRows += $this->aOfferVoucher1->save($con); } $this->setOfferVoucher1($this->aOfferVoucher1); } if ($this->aStatus !== null) { if ($this->aStatus->isModified() || $this->aStatus->isNew()) { $affectedRows += $this->aStatus->save($con); } $this->setStatus($this->aStatus); } if ($this->isNew()) { $this->modifiedColumns[] = SalesPeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = SalesPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += SalesPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } if ($this->collPurchaseDetails !== null) { foreach ($this->collPurchaseDetails as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Status(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Status'])) { $model->attributes = $_POST['Status']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Show the form for creating a new resource. * * @return Response */ public function postCreate() { $validator = Validator::make(Input::all(), Status::$rules); if ($validator->passes()) { $status = new Status(); $data = Input::all(); $status->fill($data); $status->date = date("Y-m-d", strtotime(Input::get('date'))); $status->save(); return Redirect::to(Input::get('url') . '#' . $status->id)->with('confirmation', '¡El nuevo status a sido guardado!'); } else { // validation has failed, display error messages return Redirect::to(Input::get('url') . "#formStatus")->with('message-box', 'Debes corregir los siguientes campos:')->withErrors($validator)->withInput(); } }
/** * Store a newly created resource in storage. * POST /projectstatus * * @return Response */ public function store() { Input::merge(array_map('trim', Input::all())); $input_all = Input::all(); $validation = Validator::make($input_all, Status::$rules); if ($validation->passes()) { $status = new Status(); $status->status = strtoupper(Input::get('project_status')); $status->description = strtoupper(Input::get('description')); $status->save(); return Redirect::route('project.status.index')->with('class', 'success')->with('message', 'Record successfully created.'); } else { return Redirect::route('project.status.create')->withInput()->withErrors($validation)->with('class', 'error')->with('message', 'There were validation error.'); } }
public function store() { $rules = ['name' => 'required', 'address' => 'required', 'postal_code' => 'required', 'email' => 'required|email', 'phone' => 'required']; $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } else { $password = Input::get('password'); if (Input::has('store_id')) { $id = Input::get('store_id'); $store = StoreModel::find($id); if ($password !== '') { $store->secure_key = md5($store->salt . $password); } } else { $store = new StoreModel(); if ($password === '') { $alert['msg'] = 'You have to enter password'; $alert['type'] = 'danger'; return Redirect::route('company.store.create')->with('alert', $alert); } $store->salt = str_random(8); $store->token = str_random(8); $store->secure_key = md5($store->salt . $password); $store->company_id = Session::get('company_id'); } $store->name = Input::get('name'); $store->address = Input::get('address'); $store->postal_code = Input::get('postal_code'); $store->email = Input::get('email'); $store->phone = Input::get('phone'); $store->description = Input::get('description'); $store->save(); if (!Input::has('store_id')) { $status = new StatusModel(); $status->store_id = $store->id; $startNo = rand(1, 100); $status->current_queue_no = $startNo; $status->last_queue_no = $startNo; $status->save(); } $alert['msg'] = 'Store has been saved successfully'; $alert['type'] = 'success'; return Redirect::route('company.store')->with('alert', $alert); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { if (!empty(Input::get('name'))) { $val = Status::validate(Input::all()); if ($val->fails()) { return Redirect::back()->withErrors($val); } try { $status = new Status(); $status->name = Input::get('name'); $status->save(); } catch (Exception $e) { return Redirect::back()->with('message', FlashMessage::DisplayAlert('Status can NOT be created. Already exists.', 'alert')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Status Created Successfully!', 'success')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Enter a valid status name.', 'alert')); }
public function add_status() { $inputs = Input::all(); $rules = array('status_nombre' => 'required|max:20|unique:status,status_nombre'); $validator = Validator::make($inputs, $rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator); } else { $status = new Status(); $status->status_nombre = Input::get('status_nombre'); if ($status->save()) { Session::flash('message', 'Guardado Correctamente'); Session::flash('class', 'success'); } else { Session::flash('message', 'Ha ocurrido un error, intentelo nuevamente'); Session::flash('class', 'danger'); } return Redirect::to('status'); } }
function updateStatus($id) { if (is_null($id)) { Functions::setResponse(400); } $data = Functions::getJSONData(); try { $s = new Status($id); foreach ($s->getFields() as $field) { $value = Functions::elt($data, $field['name']); if (is_null($value)) { Functions::setResponse(400); } $s->set($field['name'], $value); } $s->set('id', $id); $s->save(); return true; } catch (RuntimeException $e) { Functions::setResponse(404); } }
} else { //if the item was changed successfully, add to array $changes[] = "<strong>" . $value . "</strong> was not updated successfully."; $changes[] = $database->last_error; } } } } //now we're done with all updates //check to see if we need to create a new status record //only if it's not blank if (!empty($_POST['new_status'])) { $new_status = new Status(); $new_status->name = $_POST['new_status']; //try to save if ($new_status->save()) { $changes[] = "<strong>" . $new_status->name . "</strong> was created successfully!"; } else { $changes[] = "<strong>" . $new_status->name . "</strong> was not created successfully!"; } $changes[] = $database->last_error; } //at this point, we're done with all changes //check to see if there are any changes, if so, make them into messages if (count($changes) != 0) { $session->message(implode("<br />", $changes)); } //lastly, redirect back to itself redirect_head(current_url()); } //header template
public function addStatus($user) { $loggedInUser = $this->registry->getObject('authenticate')->getUser()->getUserID(); if ($loggedInUser == $user) { require_once 'status.php'; if (isset($_POST['status_type']) && $_POST['status_type'] != 'update') { if ($_POST['status_type'] == 'image') { require_once 'imagestatus.php'; $status = new Imagestatus($this->registry, 0, $this->username); $status->processImage('image_file'); } elseif ($_POST['status_type'] == 'video') { require_once 'videostatus.php'; $status = new Videostatus($this->registry, 0, $this->username); $status->setVideoIdFromURL($_POST['video_url']); } elseif ($_POST['status_type'] == 'link') { require_once 'linkstatus.php'; $status = new Linkstatus($this->registry, 0); $status->setURL($this->registry->getObject('db')->sanitizeData($_POST['link_url'])); $status->setDescription($this->registry->getObject('db')->sanitizeData($_POST['link_description'])); } } else { $status = new Status($this->registry, 0); } $status->setProfile($user); $status->setPoster($loggedInUser); if (isset($_POST['status'])) { $status->setStatus($this->registry->getObject('db')->sanitizeData($_POST['status'])); } $status->generateType(); $status->save(); // success message display $this->registry->getObject('template')->addTemplateBit('status_update_message', 'profile_status_update_confirm.php'); } else { require_once 'relation.php'; $relationships = new RelationsGet($this->registry); $connections = $relationships->getNetwork($user, false); if (in_array($loggedInUser, $connections)) { require_once 'status.php'; if (isset($_POST['status_type']) && $_POST['status_type'] != 'update') { if ($_POST['status_type'] == 'image') { require_once 'imagestatus.php'; $status = new Imagestatus($this->registry, 0, $this->username); $status->processImage('image_file'); } elseif ($_POST['status_type'] == 'video') { require_once 'videostatus.php'; $status = new Videostatus($this->registry, 0, $this->username); $status->setVideoIdFromURL($_POST['video_url']); } elseif ($_POST['status_type'] == 'link') { require_once 'linkstatus.php'; $status = new Linkstatus($this->registry, 0); $status->setURL($this->registry->getObject('db')->sanitizeData($_POST['link_url'])); $status->setDescription($this->registry->getObject('db')->sanitizeData($_POST['link_description'])); } } else { $status = new Status($this->registry, 0); } $status->setProfile($user); $status->setPoster($loggedInUser); $status->setStatus($this->registry->getObject('db')->sanitizeData($_POST['status'])); $status->generateType(); $status->save(); // success message display $this->registry->getObject('template')->addTemplateBit('status_update_message', 'profile_status_post_confirm.php'); } else { // error message display $this->registry->getObject('template')->addTemplateBit('status_update_message', 'profile_status_error.php'); } } }
private function addStatus($array, $user) { $loggedIn = $this->registry->getObject('authenticate')->isLoggedIn(); if ($loggedIn == true) { require_once 'status.php'; if (isset($_POST['status_type']) && $_POST['status_type'] != 'update') { if ($_POST['status_type'] == 'image') { require_once 'imagestatus.php'; $status = new Imagestatus($this->registry, 0, $user); $status->processImage('image_file'); } elseif ($_POST['status_type'] == 'video') { require_once 'videostatus.php'; $status = new Videostatus($this->registry, 0, $user); $status->setVideoIdFromURL($_POST['video_url']); } elseif ($_POST['status_type'] == 'link') { require_once 'linkstatus.php'; $status = new Linkstatus($this->registry, 0); $status->setURL($this->registry->getObject('db')->sanitizeData($_POST['link_url'])); $status->setDescription($this->registry->getObject('db')->sanitizeData($_POST['link_description'])); } } else { $status = new Status($this->registry, 0); } $status->setProfile($user); $status->setPoster($user); if (isset($_POST['status'])) { $status->setStatus($this->registry->getObject('db')->sanitizeData($_POST['status'])); } $status->generateType(); $status->save(); $newAddID = $status->getID(); //Status Wierdness Start $this->registry->getObject('template')->getPage()->addTag('referer', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''); require_once 'stream.php'; $stream = new Stream($this->registry); $status = $stream->getStatusByID($newAddID); $statusTypes = $stream->getStatusType(); if (!$stream->isEmpty()) { $this->registry->getObject('template')->buildFromTemplate('stream_more.php'); } $streamdata = $stream->getStream(); $IDs = $stream->getIDs(); $cacheableIDs = array(); foreach ($IDs as $id) { $i = array(); $i['status_id'] = $id; $cacheableIDs[] = $i; } $cache = $this->registry->getObject('db')->cacheData($cacheableIDs); $this->registry->getObject('template')->getPage()->addTag('stream', array('DATA', $cache)); //var_dump($cacheableIDs); foreach ($streamdata as $data) { $datatags = array(); foreach ($data as $tag => $value) { $datatags['status' . $tag] = $value; } //var_dump($datatags); // your own status updates if ($data['profile'] == 0) { // network updates $this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-general.php', $datatags); } elseif ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID() && $data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) { $this->registry->getObject('template')->addTemplateBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-self.php', $datatags); } elseif ($data['profile'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) { // updates to you $this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-toSelf.php', $datatags); } elseif ($data['poster'] == $this->registry->getObject('authenticate')->getUser()->getUserID()) { // updates by you $this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-fromSelf.php', $datatags); } elseif ($data['poster'] == $data['profile']) { $this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '-user.php', $datatags); } else { // network updates $this->addBit('stream-' . $data['ID'], 'updates/' . $data['type_reference'] . '.php', $datatags); } } // stream comments, likes and dislikes $status_ids = implode(',', $IDs); $start = array(); foreach ($IDs as $id) { $start[$id] = array(); } // comments $this->generateComments($start, $status_ids); //rates $this->getRates('status', $IDs); //$this->getRates('comments', $IDs); $this->registry->getObject('template')->getPage()->addTag('offset', 20); //$offset + $this->registry->getObject('template')->parseOutput(); $this->registry->ajaxReply(array('content' => $this->registry->getObject('template')->getPage()->getContentToPrint(), 'status' => 'Status Added')); //$this->registry->ajaxReply(array('content' => '<script>$(document).ready(function(){window.location.reload();})</script>', 'status' => 'Status Added')); //Status Wierdness End // success message display //$this->registry->ajaxReply( array('status'=>'Status Added', 'content'=>'') ); //$this->registry->getObject('template')->addTemplateBit( 'status_update_message', 'profile_status_update_confirm.php' ); } else { //$this->registry->ajaxReply( array('status'=>'Access Denied', 'content'=>'') ); $this->registry->errorPage('Access Denied', 'Login to continue'); } }
public function run() { DB::table('statuses')->truncate(); $status = new Status(); $status->name = "Đơn hàng mới"; $status->tran_type_id = 1; $status->color = "Grey"; $status->type = "Đơn hàng mới"; $status->save(); $status = new Status(); $status->name = "Xác nhận còn hàng"; $status->tran_type_id = 1; $status->color = "Red"; $status->type = "Đang xử lý"; $status->save(); $status = new Status(); $status->name = "Chừa hàng"; $status->tran_type_id = 1; $status->color = "Red"; $status->type = "Đang xử lý"; $status->save(); $status = new Status(); $status->name = "Đã chuyển khoản"; $status->tran_type_id = 1; $status->color = "Red"; $status->type = "Đang xử lý"; $status->save(); $status = new Status(); $status->name = "Đã gói hàng chờ chuyển"; $status->tran_type_id = 1; $status->color = "Red"; $status->type = "Đang xử lý"; $status->save(); $status = new Status(); $status->name = "Đã chuyển hàng"; $status->tran_type_id = 1; $status->color = "Red"; $status->type = "Đang xử lý"; $status->save(); $status = new Status(); $status->name = "Đã nhận hàng"; $status->tran_type_id = 1; $status->color = "Green"; $status->type = "Hoàn tất"; $status->save(); $status = new Status(); $status->name = "Báo hết hàng"; $status->tran_type_id = 1; $status->color = "Green"; $status->type = "Hoàn tất"; $status->save(); $status = new Status(); $status->name = "Khách hủy đơn"; $status->tran_type_id = 1; $status->color = "Green"; $status->type = "Hoàn tất"; $status->save(); $status = new Status(); $status->name = "Khách trả hàng"; $status->tran_type_id = 1; $status->color = "Green"; $status->type = "Hoàn tất"; $status->save(); //COD $status = new Status(); $status->name = "Đơn hàng mới"; $status->tran_type_id = 2; $status->color = "Grey"; $status->type = "Đơn hàng mới"; $status->save(); $status = new Status(); $status->name = "Xác nhận còn hàng"; $status->tran_type_id = 2; $status->color = "Red"; $status->type = "Đang xử lý"; $status->save(); $status = new Status(); $status->name = "Chừa hàng"; $status->tran_type_id = 2; $status->color = "Red"; $status->type = "Đang xử lý"; $status->save(); $status = new Status(); $status->name = "Đã gói hàng chờ chuyển"; $status->tran_type_id = 2; $status->color = "Red"; $status->type = "Đang xử lý"; $status->save(); $status = new Status(); $status->name = "Đã chuyển hàng"; $status->tran_type_id = 2; $status->color = "Red"; $status->type = "Đang xử lý"; $status->save(); $status = new Status(); $status->name = "Đã nhận hàng và thanh toán"; $status->tran_type_id = 2; $status->color = "Green"; $status->type = "Hoàn tất"; $status->save(); $status = new Status(); $status->name = "Báo hết hàng"; $status->tran_type_id = 2; $status->color = "Green"; $status->type = "Hoàn tất"; $status->save(); $status = new Status(); $status->name = "Khách hủy đơn"; $status->tran_type_id = 2; $status->color = "Green"; $status->type = "Hoàn tất"; $status->save(); $status = new Status(); $status->name = "Khách trả hàng"; $status->tran_type_id = 2; $status->color = "Green"; $status->type = "Hoàn tất"; $status->save(); }
/** * Stores the object in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param Connection $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave($con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aUser !== null) { if ($this->aUser->isModified()) { $affectedRows += $this->aUser->save($con); } $this->setUser($this->aUser); } if ($this->aSchemaPropertyElement !== null) { if ($this->aSchemaPropertyElement->isModified()) { $affectedRows += $this->aSchemaPropertyElement->save($con); } $this->setSchemaPropertyElement($this->aSchemaPropertyElement); } if ($this->aSchemaPropertyRelatedBySchemaPropertyId !== null) { if ($this->aSchemaPropertyRelatedBySchemaPropertyId->isModified()) { $affectedRows += $this->aSchemaPropertyRelatedBySchemaPropertyId->save($con); } $this->setSchemaPropertyRelatedBySchemaPropertyId($this->aSchemaPropertyRelatedBySchemaPropertyId); } if ($this->aSchema !== null) { if ($this->aSchema->isModified()) { $affectedRows += $this->aSchema->save($con); } $this->setSchema($this->aSchema); } if ($this->aProfileProperty !== null) { if ($this->aProfileProperty->isModified()) { $affectedRows += $this->aProfileProperty->save($con); } $this->setProfileProperty($this->aProfileProperty); } if ($this->aSchemaPropertyRelatedByRelatedSchemaPropertyId !== null) { if ($this->aSchemaPropertyRelatedByRelatedSchemaPropertyId->isModified()) { $affectedRows += $this->aSchemaPropertyRelatedByRelatedSchemaPropertyId->save($con); } $this->setSchemaPropertyRelatedByRelatedSchemaPropertyId($this->aSchemaPropertyRelatedByRelatedSchemaPropertyId); } if ($this->aStatus !== null) { if ($this->aStatus->isModified()) { $affectedRows += $this->aStatus->save($con); } $this->setStatus($this->aStatus); } if ($this->aFileImportHistory !== null) { if ($this->aFileImportHistory->isModified()) { $affectedRows += $this->aFileImportHistory->save($con); } $this->setFileImportHistory($this->aFileImportHistory); } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = SchemaPropertyElementHistoryPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += SchemaPropertyElementHistoryPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
public function postStatus($doc) { $toAdd = null; $status = Input::get('status'); $doc = Doc::find($doc); if (!isset($status)) { $doc->statuses()->sync(array()); } else { $toAdd = Status::where('label', $status['text'])->first(); if (!isset($toAdd)) { $toAdd = new Status(); $toAdd->label = $status['text']; } $toAdd->save(); $doc->statuses()->sync(array($toAdd->id)); } $response['messages'][0] = array('text' => 'Document saved', 'severity' => 'info'); return Response::json($response); }
/** * Stores the object in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param Connection $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave($con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aUserRelatedByCreatedUserId !== null) { if ($this->aUserRelatedByCreatedUserId->isModified()) { $affectedRows += $this->aUserRelatedByCreatedUserId->save($con); } $this->setUserRelatedByCreatedUserId($this->aUserRelatedByCreatedUserId); } if ($this->aUserRelatedByUpdatedUserId !== null) { if ($this->aUserRelatedByUpdatedUserId->isModified()) { $affectedRows += $this->aUserRelatedByUpdatedUserId->save($con); } $this->setUserRelatedByUpdatedUserId($this->aUserRelatedByUpdatedUserId); } if ($this->aConceptRelatedByConceptId !== null) { if ($this->aConceptRelatedByConceptId->isModified()) { $affectedRows += $this->aConceptRelatedByConceptId->save($con); } $this->setConceptRelatedByConceptId($this->aConceptRelatedByConceptId); } if ($this->aProfilePropertyRelatedBySkosPropertyId !== null) { if ($this->aProfilePropertyRelatedBySkosPropertyId->isModified()) { $affectedRows += $this->aProfilePropertyRelatedBySkosPropertyId->save($con); } $this->setProfilePropertyRelatedBySkosPropertyId($this->aProfilePropertyRelatedBySkosPropertyId); } if ($this->aVocabulary !== null) { if ($this->aVocabulary->isModified()) { $affectedRows += $this->aVocabulary->save($con); } $this->setVocabulary($this->aVocabulary); } if ($this->aConceptRelatedByRelatedConceptId !== null) { if ($this->aConceptRelatedByRelatedConceptId->isModified()) { $affectedRows += $this->aConceptRelatedByRelatedConceptId->save($con); } $this->setConceptRelatedByRelatedConceptId($this->aConceptRelatedByRelatedConceptId); } if ($this->aStatus !== null) { if ($this->aStatus->isModified()) { $affectedRows += $this->aStatus->save($con); } $this->setStatus($this->aStatus); } if ($this->aProfilePropertyRelatedByProfilePropertyId !== null) { if ($this->aProfilePropertyRelatedByProfilePropertyId->isModified()) { $affectedRows += $this->aProfilePropertyRelatedByProfilePropertyId->save($con); } $this->setProfilePropertyRelatedByProfilePropertyId($this->aProfilePropertyRelatedByProfilePropertyId); } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = ConceptPropertyPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += ConceptPropertyPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } if ($this->collConcepts !== null) { foreach ($this->collConcepts as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collConceptPropertyHistorys !== null) { foreach ($this->collConceptPropertyHistorys as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collDiscusss !== null) { foreach ($this->collDiscusss as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
public function saveStatusChanges($req) { if (!array_key_exists('action', $req)) { return false; } if ($req['action'] != 'saveStatus') { return false; } if ($this->readOnly) { return false; } $statusMessage = $req['textfieldStatus']; $statusRow = new Status(); $statusRow = $statusRow->find($this->uid); if (is_object($statusRow)) { $fields['uid'] = $this->uid; $fields['status'] = $statusRow->status; $fields['created'] = $statusRow->modified; $fields['cleared'] = strftime('%Y-%m-%d %H:%M:%S', time()); $fields['aid'] = -1; //Copy current status to history. $statusHistory = new StatusHistory($fields); $statusHistory->save(); } else { // Declare a new status row $statusRow = new Status(); } $fields['uid'] = $this->uid; $fields['status'] = $statusMessage; $fields['modified'] = strftime('%Y-%m-%d %H:%M:%S', time()); $fields['aid'] = -1; $statusRow->save($fields); return true; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $model->cat_id = explode(',', $model->cat_id); $model->orig_id = explode(',', $model->orig_id); if (isset($_POST['Communication'])) { $model->attributes = $_POST['Communication']; $model->archive = 0; $model->cat_id = implode(',', $model->cat_id); $model->orig_id = implode(',', $model->orig_id); $picture_name = ''; $picture_file = CUploadedFile::getInstance($model, 'comm_letter'); $model->comm_letter = $picture_file; if ($picture_file) { $picture_name = $picture_file->name; if (!is_dir(Yii::getPathOfAlias('webroot') . '/protected/document/communication/' . substr($model->ctrl_no, 0, 4) . '/' . $model->comm_letter)) { mkdir(Yii::getPathOfAlias('webroot') . '/protected/document/communication/' . substr($model->ctrl_no, 0, 4) . '/' . $model->comm_letter); } if (!is_dir(Yii::getPathOfAlias('webroot') . '/protected/document/communication/' . substr($model->ctrl_no, 0, 4) . '/' . $model->ctrl_no)) { mkdir(Yii::getPathOfAlias('webroot') . '/protected/document/communication/' . substr($model->ctrl_no, 0, 4) . '/' . $model->comm_letter); $picture_file->SaveAs(Yii::getPathOfAlias('webroot') . '/protected/document/communication/' . substr($model->ctrl_no, 0, 4) . '/' . $model->ctrl_no . '/' . $picture_file->getName()); } else { $picture_file->SaveAs(Yii::getPathOfAlias('webroot') . '/protected/document/communication/' . substr($model->ctrl_no, 0, 4) . '/' . $model->ctrl_no . '/' . $picture_file->getName()); //fwrite('/protected/document/communication/'.substr($model->ctrl_no,0,4).'/'.$model->ctrl_no,$model->comm_letter); } } $model->input_by = User::model()->findByPK(Yii::app()->user->name)->emp_id; if ($model->type_comm == 1) { $model->comm_stat = 0; } else { $model->comm_stat = 1; } if ($model->save()) { date_default_timezone_set("Asia/Manila"); $activity = new Activity(); $activity->act_desc = 'Updated Communication ID: ' . $id; $activity->act_datetime = date('Y-m-d G:i:s'); $activity->act_by = User::model()->findByPK(Yii::app()->user->name)->emp_id; $activity->save(); if ($model->type_comm == 1) { $stat = Status::model()->findByAttributes(array('ctrl_no' => $model->ctrl_no)); if (!empty($stat)) { $stat->ctrl_no = $model->ctrl_no; $stat->comm_stat = 0; $stat->referral_stat = 0; $stat->comm_meeting_stat = 0; $stat->save(); $activity->save(); } else { $stat = new Status(); $stat->ctrl_no = $model->ctrl_no; $stat->comm_stat = 0; $stat->referral_stat = 0; $stat->comm_meeting_stat = 0; $stat->save(); $activity->save(); } } else { $stat = Status::model()->findByAttributes(array('ctrl_no' => $model->ctrl_no)); if (!empty($stat)) { $stat->ctrl_no = $model->ctrl_no; $stat->comm_stat = 1; $stat->referral_stat = 1; $stat->comm_meeting_stat = 1; $stat->save(); $activity->save(); } else { $stat = new Status(); $stat->ctrl_no = $model->ctrl_no; $stat->comm_stat = 1; $stat->referral_stat = 1; $stat->comm_meeting_stat = 1; $stat->save(); $activity->save(); } } $this->redirect(array('view', 'id' => $model->ctrl_no)); } } $this->render('update', array('model' => $model)); }
/** * @param \HorseStories\Models\Statuses\Status $status * @param array $values */ public function update(Status $status, $values) { $status->body = $values['status']; $status->save(); }