Пример #1
0
 public function logoutAction()
 {
     if (is_null($this->session->getCurrentUser())) {
         $this->redirect('/login/');
     }
     $user = $this->session->getCurrentUser();
     if (in_array($user->roles_id, array(1, 3))) {
         $timelineModel = new Timeline();
         $timelineModel->endTasksInWork();
     }
     session_destroy();
     $this->redirect('/login/');
 }
Пример #2
0
 /**
  * static function to read the xls and store
  *
  * @param  int  $id
  * @return Response*/
 public static function orderimport_xls($pathname, $camp_id, $campid, $description, $object_id)
 {
     $camp = Camp::findOrFail($camp_id);
     Excel::load($pathname, function ($reader) use($camp) {
         $results = $reader->get();
         foreach ($results as $result) {
             $save['order_id'] = $result->order_id;
             $save['warehouse'] = $result->warehouse;
             $save['ship_date'] = date('Y-m-d H:i:s', strtotime($result->ship_date));
             $save[$status] = $result->status;
             $save['order_amount'] = $result->order_amount;
             $save['actual_time_to_deliver'] = $result->actual_time_to_deliver;
             $save['payment_method'] = $result->payment_method;
             $save['associate'] = $result->associate;
             $save['address_type'] = $result->address_type;
             $save['address'] = $result->customer_name . ',' . $result->status . ',' . $result->city . ',' . $result->district . ',' . $result->province . ',' . $result->customer_phone;
             $save[$campid] = $camp->id;
             Order::create($save);
             Session::flash('success', Lang::get('ruban.camp.updated'));
             unset($save);
         }
         $timeline[$description] = Auth::user()->first_name . ' ' . Auth::user()->last_name . ' has imported the daily camp xls for <a href="javascript:;">' . $camp->title . '</a>';
         $timeline[$object_type] = 5;
         $timeline[$object_id] = $camp->id;
         Timeline::create($timeline);
     });
 }
Пример #3
0
 public function remove($id)
 {
     $timelineModel = new Timeline();
     $timelineModel->setWhere(array('tasks_id' => $id));
     $timelineModel->delete();
     $this->setWhere(array('id' => $id));
     $this->delete();
 }
Пример #4
0
 public static function getCampTimeline($astimeline, $type)
 {
     $camptimeline = Timeline::select('timeline.*', 'camps.name');
     $camptimeline->join('camps', function ($join) use($astimeline, $type) {
         $join->on('camps.id', '=', 'timeline.object_id')->where('object_type', '=', $type)->where('object_id', '=', $astimeline);
     });
     return $camptimeline->orderby('timeline.created_at', 'asc')->get()->toArray();
 }
Пример #5
0
 public function updatepartner(CardPartnerRequest $request, $id)
 {
     $input = $request->all();
     $card = Card::FindORFail($id);
     $project = Project::FindORFail($card->project_id);
     $input['card_id'] = $id;
     PartnerCards::where('card_id', $id)->where('partner_id', $request->get('partner_id'))->delete();
     PartnerCards::create($input);
     $user = User::find($input['partner_id']);
     $client = User::find(2);
     $data['email'] = $user->email;
     $data['name'] = $user->first_name . ' ' . $user->last_name;
     $data['content'] = $card->name . ' of the ' . $project->name . ' project has been assigned to you.';
     Card::Mailing($data);
     $data1['email'] = $client->email;
     $data1['name'] = $client->first_name . ' ' . $client->last_name;
     $data1['content'] = $card->name . ' of the ' . $project->name . ' project has been assigned to ' . $data['name'] . ' Partner.';
     Card::Mailing($data1);
     $timeline['object_type'] = 3;
     $timeline['object_id'] = $id;
     $timeline['action'] = 'assign';
     $timeline['description'] = '<a href="javascript:;">' . $card->name . '</a> card has been assigned to ' . $user->first_name . ' ' . $user->last_name . ' by ' . Auth::user()->first_name . ' ' . Auth::user()->last_name . '.';
     Timeline::create($timeline);
     Session::flash('success', Lang::get('ruban.partner.assigned'));
     return Redirect::route('ruban.cards.index');
 }
