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!"]]);
 }
 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;
 }
 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 = '*****@*****.**';
     $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();
 }
 /**
  * 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 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');
     }
 }
 /**
  * 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();
 }
Exemple #7
0
 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';
 }
Exemple #8
0
function save($request)
{
    $contact = new Contact();
    $contact->serializeArray("Contact", $request['contact']);
    $return = $contact->save();
    echo json_encode($return);
}
Exemple #9
0
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;
    }
}
 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);
 }
Exemple #11
0
 /**
  * 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>&quot;{$model->name}&quot;</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));
 }
 /**
  * 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.";
 }
Exemple #13
0
 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');
     }
 }
 /**
  * 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);
 }
 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;
 }
 public function save()
 {
     $rules = ['firstname' => 'required', 'lastname' => 'required', 'phone' => 'required', 'message' => 'required', 'email' => 'required|email'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return View::make('error')->with('message', 'Looks like there\'s some missing data');
     }
     # Create new contact record
     $contact = new Contact();
     $contact->first_name = Input::get('firstname');
     $contact->last_name = Input::get('lastname');
     $contact->phone = Input::get('phone');
     $contact->email = Input::get('email');
     $contact->message = Input::get('message');
     $contact->save();
     # Shoot email to customer service team
     $data = Input::all();
     $email = Input::get('email');
     $data['messages'] = Input::get('message');
     // work-around message stdClass
     Mail::send('emails.contact', $data, function ($message) use($email) {
         $message->to('*****@*****.**')->subject($email . ' is requesting some information');
     });
     return View::make('thank_you')->with(['person' => 'Customer care agents']);
 }
Exemple #17
0
 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 testResolveContactToSenderOrRecipientForReceivedEmail()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $message1 = self::$message1;
     $contact = new Contact();
     $contact->firstName = 'Jason';
     $contact->lastName = 'Green';
     $contact->state = ContactsUtil::getStartingState();
     $saved = $contact->save();
     $this->assertTrue($saved);
     $contactId = $contact->id;
     $contact->forget();
     $contact = Contact::getById($contactId);
     $this->assertNull($contact->primaryEmail->emailAddress);
     ArchivedEmailMatchingUtil::resolveContactToSenderOrRecipient($message1, $contact);
     $saved = $message1->save();
     $this->assertTrue($saved);
     $messageId = $message1->id;
     $message1->forget();
     $contact->forget();
     RedBeanModel::forgetAll();
     //simulates crossing page requests
     $message1 = EmailMessage::getById($messageId);
     $contact = Contact::getById($contactId);
     $this->assertEquals(1, $message1->sender->personsOrAccounts->count());
     $castedDownModel = EmailMessageMashableActivityRules::castDownItem($message1->sender->personsOrAccounts[0]);
     $this->assertEquals('Contact', get_class($castedDownModel));
     $this->assertEquals($contact->id, $castedDownModel->id);
 }
Exemple #19
0
 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';
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof ContactWebFormEntry');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ContactWebFormsModule', 'ContactWebFormEntry');
     }
     $contactFormAttributes = array();
     $contact = new Contact();
     $contact->owner = $model->contactWebForm->defaultOwner;
     $contact->state = $model->contactWebForm->defaultState;
     $contact->firstName = $contactFormAttributes['firstName'] = $this->seedData['firstName'][$this->index];
     $contact->lastName = $contactFormAttributes['lastName'] = $this->seedData['lastName'][$this->index];
     $contact->companyName = $contactFormAttributes['companyName'] = $this->seedData['companyName'][$this->index];
     $contact->jobTitle = $contactFormAttributes['jobTitle'] = $this->seedData['jobTitle'][$this->index];
     if ($contact->validate()) {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_SUCCESS;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_SUCCESS_MESSAGE;
         $contact->save();
     } else {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_ERROR;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_ERROR_MESSAGE;
         $contact = null;
     }
     $model->contact = $contact;
     $model->status = $contactWebFormEntryStatus;
     $model->message = $contactWebFormEntryMessage;
     $contactFormAttributes['owner'] = $model->contactWebForm->defaultOwner->id;
     $contactFormAttributes['state'] = $model->contactWebForm->defaultState->id;
     $model->serializedData = serialize($contactFormAttributes);
 }
Exemple #21
0
 public function testCustomRelateFieldInDashlet()
 {
     $id = $this->relateField->ext3;
     $this->contact2->{$id} = $this->account->id;
     $this->contact2->save();
     $layoutDef = array('name' => $this->relateField->name, 'id_name' => $this->relateField->ext3, 'type' => 'relate', 'ext2' => 'Accounts', 'custom_module' => 'Contacts', 'table' => 'contacts_cstm', 'table_alias' => 'contacts', 'module' => 'Accounts', 'input_name0' => array(0 => $this->account->id));
     $out = $this->sugarWidget->queryFilterone_of($layoutDef);
     $this->assertContains($this->contact2->id, $out, 'The request for custom relate field was made incorrectly');
 }
Exemple #22
0
 protected function saveModel($contact = false)
 {
     if (Input::get('id')) {
         $contact = Contact::find(Input::get('id'));
     }
     if (!$contact) {
         $contact = new Contact();
     }
     $contact->function = Input::get('function');
     $contact->first_name = Input::get('first_name');
     $contact->last_name = Input::get('last_name');
     $contact->references = Input::get('references');
     $contact->notes = Input::get('notes');
     $address = $contact->address()->first() ?: new Address();
     $address_input = Input::get('address');
     $country = Country::where('name', Input::get('country'))->first();
     if ($country) {
         $address->country()->associate($country);
     }
     $address->address = isset($address_input['address']) ? $address_input['address'] : '';
     $address->postal_code = isset($address_input['postal_code']) ? $address_input['postal_code'] : '';
     $address->city = isset($address_input['city']) ? $address_input['city'] : '';
     $address->state_province = isset($address_input['state_province']) ? $address_input['state_province'] : '';
     $address->phone = isset($address_input['phone']) ? $address_input['phone'] : '';
     $address->fax = isset($address_input['fax']) ? $address_input['fax'] : '';
     $address->email = isset($address_input['email']) ? $address_input['email'] : '';
     $address->website = isset($address_input['website']) ? $address_input['website'] : '';
     $address->save();
     $contact->address()->associate($address);
     $contact->save();
     $parentQuery = Input::get('parent_model');
     if (!empty($parentQuery)) {
         $parentModel = null;
         switch ($parentQuery) {
             case 'events':
                 $relation = 'events';
                 $parentModel = 'Events';
                 break;
             case 'company':
                 $relation = 'companies';
                 $parentModel = 'Company';
                 break;
             case 'venue':
                 $relation = 'venues';
                 $parentModel = 'Venue';
                 break;
             default:
                 break;
         }
         if (!empty($parentModel)) {
             $contact->{$relation}()->detach($parentModel::find(Input::get('parent_id')));
             $contact->{$relation}()->attach($parentModel::find(Input::get('parent_id')));
         }
     }
     return $contact;
 }
 /**
  * @covers Moneybird\Contact_Service::getSyncList
  */
 public function testGetSyncList()
 {
     $revision = $this->object->revision;
     $this->assertNotNull($revision, 'Contact ' . self::$contactId . ' not in synclist');
     $this->object = $this->service->getById(self::$contactId);
     $this->object->setData(array('firstname' => 'Test' . time()));
     $this->object->save($this->service);
     sleep(1);
     $newRevision = null;
     $syncList = $this->service->getSyncList();
     $this->assertInstanceOf('Moneybird\\Contact_Array', $syncList);
     foreach ($syncList as $sync) {
         if ($sync->id == self::$contactId) {
             $newRevision = $sync->revision;
         }
     }
     $this->assertNotNull($newRevision, 'Contact ' . self::$contactId . ' not in synclist');
     $this->assertGreaterThan($revision, $newRevision);
 }
 public function testCreateAndGetContactWebFormEntryById()
 {
     $allAttributes = ContactWebFormsUtil::getAllAttributes();
     $placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
     $contactFormAttributes = ContactWebFormsUtil::getAllPlacedAttributes($allAttributes, $placedAttributes);
     $attributes = array_keys($contactFormAttributes);
     $this->assertTrue(ContactsModule::loadStartingData());
     $contactStates = ContactState::getByName('New');
     $contactWebForm = new ContactWebForm();
     $contactWebForm->name = 'Test Form';
     $contactWebForm->redirectUrl = 'http://google.com';
     $contactWebForm->submitButtonLabel = 'Save';
     $contactWebForm->defaultState = $contactStates[0];
     $contactWebForm->defaultOwner = Yii::app()->user->userModel;
     $contactWebForm->serializedData = serialize($attributes);
     $contactWebForm->save();
     $contact = new Contact();
     $contact->owner = $contactWebForm->defaultOwner;
     $contact->state = $contactWebForm->defaultState;
     $contact->firstName = 'Super';
     $contact->lastName = 'Man';
     $contact->jobTitle = 'Superhero';
     $contact->companyName = 'Test Inc.';
     if ($contact->validate()) {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_SUCCESS;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_SUCCESS_MESSAGE;
     } else {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_ERROR;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_ERROR_MESSAGE;
     }
     $contact->save();
     foreach ($contactFormAttributes as $attributeName => $attributeValue) {
         $contactFormAttributes[$attributeName] = $contact->{$attributeName};
     }
     $contactFormAttributes['owner'] = $contactWebForm->defaultOwner->id;
     $contactFormAttributes['state'] = $contactWebForm->defaultState->id;
     $contactWebFormEntry = new ContactWebFormEntry();
     $contactWebFormEntry->serializedData = serialize($contactFormAttributes);
     $contactWebFormEntry->status = $contactWebFormEntryStatus;
     $contactWebFormEntry->message = $contactWebFormEntryMessage;
     $contactWebFormEntry->contactWebForm = $contactWebForm;
     $contactWebFormEntry->contact = $contact;
     $this->assertTrue($contactWebFormEntry->save());
     $contactWebFormEntryId = $contactWebFormEntry->id;
     unset($contactWebFormEntry);
     $contactWebFormEntry = ContactWebFormEntry::getById($contactWebFormEntryId);
     $this->assertEquals('Test Form', $contactWebFormEntry->contactWebForm->name);
     $this->assertEquals('Super', $contactWebFormEntry->contact->firstName);
     $this->assertEquals('Man', $contactWebFormEntry->contact->lastName);
     $contactFormAttributes = unserialize($contactWebFormEntry->serializedData);
     $this->assertEquals('Super', $contactFormAttributes['firstName']);
     $this->assertEquals('Man', $contactFormAttributes['lastName']);
     $this->assertEquals('Superhero', $contactFormAttributes['jobTitle']);
     $this->assertEquals('Test Inc.', $contactFormAttributes['companyName']);
 }
