Beispiel #1
0
 public function add_telefono()
 {
     $inputs = Input::all();
     $rules = array('telefono' => 'required|numeric|unique:telefono,telefono', 'telefono_secundario' => 'numeric', 'telefono_fax' => 'numeric');
     $validator = Validator::make($inputs, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator);
     } else {
         $telefono = new Phone();
         $telefono->telefono = Input::get('telefono');
         $telefono->telefono_secundario = Input::get('telefono_secundario');
         $telefono->telefono_fax = Input::get('telefono_fax');
         if (Input::get('fk_persona') != 'NULL') {
             $telefono->fk_persona = Input::get('fk_persona');
             $telefono->fk_empresa = NULL;
             $telefono->save();
             return Redirect::to('telefono');
         } else {
             $telefono->fk_empresa = Input::get('fk_empresa');
             $telefono->fk_persona = NULL;
             $telefono->save();
             return Redirect::to('telefono');
         }
         return Redirect::to('telefono');
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Phone();
     if (isset($_GET['Phone']['city_id'])) {
         if (!empty($_GET['Phone']['city_id'])) {
             $model->city_id = $_GET['Phone']['city_id'];
         }
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Phone'])) {
         $model->attributes = $_POST['Phone'];
         $model->city_id = $_GET['Phone']['city_id'];
         if ($model->save()) {
             //$city = City::model()->findByPk($model->city_id);
             //после добавления связки - номер/шаблон, обновим статус у города, если надо, что он подвязан к шаблону
             $query = YiiBase::app()->db->createCommand('UPDATE tbl_city_site_phone SET relation_tpl=1 WHERE city_id=:city_id AND site_id=:site_id');
             $query->bindValue(':site_id', $model->site_id, PDO::PARAM_INT);
             $query->bindValue(':city_id', $model->city_id, PDO::PARAM_INT);
             $query->execute();
             $this->redirect(array('index', 'Phone[city_id]' => $model->city_id));
         }
     } else {
         if (isset($_GET['Phone'])) {
             $model->attributes = $_GET['Phone'];
         }
     }
     $this->render('create', array('model' => $model));
 }
