Beispiel #1
0
 function addcontact($_post)
 {
     $user->id = $this->getuser();
     $profile = new Contact($user->id);
     $result = $profile->create($_post);
     return $result;
 }
 public function postNewAdmin()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Identity_No' => 'required', 'Email' => 'required|email', 'Phone_Number' => 'required', 'First_Name' => 'required', 'Last_Name' => 'required', 'Photo_1' => 'image|required', 'Photo_2' => 'image|required', 'Photo_3' => 'image|required'));
     if ($validator->fails()) {
         return Redirect::route('super-admin-new-admin-get')->withErrors($validator)->withInput()->with('globalerror', 'Sorry!! The Data was not Saved, please retry');
     } else {
         $identitynumber = Input::get('Identity_No');
         $email = Input::get('Email');
         $phonenumber = Input::get('Phone Numer');
         $firstname = Input::get('First_Name');
         $lastname = Input::get('Last_Name');
         $photo_1 = Input::file('Photo_1');
         $photo_2 = Input::file('Photo_2');
         $photo_3 = Input::file('Photo_3');
         //register the new user
         $newuser = User::create(array('Identity_No' => $identitynumber, 'First_Name' => $firstname, 'Last_Name' => $lastname, 'Password' => Hash::make($identitynumber), 'Active' => TRUE));
         //register the new user contact
         $newcontact = Contact::create(array('Email' => $email, 'Phone_Number' => $phonenumber));
         //Save the three Photos
         $photo1 = $this->postPhoto($photo_1);
         $photo2 = $this->postPhoto($photo_2);
         $photo3 = $this->postPhoto($photo_3);
         $newphotos = Photo::create(array('photo_1' => $photo1, 'photo_2' => $photo2, 'photo_3' => $photo3));
         //save the details to the students table
         $newadmin = Admin::create(array('Users_Id' => $newuser->id, 'Contacts_Id' => $newcontact->id, 'Photos_Id' => $newphotos->id));
         if ($newuser && $newcontact && $newphotos && $newadmin) {
             return Redirect::route('super-admin-new-admin-get')->with('globalsuccess', 'New Admin Details Have been Added');
         }
     }
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Contact::create([]);
     }
 }
 function setUp()
 {
     parent::setUp();
     $students = 'indivi_student' . substr(sha1(rand()), 0, 7);
     $params = array('label' => $students, 'name' => $students, 'parent_id' => 1, 'is_active' => 1);
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->student = $params['name'];
     $parents = 'indivi_parent' . substr(sha1(rand()), 0, 7);
     $params = array('label' => $parents, 'name' => $parents, 'parent_id' => 1, 'is_active' => 1);
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->parent = $params['name'];
     $orgs = 'org_sponsor' . substr(sha1(rand()), 0, 7);
     $params = array('label' => $orgs, 'name' => $orgs, 'parent_id' => 3, 'is_active' => 1);
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->sponsor = $params['name'];
     $this->indiviParams = array('first_name' => 'Anne', 'last_name' => 'Grant', 'contact_type' => 'Individual');
     $this->individual = Contact::create($this->indiviParams);
     $this->indiviStudentParams = array('first_name' => 'Bill', 'last_name' => 'Adams', 'contact_type' => 'Individual', 'contact_sub_type' => $this->student);
     $this->indiviStudent = Contact::create($this->indiviStudentParams);
     $this->indiviParentParams = array('first_name' => 'Alen', 'last_name' => 'Adams', 'contact_type' => 'Individual', 'contact_sub_type' => $this->parent);
     $this->indiviParent = Contact::create($this->indiviParentParams);
     $this->organizationParams = array('organization_name' => 'Compumentor', 'contact_type' => 'Organization');
     $this->organization = Contact::create($this->organizationParams);
     $this->orgSponsorParams = array('organization_name' => 'Conservation Corp', 'contact_type' => 'Organization', 'contact_sub_type' => $this->sponsor);
     $this->orgSponsor = Contact::create($this->orgSponsorParams);
     $this->householdParams = array('household_name' => "John Doe's home", 'contact_type' => 'Household');
     $this->household = Contact::create($this->householdParams);
 }
 public function setUp()
 {
     parent::setUp();
     //create contact subtypes
     $params = array('label' => 'indivi_student', 'name' => 'indivi_student', 'parent_id' => 1, 'is_active' => 1);
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->student = $params['name'];
     $params = array('label' => 'indivi_parent', 'name' => 'indivi_parent', 'parent_id' => 1, 'is_active' => 1);
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->parent = $params['name'];
     $params = array('label' => 'org_sponsor', 'name' => 'org_sponsor', 'parent_id' => 3, 'is_active' => 1);
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->sponsor = $params['name'];
     //create contacts
     $params = array('first_name' => 'Anne', 'last_name' => 'Grant', 'contact_type' => 'Individual');
     $this->individual = Contact::create($params);
     $params = array('first_name' => 'Bill', 'last_name' => 'Adams', 'contact_type' => 'Individual', 'contact_sub_type' => $this->student);
     $this->indivi_student = Contact::create($params);
     $params = array('first_name' => 'Alen', 'last_name' => 'Adams', 'contact_type' => 'Individual', 'contact_sub_type' => $this->parent);
     $this->indivi_parent = Contact::create($params);
     $params = array('organization_name' => 'Compumentor', 'contact_type' => 'Organization');
     $this->organization = Contact::create($params);
     $params = array('organization_name' => 'Conservation Corp', 'contact_type' => 'Organization', 'contact_sub_type' => $this->sponsor);
     $this->organization_sponsor = Contact::create($params);
 }
 public function run()
 {
     Contact::truncate();
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Contact::create(["name" => $faker->name, "email" => $faker->email, "phone" => $faker->phoneNumber]);
     }
 }
    public function run()
    {
        Contact::create(['description' => 'Công ty Cổ phần truyền thông ABC
				Địa chỉ: P501, Tầng 5, Tòa nhà văn phòng, Số 5B/55, Huỳnh Thúc Kháng, Phường Láng Hạ, Quận Đống Đa, Hà Nội
				Tel: (84-4) 3.775.4334 - Fax: (84-4) 3512 1804', 'slug' => 'lien-he']);
        Contact::create(['description' => 'ABC company
				Địa chỉ: P501, Tầng 5, Tòa nhà văn phòng, Số 5B/55, Huỳnh Thúc Kháng, Phường Láng Hạ, Quận Đống Đa, Hà Nội
				Tel: (84-4) 3.775.4334 - Fax: (84-4) 3512 1804', 'slug' => 'contact']);
    }
 function create()
 {
     if (Input::exist()) {
         $data = Input::parse();
         $contact = Contact::create($data);
         $contact->save();
         echo json_encode($contact);
     }
 }
 /**
  * @param array $data
  * @param Form $form
  * @throws ValidationException
  * @throws null
  */
 public function HandleForm($data, $form)
 {
     /** @var Contact $Contact */
     $Contact = Contact::create();
     $form->saveInto($Contact);
     $Contact->write();
     Session::set('ThanksMessage', true);
     $this->redirect($this->Link() . '#section-contact');
 }
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 10; $i++) {
         Contact::create(array('user_id' => 2, 'full_name' => $faker->firstName, 'email' => $faker->email, 'last_follow_up' => date('Y-m-d H:i:s'), 'email_sent' => "", 'active' => 1, 'isAutomaticFollowUp' => 1, 'phone_number' => $faker->phoneNumber));
     }
     for ($i = 0; $i < 10; $i++) {
         Contact::create(array('user_id' => 3, 'full_name' => $faker->firstName, 'email' => $faker->email, 'last_follow_up' => date('Y-m-d H:i:s'), 'email_sent' => "", 'active' => 1, 'isAutomaticFollowUp' => 1, 'phone_number' => $faker->phoneNumber));
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::json();
     Contact::create(['name' => $input->get('name'), 'surname' => $input->get("surname"), 'phone' => $input->get("phone"), 'email' => $input->get("email"), 'description' => $input->get('description')]);
     $query = Contact::select('id')->where("email", '=', $input->get('email'))->first();
     $id = $query->id;
     Session::put('id', $id);
     $returnArray = array('id' => $id, 'name' => $input->get('name'), 'surname' => $input->get('surname'), 'phone' => $input->get('phone'), 'email' => $input->get('email'), 'description' => $input->get('description'));
     return $returnArray;
 }
 /**
  * Crear el contacto nuevo
  */
 public function crearContacto()
 {
     $rules = array('nombre' => 'required|max:250', 'apellido' => 'required|max:250');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/admin/contacts/add')->withInput()->withErrors($validator);
     } else {
         Contact::create(Input::all());
         return Redirect::route('contacts.list');
     }
 }
 public function run()
 {
     $faker = Faker::create();
     $files = \Symfony\Component\Finder\Finder::create()->files()->in(public_path('images/contacts/seeds'));
     $photos = [];
     foreach ($files as $file) {
         $photos[] = 'seeds/' . $file->getFilename();
     }
     foreach (range(1, 30) as $index) {
         Contact::create(['firstName' => $faker->firstName, 'lastName' => $faker->lastName, 'birthday' => $faker->dateTimeThisCentury, 'phone' => $faker->phoneNumber, 'address' => $faker->address, 'country_id' => Country::random()->id, 'comment' => $faker->paragraph(5), 'photo' => $faker->randomElement($photos)]);
     }
 }
Beispiel #14
0
 public function run()
 {
     // clear out the database on subsequent seeding attempts
     DB::table('contacts')->truncate();
     $faker = Faker::create();
     // add a known record
     Contact::create(['firstName' => 'Eric', 'lastName' => 'Jones', 'birthday' => date('Y-m-d'), 'street1' => '1 Monument Circle', 'city' => 'Indianapolis', 'state' => 'IN', 'zip' => '46204', 'email' => '*****@*****.**', 'phone' => '(555) 123-4444']);
     // add 99 random records
     foreach (range(1, 99) as $index) {
         Contact::create(['firstName' => $faker->firstName, 'lastName' => $faker->lastName, 'birthday' => $faker->date, 'street1' => $faker->streetAddress, 'street2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'zip' => $faker->postcode, 'email' => $faker->email, 'phone' => $faker->phoneNumber]);
     }
 }
Beispiel #15
0
 /**
  * Create contact object
  *
  * @param   array   $request_data   Request datas
  * @return  int     ID of contact
  * 
  * @url	POST contact/
  */
 function post($request_data = NULL)
 {
     if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
         throw new RestException(401);
     }
     // Check mandatory fields
     $result = $this->_validate($request_data);
     foreach ($request_data as $field => $value) {
         $this->contact->{$field} = $value;
     }
     return $this->contact->create(DolibarrApiAccess::$user);
 }
 public function run()
 {
     $faker = Faker\Factory::create();
     $faker->addProvider(new Faker\Provider\ru_RU\Person($faker));
     $faker->addProvider(new Faker\Provider\ru_RU\PhoneNumber($faker));
     //$faker->addProvider(new Faker\Provider\Lorem($faker));
     //$faker->addProvider(new Faker\Provider\Internet($faker));
     $faker->addProvider(new Faker\Provider\ru_RU\Text($faker));
     Contact::truncate();
     for ($i = 0; $i <= 20; $i++) {
         Contact::create(['name' => $faker->firstName, 'surname' => $faker->lastName, 'phone' => $faker->phoneNumber, 'email' => $faker->email, 'description' => $faker->realText($maxNbChars = 200, $indexSize = 2)]);
     }
 }
 public function add()
 {
     //creating rules for validation
     $rules = array('name' => 'required', 'email' => 'required|email', 'phone' => 'required|numeric|digits_between:8,12');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('contacts')->withErrors($validator)->withInput();
         // Return errors with inputs
     } else {
         Contact::create(array('name' => Input::get('name'), 'email' => Input::get('email'), 'Phone' => Input::get('phone'), 'userid' => '1'));
         return Redirect::to('contacts')->with('message', 'The contact was created successfully');
     }
 }
 /**
  * Store a newly created resource in storage.
  * POST /admin\admincontact
  *
  * @return Response
  */
 public function postStore()
 {
     $rules = array('company' => 'required', 'contact_first' => 'required', 'contact_last' => 'required', 'title' => 'required', 'city' => 'required', 'state' => 'required', 'email' => 'required|email');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('admin/contacts/create')->withErrors($validator)->withInput(Input::except('password'));
     } else {
         //save contact
         $contact = Contact::create(Input::except('_token'));
         // redirect
         Session::flash('message', 'Successfully created Contact!');
         return Redirect::to('admin/contacts');
     }
 }
 /**
  * Process the contact us form data
  *
  * @return \Illuminate\Support\Facades\Redirect
  */
 public function process()
 {
     $rules = ['first_name' => 'required', 'last_name' => 'required', 'company' => '', 'email' => 'required|email', 'phone' => '', 'message_body' => 'required'];
     $data = \Input::only('first_name', 'last_name', 'email', 'company', 'phone', 'message_body');
     $validator = \Validator::make($data, $rules);
     if ($validator->fails()) {
         return \Redirect::Action('ContactController@index')->withErrors($validator)->withInput();
     }
     //-- Save to database incase email is lost, or fails
     $contact = \Contact::create($data);
     \Mail::send('emails.contact', $data, function ($message) {
         $message->to('*****@*****.**', 'John Doe')->subject('Welcome!');
     });
     return \Redirect::Action('ContactController@thankYou');
 }
 public function postContactForm()
 {
     $rules = array('email' => 'email|required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::to('/kontakt')->withInput(Input::flash())->withErrors($validator)->with('alert', array('type' => 'error', 'content' => 'Podaj właściwy e-mail'));
     } else {
         Contact::create(Input::all());
         $data['email'] = Input::all();
         Mail::later(5, 'emails.contact', $data, function ($message) {
             $message->to('*****@*****.**')->subject('[hasztag.info] Nowa wiadomość');
         });
         return Redirect::to('/')->with('alert', array('type' => 'success', 'content' => 'Wiadomość wysłana. Odezwiemy się wkrótce!'));
     }
 }
Beispiel #21
0
 public function create()
 {
     if (!$this->has_post()) {
         return redirect_message(array($this->get_class()), array('_flash_message' => '非 POST 方法,錯誤的頁面請求。'));
     }
     $posts = OAInput::post();
     if ($msg = $this->_validation_posts($posts)) {
         return redirect_message(array($this->get_class()), array('_flash_message' => $msg, 'posts' => $posts));
     }
     $contact = null;
     $create = Contact::transaction(function () use($posts, &$contact) {
         return verifyCreateOrm($contact = Contact::create(array_intersect_key($posts, Contact::table()->columns)));
     });
     if (!($create && $contact)) {
         return redirect_message(array($this->get_class()), array('_flash_message' => '新增失敗,系統可能在維修,請稍候再嘗試一次!', 'posts' => $posts));
     }
     delay_job('contacts', 'mail', array('id' => $contact->id));
     return redirect_message(array($this->get_class()), array('_flash_message' => '新增成功,已經收到您的建議,我們會儘快回覆您!'));
 }
 public function run()
 {
     $faker = Faker::create('pt_BR');
     $faker->addProvider(new \Faker\Provider\pt_BR\Person($faker));
     // $faker->addProvider(new \Faker\Provider\en_US\Address($faker));
     // $faker->addProvider(new \Faker\Provider\en_US\PhoneNumber($faker));
     // $faker->addProvider(new \Faker\Provider\en_US\Company($faker));
     // $faker->addProvider(new \Faker\Provider\Lorem($faker));
     // $faker->addProvider(new \Faker\Provider\Internet($faker));
     foreach (range(1, 250) as $index) {
         //    title($gender = null|'male'|'female')     // 'Ms.'
         //    titleMale                                 // 'Mr.'
         //    titleFemale                               // 'Ms.'
         //    suffix                                    // 'Jr.'
         //    name($gender = null|'male'|'female')      // 'Dr. Zane Stroman'
         //    firstName($gender = null|'male'|'female') // 'Maynard'
         //    firstNameMale                             // 'Maynard'
         //    firstNameFemale                           // 'Rachel'
         //    lastName                                  // 'Zulauf'
         Contact::create(['first_name' => $faker->firstName(), 'middle_name' => $faker->firstName($gender = null | 'male' | ''), 'last_name' => $faker->lastName(), 'title' => $faker->prefix($gender = null | 'male' | ''), 'suffix' => $faker->suffix(), 'e_mail_address' => $faker->email(), 'e_mail_2_address' => $faker->companyEmail(), 'primary_phone' => $faker->phoneNumber(), 'home_address' => $faker->streetAddress(), 'home_street' => '', 'home_street_2' => '', 'home_street_3' => '', 'home_address_po_box' => '', 'home_city' => $faker->city(), 'home_state' => $faker->stateAbbr(), 'home_postal_code' => '', 'home_country' => '', 'spouse' => '', 'children' => '', 'managers_name' => '', 'assistants_name' => '', 'referred_by' => '', 'company_main_phone' => '', 'business_phone' => '', 'business_phone_2' => '', 'business_fax' => '', 'assistants_phone' => '', 'company' => $faker->company(), 'job_title' => '', 'department' => '', 'office_location' => '', 'organizational_id_number' => '', 'profession' => '', 'account' => '', 'business_address' => '', 'business_street' => '', 'business_street_2' => '', 'business_street_3' => '', 'business_address_po_box' => '', 'business_city' => '', 'business_state' => '', 'business_postal_code' => '', 'business_country' => '', 'other_phone' => '', 'other_fax' => '', 'other_address' => '', 'other_street' => '', 'other_street_2' => '', 'other_street_3' => '', 'other_address_po_box' => '', 'other_city' => '', 'other_state' => '', 'other_postal_code' => '', 'other_country' => '', 'callback' => '', 'car_phone' => '', 'isdn' => '', 'radio_phone' => '', 'ttytdd_phone' => '', 'telex' => '', 'user_1' => '', 'user_2' => '', 'user_3' => '', 'user_4' => '', 'keywords' => '', 'mileage' => '', 'hobby' => '', 'billing_information' => '', 'directory_server' => '', 'sensitivity' => '', 'priority' => '', 'private' => '', 'categories' => '']);
     }
 }
Beispiel #23
0
     					$contact->civilite_id		= $object->civilite_id;
                        $contact->name				= $object->name_bis;
                        $contact->firstname			= $object->firstname;
                        $contact->address			= $object->address;
                        $contact->zip				= $object->zip;
                        $contact->town				= $object->town;
                        $contact->state_id      	= $object->state_id;
                        $contact->country_id		= $object->country_id;
                        $contact->socid				= $object->id;	// fk_soc
                        $contact->status			= 1;
                        $contact->email				= $object->email;
						$contact->phone_pro			= $object->tel;
						$contact->fax				= $object->fax;
                        $contact->priv				= 0;

                        $result=$contact->create($user);
                        if (! $result >= 0)
                        {
                            $error=$contact->error; $errors=$contact->errors;
                        }
                    }

                    // Gestion du logo de la société
                    $dir     = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
                    $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
                    if ($file_OK)
                    {
                        if (image_format_supported($_FILES['photo']['name']))
                        {
                            dol_mkdir($dir);
Beispiel #24
0
     break;
 case $ACTION_contactSave:
     $contact = new Contact($_POST["contact_company_select"], new Personne($_POST["contact"], $_POST["contact_name_field"], $_POST["contact_firstname_field"], $_POST["contact_email_field"], $_POST["contact_tel_field"], $_POST["contact_address_field"]));
     $_SESSION["client"] = $_POST["contact_company_select"];
     if ($contact->save()) {
         $_SESSION["contact"] = $_POST["contact"];
         // TO DO: affiché une réussite
     } else {
         $_SESSION["contact"] = -1;
         // TO DO: gestion des erreurs
     }
     break;
 case $ACTION_contactCreate:
     $contact = new Contact($_POST["contact_company_select"], new Personne(-1, $_POST["contact_name_field"], $_POST["contact_firstname_field"], $_POST["contact_email_field"], $_POST["contact_tel_field"], $_POST["contact_address_field"]));
     $_SESSION["client"] = $_POST["contact_company_select"];
     $idContact = $contact->create();
     if ($idContact != 0) {
         $_SESSION["contact"] = $idContact;
         // TO DO: affiché une réussite
     } else {
         $_SESSION["contact"] = -1;
         // TO DO: gestion des erreurs
     }
     break;
 case $ACTION_contactDelete:
     for ($i = 0; $i < $_POST["nbCahnge"]; $i++) {
         changeContact($_POST['tacheId' . $i], $_POST['select_new_contact' . $i]);
     }
     $tempContact = new Contact(new Personne($_POST["deleteID"]));
     $tempContact->remove();
     if (isset($_POST["client"])) {
 /**
  *	Load data control
  *
  *	@param	int		$action	Action code
  *	@return	void
  */
 function doActions(&$action)
 {
     global $conf, $user, $langs;
     if ($_POST["getcustomercode"]) {
         // We defined value code_client
         $_POST["code_client"] = "Acompleter";
     }
     if ($_POST["getsuppliercode"]) {
         // We defined value code_fournisseur
         $_POST["code_fournisseur"] = "Acompleter";
     }
     // Add new third party
     if (!$_POST["getcustomercode"] && !$_POST["getsuppliercode"] && ($action == 'add' || $action == 'update')) {
         require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
         $error = 0;
         if (GETPOST("private") == 1) {
             $this->object->particulier = GETPOST("private");
             $this->object->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? trim($_POST["firstname"] . ' ' . $_POST["lastname"]) : trim($_POST["lastname"] . ' ' . $_POST["firstname"]);
             $this->object->civility_id = $_POST["civility_id"];
             // Add non official properties
             $this->object->name_bis = $_POST["lastname"];
             $this->object->firstname = $_POST["firstname"];
         } else {
             $this->object->name = $_POST["nom"];
         }
         $this->object->address = $_POST["adresse"];
         $this->object->zip = $_POST["zipcode"];
         $this->object->town = $_POST["town"];
         $this->object->country_id = $_POST["country_id"];
         $this->object->state_id = $_POST["state_id"];
         $this->object->phone = $_POST["tel"];
         $this->object->fax = $_POST["fax"];
         $this->object->email = trim($_POST["email"]);
         $this->object->url = $_POST["url"];
         $this->object->idprof1 = $_POST["idprof1"];
         $this->object->idprof2 = $_POST["idprof2"];
         $this->object->idprof3 = $_POST["idprof3"];
         $this->object->idprof4 = $_POST["idprof4"];
         $this->object->prefix_comm = $_POST["prefix_comm"];
         $this->object->code_client = $_POST["code_client"];
         $this->object->code_fournisseur = $_POST["code_fournisseur"];
         $this->object->capital = $_POST["capital"];
         $this->object->barcode = $_POST["barcode"];
         $this->object->canvas = GETPOST("canvas");
         $this->object->tva_assuj = $_POST["assujtva_value"];
         // Local Taxes
         $this->object->localtax1_assuj = $_POST["localtax1assuj_value"];
         $this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
         $this->object->tva_intra = $_POST["tva_intra"];
         $this->object->forme_juridique_code = $_POST["forme_juridique_code"];
         $this->object->effectif_id = $_POST["effectif_id"];
         if (GETPOST("private") == 1) {
             $this->object->typent_id = dol_getIdFromCode($db, 'TE_PRIVATE', 'c_typent');
         } else {
             $this->object->typent_id = $_POST["typent_id"];
         }
         $this->object->client = $_POST["client"];
         $this->object->fournisseur = $_POST["fournisseur"];
         $this->object->commercial_id = $_POST["commercial_id"];
         $this->object->default_lang = $_POST["default_lang"];
         // Check parameters
         if (empty($_POST["cancel"])) {
             if (!empty($this->object->email) && !isValidEMail($this->object->email)) {
                 $error = 1;
                 $langs->load("errors");
                 $this->error = $langs->trans("ErrorBadEMail", $this->object->email);
                 $action = $action == 'add' ? 'create' : 'edit';
             }
             if (!empty($this->object->url) && !isValidUrl($this->object->url)) {
                 $error = 1;
                 $langs->load("errors");
                 $this->error = $langs->trans("ErrorBadUrl", $this->object->url);
                 $action = $action == 'add' ? 'create' : 'edit';
             }
             if ($this->object->fournisseur && !$conf->fournisseur->enabled) {
                 $error = 1;
                 $langs->load("errors");
                 $this->error = $langs->trans("ErrorSupplierModuleNotEnabled");
                 $action = $action == 'add' ? 'create' : 'edit';
             }
         }
         if (!$error) {
             if ($action == 'add') {
                 $this->db->begin();
                 if (empty($this->object->client)) {
                     $this->object->code_client = '';
                 }
                 if (empty($this->object->fournisseur)) {
                     $this->object->code_fournisseur = '';
                 }
                 $result = $this->object->create($user);
                 if ($result >= 0) {
                     if ($this->object->particulier) {
                         dol_syslog(get_class($this) . "::doActions This thirdparty is a personal people", LOG_DEBUG);
                         $contact = new Contact($this->db);
                         $contact->civility_id = $this->object->civility_id;
                         $contact->name = $this->object->name_bis;
                         $contact->firstname = $this->object->firstname;
                         $contact->address = $this->object->address;
                         $contact->zip = $this->object->zip;
                         $contact->town = $this->object->town;
                         $contact->country_id = $this->object->country_id;
                         $contact->socid = $this->object->id;
                         // fk_soc
                         $contact->status = 1;
                         $contact->email = $this->object->email;
                         $contact->priv = 0;
                         $result = $contact->create($user);
                     }
                 } else {
                     $this->errors = $this->object->errors;
                 }
                 if ($result >= 0) {
                     $this->db->commit();
                     if ($this->object->client == 1) {
                         header("Location: " . DOL_URL_ROOT . "/comm/fiche.php?socid=" . $this->object->id);
                         return;
                     } else {
                         if ($this->object->fournisseur == 1) {
                             header("Location: " . DOL_URL_ROOT . "/fourn/fiche.php?socid=" . $this->object->id);
                             return;
                         } else {
                             header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
                             return;
                         }
                     }
                     exit;
                 } else {
                     $this->db->rollback();
                     $this->errors = $this->object->errors;
                     $action = 'create';
                 }
             }
             if ($action == 'update') {
                 if ($_POST["cancel"]) {
                     header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
                     exit;
                 }
                 $oldsoccanvas = dol_clone($this->object);
                 // To avoid setting code if third party is not concerned. But if it had values, we keep them.
                 if (empty($this->object->client) && empty($oldsoccanvas->code_client)) {
                     $this->object->code_client = '';
                 }
                 if (empty($this->object->fournisseur) && empty($oldsoccanvas->code_fournisseur)) {
                     $this->object->code_fournisseur = '';
                 }
                 $result = $this->object->update($this->object->id, $user, 1, $oldsoccanvas->codeclient_modifiable(), $oldsoccanvas->codefournisseur_modifiable());
                 if ($result >= 0) {
                     header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
                     exit;
                 } else {
                     $reload = 0;
                     $this->errors = $this->object->errors;
                     $action = "edit";
                 }
             }
         }
     }
     if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') {
         $result = $this->object->delete($this->object->id);
         if ($result >= 0) {
             header("Location: " . DOL_URL_ROOT . "/societe/societe.php?delsoc=" . $this->object->nom . "");
             exit;
         } else {
             $reload = 0;
             $this->errors = $this->object->errors;
             $action = '';
         }
     }
     /*
      * Generate document
      */
     if ($action == 'builddoc') {
         if (is_numeric(GETPOST('model'))) {
             $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model"));
         } else {
             require_once DOL_DOCUMENT_ROOT . '/core/modules/societe/modules_societe.class.php';
             $this->object->fetch_thirdparty();
             // Define output language
             $outputlangs = $langs;
             $newlang = '';
             if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) {
                 $newlang = GETPOST('lang_id');
             }
             if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
                 $newlang = $this->object->default_lang;
             }
             if (!empty($newlang)) {
                 $outputlangs = new Translate("", $conf);
                 $outputlangs->setDefaultLang($newlang);
             }
             $result = thirdparty_doc_create($this->db, $this->object->id, '', GETPOST('model', 'alpha'), $outputlangs);
             if ($result <= 0) {
                 dol_print_error($this->db, $result);
                 exit;
             }
         }
     }
 }