Exemple #25
0
 public function save($runValidation = true, $attributes = NULL)
 {
     $status = parent::save($runValidation, $attributes);
     if (!$this->getIsInversed()) {
         $inversed = new Contact();
         $inversed->user_id = $this->contact_id;
         $inversed->contact_id = $this->user_id;
         $inversed->save(false);
     }
     return $status;
 }
Exemple #26
0
 function index()
 {
     $this->load->library("securimage");
     $contact = new Contact();
     $msg = "";
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $contact->name = $this->input->post('name');
         $contact->address = $this->input->post('address');
         $contact->title = $this->input->post('title');
         $contact->email = $this->input->post('email');
         $contact->content = $this->input->post('content');
         $contact->phone = $this->input->post('phone');
         if ($this->securimage->check($_POST['captcha_code']) == false) {
             $msg = '<div class="frm-error">Vui lòng nhập đúng mã xác nhận !</div>';
             $type = 0;
         } else {
             if ($contact->save()) {
                 //redirect("lien-he/success");
                 $type = 1;
                 /*
                 $content = "<html><head></head><body>";
                 $content .= "<br>Hi Mr/ms !";
                 $content .= "<br>We've received a contact information from lienminh.com.vn website . Please see detail below :";
                 $content .= "<br>Title:".$contact->title;
                 $content .= "<br>Name:".$contact->name;
                 $content .= "<br>Email:".$contact->email;
                 $content .= "<br>Message:".$contact->content;
                 $content .="</body></html>";
                 $this->sendMail($content);
                 */
                 if ($this->_send_email($file_name, $file_path)) {
                     $msg = "Cảm ơn bạn đã gửi thông tin. Chúng tôi sẽ phản hồi sớm nhất. Trân trọng !";
                 } else {
                     $msg = "Có lỗi xảy ra trong quá trình gửi mail.";
                 }
                 $contact->clear();
             } else {
                 $msg = "Có 1 số lỗi sau :\n";
                 foreach ($contact->error->all as $row) {
                     $msg .= $row . "\n";
                 }
             }
         }
     }
     $dis['contact'] = $contact;
     $this->menu_active = "contact";
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/contact';
     $dis['msg'] = $msg;
     $this->page_title = "Liên hệ - " . $this->page_title;
     $this->page_keyword = "Liên hệ ";
     $this->page_description = "thông tin, địa chỉ liên hệ ";
     $this->viewfront($dis);
 }
 public function store()
 {
     $input = Input::all();
     $validator = Validator::make($input, Contact::$rules);
     if ($validator->fails()) {
         return Response::json(["status" => "FAIL", "errors" => $validator->messages()]);
     }
     // Validation passed
     $obj = new Contact($input);
     $obj->save();
     return Response::json(["status" => "OK"]);
 }
 public static function createLeadWithAccountByNameForOwner($firstName, $owner, $account)
 {
     ContactsModule::loadStartingData();
     $contact = new Contact();
     $contact->firstName = $firstName;
     $contact->lastName = $firstName . 'son';
     $contact->owner = $owner;
     $contact->account = $account;
     $contact->state = LeadsUtil::getStartingState();
     $saved = $contact->save();
     assert('$saved');
     return $contact;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Contact();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Contact'])) {
         $model->attributes = $_POST['Contact'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemple #30
0
 public function setUp()
 {
     SugarTestHelper::setUp('beanFiles');
     SugarTestHelper::setUp('beanList');
     SugarTestHelper::setUp('current_user');
     $this->account = SugarTestAccountUtilities::createAccount();
     $this->contact = SugarTestContactUtilities::createContact();
     $this->email = SugarTestEmailUtilities::createEmail();
     $this->opportunity = SugarTestOpportunityUtilities::createOpportunity('', $this->account);
     $this->contact->account_id = $this->account->id;
     $this->contact->save();
     $this->opportunity->load_relationship('contacts');
     $this->opportunity->contacts->add($this->contact);
     $this->email->parent_id = $this->contact->id;
     $this->email->parent_type = $this->contact->module_name;
     $this->email->save();
     if (isset($GLOBALS['app'])) {
         $this->application = $GLOBALS['app'];
     }
     $GLOBALS['app'] = new SugarApplication();
     $GLOBALS['app']->controller = new SugarController();
 }