Example #1
0
 public function register_contacts()
 {
     $contact_id_temp = '';
     $ObjContacts = new contactsModel();
     $ObjContactsTemp = new contactsTempModel();
     $ObjCompanies = new companiesModel();
     $first_name = Input::get('first_name');
     $last_name = Input::get('last_name');
     $email = Input::get('email');
     $password = Input::get('password');
     $secret_question = Input::get('secret_question');
     $secret_answer = Input::get('secret_answer');
     $confirmation = sha1($password . date('YmdHis'));
     $company_name = Input::get('company_name');
     $address = Input::get('address');
     $city = Input::get('city');
     $state = Input::get('state');
     $zipcode = Input::get('zipcode');
     $where_params = array('`email_address`=' => $email);
     $validate_contact_temp = $ObjContactsTemp->get_record($where_params);
     $where_params = array('`email_address`=' => $email);
     $validate_contact = $ObjContacts->get_record($where_params);
     if ($validate_contact_temp || $validate_contact) {
         $message = 'Email <b>' . $email . '</b> already exist.';
         return Redirect::to('register')->with('message', $message);
     } else {
         $company_id = $ObjCompanies->get_company_id_check_if_company_exist($company_name, $address, $city, $state, $zipcode);
         $email_message = '';
         if ($company_id) {
             $contacts_col = $ObjContacts->get_record_join_by_company_id($company_id);
             $comp_name = $contacts_col->comp_name;
             $comp_firstname = $contacts_col->cont_firstname;
             $comp_lastname = $contacts_col->cont_lastname;
             $comp_email = $contacts_col->cont_email;
             $status = 'Validate Company';
             $message1 = '<p>Thanks for signing up! Please check you email inbox. We sent a confirmation email to <b>' . $email . '</b>.</p>';
             $message2 = '<p>Contact <b>' . $comp_firstname . ' ' . $comp_lastname . '</b> and ask him to add you to its <b>' . $comp_name . '</b> Company with email <b>' . $comp_email . '</b>.</p>';
             $message = $message1 . '<br />' . $message2;
         } else {
             $data = array('company_name' => $company_name, 'address1' => $address, 'city' => $city, 'state_code' => $state, 'zipcode' => $zipcode);
             $company_id = $ObjCompanies->insert_data($data);
             $status = 'Contact Temp';
             $message = 'Thanks for signing up! Please check you email inbox. We sent a confirmation email to <b>' . $email . '</b>.';
         }
         $data = array('company_id' => $company_id, 'first_name' => $first_name, 'last_name' => $last_name, 'email_address' => $email, 'password' => $password, 'secret_question' => $secret_question, 'secret_answer' => $secret_answer, 'cont_confirmation' => $confirmation, 'cont_status' => $status);
         $contact_id_temp = $ObjContactsTemp->insert_data($data);
         if ($contact_id_temp) {
             $data['body_message'] = $message2;
             $data['subject'] = 'Registration confirmation of Paskr Account.';
             Mail::send('emails.registration', $data, function ($mail) use($data) {
                 $mail->to($data['email_address'], $data['first_name'] . ' ' . $data['last_name'])->subject($data['subject']);
             });
             return Redirect::to('register_success')->with('message', $message);
         } else {
             $message = 'Registration not successful.';
             return Redirect::to('register')->with('message', $message);
         }
     }
 }
Example #2
0
 public function update_company()
 {
     $ObjContactsTemp = new contactsTempModel();
     $ObjCompanies = new companiesModel();
     $contact_id = Input::get('contact_id');
     $company_id = Input::get('company_id');
     $company_name = Input::get('company_name');
     $address1 = Input::get('address1');
     $address2 = Input::get('address2');
     $city = Input::get('city');
     $state = Input::get('state');
     $zipcode = Input::get('zipcode');
     $data = array('company_name' => $company_name, 'address1' => $address1, 'address2' => $address2, 'city' => $city, 'state_code' => $state, 'zipcode' => $zipcode);
     if ($company_id) {
         $result = $ObjCompanies->update_data($data, $company_id);
         if ($result) {
             $message = 'Update Company profile successful.';
         } else {
             $message = 'Update Company profile not successful.';
         }
     } else {
         $company_id = $ObjCompanies->save_company_if_company_dont_exist($company_name, $address1, $city, $state, $zipcode, $address2);
         if ($company_id) {
             $data = array('company_id' => $company_id);
             $result = $ObjContactsTemp->update_data($data, $contact_id);
             if ($result) {
                 $message = 'Update Company profile company id successful.';
             } else {
                 $message = 'Update Company profile company id not successful.';
             }
         } else {
             $message = 'Add new Company not successful.';
         }
     }
     return Redirect::to('profile')->with('message', $message);
 }
 public function update_uploaded_contacts_value($fields, $cut_id)
 {
     $ObjContacts = new contactsModel();
     $ObjCompanies = new companiesModel();
     $error_message = '';
     $result = TRUE;
     $email_address = '';
     $last_name = '';
     $first_name = '';
     $address1 = '';
     $city = '';
     $state_code = '';
     $zipcode = '';
     $company = '';
     foreach ($fields as $col) {
         $column = $col->cuff_column;
         $fieldname = $col->cuff_fieldname;
         $status = $col->cuff_status;
         $col = Input::get($column);
         $value = $col[$cut_id];
         if ($status == 'close' && $fieldname != '') {
             ${$fieldname} = $value;
         }
     }
     $company_exist = $ObjCompanies->get_company_id_check_if_company_exist($company, $address1, $city, $state_code, $zipcode);
     if ($email_address == '') {
         $error_message = 'Email Address required';
         $result = FALSE;
     } elseif ($company == '') {
         $error_message = 'Company Name required';
         $result = FALSE;
     } elseif ($email_address) {
         $where_params = array('`j`.`email_address`=' => $email_address, '`j1`.`company_name`=' => $company, '`j1`.`address1`=' => $address1, '`j1`.`city`=' => $city, '`j1`.`state_code`=' => $state_code, '`j1`.`zipcode`=' => $zipcode);
         $check_email = $ObjContacts->get_record_join($where_params);
         if ($check_email) {
             $error_message = 'Email Address already exist.';
             $result = FALSE;
         }
     } elseif ($last_name && $first_name) {
         $where_params = array('`last_name`=' => $last_name, '`first_name`=' => $first_name);
         $check_contact = $ObjContacts->get_record($where_params);
         if ($check_contact) {
             $error_message = 'Contact Name already exist.';
             $result = FALSE;
         }
     } elseif ($company_exist != '') {
         $error_message = 'Contact Joe Smith and ask him to add you to to your companies account.';
         $result = FALSE;
     }
     foreach ($fields as $col) {
         $column = $col->cuff_column;
         $fieldname = $col->cuff_fieldname;
         $status = $col->cuff_status;
         $col = Input::get($column);
         $value = $col[$cut_id];
         if ($status == 'close' && $fieldname != '') {
             $data[$column] = $value;
         }
     }
     $data[$this->tblpref . 'error_message'] = $error_message;
     $this->update_data($data, $cut_id);
     return $result;
 }