Beispiel #26
0
 private static function create_account($user, $cdb_user)
 {
     global $Conf, $email_class;
     // check for errors
     if ($user && $user->has_database_account() && $user->activity_at > 0) {
         $email_class = " error";
         return Conf::msg_error("An account already exists for " . htmlspecialchars($_REQUEST["email"]) . ". To retrieve your password, select “I forgot my password.”");
     } else {
         if ($cdb_user && $cdb_user->allow_contactdb_password() && $cdb_user->activity_at > 0) {
             $desc = opt("contactdb_description") ?: "HotCRP";
             $email_class = " error";
             return Conf::msg_error("An account already exists for " . htmlspecialchars($_REQUEST["email"]) . " on {$desc}. Sign in using your {$desc} password or select “I forgot my password.”");
         } else {
             if (!validate_email($_REQUEST["email"])) {
                 $email_class = " error";
                 return Conf::msg_error("“" . htmlspecialchars($_REQUEST["email"]) . "” is not a valid email address.");
             }
         }
     }
     // create database account
     if (!$user || !$user->has_database_account()) {
         if (!($user = Contact::create($Conf, Contact::safe_registration($_REQUEST)))) {
             return Conf::msg_error($Conf->db_error_html(true, "while adding your account"));
         }
     }
     $user->sendAccountInfo("create", true);
     $msg = "Successfully created an account for " . htmlspecialchars($_REQUEST["email"]) . ".";
     // handle setup phase
     if ($Conf->setting("setupPhase", false)) {
         return self::first_user($user, $msg);
     }
     if (Mailer::allow_send($user->email)) {
         $msg .= " A password has been emailed to you.  Return here when you receive it to complete the registration process.  If you don’t receive the email, check your spam folders and verify that you entered the correct address.";
     } else {
         if (opt("sendEmail")) {
             $msg .= " The email address you provided seems invalid.";
         } else {
             $msg .= " The conference system is not set up to mail passwords at this time.";
         }
         $msg .= " Although an account was created for you, you need help to retrieve your password. Contact " . Text::user_html($Conf->site_contact()) . ".";
     }
     if (isset($_REQUEST["password"]) && trim($_REQUEST["password"]) != "") {
         $msg .= " Note that the password you supplied on the login screen was ignored.";
     }
     $Conf->confirmMsg($msg);
     return null;
 }
