public function testCreateAddAndSaveAndRemoveByIndexRelatedModels() { Yii::app()->user->userModel = User::getByUsername('super'); $user = UserTestHelper::createBasicUser('Billy'); $account = new Account(); $account->owner = $user; $account->name = 'Wibble Corp'; $this->assertTrue($account->save()); for ($i = 0; $i < self::CONTACTS; $i++) { $contact = ContactTestHelper::createContactByNameForOwner('sampleContact' . $i, Yii::app()->user->userModel); $account->contacts->add($contact); } $this->assertTrue($account->save()); $contact = $account->contacts[0]; $this->assertFalse($account->isModified()); $this->assertFalse($contact->isModified()); $this->assertTrue($account->save()); $this->assertFalse($account->isModified()); $this->assertFalse($contact->isModified()); $accountId = $account->id; unset($account); $account = Account::getById($accountId); $this->assertEquals('Wibble Corp', $account->name); $this->assertEquals(self::CONTACTS, $account->contacts->count()); $this->assertEquals("{$account->contacts->count()} records.", strval($account->contacts)); $contact = $account->contacts[0]; $description = $contact->description; $contact->description = "this is a contact"; $this->assertTrue($account->isModified()); $this->assertTrue($contact->isModified()); $this->assertTrue($account->save()); $this->assertFalse($account->isModified()); $this->assertFalse($contact->isModified()); }
public function setUp() { global $current_user, $currentModule; global $beanList; require 'include/modules.php'; $current_user = SugarTestUserUtilities::createAnonymousUser(); $unid = uniqid(); $time = date('Y-m-d H:i:s'); $contact = new Contact(); $contact->id = 'c_' . $unid; $contact->first_name = 'testfirst'; $contact->last_name = 'testlast'; $contact->new_with_id = true; $contact->disable_custom_fields = true; $contact->save(); $this->contact = $contact; $account = new Account(); $account->id = 'a_' . $unid; $account->first_name = 'testfirst'; $account->last_name = 'testlast'; $account->assigned_user_id = 'SugarUser'; $account->new_with_id = true; $account->disable_custom_fields = true; $account->save(); $this->account = $account; $ac_id = 'ac_' . $unid; $this->ac_id = $ac_id; //Accounts to Contacts $GLOBALS['db']->query("INSERT INTO accounts_contacts (id , contact_id, account_id, date_modified, deleted) values ('{$ac_id}', '{$contact->id}', '{$account->id}', '{$time}', 0)"); $_REQUEST['relate_id'] = $this->contact->id; $_REQUEST['relate_to'] = 'projects_contacts'; }
public function setUp() { global $current_user, $currentModule; $mod_strings = return_module_language($GLOBALS['current_language'], "Contacts"); $current_user = SugarTestUserUtilities::createAnonymousUser(); $unid = uniqid(); $time = date('Y-m-d H:i:s'); $contact = new Contact(); $contact->id = 'c_' . $unid; $contact->first_name = 'testfirst'; $contact->last_name = 'testlast'; $contact->new_with_id = true; $contact->disable_custom_fields = true; $contact->save(); $this->c = $contact; $account = new Account(); $account->id = 'a_' . $unid; $account->first_name = 'testfirst'; $account->last_name = 'testlast'; $account->assigned_user_id = 'SugarUser'; $account->new_with_id = true; $account->disable_custom_fields = true; $account->save(); $this->a = $account; $ac_id = 'ac_' . $unid; $this->ac_id = $ac_id; $GLOBALS['db']->query("insert into accounts_contacts (id , contact_id, account_id, date_modified, deleted) values ('{$ac_id}', '{$contact->id}', '{$account->id}', '{$time}', 0)"); }
public function action_create() { if (Input::has('email') && Input::has('password') && Input::has('email2') && Input::has('password2')) { if (Input::get('email') == Input::get('email2') && Input::get('password') == Input::get('password2')) { $size = Account::where_email(Input::get('email')); if ($size->count() == 0) { $email = Input::get('email'); $password = Hash::make(Input::get('password')); $account = new Account(); $account->email = $email; $account->password = $password; $account->save(); Emailer::signUpConfirmation($email); echo "Signup successful, please check your email for confirmation or login using the login bar"; // return Redirect::to('/'); } else { echo "That email is already registered."; } } else { if (Input::get('email') != Input::get('email2')) { echo "Emails do not match."; } if (Input::get('password') != Input::get('password2')) { echo "Passwords do not match."; } } } else { echo 'Error: Invalid input.'; } }
function daftarkanCC() { $creditCardId = NULL; try { // If CVV2 is not required, we need to remove it. We cannot keep it empty or '' as it is considered your CVV2 is set to '' if (isset($_POST['user']['credit_card']['cvv2']) && trim($_POST['user']['credit_card']['cvv2']) == '') { unset($_POST['user']['credit_card']['cvv2']); } // User can configure credit card info later from the // profile page or can use paypal as his funding source. if (trim($_POST['user']['credit_card']['number']) != "") { $paypal = new PaypalWrap(); $creditCardId = $paypal->saveCard($_POST['user']['credit_card']); $acc = new Account(); $acc->getByID(Account::getMyID()); $acc->admin_creditcardID = $creditCardId; $acc->load = 1; $acc->save(); } // $userId = addUser($_POST['user']['email'], $_POST['user']['password'], $creditCardId); } catch (\PayPal\Exception\PPConnectionException $ex) { $errorMessage = $ex->getData() != '' ? parseApiError($ex->getData()) : $ex->getMessage(); } catch (Exception $ex) { $errorMessage = $ex->getMessage(); } return $creditCardId; }
/** * Store a newly created account in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Account::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } // check if code exists $code = Input::get('code'); $code_exists = DB::table('accounts')->where('code', '=', $code)->count(); if ($code_exists >= 1) { return Redirect::back()->withErrors(array('error' => 'The GL code already exists'))->withInput(); } else { $account = new Account(); $account->category = Input::get('category'); $account->name = Input::get('name'); $account->code = Input::get('code'); if (Input::get('active')) { $account->active = TRUE; } else { $account->active = FALSE; } $account->save(); } Audit::logaudit('Accounts', 'create', 'created: ' . $account->name . ' ' . $account->code); return Redirect::route('accounts.index'); }
public function actionRandomOperation() { $rec = new Account(); $rec->amount = rand(-1000, 1000); $rec->save(); echo "OK"; }
/** * Logs in the user using the given username and password in the model. * @return boolean whether login is successful */ public function save() { $user = new Users(); $user->setAttributes($this->attributes); $user->setAttribute("password", BaseTool::ENPWD($this->password)); if ($user->validate() && $user->save()) { $accountarray = array('user_id' => Yii::app()->db->getLastInsertID(), 'total' => 0, 'use_money' => 0, 'no_use_money' => 0, 'newworth' => 0); $newAccount = new Account(); $newAccount->setAttributes($accountarray); $newAccount->save(); //发送邮件 $activecode = BaseTool::getActiveMailCode($this->username); $message = MailTemplet::getActiveEmail($this->username, $activecode); $mail = Yii::app()->Smtpmail; $mail->SetFrom(Yii::app()->params['adminEmail']); $mail->Subject = "好帮贷测试邮件"; $mail->MsgHTML($message); $mail->AddAddress($this->email); if ($mail->Send()) { $user->updateAll(array("regtaken" => $activecode, "regativetime" => time() + 60 * 60), "username=:username", array(":username" => $this->username)); } Yii::import("application.models.form.LoginForm", true); $loginform = new LoginForm(); $loginarray = array('rememberMe' => false, 'username' => $this->username, 'password' => $this->password); $loginform->setAttributes($loginarray); if ($loginform->validate() && $loginform->login()) { } return true; } else { $usererror = $user->errors; $this->addError("username", current(current($usererror))); return false; } }
/** * 增加系统账户页面 */ public function ActionAddAccount() { $account_model = new Account(); if (isset($_POST['Account'])) { // 密码要md5加密 if (isset($_POST['Account']['PassWord']) && !empty($_POST['Account']['PassWord']) && isset($_POST['Account']['PassWord2']) && !empty($_POST['Account']['PassWord2'])) { $password = $_POST['Account']['PassWord']; $_POST['Account']['PassWord'] = md5($password); $_POST['Account']['PassWord2'] = md5($_POST['Account']['PassWord2']); } $account_model->attributes = $_POST['Account']; // 执行添加 if ($account_model->save()) { // 添加操作日志 [S] $log = Yii::app()->user->name . '于 ' . date('Y-m-d H:i:s', time()) . ' 添加了一个名为 【' . $_POST['Account']['UserName'] . '】 的账户'; OperationLogManage::AddOperationLog($log); // 添加日志 // 添加操作日志 [E] // 发送通知邮件 $email_content = '用户名:' . $_POST['Account']['UserName'] . '<br />密 码:' . $password; Email::sendEmail($_POST['Account']['Email'], '百城资源后台管理系统账户已开通', $email_content, 'smtp.baicheng.com', CARRENTALAPI_SENDEMAIL_USERNAME, CARRENTALAPI_SENDEMAIL_PASSWORD); Yii::app()->user->setFlash('save_sign', '添加成功'); $this->redirect(Yii::app()->createUrl('Account/RestrictAccount', array('account_id' => $account_model->attributes['ID']))); } else { Yii::app()->user->setFlash('save_sign', '添加失败'); $this->renderPartial('add_account', array('account_model' => $account_model)); } } else { $this->renderPartial('add_account', array('account_model' => $account_model)); } }
public function testExportByModelIds() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $numberOfUserNotifications = Notification::getCountByTypeAndUser('ExportProcessCompleted', Yii::app()->user->userModel); $idsToExport = array(); $account1 = new Account(); $account1->owner = $super; $account1->name = 'Test Account'; $account1->officePhone = '1234567890'; $this->assertTrue($account1->save()); $account2 = new Account(); $account2->owner = $super; $account2->name = 'Test Account 2'; $account2->officePhone = '1234567899'; $this->assertTrue($account2->save()); $idsToExport[] = $account2->id; $account3 = new Account(); $account3->owner = $super; $account3->name = 'Test Account 3'; $account3->officePhone = '987654321'; $this->assertTrue($account3->save()); $idsToExport[] = $account3->id; $account4 = new Account(); $account4->owner = $super; $account4->name = 'Test Account 4'; $account4->officePhone = '198765432'; $this->assertTrue($account4->save()); $exportItem = new ExportItem(); $exportItem->isCompleted = 0; $exportItem->exportFileType = 'csv'; $exportItem->exportFileName = 'test'; $exportItem->modelClassName = 'Account'; $exportItem->serializedData = serialize($idsToExport); $this->assertTrue($exportItem->save()); $id = $exportItem->id; $exportItem->forget(); unset($exportItem); $job = new ExportJob(); $this->assertTrue($job->run()); $exportItem = ExportItem::getById($id); $fileModel = $exportItem->exportFileModel; $this->assertEquals(1, $exportItem->isCompleted); $this->assertEquals('csv', $exportItem->exportFileType); $this->assertEquals('test', $exportItem->exportFileName); $this->assertTrue($fileModel instanceof ExportFileModel); // Get csv string via regular csv export process(directly, not in background) // We suppose that csv generated thisway is corrected, this function itself // is tested in another test. $data = array(); $modelToExportAdapter = new ModelToExportAdapter($account2); $headerData = $modelToExportAdapter->getHeaderData(); $data[] = $modelToExportAdapter->getData(); $modelToExportAdapter = new ModelToExportAdapter($account3); $data[] = $modelToExportAdapter->getData(); $output = ExportItemToCsvFileUtil::export($data, $headerData, 'test.csv', false); $this->assertEquals($output, $fileModel->fileContent->content); // Check if user got notification message, and if its type is ExportProcessCompleted $this->assertEquals($numberOfUserNotifications + 1, Notification::getCountByTypeAndUser('ExportProcessCompleted', Yii::app()->user->userModel)); }
/** * Store a newly created resource in storage. * POST /debtors * * @return Response */ public function store() { $contact = new Contact(); $contact->name = Input::get('contact_person'); $contact->email = Input::get('email'); $contact->phone = Input::get('phone'); $contact->mobile = Input::get('mobile'); $contact->web = Input::get('web'); $contact->fax = Input::get('fax'); $contact->save(); $contact_id = $contact->id; $company = new Company(); $company->name = Input::get('company_name'); $company->contact_id = $contact_id; $company->address = Input::get('address'); $company->postal_code = Input::get('postal_code'); $company->city = Input::get('city'); $company->country = Input::get('country'); $company->vat = Input::get('vat'); $company->coc = Input::get('coc'); $company->save(); $company_id = $company->id; //Billing $contact_billing = new Contact(); $contact_billing->name = Input::get('billing_contact_person'); $contact_billing->billing = 'true'; $contact_billing->save(); $contact_billing_id = $contact_billing->id; $company_billing = new Company(); $company_billing->name = Input::get('billing_company_name'); $company_billing->contact_id = $contact_billing_id; $company_billing->address = Input::get('billing_address'); $company_billing->postal_code = Input::get('billing_postal_code'); $company_billing->city = Input::get('billing_city'); $company_billing->country = Input::get('billing_country'); $contact_billing->billing = 'true'; $company_billing->save(); $company_billing_id = $contact_billing->id; $bank = new Bank(); $bank->name = Input::get('bank'); $bank->bic = Input::get('bic'); $bank->save(); $bank_id = $bank->id; $account = new Account(); $account->iban = Input::get('iban'); $account->name = Input::get('account_name'); $account->bank_id = $bank_id; $account->save(); $account_id = $account->id; //Debtor Save $debtor = new Debtor(); $debtor->no = Input::get('debtor_number'); $debtor->legal = Input::get('legal'); $debtor->company_id = $company_id; $debtor->billing_company_id = $company_billing_id; $debtor->account_id = $account_id; $debtor->group_id = Input::get('group'); $debtor->save(); return $this->index(); }
public function create_temporal() { $input = Input::All(); $username = $input["username"]; $domain = Config::get("constants.TEMPORAL_DOMAIN"); $email = $username . $domain; $password = $input["password"]; $passwordVerify = $input["passwordVerify"]; $success = false; if (Account::where("email", "=", $email)->count() >= 1) { $response = "El nombre de usuario ya esta registrado."; } else { if (strcmp($password, $passwordVerify) == 0) { try { $account = new Account(array("email" => $email, "password" => Hash::make($password), "role_id" => Config::get("constants.ACCOUNT_TYPE.TEMPORAL"), "activated" => true)); $account->save(); $success = true; $response = "El usuario " . $email . " se ha creado correctamente."; } catch (Exception $ex) { $response = "No se ha podido crear el usuario"; } } else { $response = "Las contraseñas no coinciden."; } } return Response::json(array("success" => $success, "response" => $response)); }
function save($returnType = RETURN_BOOLEAN) { global $dbh; $query = ' INSERT INTO `userDetails` ( `uniqueID` , `name` ) VALUES ( "' . $this->getUniqueID() . '" , "' . $this->getName() . '" )'; switch ($returnType) { case RETURN_BOOLEAN: default: // return a boolean result $returnValue = false; try { $dbh->beginTransaction(); $dbh->exec(parent::save(1)); $dbh->exec($query); $dbh->commit(); $returnValue = true; } catch (PDOException $e) { print "Error[ 101 ]: " . $e->getMessage() . "<br/>"; die; } break; case "1": // return the query $returnValue = $query; break; } return $returnValue; }
/** * Create test user * */ public function setUp() { $this->markTestIncomplete('Skipping for now while investigating'); //setup test portal user $this->_setupTestUser(); $this->_soapClient = new nusoapclient($GLOBALS['sugar_config']['site_url'] . '/soap.php', false, false, false, false, false, 600, 600); $this->_login(); //setup test account $account = new Account(); $account->name = 'test account for bug 39855'; $account->assigned_user_id = 'SugarUser'; $account->save(); $this->_acc = $account; //setup test cases $case1 = new aCase(); $case1->name = 'test case for bug 39855 ASDF'; $case1->account_id = $this->_acc->id; $case1->status = 'New'; $case1->save(); $this->_case1 = $case1; $case2 = new aCase(); //$account->id = 'a_'.$unid; $case2->name = 'test case for bug 39855 QWER'; $case2->account_id = $this->_acc->id; $case2->status = 'Rejected'; $case2->save(); $this->_case2 = $case2; }
public function writeDefaultConfig($config) { $account = new Account(); $account->name = $config['name']; $account->workingdays = '31'; $account->type = 'unlimited'; $account->save(); // add timeitem types $tit = new TimeItemType(); $tit->account_id = $account->id; $tit->name = 'DEV'; $tit->save(); $tit = new TimeItemType(); $tit->account_id = $account->id; $tit->name = 'ADMIN'; $tit->default_item = true; $tit->save(); $admin_settings = new Setting(); $admin_settings->theme = 'green'; $admin = new User(); $admin->Account = $account; $admin->administrator = true; $admin->username = $config['username']; $admin->password = md5($config['password']); $admin->Setting = $admin_settings; $admin->save(); return $account->id; }
public function create() { $user = Confide::user(); //throw new Exception($user); if (Request::isMethod('GET')) { $patient = Patient::find($user->id); return View::make('home/patient/create', compact('user', 'patient')); } elseif (Request::isMethod('POST')) { // Create a new Appointment with the given data $user = Confide::user(); $user->fill(Input::all()); $user->save(); // If patient already exists in system $patient = Patient::find($user->id); if ($patient != null) { // Retreive Patient } else { // Create a new account for the Patient $account = new Account(); $account->patient_id = $user->id; $account->save(); // Create a new Patient $patient = new Patient(); $patient->fill(Input::all()); //$patient->dob = new Date(); $patient->user_id = $user->id; $patient->save(); } return Redirect::route('home.index'); } }
public function setUp() { SugarTestHelper::setUp('beanFiles'); SugarTestHelper::setUp('beanList'); SugarTestHelper::setUp('current_user'); $unid = uniqid(); $time = date('Y-m-d H:i:s'); $contact = new Contact(); $contact->id = 'c_' . $unid; $contact->first_name = 'testfirst'; $contact->last_name = 'testlast'; $contact->new_with_id = true; $contact->disable_custom_fields = true; $contact->save(); $this->contact = $contact; $account = new Account(); $account->id = 'a_' . $unid; $account->first_name = 'testfirst'; $account->last_name = 'testlast'; $account->assigned_user_id = 'SugarUser'; $account->new_with_id = true; $account->disable_custom_fields = true; $account->save(); $this->account = $account; $ac_id = 'ac_' . $unid; $this->ac_id = $ac_id; //Accounts to Contacts $GLOBALS['db']->query("INSERT INTO accounts_contacts (id , contact_id, account_id, date_modified, deleted) values ('{$ac_id}', '{$contact->id}', '{$account->id}', '{$time}', 0)"); $_REQUEST['relate_id'] = $this->contact->id; $_REQUEST['relate_to'] = 'projects_contacts'; }
public static function initializeAccount($options) { $account = new Account(); $account['name'] = isset($options['name']) ? $options['name'] : 'New Account'; $account['type'] = isset($options['type']) ? $options['type'] : Account::TYPE_NORMAL; $account->save(); return $account->account_id; }
/** * Deleting an object by its ID should not fail. */ public function testDeleteById() { $at = getenv("BB_ACCESS_TOKEN"); $accountGroups = AccountGroup::getAll($at); $accountGroup = $accountGroups[0]; $object = new Account($at, 'newAccountName', $accountGroup->id); $object->save(); Account::deleteById($at, $object->id); }
/** * Создать счет с набором свойств */ public function testMakeWithProperties() { $data = array('user_id' => $this->helper->makeUser()->getId(), 'name' => 'Название счета', 'type_id' => 5, 'currency_id' => 1, 'Properties' => array($prop1 = array('field_id' => 10, 'field_value' => 'Значение 1'), $prop2 = array('field_id' => 20, 'field_value' => 'Значение 2'))); $acc = new Account(); $acc->fromArray($data, $deep = true); $acc->save(); $prop1['account_id'] = $prop2['account_id'] = $acc->getId(); $this->assertEquals(1, $this->queryFind('AccountProperty', $prop1)->count(), 'Prop 1'); $this->assertEquals(1, $this->queryFind('AccountProperty', $prop2)->count(), 'Prop 1'); }
/** * Make changes to the database. * * @return void */ public function up() { // for ($i = 0; $i < 10; $i++) { $account = new Account(); $account->email = "{$i}@gmail.com"; $account->password = Hash::make($i); $account->save(); } }
/** * Test that a given condition is met. * * @return void */ public function testinsertReadDelete() { $account = new Account(); $account->email = '*****@*****.**'; $account->password = Hash::make('password'); $account->save(); $read = Account::where_email('*****@*****.**')->first(); if (Hash::check('password', $read->password)) { $this->assertTrue(true); } }
public static function createAccountByNameTypeAndIndustryForOwner($name, $type, $industry, $owner) { $account = new Account(); $account->name = $name; $account->industry->value = $industry; $account->type->value = $type; $account->owner = $owner; $saved = $account->save(); assert('$saved'); return $account; }
/** * Test if background export job generated csv file, * check if content of this csv file is correct, and * finally check if user got notification message that * his downloads are completed. */ public function testRun() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $numberOfUserNotifications = Notification::getCountByTypeAndUser('ExportProcessCompleted', Yii::app()->user->userModel); $account = new Account(); $account->owner = $super; $account->name = 'Test Account'; $account->officePhone = '1234567890'; $this->assertTrue($account->save()); $account = new Account(); $account->owner = $super; $account->name = 'Test Account 2'; $account->officePhone = '1234567899'; $this->assertTrue($account->save()); $account = new Account(false); $searchForm = new AccountsSearchForm($account); $dataProvider = ExportTestHelper::makeRedBeanDataProvider($searchForm, 'Account', 0, Yii::app()->user->userModel->id); $totalItems = $dataProvider->getTotalItemCount(); $this->assertEquals(2, $totalItems); $exportItem = new ExportItem(); $exportItem->isCompleted = 0; $exportItem->exportFileType = 'csv'; $exportItem->exportFileName = 'test'; $exportItem->modelClassName = 'Account'; $exportItem->serializedData = serialize($dataProvider); $this->assertTrue($exportItem->save()); $id = $exportItem->id; $exportItem->forget(); unset($exportItem); $job = new ExportJob(); $this->assertTrue($job->run()); $exportItem = ExportItem::getById($id); $fileModel = $exportItem->exportFileModel; $this->assertEquals(1, $exportItem->isCompleted); $this->assertEquals('csv', $exportItem->exportFileType); $this->assertEquals('test', $exportItem->exportFileName); $this->assertTrue($fileModel instanceof ExportFileModel); // Get csv string via regular csv export process(directly, not in background) // We suppose that csv generated thisway is corrected, this function itself // is tested in another test. $data = array(); $rows = $dataProvider->getData(); $modelToExportAdapter = new ModelToExportAdapter($rows[0]); $headerData = $modelToExportAdapter->getHeaderData(); foreach ($rows as $model) { $modelToExportAdapter = new ModelToExportAdapter($model); $data[] = $modelToExportAdapter->getData(); } $output = ExportItemToCsvFileUtil::export($data, $headerData, 'test.csv', false); $this->assertEquals($output, $fileModel->fileContent->content); // Check if user got notification message, and if its type is ExportProcessCompleted $this->assertEquals($numberOfUserNotifications + 1, Notification::getCountByTypeAndUser('ExportProcessCompleted', Yii::app()->user->userModel)); }
/** * Make changes to the database. * * @return void */ public function up() { // for ($i = 1; $i <= 10; $i++) { $account = new Account(); $account->email = "{$i}@gmail.com"; $account->password = Hash::make($i); $account->wishlist_frequency = $i; $account->save(); } }
public function createAccount($name, $user_id) { $account = new Account(); $account->id = uniqid(); $account->name = $name; $account->assigned_user_id = $user_id; $account->new_with_id = true; $account->disable_custom_fields = true; $account->save(); $GLOBALS['db']->commit(); return $account; }
public function save() { $this->_user->save(); JUserHelper::setUserGroups($this->_user->id, $this->_userGroups); parent::save(); $uid = $this->params->get('user'); if (!$uid || $uid != $this->_user->id) { $this->params->set('user', $this->_user->id); $this->mapUser(); } return $this; }
public function getStarted() { $code = Input::get('code'); if ($code == IPX_KEY) { if (Auth::check()) { return Redirect::to('dashboard'); } // $account = DB::table('accounts')->select('pro_plan_paid')->orderBy('id', 'desc')->first(); // if($account) // { // $datePaid = $account->pro_plan_paid; // if (!$datePaid || $datePaid == '0000-00-00') // { // return 'Vuelva a intentarlo mas tarde'; // } // } $account = new Account(); $account->ip = Request::getClientIp(); $account->account_key = str_random(RANDOM_KEY_LENGTH); $account->nit = trim(Input::get('nit')); $account->name = trim(Input::get('name')); $account->language_id = 1; $account->save(); $user = new User(); $username = trim(Input::get('username')); $user->username = $username . "@" . $account->nit; $user->password = trim(Input::get('password')); $user->confirmation_code = ''; $user->is_admin = true; $account->users()->save($user); $category = new Category(); $category->user_id = $user->getId(); $category->name = "General"; $category->public_id = 1; $account->categories()->save($category); $InvoiceDesign = new InvoiceDesign(); $InvoiceDesign->user_id = $user->getId(); $InvoiceDesign->logo = ""; $InvoiceDesign->x = "5"; $InvoiceDesign->y = "5"; $InvoiceDesign->javascript = "displaytittle(doc, invoice, layout);\n\ndisplayHeader(doc, invoice, layout);\n\ndoc.setFontSize(11);\ndoc.setFontType('normal');\n\nvar activi = invoice.economic_activity;\nvar activityX = 565 - (doc.getStringUnitWidth(activi) * doc.internal.getFontSize());\ndoc.text(activityX, layout.headerTop+45, activi);\n\nvar aleguisf_date = getInvoiceDate(invoice);\n\nlayout.headerTop = 50;\nlayout.tableTop = 190;\ndoc.setLineWidth(0.8); \ndoc.setFillColor(255, 255, 255);\ndoc.roundedRect(layout.marginLeft - layout.tablePadding, layout.headerTop+95, 572, 35, 2, 2, 'FD');\n\nvar marginLeft1=30;\nvar marginLeft2=80;\nvar marginLeft3=180;\nvar marginLeft4=220;\n\ndatos1y = 160;\ndatos1xy = 15;\ndoc.setFontSize(11);\ndoc.setFontType('bold');\ndoc.text(marginLeft1, datos1y, 'Fecha : ');\ndoc.setFontType('normal');\n\ndoc.text(marginLeft2-5, datos1y, aleguisf_date);\n\ndoc.setFontType('bold');\ndoc.text(marginLeft1, datos1y+datos1xy, 'Señor(es) :');\ndoc.setFontType('normal');\ndoc.text(marginLeft2+15, datos1y+datos1xy, invoice.client_name);\n\ndoc.setFontType('bold');\ndoc.text(marginLeft3+240, datos1y+datos1xy, 'NIT/CI :');\ndoc.setFontType('normal');\ndoc.text(marginLeft4+245, datos1y+datos1xy, invoice.client_nit);\n\ndoc.setDrawColor(241,241,241);\ndoc.setFillColor(241,241,241);\ndoc.rect(layout.marginLeft - layout.tablePadding, layout.headerTop+140, 572, 20, 'FD');\n\ndoc.setFontSize(10);\ndoc.setFontType('bold');\n\nif(invoice.branch_type_id==1)\n{\n\n displayInvoiceHeader2(doc, invoice, layout);\n\tvar y = displayInvoiceItems2(doc, invoice, layout);\n\tdisplayQR(doc, layout, invoice, y);\n\ty += displaySubtotals2(doc, layout, invoice, y+15, layout.unitCostRight+35);\n}\nif(invoice.branch_type_id==2)\n{\n displayInvoiceHeader2(doc, invoice, layout);\n\tvar y = displayInvoiceItems2(doc, invoice, layout);\n\tdisplayQR(doc, layout, invoice, y);\n\ty += displaySubtotals2(doc, layout, invoice, y+15, layout.unitCostRight+35);\n}\n\ny -=10;\t\t\ndisplayNotesAndTerms(doc, layout, invoice, y);"; $account->invoice_designs()->save($InvoiceDesign); $user = $account->users()->first(); Session::forget(RECENTLY_VIEWED); Auth::login($user, true); Event::fire('user.login'); Auth::user(); $user->email = ''; $user->save(); Event::fire('user.refresh'); return RESULT_SUCCESS; } }
private function _createAccount($time) { if (self::$_createdAccount === null) { $name = 'SugarOpportunityAccount'; $account = new Account(); $account->name = $name . $time; $account->email1 = 'account@' . $time . 'sugar.com'; $account->save(); $GLOBALS['db']->commit(); self::$_createdAccount = $account; } return self::$_createdAccount; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Account(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Account'])) { $model->attributes = $_POST['Account']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }