Esempio n. 1
0
 /**
  * 
  * @param array $data
  * @param type $id
  * @return type
  */
 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $id);
     } catch (ValidatorException $e) {
         return ['error' => 'true', 'messege' => $e->getMessageBag()];
     } catch (\Exception $e) {
         return ['error' => 'true', 'messege' => "Usuário não encontrado!"];
     }
 }
Esempio n. 2
0
 /**
  *
  * @param \Music\Model\Artist $artist
  * @throws \Exception
  */
 public function saveArtist(Artist $artist)
 {
     $data = array('full_name' => $artist->getFullName(), 'year_found' => $artist->getYearFound(), 'origin' => $artist->getOrigin(), 'createdby' => $this->id);
     $artist_id = (int) $artist->getArtistId();
     if ($artist_id == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getArtist($artist_id)) {
             //\Zend\Debug\Debug::dump($artist_id);
             $this->tableGateway->update($data, array('artist_id' => $artist_id));
         } else {
             throw new \Exception('Form id does not exist');
         }
     }
 }
Esempio n. 3
0
 /**
  * 
  * @param Request $request
  * @param type $id
  */
 public function update(Request $request, $id)
 {
     $produto = $this->service->show($id);
     if ($produto['error']) {
         return redirect($this->url)->with("danger", $produto['messege']);
     }
     $this->service->update($request->all(), $id);
     return redirect($this->url)->with("success", "Produto atualizado!");
 }
Esempio n. 4
0
 /**
  * Updates a contact
  * @param array $data
  * @param int $id
  * @return boolean
  */
 public function updateContact($data, $id)
 {
     try {
         $this->tableGateway->update($data, array('contact_id' => $id));
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Esempio n. 5
0
 /**
  * 修改数据
  * @param array $entity                 键值组成的数组
  * @param array $whereData              一维数组或k、v、s结构组成的数组。一维数组元素之间为and关系,键和值为等于关系;k、v、s结构数组,k:属性名,v:属性值,s:属性名和属性值之间的操作符
  * @param string $table                 修改数据的表,若为空,修改默认表数据
  * @param array $filter                 认为是表达式的键,$entity的键在该参数中时,认为$entity相应键对应的值是表达式
  * @param boolean $isReturnAffectedRows 是否返回删除记录的条数,默认是不返回
  * @return boolean
  */
 public function update(array $entity, $whereData = array(), $table = '', $isReturnAffectedRows = 0, array $filter = array())
 {
     if (is_null($this->db)) {
         $this->db = \Util\Db\Manager::getInstance($this->dbName);
     }
     //如果方法中没传递表名,则向默认表中插入数据
     $table = is_string($table) && $table != '' ? $table : $this->defaultTable;
     $state = $this->db->update($entity, $table, $whereData, $filter);
     if ($isReturnAffectedRows && $state) {
         return $this->db->getAffectedRows();
     }
     return $state;
 }
Esempio n. 6
0
 private function reset(Section $section = null)
 {
     if (null != $section) {
         // Get default values for section
         $names = array();
         foreach ($section->fields as $field) {
             if ($field instanceof ValueFieldInterface) {
                 $names[] = $field->get_name();
             }
         }
         $this->options->update($this->updater->reset($names));
     } else {
         // No values are passed to the OptionsUpdater so that the default values
         // Will be returned.
         $this->options->update($this->updater->reset());
     }
 }
Esempio n. 7
0
 /**
  * Save
  * 
  * @return integer 
  */
 public function save()
 {
     if (is_array($this->primaryKey)) {
         // @todo compound primary keys
     }
     if (isset($this->originalData[$this->primaryKey])) {
         // UPDATE
         $where = array($this->primaryKey => $this->originalData[$this->primaryKey]);
         $data = $this->currentData;
         unset($data[$this->primaryKey]);
         $rowsAffected = $this->tableGateway->update($data, $where);
     } else {
         // INSERT
         $rowsAffected = $this->tableGateway->insert($this->currentData);
         $primaryKey = $this->tableGateway->getLastInsertId();
         $where = array($this->primaryKey => $primaryKey);
     }
     // refresh data
     $result = $this->tableGateway->select($where);
     $rowData = $result->current();
     $this->populateOriginalData($rowData);
     return $rowsAffected;
 }
Esempio n. 8
0
 /**
  * 
  * @param Request $request
  * @param type $id
  */
 public function update(Request $request, $id)
 {
     $this->service->update($request->all(), $id);
 }
Esempio n. 9
0
 /**
  * 
  * @param User $entity
  * @return type
  */
 public function update(User $entity)
 {
     $result = $this->cbo->update($entity);
     return $result;
 }
Esempio n. 10
0
 /**
  * 
  * @param type $answer
  * @param type $results
  * @param type $options
  * @param type $form
  * @return string
  */
 public function makeInput($answer, $results = null, $options = [], $form = '')
 {
     $html = '';
     $type = $answer->type;
     $name = $answer->akey;
     $text = !empty($answer->text) ? _t(ucfirst($answer->text)) : '';
     $ansval = $answer->value;
     $section = $answer->question->section;
     $qslug = $answer->question->slug;
     $qid = $answer->question->id;
     if (empty($answer->slug)) {
         $answer->update(['slug' => snake_case($answer->akey)]);
     }
     $ans_slug = $answer->slug;
     $options['id'] = $ans_slug;
     $options['data-logic'] = json_encode($answer->logic);
     $value = null;
     if (!is_null($results)) {
         $rs = $results->where('section_id', $section)->first();
         if (!is_null($rs)) {
             foreach ($rs->answers as $values) {
                 if (in_array($ans_slug, $values->toArray())) {
                     if ($type == 'radio') {
                         $value = true;
                     } else {
                         $value = $values->value;
                     }
                     break;
                 } else {
                     $value = null;
                 }
             }
         }
     } else {
         $value = null;
     }
     if ($type == 'radio') {
         $inputname = "answer[{$section}][{$qslug}][radio]";
     } else {
         $inputname = "answer[{$section}][{$qslug}][{$ans_slug}]";
     }
     if (array_key_exists('class', $options)) {
         $cssClass = $options['class'];
     } else {
         $cssClass = '';
     }
     switch ($type) {
         case 'radio':
             $options['data-value'] = $ansval;
             $html .= "<div class=\"radio\">";
             $html .= "<label class='control-label'>";
             $html .= $this->radio($inputname, $ans_slug, $value, $options);
             $html .= "<span class='badge'>{$ansval}</span> ";
             $html .= $text;
             $html .= "</label>";
             $html .= "</div>";
             break;
         case 'checkbox':
             $html .= "<div class=\"checkbox\">";
             $html .= "<label class='control-label'>";
             $html .= $this->checkbox($inputname, $ansval, $value, $options);
             $html .= "<span class='badge'>{$ansval}</span> ";
             $html .= $text;
             $html .= "</label>";
             $html .= "</div>";
             break;
         case 'textarea':
             $options['class'] = $cssClass . ' form-control';
             $html .= "<label for=\"{$inputname}\" class='col-xs-2 text-normal'>{$text}</label>";
             $html .= "<div class='col-xs-10' style='padding-left:0px'>";
             $html .= $this->textarea($inputname, $value, $options);
             $html .= "</div>";
             break;
         case 'option':
             break;
         case 'question':
             break;
         default:
             $options['class'] = $cssClass . ' form-control';
             $html .= "<label style='padding-left:0px;margin-top:15px' for=\"{$inputname}\" class='col-xs-3 text-normal'>{$text}</label>";
             $html .= "<div style='padding-left:0px;margin-top:15px' class='col-xs-9' style='padding-left:0px'>";
             $html .= $this->input($type, $inputname, $value, $options);
             $html .= "</div>";
             break;
     }
     return $html;
 }
 /**
  * 
  * @param Subsecretaria $subsecretaria
  * @return type
  */
 public function update(Subsecretaria $subsecretaria)
 {
     $result = $this->subsecretariaDAO->update($subsecretaria);
     return $result;
 }
Esempio n. 12
0
 /**
  * 
  * @param Permissao $entity
  * @return type
  */
 public function update(Permissao $entity)
 {
     $result = $this->cbo->update($entity);
     return $result;
 }
Esempio n. 13
0
 /**
  * 
  * @param Setores $setores
  * @return type
  */
 public function update(Setores $setores)
 {
     $result = $this->setoresDAO->update($setores);
     return $result;
 }
Esempio n. 14
0
 /**
  * @param type $form
  * @param type $model
  * @param type $successMsg
  * @return boolean
  * @throws InvalidArgumentException
  */
 protected function updateModelWithFormValidation($form, $model, $successMsg)
 {
     if ($form->isValid() && $model->update()) {
         if (!empty($successMsg)) {
             $this->flashSession->notice($successMsg);
         }
         return true;
     }
     $m = "";
     foreach ($form->getMessages() as $msg) {
         $m .= $msg . "<br>";
     }
     foreach ($model->getMessages() as $msg) {
         $m .= $msg . "<br>";
     }
     throw new InvalidArgumentException($m);
 }
 /**
  * 
  * @param Encaminhamentos $encaminhamentos
  * @return type
  */
 public function update(Encaminhamentos $encaminhamentos)
 {
     $result = $this->encaminhamentosDAO->update($encaminhamentos);
     return $result;
 }
Esempio n. 16
0
 /**
  * 
  * @param type $c the comment to update
  * @param string $vars the array used to update the attributes of the comment
  * @return the updated comment
  */
 public function update($c, &$vars)
 {
     $this->dao->escape($vars['TextWhere']);
     $this->dao->escape($vars['TextFree']);
     $this->dao->escape($vars['Quality']);
     $syshcvol = PVars::getObj('syshcvol');
     $proximity = "";
     foreach ($syshcvol->LenghtComments as $elem) {
         if (!array_key_exists($elem, $vars)) {
             $vars[$elem] = "off";
         }
         $this->dao->escape($vars[$elem]);
         $proximity .= $vars[$elem] == 'on' ? $elem . ',' : '';
     }
     if (strlen($proximity) > 0) {
         $proximity = substr($proximity, 0, strlen($proximity) - 1);
     }
     $c->TextWhere = $vars['TextWhere'];
     $c->TextFree = $vars['TextFree'];
     $c->Quality = $vars['Quality'];
     $c->Lenght = $proximity;
     return $c->update();
 }
Esempio n. 17
0
 /**
  * 
  * @param Entradas $entradas
  * @return type
  */
 public function update(Entradas $entradas)
 {
     $result = $this->entradasDAO->update($entradas);
     return $result;
 }
Esempio n. 18
0
 /**
  * 
  * @param Canditato $entity
  * @return type
  */
 public function update(Canditato $entity)
 {
     $result = $this->cbo->update($entity);
     return $result;
 }
 /**
  * 
  * @param type $entity
  * @return type
  */
 public function update($entity)
 {
     $result = $this->entityDAO->update($entity);
     return $result;
 }
Esempio n. 20
0
 /**
  * 
  * @param Aplicacao $entity
  * @return type
  */
 public function update(Aplicacao $entity)
 {
     $result = $this->cbo->update($entity);
     return $result;
 }
 /**
  * 
  * @param Documentos $documentos
  * @return type
  */
 public function update(Documentos $documentos)
 {
     $result = $this->documentosDAO->update($documentos);
     return $result;
 }
Esempio n. 22
0
 /**
  * update a payment
  * @param type $paymentModel
  * @throws Exception
  * @return string|true
  */
 private function updatePayment($paymentModel)
 {
     $transaction = Yii::$app->db->beginTransaction();
     $save = true;
     $message = null;
     // begin transaction
     try {
         $entryValueOld = $paymentModel->entry_value;
         $paymentModel->description = serialize($paymentModel->arr_entry_log);
         $paymentModel->entry_value = $paymentModel->entry_updated;
         // save payment
         if ($save) {
             $save = $paymentModel->update();
         }
         // save source
         if ($paymentModel->account_source == $paymentModel->account_source_old) {
             if ($paymentModel->account_source != 0 && $save !== false) {
                 $accountSource = FinAccount::findOne($paymentModel->account_source);
                 $accountSource->opening_balance -= $paymentModel->entry_adjust;
                 $save = $accountSource->update();
             }
         } else {
             // old source
             if ($paymentModel->account_source_old != 0 && $save !== false) {
                 $accountSource = FinAccount::findOne($paymentModel->account_source_old);
                 $accountSource->opening_balance += $entryValueOld;
                 $save = $accountSource->update();
             }
             // new source
             if ($paymentModel->account_source != 0 && $save !== false) {
                 $accountSource = FinAccount::findOne($paymentModel->account_source);
                 $accountSource->opening_balance -= $paymentModel->entry_value;
                 $save = $accountSource->update();
             }
         }
         // save Target
         if ($paymentModel->account_target == $paymentModel->account_target_old) {
             if ($paymentModel->account_target != 0 && $save !== false) {
                 $accountTarget = FinAccount::findOne($paymentModel->account_target);
                 $accountTarget->opening_balance += $paymentModel->entry_adjust;
                 $save = $accountTarget->update();
             }
         } else {
             // old target
             if ($paymentModel->account_target_old != 0 && $save !== false) {
                 $accountTarget = FinAccount::findOne($paymentModel->account_target_old);
                 $accountTarget->opening_balance -= $entryValueOld;
                 $save = $accountTarget->update();
             }
             // new target
             if ($paymentModel->account_target != 0 && $save !== false) {
                 $accountTarget = FinAccount::findOne($paymentModel->account_target);
                 $accountTarget->opening_balance += $paymentModel->entry_value;
                 $save = $accountTarget->update();
             }
         }
         // save note
         if ($save !== false && count($paymentModel->arr_entry_log) > 0) {
             $startDateNote = $paymentModel->entry_date . ' 00:00:00';
             OthNote::updateAll(['start_date' => $startDateNote], ['entry_log' => $paymentModel->arr_entry_log]);
         }
     } catch (Exception $e) {
         $save = false;
         $message = Yii::t('common', 'Unable to save {record}.', ['record' => Yii::t('fin.models', 'Payment')]);
     }
     // end transaction
     try {
         if ($save === false) {
             $transaction->rollback();
             return $message;
         } else {
             $transaction->commit();
         }
     } catch (Exception $e) {
         throw Exception(Yii::t('common', 'Unable to excute Transaction.'));
     }
     return true;
 }