public function save() { $this->load->model('contacts'); $contact = new Contacts(); $contact->id = 1; $contact->name = $this->input->post('name'); $contact->number = $this->input->post('number'); $contact->city = $this->input->post('city'); if ($contact->save()) { die('Saved'); } }
/** * Add a new contact * @param $id * @param array $data * @return integer contact_id */ public static function AddNew(array $data, $id = "") { if (is_numeric($id)) { $contact = self::find($id); } else { $contact = new Contacts(); } $contact['contact'] = $data['contact']; $contact['type_id'] = $data['type_id']; $contact['customer_id'] = $data['customer_id']; $contact->save(); return $contact['contact_id']; }
private function createContact($con) { $con_model = new \Contacts(); $con_model->attributes = $con; $con_model->ID_user = $this->tiUser->ID; try { if (!$con_model->save()) { new \Error(5, null, json_encode($con_model->getErrors())); } } catch (Exception $e) { new \Error(5, null, $e->getMessage()); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $this->layout = 'main'; $model = new Contacts(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Contacts'])) { $model->attributes = $_POST['Contacts']; $model->date = new CDbExpression('NOW()'); if ($model->save()) { $notif = Yii::app()->getComponent('user'); $notif->setFlash('success', "<strong>Message successfully send!</strong>"); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Contacts(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Contacts'])) { $model->attributes = $_POST['Contacts']; if ($model->save()) { $msg = 'Контакт #' . $model->id . ' - ' . $model->name . ' создан'; Yii::app()->user->setFlash('success', $msg); Yii::app()->logger->write($msg); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionSendContact() { $model = new Contacts(); if (isset($_POST['Contacts'])) { $model->attributes = $_POST['Contacts']; $model->date = new CDbExpression('NOW()'); if ($model->save()) { echo 'Thank you for contacting us. We will respond to you as soon as possible.'; } else { echo 'Send contact failed, please fix some error:'; foreach ($model->errors as $err) { echo '<br>' . ' - ' . $err[0]; } } } else { echo 'Error '; } }
/** * Method of creating a Contact called by the Quick Create widget */ public function actionQuickContact() { $model = new Contacts(); // collect user input data if (isset($_POST['Contacts'])) { // clear values that haven't been changed from the default //$temp=$model->attributes; $model->setX2Fields($_POST['Contacts']); $model->visibility = 1; // validate user input and save contact // $changes = $this->calculateChanges($temp, $model->attributes, $model); // $model = $this->updateChangelog($model, $changes); $model->createDate = time(); //if($model->validate()) { if ($model->save()) { } else { //echo CHtml::errorSummary ($model); echo CJSON::encode($model->getErrors()); } return; //} //echo ''; //echo CJSON::encode($model->getErrors()); } $this->renderPartial('application.components.views.quickContact', array('model' => $model)); }
private function importExcel($file) { $fp = fopen($file, 'r+'); $meta = fgetcsv($fp); while ($arr = fgetcsv($fp)) { $model = new Contacts(); $attributes = array_combine($meta, $arr); foreach ($attributes as $attribute => $value) { if (array_search($attribute, array_keys($model->attributes)) !== false) { $model->{$attribute} = $value; } } if ($model->save()) { } } unlink($file); $this->redirect('index'); }
$key = array_rand($street_address_array); $contact->column_fields["mailingstreet"] = $street_address_array[$key]; $key = array_rand($city_array); $contact->column_fields["mailingcity"] = $city_array[$key]; $contact->column_fields["mailingstate"] = "CA"; $contact->column_fields["mailingzip"] = '99999'; $contact->column_fields["mailingcountry"] = 'USA'; $key = array_rand($comboFieldArray['leadsource_dom']); $contact->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key]; $titles = array("President", "VP Operations", "VP Sales", "Director Operations", "Director Sales", "Mgr Operations", "IT Developer", ""); $key = array_rand($titles); $contact->column_fields["title"] = $titles[$key]; $account_key = array_rand($account_ids); $contact->column_fields["account_id"] = $account_ids[$account_key]; //$contact->saveentity("Contacts"); $contact->save("Contacts"); $contact_ids[] = $contact->id; if ($i > 8) { $freetag = $adb->getUniqueId('vtiger_freetags'); $query = "insert into vtiger_freetags values (?,?,?)"; $qparams = array($freetag, $cloudtag[2], $cloudtag[2]); $res1 = $adb->pquery($query, $qparams); $date = $adb->formatDate(date('YmdHis'), true); $query_tag = "insert into vtiger_freetagged_objects values (?,?,?,?,?)"; $tag_params = array($freetag, 1, $contact->id, $date, 'Contacts'); $result1 = $adb->pquery($query_tag, $tag_params); } // This assumes that there will be one opportunity per company in the seed data. $opportunity_key = array_rand($opportunity_ids); $query = "insert into vtiger_contpotentialrel ( contactid, potentialid ) values (?,?)"; $adb->pquery($query, array($contact->id, $opportunity_ids[$opportunity_key]));
if ($email->relationship["type"] == "Contacts") { add_attachment_to_contact($email->relationship["id"], $email, $focus->id); } } else { //if relationship is not available create a contact and relate the email to the contact require_once 'modules/Contacts/Contacts.php'; $contact_focus = new Contacts(); //Populate the lastname as emailid if email doesn't have from name if ($email->fromname) { $contact_focus->column_fields['lastname'] = $email->fromname; } else { $contact_focus->column_fields['lastname'] = $email->from; } $contact_focus->column_fields['email'] = $email->from; $contact_focus->column_fields["assigned_user_id"] = $current_user->id; $contact_focus->save("Contacts"); $focus->column_fields['parent_id'] = $contact_focus->id . '@' . $fieldid . '|'; $focus->save("Emails"); add_attachment_to_contact($contact_focus->id, $email, $focus->id); } function add_attachment_to_contact($cid, $email, $emailid) { // add vtiger_attachments to contact global $adb, $current_user, $default_charset; for ($j = 0; $j < 2; $j++) { if ($j == 0) { $attachments = $email->downloadAttachments(); } else { $attachments = $email->downloadInlineAttachments(); } $upload_filepath = decideFilePath();
public function actionSave() { $response = array('status' => 'failed'); if (Yii::app()->request->isAjaxRequest) { if (isset($_POST['datas']) and $_POST['datas'] != "" and isset($_POST['import_fields']) and count($_POST['import_fields']) > 0) { $datas = json_decode($_POST['datas']); $fields = $_POST['import_fields']; $start = 1; $singlequery = false; $inserted_rows = 0; $requiredattributes = array(); if (Contacts::model()->import_contacts_config()) { $import_config = Contacts::model()->import_contacts_config(); if ($import_config['required_attributes']) { $requiredattributes = $import_config['required_attributes']; } } $valid = true; foreach ($fields as $field => $value) { if (in_array($field, $requiredattributes) and $value == NULL) { $valid = false; } } if (!$valid) { $response['data'] = $this->renderPartial('import/_error', array('error' => 2), true); } else { while ($start < count($datas)) { if (!$singlequery) { $contact = new Contacts(); $contact->created_by = Yii::app()->user->id; $contact->created_at = date('Y-m-d H:i:s'); $contact->status = 1; foreach ($fields as $field => $value) { if ($value != NULL) { $contact->{$field} = $datas[$start][$value]; } } if ($contact->save()) { $inserted_rows++; if (isset($_POST['groups']) and count($_POST['groups']) > 0) { foreach ($_POST['groups'] as $group) { $list = new ContactsList(); $list->contact_id = $contact->id; $list->group_id = $group; $list->save(); } } } } $start++; } $response['status'] = "success"; $response['data'] = $this->renderPartial('import/_step3', array('inserted_rows' => $inserted_rows, 'total_rows' => count($datas) - 1), true); } } } echo json_encode($response); Yii::app()->end(); }
public function createContactAction() { if ($this->request->isPost() == true) { try { $this->response->setContentType('application/json'); $user_id = $this->request->getPost('user_id'); $email = $this->request->getPost('email'); $number = $this->request->getPost('number', 'striptags'); $contact_name = $this->request->getPost('contact_name'); $address = $this->request->getPost('address'); if ($email == '' || $email == null) { $email = null; } $contact = new Contacts(); $msg = 'contact created'; $contact_data = array('contact_name' => $contact_name, 'email' => $email, 'number' => $number, 'address' => $address, 'user_id' => $user_id, 'msg' => $msg); $contact->assign(array('name' => $contact_name, 'number' => $number, 'user_id' => $user_id, 'email' => $email, 'address' => $address, 'updated_at' => date("Y-m-d H:i:s"), 'created_at' => date("Y-m-d H:i:s"))); if ($contact->save()) { $data = array('status' => 'success', 'msg' => $msg, 'code' => 2); } else { $data = $this->updateContact($contact_data); } } catch (Exception $ex) { $data = $this->updateContact($contact_data); } $this->response->setContent(json_encode($data)); $this->response->send(); } }
public function admin_settings() { if (count($this->_managerImages) != 0) { foreach ($this->_managerImages as $file) { if ($file->name != '') { $imageExtention = pathinfo($file->getName(), PATHINFO_EXTENSION); $imageName = substr(md5($file->name . microtime()), 0, 28) . '.' . $imageExtention; $image = Yii::app()->image->load($file->tempName); $image->resize(self::$image_w, self::$image_h); $image->save('./uploads/' . $imageName); $this->manager_image = $imageName; } break; } } Contacts::model()->deleteAll(); if (count($_POST['contacts_title_ru']) != 0) { foreach ($_POST['contacts_title_ru'] as $key => $c) { $contacts = new Contacts(); $contacts->title_ru = trim($_POST['contacts_title_ru'][$key]); $contacts->title_en = trim($_POST['contacts_title_en'][$key]); $contacts->title_es = trim($_POST['contacts_title_es'][$key]); $contacts->value = trim($_POST['contacts_value'][$key]); $contacts->save(); } } ManagerContacts::model()->deleteAll(); if (count($_POST['managerContacts_title_ru']) != 0) { foreach ($_POST['managerContacts_title_ru'] as $key => $c) { $managerContacts = new ManagerContacts(); $managerContacts->title_ru = trim($_POST['managerContacts_title_ru'][$key]); $managerContacts->title_en = trim($_POST['managerContacts_title_en'][$key]); $managerContacts->title_es = trim($_POST['managerContacts_title_es'][$key]); $managerContacts->value = trim($_POST['managerContacts_value'][$key]); $managerContacts->save(); } } if ($this->save(false)) { return true; } else { return false; } }
include_once 'build/cbHeader.inc'; require_once 'modules/Contacts/Contacts.php'; $time_elapsed_us = microtime(true) - $start; echo "Load time: {$time_elapsed_us}\n"; $num2create = 100; $_REQUEST['assigntype'] == 'U'; $recs2del = array(); $start = microtime(true); for ($i = 0; $i < $num2create; $i++) { $focus = new Contacts(); $focus->column_fields['firstname'] = 'firstname' . $i; $focus->column_fields['lastname'] = 'lastname' . $i; $focus->email_opt_out = 'off'; $focus->do_not_call = 'off'; $focus->column_fields['assigned_user_id'] = $current_user->id; $focus->save("Contacts"); $recs2del[] = $focus->id; if ($i % 10 == 0) { echo $i . "\n"; foreach ($recs2del as $c) { $f2 = new Contacts(); $f2->retrieve_entity_info($c, 'Contacts'); DeleteEntity('Contacts', 'Contacts', $f2, $c, $c); } $recs2del = array(); } } foreach ($recs2del as $c) { $f2 = new Contacts(); $f2->retrieve_entity_info($c, 'Contacts'); DeleteEntity('Contacts', 'Contacts', $f2, $c, $c);
function create_contact1($user_name, $first_name, $last_name, $email_address, $account_name, $salutation, $title, $phone_mobile, $reports_to, $primary_address_street, $primary_address_city, $primary_address_state, $primary_address_postalcode, $primary_address_country, $alt_address_city, $alt_address_street, $alt_address_state, $alt_address_postalcode, $alt_address_country, $office_phone, $home_phone, $other_phone, $fax, $department, $birthdate, $assistant_name, $assistant_phone, $description = '') { global $adb, $log; global $current_user; require_once 'modules/Users/Users.php'; $seed_user = new Users(); $user_id = $seed_user->retrieve_user_id($user_name); $current_user = $seed_user; $current_user->retrieve_entity_info($user_id, 'Users'); require_once 'modules/Contacts/Contacts.php'; if (isPermitted("Contacts", "EditView") == "yes") { $contact = new Contacts(); $contact->column_fields[firstname] = $first_name; $contact->column_fields[lastname] = $last_name; //$contact->column_fields[account_id]=retrieve_account_id($account_name,$user_id);// NULL value is not supported NEED TO FIX $contact->column_fields[salutation] = $salutation; // EMAIL IS NOT ADDED $contact->column_fields[title] = $title; $contact->column_fields[email] = $email_address; $contact->column_fields[mobile] = $phone_mobile; //$contact->column_fields[reports_to_id] =retrievereportsto($reports_to,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP $contact->column_fields[mailingstreet] = $primary_address_street; $contact->column_fields[mailingcity] = $primary_address_city; $contact->column_fields[mailingcountry] = $primary_address_country; $contact->column_fields[mailingstate] = $primary_address_state; $contact->column_fields[mailingzip] = $primary_address_postalcode; $contact->column_fields[otherstreet] = $alt_address_street; $contact->column_fields[othercity] = $alt_address_city; $contact->column_fields[othercountry] = $alt_address_country; $contact->column_fields[otherstate] = $alt_address_state; $contact->column_fields[otherzip] = $alt_address_postalcode; $contact->column_fields[assigned_user_id] = $user_id; // new Fields $contact->column_fields[phone] = $office_phone; $contact->column_fields[homephone] = $home_phone; $contact->column_fields[otherphone] = $other_phone; $contact->column_fields[fax] = $fax; $contact->column_fields[department] = $department; $contact->column_fields[birthday] = DateTimeField::convertToUserFormat($birthdate); $contact->column_fields[assistant] = $assistant_name; $contact->column_fields[assistantphone] = $assistant_phone; $contact->column_fields[description] = $description; $contact->save("Contacts"); if ($contact->id != '') { return 'Contact added successfully'; } else { return "Contact creation failed. Try again"; } } else { return $accessDenied; } }
public function actionNew() { $model = new Contacts(); $attributeLabels = $model->attributeLabels(); /*if(isset($_POST['ajax']) && $_POST['ajax']=='quick-contact-form') { echo CActiveForm::validate($model); Yii::app()->end(); }*/ // collect user input data if (isset($_POST['Contacts'])) { // $this->redirect('http://www.google.com/'); //$model->attributes = $_POST['Contacts']; $model->setX2Fields($_POST['Contacts']); // // $model->firstName = 'bob'; // $model->lastName = 'dole'; // $model->phone = ''; // $model->email = ''; $model->visibility = 1; // reset to blank if it's the default value /*if($model->firstName == $attributeLabels['firstName']) $model->firstName = ''; if($model->lastName == $attributeLabels['lastName']) $model->lastName = ''; if($model->phone == $attributeLabels['phone']) $model->phone = ''; if($model->email == $attributeLabels['email']) $model->email = '';*/ $model->createDate = time(); // validate user input and save contact if ($model->save()) { echo "1"; $this->redirect(array('/mobile/contacts/view', 'id' => $model->id)); } //else print_r($model->getErrors()); } $this->render('quickContact', array('model' => $model)); }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $form = $this->getForm("/profile/process"); $request = $this->getRequest(); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('index', 'index', 'default'); } if ($form->isValid($request->getPost())) { // Get the id $id = $this->getRequest()->getParam('customer_id'); try { // Set the new values if (is_numeric($id)) { $customer = Doctrine::getTable('Customers')->find($id); $oldCustomer = $customer->toArray(); // Get the values posted $params = $form->getValues(); $customer->company = $params['company']; $customer->firstname = $params['firstname']; $customer->lastname = $params['lastname']; $customer->email = $params['email']; $customer->birthdate = Shineisp_Commons_Utilities::formatDateIn($params['birthdate']); if (!empty($params['password'])) { $customer->password = MD5($params['password']); } $customer->birthplace = $params['birthplace']; $customer->birthdistrict = $params['birthdistrict']; $customer->birthcountry = $params['birthcountry']; $customer->birthnationality = $params['birthnationality']; $customer->vat = $params['vat']; $customer->taxpayernumber = $params['taxpayernumber']; $customer->type_id = !empty($params['company_type_id']) ? $params['company_type_id'] : NULL; $customer->legalform_id = $params['legalform']; $customer->gender = $params['gender']; // Save the data $customer->save(); $id = is_numeric($id) ? $id : $customer->getIncremented(); // Manage the address of the customer $address = new Addresses(); $mainAddress = $address->findOneByUserId($id); if ($mainAddress) { $address = $mainAddress; } $address->address = $params['address']; $address->city = $params['city']; $address->code = $params['code']; $address->country_id = $params['country_id']; $address->area = $params['area']; $address->customer_id = $id; $address->save(); if (!empty($params['contact'])) { $contacts = new Contacts(); $contacts->contact = $params['contact']; $contacts->type_id = $params['contacttypes']; $contacts->customer_id = $id; $contacts->save(); } // Add or Remove the customer email in the newsletter list Customers::newsletter_subscription($id, $params['newsletter']); $retval = Shineisp_Commons_Utilities::getEmailTemplate('profile_changed'); if ($retval) { $subject = $retval['subject']; $subject = str_replace("[user]", $params['firstname'] . " " . $params['lastname'], $retval['subject']); // Alert the administrator about the changing of the customer information $body = $retval['template']; $body = str_replace("[user]", $params['firstname'] . " " . $params['lastname'], $body); $body = str_replace("[old]", print_r($oldCustomer, true), $body); $body = str_replace("[new]", print_r($customer->toArray(), true), $body); $isp = Shineisp_Registry::get('ISP'); Shineisp_Commons_Utilities::SendEmail($isp->email, $isp->email, null, $subject, $body); } } } catch (Exception $e) { echo $e->getMessage(); die; } return $this->_helper->redirector('account', 'profile', 'default', array('mex' => 'The task requested has been executed successfully.', 'status' => 'success')); } else { $this->view->form = $form; $this->view->title = $this->translator->translate("Profile details"); $this->view->description = $this->translator->translate("Update here your details filling the applicant form with all the information about you."); return $this->_helper->viewRenderer('applicantform'); } }
public function testModifyColumn() { $schema = Yii::app()->db->schema; $field = new Fields('test'); $field->modelName = $this->getTestModelName(); $field->fieldName = $this->getTestColumnName(); $field->type = 'varchar'; $field->custom = 0; $tableName = X2Model::model($field->modelName)->tableName(); try { $field->createColumn(); } catch (Exception $e) { $this->tearDownTestColumn(); throw $e; } Yii::app()->db->schema->refresh(); $columnsAfterAdd = Yii::app()->db->schema->tables[$tableName]->columnNames; $column = Yii::app()->db->schema->tables[$tableName]->columns[$field->fieldName]; $this->assertEquals('varchar(255)', $column->dbType); $this->assertTrue(in_array($field->fieldName, $columnsAfterAdd), "Column {$field->fieldName} was not created."); // test column modification $field->type = 'float'; $this->assertTrue($field->modifyColumn()); Yii::app()->db->schema->refresh(); $column = Yii::app()->db->schema->tables[$tableName]->columns[$field->fieldName]; $this->assertEquals('float', $column->dbType); // test strict mode. Try to truncate column and ensure that modifyColumn returns false in // indicating CDbException $contact = Contacts::model()->findByPk(12345); if (!$contact) { // temporary fix to get test to work in opensource. For some reason the contact // fixture isn't being loaded. $contact = new Contacts(); $contact->setAttributes(array('id' => 12345, 'name' => 'Testfirstname Testlastname', 'nameId' => 'Testfirstname Testlastname_12345', 'company' => 'Black Mesa_1', 'firstName' => 'Testfirstname', 'lastName' => 'Testlastname', 'email' => '*****@*****.**', 'assignedTo' => 'Anyone', 'visibility' => 1, 'phone' => '(234) 918-2348', 'phone2' => '398-103-6291', 'trackingKey' => '12345678901234567890'), false); $contact->save(); } $fieldName = $field->fieldName; $field->type = 'text'; $this->assertTrue($field->modifyColumn()); Yii::app()->db->schema->refresh(); $column = $schema->tables[$tableName]->columns[$field->fieldName]; $this->assertEquals('text', $column->dbType); $contact->refreshMetaData(); // set field value to a string with length > 255 $contact->{$fieldName} = '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'; $this->assertSaves($contact); $field->type = 'varchar'; Yii::app()->db->createCommand('set sql_mode=STRICT_ALL_TABLES;')->execute(); $this->assertFalse($field->modifyColumn()); $column = $schema->tables[$tableName]->columns[$field->fieldName]; $this->assertEquals('text', $column->dbType); Yii::app()->db->createCommand('set sql_mode="";')->execute(); $this->tearDownTestColumn(); }
function UpdateContacts($username, $session, $cntdtls) { if (!validateSession($username, $session)) { return null; } global $adb; global $current_user; require_once 'modules/Users/Users.php'; require_once 'modules/Contacts/Contacts.php'; $seed_user = new Users(); $user_id = $seed_user->retrieve_user_id($username); $current_user = $seed_user; $current_user->retrieve_entity_info($user_id, "Users"); $contact = new Contacts(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and vtiger_field.presence in (0,2)"; $params1 = array(); } else { $profileList = getCurrentUserProfileList(); $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.displaytype in (1,2,4,3) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_field.presence in (0,2)"; $params1 = array(); if (count($profileList) > 0) { $sql1 .= " and vtiger_profile2field.profileid in (" . generateQuestionMarks($profileList) . ")"; array_push($params1, $profileList); } } $result1 = $adb->pquery($sql1, $params1); for ($i = 0; $i < $adb->num_rows($result1); $i++) { $permitted_lists[] = $adb->query_result($result1, $i, 'fieldname'); } foreach ($cntdtls as $cntrow) { if (isset($cntrow)) { $contact->retrieve_entity_info($cntrow["id"], "Contacts"); $contact->column_fields[salutationtype] = in_array('salutationtype', $permitted_lists) ? $cntrow["title"] : ""; $contact->column_fields[firstname] = in_array('firstname', $permitted_lists) ? $cntrow["firstname"] : ""; if ($cntrow["middlename"] != "") { $contact->column_fields[lastname] = $cntrow["middlename"] . " " . $cntrow["lastname"]; } elseif ($cntrow["lastname"] != "") { $contact->column_fields[lastname] = $cntrow["lastname"]; } else { $contact->column_fields[lastname] = $cntrow["firstname"] . " " . $cntrow["middlename"] . " " . $cntrow["lastname"]; } $contact->column_fields[birthday] = in_array('birthday', $permitted_lists) ? getDisplayDate($cntrow["birthdate"]) : ""; $contact->column_fields[email] = in_array('email', $permitted_lists) ? $cntrow["emailaddress"] : ""; $contact->column_fields[title] = in_array('title', $permitted_lists) ? $cntrow["jobtitle"] : ""; $contact->column_fields[department] = in_array('department', $permitted_lists) ? $cntrow["department"] : ""; $contact->column_fields[account_id] = in_array('account_id', $permitted_lists) ? retrieve_account_id($cntrow["accountname"], $user_id) : ""; $contact->column_fields[phone] = in_array('phone', $permitted_lists) ? $cntrow["officephone"] : ""; $contact->column_fields[homephone] = in_array('homephone', $permitted_lists) ? $cntrow["homephone"] : ""; $contact->column_fields[otherphone] = in_array('otherphone', $permitted_lists) ? $cntrow["otherphone"] : ""; $contact->column_fields[fax] = in_array('fax', $permitted_lists) ? $cntrow["fax"] : ""; $contact->column_fields[mobile] = in_array('mobile', $permitted_lists) ? $cntrow["mobile"] : ""; $contact->column_fields[assistant] = in_array('assistant', $permitted_lists) ? $cntrow["asstname"] : ""; $contact->column_fields[assistantphone] = in_array('assistantphone', $permitted_lists) ? $cntrow["asstphone"] : ""; //$contact->column_fields[reports_to_id] =retrievereportsto($reportsto,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP $contact->column_fields[mailingstreet] = in_array('mailingstreet', $permitted_lists) ? $cntrow["mailingstreet"] : ""; $contact->column_fields[mailingcity] = in_array('mailingcity', $permitted_lists) ? $cntrow["mailingcity"] : ""; $contact->column_fields[mailingstate] = in_array('mailingstate', $permitted_lists) ? $cntrow["mailingstate"] : ""; $contact->column_fields[mailingzip] = in_array('mailingzip', $permitted_lists) ? $cntrow["mailingzip"] : ""; $contact->column_fields[mailingcountry] = in_array('mailingcountry', $permitted_lists) ? $cntrow["mailingcountry"] : ""; $contact->column_fields[otherstreet] = in_array('otherstreet', $permitted_lists) ? $cntrow["otherstreet"] : ""; $contact->column_fields[othercity] = in_array('othercity', $permitted_lists) ? $cntrow["othercity"] : ""; $contact->column_fields[otherstate] = in_array('otherstate', $permitted_lists) ? $cntrow["otherstate"] : ""; $contact->column_fields[otherzip] = in_array('otherzip', $permitted_lists) ? $cntrow["otherzip"] : ""; $contact->column_fields[othercountry] = in_array('othercountry', $permitted_lists) ? $cntrow["othercountry"] : ""; $contact->column_fields[assigned_user_id] = in_array('assigned_user_id', $permitted_lists) ? $user_id : ""; $contact->column_fields[description] = in_array('description', $permitted_lists) ? $cntrow["description"] : ""; $contact->id = $cntrow["id"]; $contact->mode = "edit"; //saving date information in 'yyyy-mm-dd' format and displaying it in user's date format $user_old_date_format = $current_user->date_format; $current_user->date_format = 'yyyy-mm-dd'; $contact->save("Contacts"); $current_user->date_format = $user_old_date_format; } } $contact = $contact; return $contact->id; }
$return_action = $_REQUEST['return_action']; global $rstart; //Added to fix 4600 $url = getBasic_Advance_SearchURL(); if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') { $rstart = "&start=" . $_REQUEST['start']; } $quickedit_field = $_REQUEST['quickedit_field']; $quickedit_value = $_REQUEST['quickedit_value']; global $log; $log->info("quickedit_field=" . $quickedit_field . ",quickedit_value=" . $quickedit_value); if (isset($idlist)) { $recordids = explode(';', $idlist); $_REQUEST['ajxaction'] = "DETAILVIEW"; for ($index = 0; $index < count($recordids); ++$index) { $recordid = $recordids[$index]; $log->info("recordid=" . $recordid); if ($recordid == '') { continue; } // Save each module record with update value. $focus = new Contacts(); $focus->retrieve_entity_info($recordid, 'Contacts'); $focus->mode = 'edit'; $focus->id = $recordid; $focus->column_fields[$quickedit_field] = $quickedit_value; $focus->save('Contacts'); // END } } redirect("index.php?module={$return_module}&action=" . $return_module . "Ajax&file=ListView&ajax=changestate" . $rstart . "&viewname=" . $viewid . "&errormsg=" . $errormsg . $url);
/** function used to create or map with existing contact if the notes has mapped with an contact during import */ function add_create_contact() { global $imported_ids; global $current_user; $contact_name = $this->column_fields['contact_id']; if (!isset($contact_name) || $contact_name == '') { return; } $arr = array(); // check if it already exists $focus = new Contacts(); $query = ''; // if user is defining the ec_contact id to be associated with this contact.. //Modified to remove the spaces at first and last in ec_contactdetails name -- after 4.2 patch 2 $contact_name = trim(addslashes($contact_name)); //Modified the query to get the available account only ie., which is not deleted $query = "select * from ec_contactdetails WHERE lastname='{$contact_name}' and deleted=0"; $result = $this->db->query($query); $row = $this->db->fetchByAssoc($result, -1, false); // we found a row with that id if (isset($row['contactid']) && $row['contactid'] != -1) { $focus->id = $row['contactid']; } // if we didnt find the ec_contactdetails, so create it if (!isset($focus->id) || $focus->id == '') { //$this->db->println("Createing new ec_account"); $focus->column_fields['lastname'] = $contact_name; $focus->column_fields['assigned_user_id'] = $current_user->id; $focus->column_fields['modified_user_id'] = $current_user->id; $focus->save("Contacts"); $contact_id = $focus->id; // avoid duplicate mappings: if (!isset($imported_ids[$contact_id])) { $imported_ids[$acc_id] = 1; } } // now just link the ec_contactdetails $this->column_fields["contact_id"] = $focus->id; }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/contacts.php"; session_start(); if (empty($_SESSION['list_of_contacts'])) { $_SESSION['list_of_contacts'] = array(); } $app = new Silex\Application(); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); $app->get("/", function () use($app) { return $app['twig']->render('home.html.twig', array('contact' => Contacts::getAll())); }); $app->post("/create_contact", function () use($app) { $contact = new Contacts($_POST['list_of_contacts']); $contact->save(); return $app['twig']->render('create_contact.html.twig', array('newcontact' => $contact)); }); $app->post("/delete_contacts", function () use($app) { Task::deleteAll(); return $app['twig']->render('delete_contacts.html.twig'); }); return $app;
public function testMergeLinkFields() { $contact = $this->contact('testAnyone'); $account = $this->account('testQuote'); $account->primaryContact = $contact->nameId; $account->save(); $model = new Contacts(); foreach ($contact->attributes as $key => $val) { if ($key != 'id' && $key != 'nameId') { $model->{$key} = $val; } } $model->save(); $this->assertEquals($contact->nameId, $account->primaryContact); $this->assertNotEquals($contact->nameId, $model->nameId); $mergeData = $model->mergeLinkFields($contact, true); $account = X2Model::model('Accounts')->findByPk($account->id); $this->assertEquals($model->nameId, $account->primaryContact); $this->assertNotEquals($contact->nameId, $model->nameId); $model->unmergeLinkFields($contact->id, $mergeData); $account = X2Model::model('Accounts')->findByPk($account->id); $this->assertEquals($contact->nameId, $account->primaryContact); $this->assertNotEquals($contact->nameId, $model->nameId); }
$ajaxaction = $_REQUEST["ajxaction"]; if ($ajaxaction == "DETAILVIEW") { $crmid = $_REQUEST["recordid"]; $tablename = $_REQUEST["tableName"]; $fieldname = $_REQUEST["fldName"]; $fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]); if ($crmid != "") { if ((!isset($is_disable_approve) || isset($is_disable_approve) && !$is_disable_approve) && (isset($module_enable_approve) && $module_enable_approve)) { $sql = "select approved from ec_contacts where deleted=0 and contactsid='" . $crmid . "'"; $result = $adb->query($sql); $approved = $adb->query_result($result, 0, "approved"); if ($approved == 1) { echo ":#:FAILURE"; die; } } $modObj = new Contacts(); $modObj->retrieve_entity_info($crmid, "Contacts"); $modObj->column_fields[$fieldname] = $fieldvalue; $modObj->id = $crmid; $modObj->mode = "edit"; $modObj->save("Contacts"); if ($modObj->id != "") { echo ":#:SUCCESS"; } else { echo ":#:FAILURE"; } } else { echo ":#:FAILURE"; } }
function AddContact($user_name, $first_name, $last_name, $email_address, $account_name, $salutation, $title, $phone_mobile, $reports_to, $primary_address_street, $primary_address_city, $primary_address_state, $primary_address_postalcode, $primary_address_country, $alt_address_city, $alt_address_street, $alt_address_state, $alt_address_postalcode, $alt_address_country, $office_phone = "", $home_phone = "", $fax = "", $department = "", $password, $description = "") { if (authentication($user_name, $password)) { global $adb; global $current_user; require_once 'modules/Users/Users.php'; require_once 'modules/Contacts/Contacts.php'; $seed_user = new Users(); $user_id = $seed_user->retrieve_user_id($user_name); $current_user = $seed_user; $current_user->retrieve_entity_info($user_id, "Users"); checkFileAccessForInclusion('user_privileges/user_privileges_' . $current_user->id . '.php'); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; checkFileAccessForInclusion('user_privileges/sharing_privileges_' . $current_user->id . '.php'); require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and block <> 5 and vtiger_field.presence in (0,2)"; $params1 = array(); } else { $profileList = getCurrentUserProfileList(); $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_field.presence in (0,2)"; $params1 = array(); if (count($profileList) > 0) { $sql1 .= " and vtiger_profile2field.profileid in (" . generateQuestionMarks($profileList) . ")"; array_push($params1, $profileList); } } $result1 = $adb->pquery($sql1, $params1); for ($i = 0; $i < $adb->num_rows($result1); $i++) { $permitted_lists[] = $adb->query_result($result1, $i, 'fieldname'); } $contact = new Contacts(); $contact->column_fields[firstname] = in_array('firstname', $permitted_lists) ? $first_name : ""; $contact->column_fields[lastname] = in_array('lastname', $permitted_lists) ? $last_name : ""; $contact->column_fields[email] = in_array('email', $permitted_lists) ? $email_address : ""; $contact->column_fields[title] = in_array('title', $permitted_lists) ? $title : ""; $contact->column_fields[department] = in_array('department', $permitted_lists) ? $department : ""; $contact->column_fields[account_id] = in_array('account_id', $permitted_lists) ? retrieve_account_id($account_name, $user_id) : ""; $contact->column_fields[phone] = in_array('phone', $permitted_lists) ? $office_phone : ""; $contact->column_fields[homephone] = in_array('homephone', $permitted_lists) ? $home_phone : ""; $contact->column_fields[fax] = in_array('fax', $permitted_lists) ? $fax : ""; $contact->column_fields[mobile] = in_array('mobile', $permitted_lists) ? $phone_mobile : ""; $contact->column_fields[mailingstreet] = in_array('mailingstreet', $permitted_lists) ? $primary_address_street : ""; $contact->column_fields[mailingcity] = in_array('mailingcity', $permitted_lists) ? $primary_address_city : ""; $contact->column_fields[mailingstate] = in_array('mailingstate', $permitted_lists) ? $primary_address_state : ""; $contact->column_fields[mailingzip] = in_array('mailingzip', $permitted_lists) ? $primary_address_postalcode : ""; $contact->column_fields[mailingcountry] = in_array('mailingcountry', $permitted_lists) ? $primary_address_country : ""; $contact->column_fields[otherstreet] = in_array('otherstreet', $permitted_lists) ? $alt_address_street : ""; $contact->column_fields[othercity] = in_array('othercity', $permitted_lists) ? $alt_address_city : ""; $contact->column_fields[otherstate] = in_array('otherstate', $permitted_lists) ? $alt_address_state : ""; $contact->column_fields[otherzip] = in_array('otherzip', $permitted_lists) ? $alt_address_postalcode : ""; $contact->column_fields[othercountry] = in_array('othercountry', $permitted_lists) ? $alt_address_country : ""; $contact->column_fields[assigned_user_id] = in_array('assigned_user_id', $permitted_lists) ? $user_id : ""; $contact->column_fields[description] = ""; $contact->save("Contacts"); $contact = $contact; return $contact->id; } }
function addEmailContact($lastname, $email) { global $adb; global $current_user; include_once "modules/Contacts/Contacts.php"; $query = "SELECT contactid FROM ec_contactdetails WHERE deleted=0 and (email ='" . $email . "' or otheremail='" . $email . "' or yahooid='" . $email . "' or msn='" . $email . "')"; $result = $adb->query($query); if ($adb->num_rows($result) == 0) { $focus = new Contacts(); if (empty($lastname)) { $iPos = strpos($email, '@'); $lastname = substr($email, 0, $iPos); } $focus->column_fields['lastname'] = $lastname; $focus->column_fields['email'] = $email; $focus->column_fields['assigned_user_id'] = $current_user->id; $focus->save("Contacts"); unset($focus); } }