Beispiel #3
0
 public function actionCreate()
 {
     $model = new Phone();
     if (isset($_POST['Phone'])) {
         $model->setAttributes($_POST['Phone']);
         if ($model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function handleCreate()
 {
     DB::transaction(function () {
         $input = Input::all();
         $person = new Person();
         $localizationController = new LocalizationController();
         $person->names = $input['names'];
         $person->last_name = $input['last_name'];
         $person->doc_number = $input['doc_number'];
         $person->doc_type = $input['doc_type'];
         $person->email = $input['email'];
         $person->career = $input['career'];
         $person->state = 1;
         //para transformar a fecha
         $borndate = date("Y-m-d", strtotime($input['born_date']));
         $person->born_date = $borndate;
         $person->nationality = $input['nationality'];
         $person->academicdegree_id = $input['academicdegree_id'];
         $person->localization_id = $localizationController->getLocalizationId($input['localization_dept'], $input['localization_prov'], $input['localization_dist']);
         $person->save();
         $i = 0;
         foreach ($input['mobile_number'] as $mobil) {
             $phone = new Phone();
             $phone->person()->associate($person);
             $phone->mobile_number = $mobil;
             $phone->type = $input['phone_type'][$i];
             $phone->save();
             $i = $i + 1;
         }
         if (isset($input['notif1'])) {
             //asociar la persona a las notificaciones de tipo 1
             //$person->notifications()->save(Notification::find(1));
             $person->notifications()->attach(1);
             $person->notifications()->where('person_id', '=', $person->id)->update(array('state' => 1));
         }
         if (isset($input['notif2'])) {
             //asociar la persona a las notificaciones de tipo 1
             $person->notifications()->attach(2);
             $person->notifications()->where('person_id', '=', $person->id)->update(array('state' => 1));
         }
     });
     return Redirect::to('registro');
 }
Beispiel #5
0
 /**
  * Добавляет юзеру номер телефона, принимая объект номера телефона,
  * ассоциативный массив с кодом страны, кодом оператора и т.д. или
  * строку с неформатированым номером телефона.
  * Сохраняет телефонный номер в бд и возвращает его в случае успеха или
  * false при неудаче 
  */
 public function add_phone_number($phone)
 {
     if (gettype($phone) === 'array') {
         $phone = new Phone($phone);
     } else {
         if (gettype($phone) === 'string') {
             $params = array();
             $params['country_code'] = substr($phone, 0, 3);
             $params['operator_code'] = substr($phone, 3, -7);
             $params['phone_number'] = substr($phone, 5);
             $phone = new Phone($params);
         }
     }
     $phone->user_id = $this->id;
     if ($phone->save()) {
         $this->phones[] = $phone;
         return $phone;
     }
     return false;
 }
Beispiel #6
0
if ($skipped != 0) {
    printf("\n%u addresses skipped.\n", $skipped);
}
if ($fixed != 0) {
    printf("\n%u addresses fixed.\n", $fixed);
}
print "\nAddress formating done.\n\n";
print "Formats non formated phones. (3/4)\n";
$it = XDB::rawIterator("SELECT  search_tel AS search, display_tel AS display, comment, link_id,\n                                tel_type AS type, link_type, tel_id AS id, pid, pub\n                          FROM  profile_phones\n                         WHERE  search_tel = '' OR search_tel IS NULL\n                      ORDER BY  pid, link_id, tel_id");
$total = $it->total();
$i = 0;
$j = 0;
while ($item = $it->next()) {
    $phone = new Phone($item);
    $phone->delete();
    $phone->save();
    ++$i;
    ++$j;
    if ($j == 100) {
        $j = 0;
        printf("\r%u / %u", $i, $total);
    }
}
printf("\r%u / %u", $i, $total);
print "\nFormating done.\n\n";
print "Deletes duplicated phones. (4/4)\n";
$pids = XDB::rawFetchColumn("SELECT  DISTINCT(pid)\n                               FROM  profile_phones AS p1\n                              WHERE  link_type = 'user' AND EXISTS (SELECT  *\n                                                                      FROM  profile_phones AS p2\n                                                                     WHERE  p2.link_type = 'user' AND p2.pid = p1.pid AND p2.tel_id != p1.tel_id)\n                           ORDER BY  pid");
$total = count($pids);
$done = 0;
$aux = 0;
$deleted = 0;
Beispiel #7
0
 function handler_jobs($page, $id = -1)
 {
     $page->changeTpl('admin/jobs.tpl');
     if (Env::has('search')) {
         $res = XDB::query("SELECT  id, name, acronym\n                                 FROM  profile_job_enum\n                                WHERE  name LIKE CONCAT('%', {?}, '%') OR acronym LIKE CONCAT('%', {?}, '%')", Env::t('job'), Env::t('job'));
         if ($res->numRows() <= 20) {
             $page->assign('jobs', $res->fetchAllAssoc());
         } else {
             $page->trigError("Il y a trop d'entreprises correspondant à ton choix. Affine-le !");
         }
         $page->assign('askedJob', Env::v('job'));
         return;
     }
     if (Env::has('edit')) {
         S::assert_xsrf_token();
         $selectedJob = Env::has('selectedJob');
         Phone::deletePhones(0, Phone::LINK_COMPANY, $id);
         Address::deleteAddresses(null, Address::LINK_COMPANY, $id);
         if (Env::has('change')) {
             if (Env::has('newJobId') && Env::i('newJobId') > 0) {
                 XDB::execute('UPDATE  profile_job
                                  SET  jobid = {?}
                                WHERE  jobid = {?}', Env::i('newJobId'), $id);
                 XDB::execute('DELETE FROM  profile_job_enum
                                     WHERE  id = {?}', $id);
                 $page->trigSuccess("L'entreprise a bien été remplacée.");
             } else {
                 $page->trigError("L'entreprise n'a pas été remplacée car l'identifiant fourni n'est pas valide.");
             }
         } else {
             XDB::execute('UPDATE  profile_job_enum
                              SET  name = {?}, acronym = {?}, url = {?}, email = {?},
                                   SIREN_code = {?}, NAF_code = {?}, AX_code = {?}, holdingid = {?}
                            WHERE  id = {?}', Env::t('name'), Env::t('acronym'), Env::t('url'), Env::t('email'), Env::t('SIREN') == 0 ? null : Env::t('SIREN'), Env::t('NAF_code') == 0 ? null : Env::t('NAF_code'), Env::i('AX_code') == 0 ? null : Env::t('AX_code'), Env::i('holdingId') == 0 ? null : Env::t('holdingId'), $id);
             $phone = new Phone(array('display' => Env::v('tel'), 'link_id' => $id, 'id' => 0, 'type' => 'fixed', 'link_type' => Phone::LINK_COMPANY, 'pub' => 'public'));
             $fax = new Phone(array('display' => Env::v('fax'), 'link_id' => $id, 'id' => 1, 'type' => 'fax', 'link_type' => Phone::LINK_COMPANY, 'pub' => 'public'));
             $address = new Address(array('jobid' => $id, 'type' => Address::LINK_COMPANY, 'text' => Env::t('address')));
             $phone->save();
             $fax->save();
             $address->save();
             $page->trigSuccess("L'entreprise a bien été mise à jour.");
         }
     }
     if (!Env::has('change') && $id != -1) {
         $res = XDB::query("SELECT  e.id, e.name, e.acronym, e.url, e.email, e.SIREN_code AS SIREN, e.NAF_code, e.AX_code,\n                                       h.id AS holdingId, h.name AS holdingName, h.acronym AS holdingAcronym,\n                                       t.display_tel AS tel, f.display_tel AS fax, a.text AS address\n                                 FROM  profile_job_enum  AS e\n                            LEFT JOIN  profile_job_enum  AS h ON (e.holdingid = h.id)\n                            LEFT JOIN  profile_phones    AS t ON (t.pid = e.id AND t.link_type = 'hq' AND t.tel_id = 0)\n                            LEFT JOIN  profile_phones    AS f ON (f.pid = e.id AND f.link_type = 'hq' AND f.tel_id = 1)\n                            LEFT JOIN  profile_addresses AS a ON (a.jobid = e.id AND a.type = 'hq')\n                                WHERE  e.id = {?}", $id);
         if ($res->numRows() == 0) {
             $page->trigError('Auncune entreprise ne correspond à cet identifiant.');
         } else {
             $page->assign('selectedJob', $res->fetchOneAssoc());
         }
     }
 }
 /**
  * Try to find this person in the database.
  * If we cannot find them, create a new person record.
  *
  * @return Person
  */
 public static function findPerson($post)
 {
     $search = array();
     // Translates Open311 parameters into PersonList search parameters
     // open311 => personList
     $fields = array('first_name' => 'firstname', 'last_name' => 'lastname', 'email' => 'email', 'phone' => 'phoneNumber', 'device_id' => 'phoneDeviceId');
     foreach ($fields as $open311Field => $crmField) {
         if (!empty($post[$open311Field])) {
             $search[$crmField] = $post[$open311Field];
         }
     }
     // If the user provided any personal info, do a person search
     if (count($search)) {
         $table = new PersonTable();
         $list = $table->find($search);
         // When we find one and only one record, use the record we found
         if (count($list) == 1) {
             $person = $list->current();
         } else {
             $p = array();
             foreach ($fields as $key => $field) {
                 if (!empty($post[$key])) {
                     $p[$field] = $post[$key];
                 }
             }
             if (count($p)) {
                 $person = new Person();
                 try {
                     $person->handleUpdate($p);
                     $person->save();
                     if (!empty($post['email'])) {
                         $email = new Email();
                         $email->setPerson($person);
                         $email->setEmail($post['email']);
                         $email->save();
                     }
                     if (!empty($post['phone']) || !empty($post['device_id'])) {
                         $phone = new Phone();
                         $phone->setPerson($person);
                         if (!empty($post['phone'])) {
                             $phone->setNumber($post['phone']);
                         }
                         if (!empty($post['device_id'])) {
                             $phone->setDeviceId($post['device_id']);
                         }
                         $phone->save();
                     }
                 } catch (\Exception $e) {
                     unset($person);
                 }
             }
         }
     }
     return isset($person) ? $person : null;
 }
Beispiel #9
0
 /** Saves phones into the database.
  * @param $data: an array of form formatted phones.
  * @param $pid, $link_type, $link_id: pid, link_type and link_id concerned by the update.
  */
 public static function savePhones(array $data, $pid, $link_type, $link_id = null)
 {
     foreach ($data as $id => $value) {
         $value['id'] = $id;
         if (!is_null($pid)) {
             $value['pid'] = $pid;
         }
         if (!is_null($link_type)) {
             $value['link_type'] = $link_type;
         }
         if (!is_null($link_id)) {
             $value['link_id'] = $link_id;
         }
         $phone = new Phone($value);
         $phone->save();
     }
 }
 public function addNewLead($domain, $linkedin_contact_id)
 {
     $domain = DomainHelper::getDomain($domain);
     $company_domain = CompanyDomain::where("linkedin_contact_id", "=", $linkedin_contact_id)->get();
     for ($i = 0; $i < count($company_domain); $i++) {
         $company_domain[$i]->status = CompanyDomain::UNSELECTED;
         $company_domain[$i]->save();
     }
     $company_domain = CompanyDomain::where("linkedin_contact_id", "=", $linkedin_contact_id)->where("url", "=", $domain)->first();
     if (count($company_domain) == 0) {
         $linkedin_contact = LinkedinContact::find($linkedin_contact_id);
         $company_domain = new CompanyDomain();
         $company_domain->url = $domain;
         $company_domain->linkedin_url = "";
         $company_domain->status = CompanyDomain::SELECTED;
         $company_domain = $linkedin_contact->companyDomain()->save($company_domain);
         $company_domain->save();
         if ($linkedin_contact->started_at == '' || $linkedin_contact->started_at == '0000-00-00 00:00:00') {
             $linkedin_contact->started_at = date("Y-m-d H:i:s");
             $linkedin_contact->save();
         }
     } else {
         $company_domain = CompanyDomain::find($company_domain->id);
         $company_domain->status = CompanyDomain::SELECTED;
         $company_domain->save();
     }
     //SEO Scrapping Start
     $company_seo_data = $this->scrapeCompanySEO($domain);
     $company_domain->seo_company_title = $company_seo_data['seo_company_title'];
     $company_domain->seo_company_descriptoin = $company_seo_data['seo_company_descriptoin'];
     $company_domain->seo_company_keywords = $company_seo_data['seo_company_keywords'];
     //SEO Scrapping End
     //Company Social URL --Start
     $company_social_url = $this->companySocialURL($domain);
     $company_domain->company_facebook_url = $company_social_url['company_facebook_url'];
     $company_domain->company_twitter_url = $company_social_url['company_twitter_url'];
     $company_domain->company_google_url = $company_social_url['company_google_url'];
     $company_domain->fullcontact_company = $company_social_url['full_contact_company'];
     //Company Social URL --End
     // Company Visistat --Start
     $params = array('website' => $domain);
     //Query by Domain
     $objVisistat = new Visistat();
     $response_Visistat = $objVisistat->makeCall($params);
     $company_domain->visistat = $response_Visistat;
     // Company Visistat URL --End
     $company_domain->save();
     $linkedin_contact = LinkedinContact::find($linkedin_contact_id);
     $domain_list = $linkedin_contact->companyDomain()->get();
     $domain = array();
     $email_list = array();
     $valid_email_array_list = array();
     $api_email_array_list = array();
     $emails = array();
     $key = "id-";
     foreach ($domain_list as $domain_item) {
         $domain_id = $domain_item->id;
         $domain["id-" . $domain_item->id] = $domain_item->url;
         if ($domain_item->status == CompanyDomain::SELECTED) {
             $key = "id-" . $domain_item->id;
             $email_list = $this->emailGenerator($linkedin_contact->firstname, $linkedin_contact->lastname, $domain_item->url);
             $final_domain = $domain_item->url;
             $test_domain = explode("www.", $domain_item->url);
             if (count($test_domain) == 2) {
                 $final_domain = $test_domain[1];
             }
             $check_email = strtolower($linkedin_contact->firstname . "_" . $linkedin_contact->lastname . '@' . $final_domain);
             //echo $check_email; exit;
             //save paid email for a specific contact according to history patterns of that domain
             $paid_db_email_patterns_list = PaidDatabaseEmail::select('url', 'pattern_id', 'level', 'percentage', 'paid_db')->distinct()->where("url", "=", $domain_item->url)->get();
             if (count($paid_db_email_patterns_list) > 0) {
                 foreach ($paid_db_email_patterns_list as $patterns) {
                     $paid_email = "";
                     switch ($patterns['pattern_id']) {
                         case 1:
                             $patt = $linkedin_contact->firstname;
                             //first
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 2:
                             $patt = $linkedin_contact->firstname . "." . $linkedin_contact->lastname;
                             //first.last
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 3:
                             $patt = substr($linkedin_contact->firstname, 0, 1) . '' . $linkedin_contact->lastname;
                             //flast
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 4:
                             $patt = $linkedin_contact->lastname;
                             //last
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 5:
                             $patt = $linkedin_contact->firstname . "_" . $linkedin_contact->lastname;
                             //first_last
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 6:
                             $patt = $linkedin_contact->firstname . substr($linkedin_contact->lastname, 0, 1);
                             //firstl
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 7:
                             $patt = $linkedin_contact->firstname . $linkedin_contact->lastname;
                             //firstlast
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 8:
                             $patt = $linkedin_contact->lastname . substr($linkedin_contact->firstname, 0, 1);
                             //lastf
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 9:
                             $patt = substr($linkedin_contact->lastname, 0, 1) . $linkedin_contact->firstname;
                             //lfirst
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 10:
                             $patt = substr($linkedin_contact->firstname, 0, 1) . '.' . $linkedin_contact->lastname;
                             //f.last
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 11:
                             $patt = $linkedin_contact->lastname . '.' . substr($linkedin_contact->firstname, 0, 1);
                             //last.f
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 12:
                             $patt = substr($linkedin_contact->firstname, 0, 1) . $linkedin_contact->lastname . substr(0, 1);
                             //fl
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 13:
                             $patt = substr($linkedin_contact->firstname, 0, 1) . $linkedin_contact->lastname . "8";
                             //flast8
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 14:
                             $patt = $linkedin_contact->firstname . "-" . $linkedin_contact->lastname;
                             //first-last
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 15:
                             $patt = $linkedin_contact->firstname . "." . substr($linkedin_contact->lastname, 0, 1);
                             //first.l
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         case 16:
                             $patt = $linkedin_contact->lastname . "." . $linkedin_contact->firstname;
                             //last.first
                             $paid_email = strtolower($patt . '@' . $final_domain);
                             break;
                         default:
                             //echo "default";
                     }
                     if ($paid_email != "") {
                         $_email_exist = PaidDatabaseEmail::where("email", "=", $paid_email)->get();
                         if (count($_email_exist) > 0) {
                             //$_JSON["result"] = "This mail is already taken";
                         } else {
                             try {
                                 $email_obj = new PaidDatabaseEmail();
                                 $email_obj->url = $patterns['url'];
                                 $email_obj->email = $paid_email;
                                 $email_obj->paid_db = $patterns['paid_db'];
                                 $email_obj->pattern_id = $patterns['pattern_id'];
                                 $email_obj->level = $patterns['level'];
                                 $email_obj->percentage = $patterns['percentage'];
                                 $email_obj->linkedin_contact_id = $linkedin_contact->id;
                                 $email_obj->save();
                             } catch (Exception $e) {
                                 Log::notice($e);
                             }
                         }
                     }
                 }
             }
             //saving paid db1 and paid db2 for final phone
             $paid_phone_list = PaidDatabasePhone::select('url', 'phone', 'level', 'percentage', 'paid_db')->distinct()->where("url", "=", $domain_item->url)->get();
             if (count($paid_phone_list) > 0) {
                 foreach ($paid_phone_list as $phone_item) {
                     $paid_phone = $phone_item['phone'];
                     if ($paid_phone != "") {
                         $_phone_exist = Phone::where("phone", "=", $paid_phone)->where("linkedin_contact_id", "=", $linkedin_contact->id)->get();
                         if (count($_phone_exist) > 0) {
                             //$_JSON["result"] = "This phone is already taken";
                         } else {
                             try {
                                 $ph_obj = new Phone();
                                 $ph_obj->phone = $paid_phone;
                                 $ph_obj->level = $phone_item['level'];
                                 $ph_obj->percentage = $phone_item['percentage'];
                                 $ph_obj->linkedin_contact_id = $linkedin_contact->id;
                                 $ph_obj->save();
                                 //$insertedId = $ph_obj->id;
                             } catch (Exception $e) {
                                 Log::notice($e);
                             }
                         }
                     }
                 }
             }
             // first name or last name has been changed
             $check_email_validator = EmailDomainValidator::where("domain_id", "=", $domain_id)->where('email_pattern', '=', $check_email)->orderBy('status', 'desc')->get()->toArray();
             $email_validator = EmailDomainValidator::where("domain_id", "=", $domain_id)->orderBy('status', 'desc')->get()->toArray();
             if (!count($email_validator) || !count($check_email_validator)) {
                 $emails = $email_list;
                 array_shift($emails);
                 set_time_limit(0);
                 foreach ($emails as $email) {
                     $api_key = '9bbfe3db-eeb8-413b-810c-f4aa02d62448';
                     $client = new BriteAPIContact($api_key);
                     $client->email = $email;
                     $client->verify();
                     $response = $client->response['email'];
                     $status = $response['status'];
                     $full_status = 0;
                     $likelihood = 0;
                     //Added by developer
                     $validator = new EmailDomainValidator();
                     $validator->domain_id = $domain_id;
                     $validator->email_pattern = $email;
                     $validator->status = $response['status'];
                     $validator->disposable = $response['disposable'];
                     $validator->role_address = $response['role_address'];
                     $validator->duration = $response['duration'];
                     $validator->result = json_encode($response);
                     $validator->save();
                     $validator_id = $validator->id;
                     if ($response['status'] == 'invalid') {
                         // We are doing nothing with it. Domain might be Invalid
                         $response_json = "";
                         $errors = $client->errors();
                         $errors_codes = $client->error_codes();
                         $error_code = $errors_codes[0];
                         $error = $errors['email'];
                     } else {
                         // If status is not Valid, We are saving the pattern along with Full Contact Person API response
                         $valid_email_array_list[$email] = $email;
                         $response_json = $this->createWebhook($email, $validator_id);
                         $response_obj = json_decode($response_json);
                         $likelihood = 0;
                         $full_status = $response_obj->status;
                         // for api result copy patterns
                         if (is_object($response_obj)) {
                             if ($response_obj->status == 202) {
                                 //$api_email_list[$email->email_pattern] = $email->email_pattern;
                                 $api_email_array_list[$email] = $email;
                             } else {
                                 if ($response_obj->status == 200) {
                                     //$api_email_list[$email->email_pattern] = $email->email_pattern;
                                     $api_email_array_list[$email] = $email;
                                     $likelihood = $response_obj->likelihood;
                                 }
                             }
                         }
                         $error_code = "";
                         $error = "";
                     }
                     $validator->likelihood = $likelihood;
                     $validator->error_code = $error_code;
                     $validator->error = $error;
                     if ($response['status'] == 'valid') {
                         $objFullContactPerson = new FullContactPerson();
                         $response_json = $objFullContactPerson->makeCall($email);
                         $validator->fullcontact = $response_json;
                         $response_obj = json_decode($response_json);
                         $validator->full_status = $response_obj->status;
                     } else {
                         $validator->full_status = $full_status;
                         $validator->fullcontact = $response_json;
                     }
                     $validator->webhook = 1;
                     $validator->save();
                     // save record for accept all tracking
                     // This needs to be placed under BriteVerify Status Level based on its most VALID recommendation.
                     $accept_all_domain = CompanyDomain::find($domain_id);
                     $accept_all_domain->brite_api_status = $response['status'];
                     $accept_all_domain->save();
                     //auto save email for contact if it is valid by Brite api
                     /*
                     if ($response['status'] == 'valid') {
                                                 if (Email::where('email', '=', $email)->exists()) {
                                                     // email found
                                                 } else {
                                                     $email_object = new Email();
                                                     $email_object->linkedin_contact_id = $linkedin_contact->id;
                                                     $email_object->email = $email;
                                                     $email_object->level = 'Verified';
                                                     $email_object->percentage = '10';
                                                     $email_object->save();
                                                 }
                                             }
                     */
                 }
             }
             // CONDITIONAL LOGIC FOR BRITEVERIFY STATUSES STARTS HERE
             // Initial Check - If any of the Email Pattern(s) is VALID
             $email_validator = EmailDomainValidator::where("domain_id", "=", $domain_id)->where('status', '=', "valid")->orderBy('status', 'desc')->get()->toArray();
             if (!empty($email_validator)) {
                 //echo " == Found Valid email ==" ;
                 //print_r ($email_validator);
                 $responseSocialURL = $this->socialURL($domain_id, 'valid');
                 $is_valid_lead = $responseSocialURL['is_valid'];
                 if ($is_valid_lead == 1) {
                     //echo " == Have found correct Social Data FullContact ==";
                 }
                 //else
                 //echo " == Not found correct Social Data in FullContact ==";
                 //exit ;
                 // Fetch FULL Contact Social information through Email validator table against found VALID records. And show the results in Email POP UP
             } elseif (empty($email_validator)) {
                 // Check if all email patterns are INVALID
                 $email_validator = EmailDomainValidator::where("domain_id", "=", $domain_id)->where('status', '=', "invalid")->orderBy('status', 'desc')->get()->toArray();
                 if (!empty($email_validator) && count($email_validator) == 10) {
                     //echo "== All Email Patterns are INVALID ==";
                     //print_r ($email_validator);
                     //exit;
                     // Domain might not correct or email patterns don't exist
                 } else {
                     // All are not Invalid, Check if we have got unknown or accept_all
                     $email_validator = EmailDomainValidator::whereIn('status', array('unknown', 'accept_all'))->where("domain_id", "=", $domain_id)->orderBy('status', 'desc')->get()->toArray();
                     if (!empty($email_validator)) {
                         // echo "== Found unknown and/or accept_all email ==" ;
                         // print_r ($email_validator);
                         // Validating Social Data
                         $responseSocialURL = $this->socialURL($domain_id, 'accept_all');
                         $is_valid_lead = $responseSocialURL['is_valid'];
                         if ($is_valid_lead == 1) {
                             //echo " == Have found correct Social Data in FullContact ==";
                             // WE NEED TO UPDATE THE EMAIL PATTERN STATUS to VALID
                         } elseif ($is_valid_lead == 0) {
                             // echo " == Not found any Social Data in FullContact ==";
                             // If Social Links are invalid then we would go further to following APis
                             //$objNetProspexPerson = new NetProspexPerson();
                             //$objZoomInfoPersonDetail = new ZoomInfoPersonDetail();
                             /*
                             // ZoominfoPersonMatch API
                                                             $objZoomInfoPersonMatch = new ZoomInfoPersonMatch();
                                                             $response_ZoomInfoPersonMatch = $objZoomInfoPersonMatch->makeCall(array('firstName' => $linkedin_contact->firstname,
                                                                                                                                     'lastName' => $linkedin_contact->lastname,
                                                                                                                                     'companyName' => $final_domain));
                             $company_domain = CompanyDomain::find($domain_id);
                                                             $company_domain->zoominfo_search = $response_ZoomInfoPersonMatch;
                                                             $company_domain->save();
                             */
                             /*
                             foreach ($email_validator as $key => $pattern) {
                                 // NetProsPexPerson API
                                                                 $response_NetProspexPerson = $objNetProspexPerson->makeCall(array('email' => $pattern['email_pattern'] ));
                                 // ZoominfoPersonDetail API
                                                                 $response_ZoomInfoPersonDetail = $objZoomInfoPersonDetail->makeCall(array('EmailAddress' => $pattern['email_pattern'] ));
                                 // Saving NetprosPex and Zoominfo API calls response in DB, email_validator table
                                 $validator = EmailDomainValidator::find($pattern['id']);
                                 $validator->netprospex_match = $response_NetProspexPerson;
                                                                 $validator->zoominfo_detail = $response_ZoomInfoPersonDetail;
                                                                 //$validator->zoominfo_detail = $response_ZoomInfoPersonMatch; // Saving Person Match Result in DB
                                 $validator->save();
                             }
                             */
                             // echo "== NetProsPex and ZoomInfo Response has been saved in DB ==" ;
                             // Fetch NetprosPex and Zoominfo Reponse to check if they have returned some Valid info
                             /*
                             $netProsPexResponse = $this->validateNetprosPex($domain_id, "accept_all") ;
                                                             $is_valid_netprospex = $netProsPexResponse['is_found'] ;
                             $zoomInfoResponse = $this->validateZoomInfo($domain_id, "accept_all") ;
                                                             $is_valid_zoominfo = $zoomInfoResponse['is_found'] ;
                             */
                             //if ( $is_valid_netprospex > 0  )
                             //{
                             // echo "== Found in NetprosPexPerson ==" ;
                             // WE NEED TO UPDATE THE EMAIL PATTERN STATUS to VALID
                             //} else {
                             // echo "== Not found in NetprosPexPerson ==";
                             //}
                             // LETS CHECK OUT ZOOMINFO RESPONSE
                             //if ( $is_valid_zoominfo > 0  )
                             //{
                             // echo "== Found in ZoominfoPerson ==" ;
                             // WE NEED TO UPDATE THE EMAIL PATTERN STATUS to VALID
                             //} else {
                             // echo "== Not found in ZoominfoPerson ==";
                             //}
                             // NetProsPex Person Search AND ZoomInfo Person Search
                             $is_valid_netprospex = 0;
                             $is_valid_zoominfo = 0;
                             if ($is_valid_netprospex == 0 && $is_valid_zoominfo == 0) {
                                 // We are unable to find success with FullcontactPerson, NetProsPexPerson and ZoominfoPerson, we need to keep looking
                                 // Before making following person search calls, we will look into company_domain_patterns table if we have already saved email patterns
                                 // for requested domain. If we already have, then we will get the patterns from DB and won't make new API calls for the same domain:
                                 $objNetProspexPersonList = new NetProspexPersonList();
                                 $objZoomInfoPersonSearch = new ZoomInfoPersonSearch();
                                 // NetProsPexPersonList API
                                 $response_NetProspexPersonList = $objNetProspexPersonList->makeCall(array('organizationWebsite' => $final_domain));
                                 // ZoominfoPersonDetail API
                                 $response_ZoomInfoPersonSearch = $objZoomInfoPersonSearch->makeCall(array('companyDomainName' => $final_domain, 'companyPastOrPresent' => '1'));
                                 // Saving NetprosPex and Zoominfo API calls response in DB, company_domain table
                                 if ($response_NetProspexPersonList != "") {
                                     $company_domain = CompanyDomain::find($domain_id);
                                     $company_domain->netprospex_list = $response_NetProspexPersonList;
                                     $company_domain->save();
                                     // Fetching email patterns / phone numbers out of Netprospex Person Search API to save these in
                                     // company_domain_patterns table for current / future use.
                                     $this->parseNetprospexList($domain_id, $final_domain);
                                 }
                                 if ($response_ZoomInfoPersonSearch != "") {
                                     $company_domain = CompanyDomain::find($domain_id);
                                     $company_domain->zoominfo_search = $response_ZoomInfoPersonSearch;
                                     $company_domain->save();
                                     // Fetching email patterns / phone numbers out of Zoominfo Person Search API to save these in
                                     // company_domain_patterns table for current / future use.
                                     $this->parseZoomInfoList($domain_id, $final_domain);
                                 }
                             }
                         }
                     }
                 }
             }
             // PHONE Validator Code goes here..
             $this->parsePhoneNumbers($domain_id);
             // Email pattern recognition Code
             // First we need to fetch the leads First Name, Last Name and Domain URL
             $response_lead = EmailDomainValidator::where("domain_id", "=", $domain_id)->get()->toArray();
             $leadEmails = array();
             foreach ($response_lead as $lead) {
                 $leadEmails[] = $lead['email_pattern'];
             }
             // Second, we need to fetch the domain email patterns through DB
             $response_domain = CompanyDomainPatterns::where("company_domain_id", "=", $domain_id)->get()->toArray();
             foreach ($response_domain as $lead) {
                 $array = $this->emailGenerator($lead['first_name'], $lead['last_name'], $final_domain);
                 $i = -1;
                 foreach ($array as $email) {
                     if ($email == $lead['email']) {
                         // Update the lead email pattern status to 1 in company_status column to effect the Recommendation Formula on Email Popup
                         $validator = EmailDomainValidator::where('email_pattern', $leadEmails[$i])->first();
                         $validator->company_status = $validator->company_status + 1;
                         $validator->save();
                         break;
                     }
                     $i++;
                 }
             }
             // Preselect top email pattern as Current
             $this->markTopEmailAsCurrent($domain_id, 1);
             // exit ;
         }
     }
 }
Beispiel #11
0
 function handler_edit($page)
 {
     global $globals;
     $page->changeTpl('xnetgrp/edit.tpl');
     $error = false;
     if (S::admin()) {
         $domains = XDB::iterator('SELECT  *
                                     FROM  group_dom
                                 ORDER BY  nom');
         $page->assign('domains', $domains);
         $page->assign('super', true);
     }
     if (Post::has('submit')) {
         S::assert_xsrf_token();
         $flags = new PlFlagSet('wiki_desc');
         $flags->addFlag('notif_unsub', Post::i('notif_unsub') == 1);
         $site = Post::t('site');
         if ($site && $site != "http://") {
             $scheme = parse_url($site, PHP_URL_SCHEME);
             if (!$scheme) {
                 $site = "http://" . $site;
             }
         } else {
             $site = "";
         }
         $notify_all = Post::v('notify_all') ? true : false;
         if (!$notify_all) {
             $to_notify = array();
             $uf = new UserFilter(new UFC_Group($globals->asso('id'), true));
             $uids = $uf->getIds();
             foreach ($uids as $uid) {
                 if (Post::b('to_notify_' . $uid)) {
                     $to_notify[] = $uid;
                 }
             }
             if (count($to_notify) == 0) {
                 $notify_all = true;
                 $page->trigWarning("Aucun animateur n'ayant été selectionné pour recevoir les demandes d'inscriptions, tous le seront.");
             }
         }
         $flags->addFlag('notify_all', $notify_all);
         if (S::admin()) {
             $page->assign('super', true);
             if (Post::v('mail_domain') && strstr(Post::v('mail_domain'), '.') === false) {
                 $page->trigError('Le domaine doit être un FQDN (aucune modification effectuée)&nbsp;!!!');
                 $error = true;
             }
             if (Post::t('nom') == '' || Post::t('diminutif') == '') {
                 $page->trigError('Ni le nom ni le diminutif du groupe ne peuvent être vide.');
                 $error = true;
             }
             if ($error) {
                 $page->assign('nom', Post::t('nom'));
                 $page->assign('diminutif', Post::t('diminutif'));
                 $page->assign('mail_domain', Post::t('mail_domain'));
                 $page->assign('cat', Post::v('cat'));
                 $page->assign('dom', Post::v('dom'));
                 $page->assign('ax', Post::v('ax'));
                 $page->assign('axDate', Post::t('axDate'));
                 $page->assign('site', $site);
                 $page->assign('resp', Post::t('resp'));
                 $page->assign('mail', Post::t('mail'));
                 $page->assign('phone', Post::t('phone'));
                 $page->assign('fax', Post::t('fax'));
                 $page->assign('address', Post::t('address'));
                 $page->assign('forum', Post::t('forum'));
                 $page->assign('inscriptible', Post::v('inscriptible'));
                 $page->assign('sub_url', Post::t('sub_url'));
                 $page->assign('unsub_url', Post::t('unsub_url'));
                 $page->assign('welcome_msg', Post::t('welcome_msg'));
                 $page->assign('pub', Post::v('pub'));
                 $page->assign('notif_unsub', Post::i('notif_unsub'));
                 $page->assign('descr', Post::t('descr'));
                 $page->assign('disable_mails', Post::b('disable_mails'));
                 $page->assign('status', Post::v('status'));
                 $page->assign('error', $error);
                 return;
             }
             $axDate = make_datetime(Post::v('axDate'));
             if (Post::t('axDate') != '') {
                 $axDate = make_datetime(Post::v('axDate'))->format('Y-m-d');
             } else {
                 $axDate = null;
             }
             XDB::execute("UPDATE  groups\n                        SET  nom={?}, diminutif={?}, cat={?}, dom={?},\n                             descr={?}, site={?}, mail={?}, resp={?},\n                             forum={?}, mail_domain={?}, ax={?}, axDate = {?}, pub={?},\n                             sub_url={?}, inscriptible={?}, unsub_url={?},\n                             flags = {?}, welcome_msg = {?}, disable_mails = {?},\n                             status = {?}\n                      WHERE  id={?}", Post::v('nom'), Post::v('diminutif'), Post::v('cat'), Post::i('dom') == 0 ? null : Post::i('dom'), Post::v('descr'), $site, Post::v('mail'), Post::v('resp'), Post::v('forum'), Post::v('mail_domain'), Post::has('ax'), $axDate, Post::v('pub'), Post::v('sub_url'), Post::v('inscriptible'), Post::v('unsub_url'), $flags, Post::t('welcome_msg'), Post::b('disable_mails'), Post::v('status'), $globals->asso('id'));
             if (Post::v('mail_domain')) {
                 XDB::execute('INSERT IGNORE INTO  email_virtual_domains (name)
                                           VALUES  ({?})', Post::t('mail_domain'));
                 XDB::execute('UPDATE  email_virtual_domains
                                  SET  aliasing = id
                                WHERE  name = {?}', Post::t('mail_domain'));
             }
         } else {
             XDB::execute("UPDATE  groups\n                        SET  descr={?}, site={?}, mail={?}, resp={?},\n                             forum={?}, pub= {?}, sub_url={?},\n                             unsub_url = {?}, flags = {?}, welcome_msg = {?},\n                             status = {?}\n                      WHERE  id={?}", Post::v('descr'), $site, Post::v('mail'), Post::v('resp'), Post::v('forum'), Post::v('pub'), Post::v('sub_url'), Post::v('unsub_url'), $flags, Post::t('welcome_msg'), Post::v('status'), $globals->asso('id'));
         }
         Phone::deletePhones(0, Phone::LINK_GROUP, $globals->asso('id'));
         $phone = new Phone(array('link_type' => 'group', 'link_id' => $globals->asso('id'), 'id' => 0, 'type' => 'fixed', 'display' => Post::v('phone'), 'pub' => 'public'));
         $fax = new Phone(array('link_type' => 'group', 'link_id' => $globals->asso('id'), 'id' => 1, 'type' => 'fax', 'display' => Post::v('fax'), 'pub' => 'public'));
         $phone->save();
         $fax->save();
         Address::deleteAddresses(null, Address::LINK_GROUP, null, $globals->asso('id'));
         $address = new Address(array('groupid' => $globals->asso('id'), 'type' => Address::LINK_GROUP, 'text' => Post::v('address')));
         $address->save();
         if ($_FILES['logo']['name']) {
             $upload = PlUpload::get($_FILES['logo'], $globals->asso('id'), 'asso.logo', true);
             if (!$upload) {
                 $page->trigError("Impossible de télécharger le logo.");
             } else {
                 XDB::execute('UPDATE  groups
                                  SET  logo = {?}, logo_mime = {?}
                                WHERE  id = {?}', $upload->getContents(), $upload->contentType(), $globals->asso('id'));
                 $upload->rm();
             }
         }
         XDB::execute("UPDATE  group_members\n                             SET  flags = ''\n                           WHERE  asso_id = {?}", $globals->asso('id'));
         if (!$notify_all) {
             XDB::execute("UPDATE  group_members\n                                 SET  flags = 'notify'\n                               WHERE  asso_id = {?} AND uid IN {?}", $globals->asso('id'), $to_notify);
         }
         pl_redirect('../' . Post::v('diminutif', $globals->asso('diminutif')) . '/edit');
     }
     $uf = new UserFilter(new UFC_Group($globals->asso('id'), true, UFC_Group::NOTIFIED));
     $page->assign('notified', $uf->getUsers());
     $uf = new UserFilter(new UFC_Group($globals->asso('id'), true, UFC_Group::UNNOTIFIED));
     $page->assign('unnotified', $uf->getUsers());
     $page->assign('error', $error);
     $page->assign('cat', $globals->asso('cat'));
     $page->assign('dom', $globals->asso('dom'));
     $page->assign('ax', $globals->asso('ax'));
     $page->assign('inscriptible', $globals->asso('inscriptible'));
     $page->assign('pub', $globals->asso('pub'));
     $page->assign('notif_unsub', $globals->asso('notif_unsub'));
     $page->assign('notify_all', $globals->asso('notify_all'));
     $page->assign('disable_mails', $globals->asso('disable_mails'));
     $page->assign('status', $globals->asso('status'));
 }
Beispiel #12
0
 public function commit()
 {
     $res = XDB::query('SELECT  id
                          FROM  profile_job_enum
                         WHERE  name = {?}', $this->name);
     if ($res->numRows() != 1) {
         XDB::execute('INSERT INTO  profile_job_enum (name, acronym, url, email, holdingid, SIREN_code, NAF_code, AX_code)
                            VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $this->name, $this->acronym, $this->url, $this->email, $this->holdingid, $this->SIREN, $this->NAF_code, $this->AX_code);
         $jobid = XDB::insertId();
         $phone = new Phone(array('link_type' => 'hq', 'link_id' => $jobid, 'id' => 0, 'type' => 'fixed', 'display' => $this->tel, 'pub' => 'public'));
         $fax = new Phone(array('link_type' => 'hq', 'link_id' => $jobid, 'id' => 1, 'type' => 'fax', 'display' => $this->fax, 'pub' => 'public'));
         $address = new Address(array('jobid' => $jobid, 'type' => Address::LINK_COMPANY, 'text' => $this->address));
         $phone->save();
         $fax->save();
         $address->save();
     } else {
         $jobid = $res->fetchOneCell();
     }
     XDB::execute('UPDATE  profile_job
                      SET  jobid = {?}
                    WHERE  pid = {?} AND id = {?}', $jobid, $this->profile->id(), $this->id);
     if (XDB::affectedRows() == 0) {
         return XDB::execute('INSERT INTO  profile_job (jobid, pid, id)
                                   VALUES  ({?}, {?}, {?})', $jobid, $this->profile->id(), $this->id);
     }
     return true;
 }
Beispiel #13
0
    echo json_encode(objectToArray(json_decode($phones)));
});
// Get specific phone
$contactList->get("/phones/:id", function ($id) use($contactList) {
    $phones = Phone::find($id);
    $contactList->response()->header('Content-Type', 'application/json');
    echo json_encode(objectToArray(json_decode($phones)));
});
// Add new phone
$contactList->post("/phones", function () use($contactList) {
    $contactId = $contactList->request->params('contactid');
    $phone = $contactList->request->params('phone');
    $newPhone = new Phone();
    $newPhone->contactId = $contactId;
    $newPhone->phone = $phone;
    if ($newPhone->save()) {
        $data['msg'] = 'Phone saved successfully!';
        $data['id'] = $newPhone->id;
    } else {
        $data['msg'] = 'An error occurred while saving the phone!';
    }
    $contactList->response()->header('Content-Type', 'application/json');
    echo json_encode($data);
});
// Edit phone
$contactList->put("/phones/:id", function ($id) use($contactList) {
    $phone = $contactList->request->params('phone');
    $editPhone = Phone::find($id);
    $editPhone->phone = $phone;
    if ($editPhone->save()) {
        $data['msg'] = 'Phone saved successfully!';