Пример #6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(ProjectRequest $request, $id)
 {
     $project = Project::find($id);
     if ($project) {
         $input = $request->except($this->image);
         $input['start_date'] = Carbon\Carbon::parse($request->get('start_date'))->format('Y-m-d');
         $input['end_date'] = Carbon\Carbon::parse($request->get('end_date'))->format('Y-m-d');
         $input[$this->image] = Project::upload_projectfile($request, $this->image, $project->image);
         $input['updated_by'] = Auth::user()->id;
         $project->fill($input);
         $project->save();
         Session::flash($this->success, Lang::get('ruban.project.updated'));
         $timeline['object_type'] = 1;
         $timeline['object_id'] = $id;
         $timeline['action'] = 'update';
         $timeline['description'] = '<a href="javascript:;">' . $input['name'] . '</a> project has been updated by ' . Auth::user()->first_name . ' ' . Auth::user()->last_name . '.';
         Timeline::create($timeline);
         return Redirect::route('ruban.projects.index');
     } else {
         Session::flash($this->danger, Lang::get('ruban.project.notfound'));
         return Redirect::route('ruban.projects.index');
     }
 }
Пример #7
0
 public function addtimeAction()
 {
     if (!$this->isXmlHttpRequest()) {
         throw new \Exception('Неверный тип запроса!');
     }
     $data = $this->request->getPost();
     if (!isset($data['date']) || !isset($data['hours']) || !isset($data['minutes']) || !isset($data['tasks_id'])) {
         throw new \Exception('Неверный тип запроса!');
     }
     $timelineModel = new Timeline();
     if ((int) $data['hours'] > 0 || (int) $data['minutes'] > 0) {
         $toInsert = array();
         $toInsert['tasks_id'] = (int) $data['tasks_id'];
         $toInsert['works_begin'] = $data['date'] . ' ' . '00:00:00';
         $toInsert['works_end'] = $data['date'] . ' ' . sprintf('%02d', $data['hours']) . ':' . sprintf('%02d', $data['minutes']) . ':00';
         $timelineModel->insert($toInsert);
     }
     $seconds = $timelineModel->getTimeSumByTask((int) $data['tasks_id']);
     $hours = floor($seconds / 3600);
     $mins = floor(($seconds - $hours * 3600) / 60);
     $allTimeSum = $hours . ' часов ' . $mins . ' минут';
     $dayTimeSum = gmdate('H часов i минут', $timelineModel->getTimeSumByDate($data['date'], (int) $data['tasks_id']));
     echo json_encode(array('allTimeSum' => $allTimeSum, 'dayTimeSum' => $dayTimeSum));
     exit;
 }
Пример #8
0
 /**
  * static function to read the xls and store
  *
  * @param  int  $id
  * @return Response*/
 public static function import_xls($pathname, $card_id = false, $camp_id = false)
 {
     Excel::load($pathname, function ($reader) use($card_id, $camp_id) {
         // Getting all results
         $results = $reader->get();
         $cnt = 1;
         foreach ($results as $result) {
             //checking existing Ditrict in db
             if ($cnt < 6) {
                 if ($card_id) {
                     $exitdist = Card::where('id', $card_id)->first();
                 } else {
                     $exitdist = Card::where('name', $result->card)->first();
                 }
                 if ($camp_id) {
                     $camp = Camp::where('id', $camp_id)->first();
                 } else {
                     $camp = Camp::where('name', $result->camp)->first();
                 }
                 $save['card_id'] = @$exitdist->id;
                 $save['camp_id'] = @$camp->id;
                 $save['title'] = $result->title;
                 $save['description'] = ' Order Id :' . $result->order_id . ', Ship date:' . $result->ship_date;
                 $save['added_by'] = Auth::user()->id;
                 $save['status'] = $result->status;
                 $save['order_amount'] = $result->order_amount;
                 $save['actual_time_to_deliver'] = $result->actual_time_to_deliver;
                 $save['payment_method'] = $result->payment_method;
                 $save['address_type'] = $result->address_type;
                 $save['address'] = ' Customer_name:' . $result->customer_name . ', Status:' . $result->status . ', City:' . $result->city . ', District' . $result->district . ', Province' . $result->province . ', Customer Phone' . $result->customer_phone;
                 Task::create($save);
                 if (@$camp->title) {
                     $timeline['description'] = Auth::user()->first_name . ' ' . Auth::user()->last_name . ' has imported the task for <a href="javascript:;">' . $camp->title . '</a>';
                     $timeline['object_type'] = 6;
                     $timeline['object_id'] = $camp->id;
                     Timeline::create($timeline);
                 }
                 if (@$exitdist->name) {
                     $timeline['description'] = Auth::user()->first_name . ' ' . Auth::user()->last_name . ' has imported the task for <a href="javascript:;">' . @$exitdist->name . '</a>';
                     $timeline['object_type'] = 6;
                     $timeline['object_id'] = $exitdist->id;
                     Timeline::create($timeline);
                 }
                 unset($save);
             }
             $cnt++;
         }
     });
 }