/** * * @param sfWebRequest $request * @param sfForm $form */ private function processForm(sfWebRequest $request, sfForm $form, $account_id = null) { $parameters = $request->getParameter($form->getName()); if ($parameters['imputation']['imputation_type'] == ImputationDefaultValues::COUNTABLE_SERVICE_TYPE) { $parameters['account']['value'] = $parameters['initial_value']; $parameters['account']['monetary_account'] = $form->getObject()->getImputation()->getAct()->getMonetaryAccount(); $parameters['account']['created_at'] = $parameters['imputation']['date']; $parameters['account']['act_id'] = $form->getObject()->getImputation()->getActId(); unset($parameters['account_is_shared']); } $form->bind($parameters); if ($form->isValid()) { //If the method of payment is 'account': if ($parameters['imputation']['method_of_payment_id'] == ImputationDefaultValues::getAccountMethodId()) { //We create a new 'hidden' imputation of type account_transaction if (ImputationAccountTransaction::buildAndSaveTransactionFrom($parameters)) { $saved_object = $form->save(); $this->error_account = false; } else { if ($parameters['imputation']['account_id'] == 0) { $this->error_account = true; } else { $this->error_account = false; } return false; } } else { $saved_object = $form->save(); $this->error_account = false; } //If the type of the imputation is 'countable_service' if ($parameters['imputation']['imputation_type'] == ImputationDefaultValues::COUNTABLE_SERVICE_TYPE) { //We create a new account user entry: if (!is_null($account_id)) { ImputationCountableService::createAccountUser($form->getEmbeddedForm('imputation')->getObject()->getUserId(), $account_id); } else { $this->current_account_id = ImputationCountableService::createAccountUser($form->getEmbeddedForm('imputation')->getObject()->getUserId(), $form->getEmbeddedForm('account')->getObject()->getId()); } } //A FAIRE ICI: DUPLICATION DANS LA TABLE ARCHIVE /** * @todo */ $archive = new ImputationArchive(); $archive->fillAndSave($form); return true; } else { if ($parameters['imputation']['account_id'] == 0) { $this->error_account = true; } else { $this->error_account = false; } return false; } }