public function exportExcelPaymentDetail($id)
 {
     $model = new PaymentRequestDetailBaseModel();
     $data['data'] = $model->getItemsByPaymentRequestId($id);
     if (count($data['data']) > 0) {
         $data['publisher'] = $data['data']['0']->publisher;
         if ($data['publisher']) {
             $pid = $data['publisher']->id;
             $data['pubName'] = PublisherBaseModel::getPublisherName($pid);
         } else {
             $data['pubName'] = '';
         }
         return $model->exportExcel($data);
     } else {
         return Redirect::to($this->moduleURL . 'payment-request/waiting');
     }
 }
Exemplo n.º 2
0
 public function createMonthlyPaymentRequest()
 {
     $startDate = Carbon::now()->firstOfMonth()->subMonth();
     $endDate = Carbon::now()->firstOfMonth()->subMonth()->lastOfMonth();
     $date = $startDate->format('Y-m');
     $check = PaymentRequestBaseModel::where(array('publisher_id' => $this->id, 'date' => $date))->first();
     $websiteLists = $this->publisherSite->lists('id');
     if (empty($check)) {
         $tracking = new TrackingSummaryBaseModel();
         $data = $tracking->sumEarnPerCampaign($websiteLists, $startDate, $endDate);
         $campaigns = $data['campaign'];
         $total = $data['total'];
         $pr = new PaymentRequestBaseModel();
         $pr->publisher_id = $this->id;
         $pr->date = $date;
         $pr->amount = $total;
         $pr->save();
         if (!empty($campaigns)) {
             foreach ($campaigns as $campaignID => $campaign) {
                 $prd = new PaymentRequestDetailBaseModel();
                 $prd->publisher_id = $this->id;
                 $prd->campaign_id = $campaignID;
                 $prd->amount = $campaign['cost'];
                 $prd->impression = $campaign['impression'];
                 $prd->click = $campaign['click'];
                 if ($campaign['click'] != 0 && $campaign['impression'] != 0) {
                     $prd->ctr = $campaign['click'] / $campaign['impression'];
                 } else {
                     $prd->ctr = 0;
                 }
                 $prd->date = $date;
                 $prd->payment_request_id = $pr->id;
                 $prd->save();
             }
         }
     }
 }
 public function exportExcelPaymentDetail($id)
 {
     $model = new PaymentRequestDetailBaseModel();
     $data['data'] = $model->getItemsByPaymentRequestId($id);
     if (count($data['data']) > 0) {
         $data['publisher'] = $data['data']['0']->publisher;
         $data['pubName'] = Sentry::getUser()->username;
         return $model->exportExcel($data);
     } else {
         return Redirect::to($this->moduleURL . 'payment-request');
     }
 }