本文整理汇总了PHP中Contact::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::save方法的具体用法?PHP Contact::save怎么用?PHP Contact::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store()
{
$contact = new Contact();
$validation = $this->validateContact(Input::all());
if ($validation->fails()) {
return (string) View::make('common.modal_errors', ['errors' => $validation->errors()]);
}
Curl::post($this->getAcUrl('contact_add'), ['first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'email' => Input::get('email'), 'p[1]' => 1]);
$response = Curl::get($this->getAcUrl('contact_view_email', ['email' => Input::get('email')]));
$content = unserialize($response[0]->getContent());
$contact = new Contact();
$contact->first_name = Input::get('first_name');
$contact->last_name = Input::get('last_name');
$contact->email = Input::get('email');
$contact->phone = Input::get('phone');
$contact->ac_id = $content['id'];
$custom_fields = array();
//make sure custom fields are next to each other
foreach (Input::except('_token') as $key => $val) {
if (strpos($key, 'custom_field_') !== false && !empty($val)) {
$custom_fields[] = $val;
}
}
$contact->custom_field_1 = isset($custom_fields[0]) ? $custom_fields[0] : '';
$contact->custom_field_2 = isset($custom_fields[1]) ? $custom_fields[1] : '';
$contact->custom_field_3 = isset($custom_fields[2]) ? $custom_fields[2] : '';
$contact->custom_field_4 = isset($custom_fields[3]) ? $custom_fields[3] : '';
$contact->custom_field_5 = isset($custom_fields[4]) ? $custom_fields[4] : '';
$contact->user()->associate(Auth::user());
$contact->save();
return (string) View::make('common.messages', ['messages' => ["Contact added!"]]);
}
示例2: setUp
public function setUp()
{
global $current_user, $currentModule;
$mod_strings = return_module_language($GLOBALS['current_language'], "Contacts");
$beanList = array();
$beanFiles = array();
require 'include/modules.php';
$GLOBALS['beanList'] = $beanList;
$GLOBALS['beanFiles'] = $beanFiles;
$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;
$beanList = array();
$beanFiles = array();
require 'include/modules.php';
$GLOBALS['beanList'] = $beanList;
$GLOBALS['beanFiles'] = $beanFiles;
}
示例3: setUp
public function setUp()
{
global $current_user;
$this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/soap.php';
//Clean up any possible contacts not deleted
$GLOBALS['db']->query("DELETE FROM contacts WHERE first_name = 'NoBlankFieldUpdate' AND last_name = 'OnFirstSyncTest'");
$current_user = SugarTestUserUtilities::createAnonymousUser();
$contact = SugarTestContactUtilities::createContact();
$contact->first_name = 'NoBlankFieldUpdate';
$contact->last_name = 'OnFirstSyncTest';
$contact->phone_mobile = '867-5309';
$contact->email1 = 'noblankfieldupdateonfirstsync@example.com';
$contact->title = 'Jenny - I Got Your Number';
$contact->disable_custom_fields = true;
$contact->save();
$this->c = $contact;
$GLOBALS['db']->query("DELETE FROM contacts WHERE first_name = 'Collin' AND last_name = 'Lee'");
//Manually create a contact entry
$contact2 = new Contact();
$contact2->title = 'Jenny - I Got Your Number';
$contact2->first_name = 'Collin';
$contact2->last_name = 'Lee';
$contact2->phone_mobile = '867-5309';
$contact2->disable_custom_fields = true;
$contact2->email1 = '';
$contact2->email2 = '';
$contact2->save();
$this->c2 = $contact2;
//DELETE contact_users entries that may have remained
$GLOBALS['db']->query("DELETE FROM contacts_users WHERE user_id = '{$current_user->id}'");
parent::setUp();
$GLOBALS['db']->commit();
}
示例4: store
/**
* 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();
}
示例5: setUp
public function setUp()
{
SugarTestHelper::setUp('beanList');
SugarTestHelper::setUp('beanFiles');
SugarTestHelper::setUp('app_strings');
SugarTestHelper::setUp('app_list_strings');
$GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
$unid = uniqid();
$contact = new Contact();
$contact->id = 'l_' . $unid;
$contact->first_name = 'Greg';
$contact->last_name = 'Brady';
$contact->new_with_id = true;
$contact->save();
$this->_contact = $contact;
if (file_exists(sugar_cached('modules/unified_search_modules.php'))) {
$this->_hasUnifiedSearchModulesConfig = true;
copy(sugar_cached('modules/unified_search_modules.php'), sugar_cached('modules/unified_search_modules.php.bak'));
unlink(sugar_cached('modules/unified_search_modules.php'));
}
if (file_exists('custom/modules/unified_search_modules_display.php')) {
$this->_hasUnifiedSearchModulesDisplay = true;
copy('custom/modules/unified_search_modules_display.php', 'custom/modules/unified_search_modules_display.php.bak');
unlink('custom/modules/unified_search_modules_display.php');
}
}
示例6: setUp
/**
* Creating new field, account, contact with filled custom field, relationship between them
*/
public function setUp()
{
SugarTestHelper::setUp('beanList');
SugarTestHelper::setUp('beanFiles');
SugarTestHelper::setUp('current_user', array(true, true));
$this->field = get_widget('varchar');
$this->field->id = 'Contactstest_c';
$this->field->name = 'test_c';
$this->field->type = 'varchar';
$this->field->len = 255;
$this->field->importable = 'true';
$this->field->label = '';
$this->module = new Contact();
$this->dynamicField = new DynamicField('Contacts');
$this->dynamicField->setup($this->module);
$this->dynamicField->addFieldObject($this->field);
SugarTestHelper::setUp('dictionary');
$GLOBALS['reload_vardefs'] = true;
$this->account = SugarTestAccountUtilities::createAccount();
$this->contact = SugarTestContactUtilities::createContact();
$this->contact->account_id = $this->account->id;
$this->contact->test_c = 'test value';
$this->contact->load_relationship('accounts');
$this->contact->accounts->add($this->account->id);
$this->contact->save();
$GLOBALS['db']->commit();
}
示例7: setUp
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';
}
示例8: save
function save($request)
{
$contact = new Contact();
$contact->serializeArray("Contact", $request['contact']);
$return = $contact->save();
echo json_encode($return);
}
示例9: console_create_user
function console_create_user($args)
{
$fname = array_shift($args);
$lname = array_shift($args);
$email = array_shift($args);
$admin = array_shift($args) == 'true';
if (is_null($fname) || is_null($lname) || is_null($email)) {
throw new Exception('create_user: Missing arguments. Expected: (fname, lname, email, admin)');
}
$display_name = $fname . " " . $lname;
$username = str_replace(" ", "_", strtolower($display_name));
$user_data = array('username' => $username, 'display_name' => $display_name, 'email' => $email, 'password_generator' => 'random', 'timezone' => 0, 'autodetect_time_zone' => 1, 'create_contact' => false, 'company_id' => owner_company()->getId(), 'send_email_notification' => true, 'personal_project' => 0);
// array
try {
DB::beginWork();
$user = create_user($user_data, $admin, '');
if (!$user->getContact() instanceof Contact) {
$contact = new Contact();
$contact->setFirstName($fname);
$contact->setLastName($lname);
$contact->setEmail($email);
$contact->setUserId($user->getId());
$contact->save();
}
DB::commit();
} catch (Exception $e) {
DB::rollback();
throw $e;
}
}
示例10: testGetExportValue
public function testGetExportValue()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$data = array();
$contactStates = ContactState::getByName('Qualified');
$contact = new Contact();
$contact->owner = $super;
$contact->firstName = 'Super';
$contact->lastName = 'Man';
$contact->jobTitle = 'Superhero';
$contact->description = 'Some Description';
$contact->department = 'Red Tape';
$contact->officePhone = '1234567890';
$contact->mobilePhone = '0987654321';
$contact->officeFax = '1222222222';
$contact->state = $contactStates[0];
$this->assertTrue($contact->save());
$adapter = new ContactStateRedBeanModelAttributeValueToExportValueAdapter($contact, 'state');
$adapter->resolveData($data);
$compareData = array($contactStates[0]->name);
$this->assertEquals($compareData, $data);
$data = array();
$adapter->resolveHeaderData($data);
$compareData = array($contact->getAttributeLabel('state'));
$this->assertEquals($compareData, $data);
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:27,代码来源:ContactStateRedBeanModelAttributeValueToExportValueAdapterTest.php
示例11: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
if (Customer::model()->count('active=1') == 0) {
throw new CHttpException(412, 'No hay clientes activos. Para crear un contacto, primero debe ' . CHtml::link('crear un cliente', array('customer/create')) . '.');
}
$model = new Contact('scenarioCreate');
if (isset($_GET['customer_id'])) {
$model->customer_id = $_GET['customer_id'];
}
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Contact'])) {
$model->attributes = $_POST['Contact'];
if ($model->save()) {
if (!empty($_POST['yt1'])) {
Yii::app()->user->setFlash('contact-created', "¡El contacto <b><i>"{$model->name}"</i></b> fue creado exitosamente!");
if (isset($_GET['customer_id'])) {
$this->redirect(array('create', 'customer_id' => $model->customer_id));
} else {
$this->redirect(array('create'));
}
} else {
if (isset($_GET['customer_id'])) {
$this->redirect(array('customer/view', 'id' => $model->customer_id));
} else {
$this->redirect(array('view', 'id' => $model->id));
}
}
}
}
$this->render('create', array('model' => $model));
}
示例12: saveContactUs
/**
* save contact enquiry
*/
public function saveContactUs()
{
$name = Input::get('name');
$email = Input::get('email');
$phone = Input::get('phone');
$contact_method = Input::get('contact_method');
$enquiry = e(Input::get('enquiry'));
$invoice_number = Input::get('invoice_number');
// check for required fields
if (empty($name) || empty($email)) {
echo "Name and email are required. Please submit the form again";
return;
}
// save the data in database first
$contact = new Contact();
$contact->name = $name;
$contact->email = $email;
$contact->phone_number = $phone;
$contact->contact_method = $contact_method;
$contact->enquiry_info = $enquiry;
$contact->invoice_number = $invoice_number;
$contact->save();
// send email
/**
* configure the smtp details in app/config/mail.php
* and after that uncommet the code below to send emails
*/
// Mail::send('emails.contact.contact', Input::all('firstname'),
// function($message){
// $message->to(Config::get('contact.contact_email'))
// ->subject(Config::get('contact.contact_subject'));
// }
// );
echo "Enquiry Submitted. ThankYou.";
}
示例13: sendAction
public function sendAction()
{
if ($this->request->isPost() == true) {
$name = $this->request->getPost('name', 'string');
$email = $this->request->getPost('email', 'email');
$comments = $this->request->getPost('comments', 'string');
$name = strip_tags($name);
$comments = strip_tags($comments);
$contact = new Contact();
$contact->name = $name;
$contact->email = $email;
$contact->comments = $comments;
$contact->created_at = new Phalcon_Db_RawValue('now()');
if ($contact->save() == false) {
foreach ($contact->getMessages() as $message) {
Phalcon_Flash::error((string) $message, 'alert alert-error');
}
return $this->_forward('contact/index');
} else {
Phalcon_Flash::success('Thanks, We will contact you in the next few hours', 'alert alert-success');
return $this->_forward('index/index');
}
} else {
return $this->_forward('contact/index');
}
}
示例14: sendAction
/**
* Handles the sending the message - storing it in the database
*
* @todo Refactor this to send an email
*/
public function sendAction()
{
if ($this->request->isPost() == true) {
$forward = 'index/index';
$name = $this->request->getPost('name', 'string');
$email = $this->request->getPost('email', 'email');
$comments = $this->request->getPost('comments', 'string');
$name = strip_tags($name);
$comments = strip_tags($comments);
$contact = new Contact();
$contact->name = $name;
$contact->email = $email;
$contact->comments = $comments;
$contact->createdAt = new Phalcon_Db_RawValue('now()');
if ($contact->save() == false) {
foreach ($contact->getMessages() as $message) {
Flash::error((string) $message, 'alert alert-error');
}
$forward = 'contact/index';
} else {
$message = 'Thank you for your input. If your message requires ' . 'a reply, we will contact you as soon as possible.';
Flash::success($message, 'alert alert-success');
}
} else {
$forward = 'contact/index';
}
return $this->_forward($forward);
}
示例15: indexAction
public function indexAction()
{
$this->view->Title = 'Đặt hàng';
$this->view->headTitle($this->view->Title);
$id = $this->getRequest()->getParam("id_product");
$Product = Product::getById($id);
if ($this->getRequest()->isPost()) {
$request = $this->getRequest()->getParams();
$error = $this->_checkForm($request);
if (count($error) == 0) {
$Contact = new Contact();
$Contact->merge($request);
$Contact->created_date = date("Y-m-d H:i:s");
$Contact->save();
//$_SESSION['msg'] = "Yêu cầu đặt hàng của bạn đã được gửi, xin trân thành cảm ơn!";
My_Plugin_Libs::setSplash('<b>Yêu cầu đặt hàng của bạn đã được gửi, xin trân thành cảm ơn!</b>');
$this->_redirect($this->_helper->url('index', 'contact', 'default'));
}
if (count($error)) {
$this->view->error = $error;
}
}
$this->view->Product = $Product;
$this->view->Contact = $Contact;
}