Exemplo n.º 1
0
 public static function sendManualEmail($memberid, $contactid, $templateid)
 {
     $contact = Contact::findOrFail($contactid);
     $user = User::findOrFail($memberid);
     if (!$user || !$contact) {
         return false;
     }
     if (!$user->active || !$contact->active) {
         return false;
     }
     if (EmailSchedullerPool::sendmail($memberid, $contactid, $templateid)) {
         if ($contact->email_sent == "" || $contact->email_sent == 0) {
             $contact->email_sent = $templateid;
             $contact->last_follow_up = date('Y-m-d H:i:s');
             $contact->save();
         } else {
             if ($contact->templateExist($templateid)) {
                 //do nothing
             } else {
                 $contact->email_sent = $contact->email_sent . "," . $templateid;
                 $contact->save();
             }
         }
         $contact->saveHistory("success", $memberid, $templateid);
         return true;
     } else {
         return false;
     }
 }
 public function storeProcess($job, $data)
 {
     //Log::info(['STORE', $data]);
     $ac_contact = ['email' => $data['email'], 'first_name' => $data['name'], 'last_name' => $data['surname'], 'phone' => $data['phone'], 'orgname' => 'Acme, Inc.', 'tags' => 'api,test', 'field[1,0]' => $data['field1'], 'field[2,0]' => $data['field2'], 'field[3,0]' => $data['field3'], 'field[4,0]' => $data['field4'], 'field[5,0]' => $data['field5'], "p[1]" => 1, "status[1]" => 1];
     $result = $this->activeCampaignAPI('contact/add', $ac_contact);
     if ($result[0] == 'ok') {
         $contact = Contact::findOrFail($data['id']);
         $contact->ac_subscriber_id = $result[1];
         $contact->save();
     } else {
         // error, already logged.
     }
     $job->delete();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $contact = Contact::findOrFail($id);
     if ($contact->user->id == Auth::User()->id) {
         $contact->delete();
         Queue::push('activeCampaignWorker@deleteProcess', $contact);
         return Response::json(["ok", ""]);
     } else {
         return Response::json(["error", "Contact doesn't exist or not from the authenticaded user."]);
     }
 }
Exemplo n.º 4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function getDelete($id)
 {
     if (Session::get('user_level') < Config::get('cms.deleteContacts')) {
         return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning');
     }
     try {
         $contact = Contact::findOrFail($id);
         $contact->marks()->delete();
         $contact->newsContacts()->delete();
         $contact->delete();
         return Redirect::to(_l(URL::action('ContactController@getIndex')))->with('message', Lang::get('admin.contactDeleted'))->with('notif', 'success');
     } catch (Exception $e) {
         return Redirect::to(_l(URL::action('ContactController@getIndex')))->with('message', Lang::get('admin.noSuchContact'))->with('notif', 'danger');
     }
 }
 /**
  * Update the specified resource in storage.
  * PUT /frontend/publiccontact/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function oceni($id)
 {
     try {
         if (!Session::get('id')) {
             return Redirect::to(Request::root() . '/login?ref=' . rawurlencode("ljudi/" . $id));
         } else {
             $contact = Contact::findOrFail($id);
             $update = false;
             try {
                 $mark = Mark::where('people_id', '=', $id)->where('user_id', '=', Session::get('id'))->firstOrFail();
                 $update = true;
             } catch (Exception $e) {
                 $mark = new Mark();
             }
             $mark->user_id = Session::get('id');
             $mark->people_id = $id;
             $mark->uskladjenost = Input::get('uskladjenost');
             $mark->jasnost = Input::get('jasnost');
             $mark->interakcija = Input::get('interakcija');
             $mark->komunikacija = Input::get('komunikacija');
             $mark->konflikt = Input::get('konflikt');
             $mark->inspiracija = Input::get('inspiracija');
             $mark->aktivnost = Input::get('aktivnost');
             $mark->kvalitet_literature = Input::get('literatura');
             $mark->student_relations = Input::get('odnos');
             $avg = ($mark->uskladjenost + $mark->jasnost + $mark->interakcija + $mark->komunikacija + (11 - $mark->konflikt) + $mark->inspiracija + $mark->aktivnost + $mark->kvalitet_literature + $mark->student_relations) / 9;
             $mark->total_impression = $avg;
             $mark->note = Input::get('komentar');
             $mark->save();
             $mark_count = Mark::where('people_id', '=', $id)->count();
             $contact->mark_count++;
             $contact->uskladjenost = ($contact->uskladjenost * ($mark_count - 1) + $mark->uskladjenost) / $mark_count;
             $contact->jasnost = ($contact->jasnost * ($mark_count - 1) + $mark->jasnost) / $mark_count;
             $contact->interakcija = ($contact->interakcija * ($mark_count - 1) + $mark->interakcija) / $mark_count;
             $contact->komunikacija = ($contact->komunikacija * ($mark_count - 1) + $mark->komunikacija) / $mark_count;
             $contact->konflikt = ($contact->konflikt * ($mark_count - 1) + $mark->konflikt) / $mark_count;
             $contact->inspiracija = ($contact->inspiracija * ($mark_count - 1) + $mark->inspiracija) / $mark_count;
             $contact->aktivnost = ($contact->aktivnost * ($mark_count - 1) + $mark->aktivnost) / $mark_count;
             $contact->kvalitet_literature = ($contact->kvalitet_literature * ($mark_count - 1) + $mark->kvalitet_literature) / $mark_count;
             $contact->student_relations = ($contact->student_relations * ($mark_count - 1) + $mark->student_relations) / $mark_count;
             $contact->total_impression = ($contact->total_impression * ($mark_count - 1) + $mark->total_impression) / $mark_count;
             $contact->save();
             if ($update) {
                 return Redirect::to(Request::root() . '/ljudi/' . $id)->with('notif', 'success')->with('message', __("Оцена предавача ажурирана"));
             }
             return Redirect::to(Request::root() . '/ljudi/' . $id)->with('notif', 'success')->with('message', __("Успешно сте оценили предавача"));
         }
     } catch (Exception $e) {
         return Redirect::to(Request::root() . '/ljudi/' . $id)->with('notif', 'danger')->with('message', __("Одабрани предавач не постоји"));
     }
 }
Exemplo n.º 6
0
 /**
  * Update the specified Contact in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $contact = Contact::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Contact::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $contact->update($data);
     return Redirect::route(Auth::user()->roleString() . '.contacts.index')->with("message", "Data berhasil disimpan");
 }