Exemplo n.º 1
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);
     });
 }
Exemplo n.º 2
0
 public static function get_camppayouts($card_id, $status = false)
 {
     $camppayouts = Camp::where('card_id', $card_id);
     if ($status) {
         $camppayouts->where('status', $status);
     }
     return $camppayouts->count();
 }
Exemplo n.º 3
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $data['colors'] = array('red', 'yellow', 'aqua', 'blue', 'light-blue', 'green', 'navy', 'teal', 'olive', 'lime', 'orange', 'fuchsia', 'purple', 'maroon', 'black', 'red-active', 'yellow-active', 'aqua-active', 'blue-active', 'light-blue-active', 'green-active', 'navy-active', 'teal-active', 'olive-active', 'lime-active', 'orange-active', 'fuchsia-active', 'purple-active', 'maroon-active', 'black-active');
     $data['card'] = $card = Card::get_card_result($id);
     if ($card) {
         $data['project'] = Project::find($card->project_id);
         $data['goals'] = Project::get_goals($card->project_id);
         $data['campgoals'] = Card::get_campgoals($id);
         $data['plannedcampgoals'] = Card::get_panned_campgoals($id);
         $data['partner'] = Card::get_partner($id, $card->sector_id);
         $data['partners'] = Card::get_partners($id, $card->sector_id);
         $data['camps'] = Camp::where('card_id', $id)->get()->toArray();
         $data['selectedpartner'] = PartnerCards::where('card_id', $id)->first();
         $data['cardtimelines'] = Timeline::getFinalCardTimeline($id, 2);
         $data['campcreatebtn'] = Permission::hasPermission('camps.create');
         $data['campeditbtn'] = Permission::hasPermission('camps.edit');
         $data['campdeletebtn'] = Permission::hasPermission('camps.delete');
         $data['campimportbtn'] = Permission::hasPermission('camps.import');
         $data['taskimportbtn'] = Permission::hasPermission('tasks.import');
         $data['taskeditbtn'] = Permission::hasPermission('tasks.edit');
         $data['taskcreatebtn'] = Permission::hasPermission('tasks.create');
         $data['taskdeletebtn'] = Permission::hasPermission('tasks.delete');
         $data['tasklistbtn'] = Permission::hasPermission('tasks.index');
         $data['campviewbtn'] = Permission::hasPermission('camps.show');
         $data['tasks'] = Task::all();
         return view('cards.view', $data);
     } else {
         Session::flash('danger', Lang::get('ruban.card.notfound'));
         return Redirect::route('ruban.cards.index');
     }
 }
Exemplo n.º 4
0
 /**
  * get the palnned goal completion for the specified cards with camps
  * params @int $id
  *
  * return array
  */
 public static function get_panned_campgoals($id)
 {
     $pannedcamp = Camp::select(DB::Raw('sum(rb_camps.budget) as budget'), DB::Raw('count(rb_camps.id) as camps'), DB::Raw('sum(rb_camps.no_of_people) as total_villagers'), DB::Raw('sum(rb_camps.order) as orders'), DB::Raw('avg(rb_camps.deliver_time) as deliver_time'));
     $pannedcamp->join(static::$cards, static::$c_id, '=', 'camps.card_id');
     $pannedcamp->where('camps.card_id', $id);
     return $pannedcamp->first();
 }
Exemplo n.º 5
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++;
         }
     });
 }