Beispiel #27
0
 public function testContactDelete()
 {
     //Creating contact...
     Client::relateIQ(GlobalVar::KEY, GlobalVar::SECRET);
     $contact = new Contact([]);
     $contact->name("James McSales");
     $contact->email(["*****@*****.**", "*****@*****.**"]);
     $contact->phone(["(888) 555-1234", "(888) 555-0000"]);
     $contact->address("123 Main St, USA");
     $contact->company("RelateIQ");
     $contact->title("Noob");
     $contact->twhan("@jamesmcsales");
     $res = $contact->create();
     $id = $res->id();
     $this->assertNotNull($id);
     // "Deleting contact..."
     $res2 = $contact->delete();
     $this->assertEquals(true, $res2);
     // "Verifying deletion..."
     $contact2 = new Contact(["id" => $id]);
     $res3 = $contact2->exists();
     $this->assertEquals(false, $res3);
 }
function requestReview($email)
{
    global $Conf, $Me, $Error, $prow;
    $Them = Contact::create(array("name" => @$_REQUEST["name"], "email" => $email));
    if (!$Them) {
        if (trim($email) === "" || !validate_email($email)) {
            Conf::msg_error("“" . htmlspecialchars(trim($email)) . "” is not a valid email address.");
            $Error["email"] = true;
        } else {
            Conf::msg_error("Error while finding account for “" . htmlspecialchars(trim($email)) . ".”");
        }
        return false;
    }
    $reason = trim(defval($_REQUEST, "reason", ""));
    $round = $Conf->current_round();
    if (isset($_REQUEST["round"]) && $_REQUEST["round"] != "" && ($rname = $Conf->sanitize_round_name($_REQUEST["round"])) !== false) {
        $round = $Conf->round_number($rname, false);
    }
    // look up the requester
    $Requester = $Me;
    if ($Conf->setting("extrev_chairreq")) {
        $result = Dbl::qe("select firstName, lastName, u.email, u.contactId from ReviewRequest rr join ContactInfo u on (u.contactId=rr.requestedBy) where paperId={$prow->paperId} and rr.email=?", $Them->email);
        if ($result && ($recorded_requester = Contact::fetch($result))) {
            $Requester = $recorded_requester;
        }
    }
    Dbl::qe_raw("lock tables PaperReview write, PaperReviewRefused write, ReviewRequest write, ContactInfo read, PaperConflict read, ActionLog write");
    // NB caller unlocks tables on error
    // check for outstanding review request
    if (!($result = requestReviewChecks(Text::user_html($Them), $Them->contactId))) {
        return $result;
    }
    // at this point, we think we've succeeded.
    // store the review request
    $Me->assign_review($prow->paperId, $Them->contactId, REVIEW_EXTERNAL, ["mark_notify" => true, "requester_contact" => $Requester, "requested_email" => $Them->email, "round_number" => $round]);
    Dbl::qx_raw("unlock tables");
    // send confirmation email
    HotCRPMailer::send_to($Them, "@requestreview", $prow, array("requester_contact" => $Requester, "other_contact" => $Requester, "reason" => $reason));
    $Conf->confirmMsg("Created a request to review paper #{$prow->paperId}.");
    return true;
}
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::json();
     return Contact::create(array('first_name' => $input->first_name, 'last_name' => $input->last_name, 'email_address' => $input->email_address, 'description' => $input->description));
 }
Beispiel #30
0
	'e'              => FILTER_VALIDATE_INT
);

$filtered  = filter_input_array(INPUT_POST, $filter);
$filteredG = filter_input_array(INPUT_GET, $filter);

try {
	if ($filtered['contact-submit']) {
		if ($filtered['contact-email'] and verifyEmail($filtered['contact-email'])) {
			$c        = new Contact();
			$c->email = $filtered['contact-email'];
			$c->type  = CONTACT_TYPE_CONTACT_PAGE;
			$c->text  = base64_encode($filtered['contact-text']);
			$c->date  = time();
			$c->done  = 0;
			$id = $c->create();
			
			if (!$id) {
				throw new Exception('Error processing, please submit again');
			}
			else {
				header('Location: contact.php?e=1');
				exit;
			}
		}
		else {
			throw new Exception('A contact email must be submitted');
		}
	}
}
catch (Exception $e) {