예제 #1
0
 /**
  * 使用 Bill 模型实例填充表单。用于 Update 方法。
  *
  * @param Bill  $bill
  * @param array $fields
  *
  * @return array
  */
 protected function fieldsFromModel(Bill $bill, array $fields)
 {
     $fieldNames = array_keys(array_except($fields, ['categories']));
     $fields = ['id' => $this->bill->id];
     foreach ($fieldNames as $field) {
         $fields[$field] = $bill->{$field};
     }
     $fields['categories'] = $bill->categories()->lists('name')->all();
     return $fields;
 }
예제 #2
0
파일: SendEmail.php 프로젝트: enspdf/billr
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // grab the user
     $user = User::find($this->user_id);
     // grab the bill
     $bill = Bill::find($this->bill_id);
     // check the user hasn't been disabled
     if (empty($user)) {
         return false;
     }
     // validate that the user has an email
     if (empty($user['email'])) {
         return false;
     }
     // setup the default template
     $template = 'emails.email.notification';
     // setup the default subject
     $subject = 'Upcoming Bill - ' . $bill->company['name'] . ' (' . $bill['amount'] . ') on ' . date('F d, Y', strtotime($bill['due']));
     // check to see if this bill is over due
     if ($this->isOverDue) {
         $template = 'emails.email.notification_overdue';
         $subject = 'Overdue Bill - ' . $bill->company['name'] . ' (' . $bill['amount'] . ') on ' . date('F d, Y', strtotime($bill['due'])) . '!';
     }
     // Try to send an Email
     Mail::send($template, ['bill' => $bill], function ($message) use($user, $subject) {
         $message->from('*****@*****.**', 'MyBillr Notification');
         $message->subject($subject);
         $message->to($user['email']);
     });
 }
 /**
  * Create a new event instance.
  *
  * @param $c_id
  * @param $nom_responsable
  * @param $nom_enfant
  * @param $date_inscription
  * @param $date_prochain_paiement
  * @param $pseudo_compte_famille
  * @param $responsable
  * @param $mot_de_pass_temporaire_compte_famille
  */
 public function __construct($c_id, $nom_responsable, $nom_enfant, $date_inscription, $date_prochain_paiement, $pseudo_compte_famille, $responsable, $mot_de_pass_temporaire_compte_famille)
 {
     $this->child_id = $c_id;
     $this->nom_responsable = $nom_responsable;
     $this->nom_enfant = $nom_enfant;
     $this->date_inscription = $date_inscription;
     $this->date_prochain_paiement = $date_prochain_paiement;
     $this->pseudo_compte_famille = $pseudo_compte_famille;
     $this->responsable = $responsable;
     $this->mot_de_pass_temporaire_compte_famille = $mot_de_pass_temporaire_compte_famille;
     $user = new User();
     $user->nom_responsable = $this->nom_responsable;
     $user->name = $this->nom_responsable;
     $user->type = 'famille';
     $user->email = $this->pseudo_compte_famille;
     $user->password = \Hash::make($this->mot_de_pass_temporaire_compte_famille);
     if ($this->responsable == 1) {
         $user->sexe = 'homme';
     } else {
         $user->sexe = 'femme';
     }
     $user->save();
     if ($user) {
         $child = Child::findOrFail($this->child_id);
         $child->f_id = $user->id;
         $child->save();
         $bill = Bill::where('child_id', $this->child_id)->first();
         $bill->f_id = $user->id;
         $bill->save();
         $info = ['responsable' => $this->nom_responsable, 'nom_enfant' => $this->nom_enfant, 'date_inscription' => $this->date_inscription, 'date_pro_paim' => $this->date_prochain_paiement, 'pseudo_email' => $this->pseudo_compte_famille, 'respons' => $this->responsable, 'pass' => $this->mot_de_pass_temporaire_compte_famille];
         Mail::queue('emails.test', $info, function ($message) {
             $message->to($this->pseudo_compte_famille, 'ok')->from('*****@*****.**')->subject('Bienvenue  !');
         });
     }
 }
예제 #4
0
 /**
  * Handle creation of new bill.
  *
  * @param CreateBillRequest $request
  * @return array
  */
 public function create(CreateBillRequest $request)
 {
     // Save request data
     $clientName = $request->get('client');
     $useCurrentCampaign = $request->get('use_current_campaign');
     $campaignYear = $request->get('campaign_year');
     $campaignNumber = $request->get('campaign_number');
     $client = DB::table('clients')->where('name', $clientName)->where('user_id', Auth::user()->id)->first();
     // Create new client if not exists
     if (!$client) {
         $client = new Client();
         $client->user_id = Auth::user()->id;
         $client->name = $clientName;
         $client->save();
     }
     // Create new bill
     $bill = new Bill();
     $bill->client_id = $client->id;
     $bill->user_id = Auth::user()->id;
     $campaign = Campaigns::current();
     // Check if current campaign should be used
     if (!$useCurrentCampaign) {
         $campaign = Campaign::where('year', $campaignYear)->where('number', $campaignNumber)->first();
     }
     $bill->campaign_id = $campaign->id;
     $bill->campaign_order = Campaigns::autoDetermineOrderNumber($campaign, $client->id);
     $bill->save();
     event(new UserCreatedNewBill(Auth::user()->id, $bill->id));
     // Return response
     $response = new AjaxResponse();
     $response->setSuccessMessage(trans('bills.bill_created'));
     return response($response->get());
 }
예제 #5
0
 /**
  * Create a new event instance.
  *
  * @param $start
  * @param $end
  * @param $status
  * @param $somme
  * @param $child_id
  * @param $user_id
  */
 public function __construct($start, $end, $status, $somme, $child_id, $user_id)
 {
     $this->start = $start;
     $this->end = $end;
     $this->status = $status;
     $this->somme = $somme;
     $this->child_id = $child_id;
     $this->user_id = $user_id;
     $bill = new Bill();
     $bill->start = $this->start;
     $bill->end = $this->end;
     $bill->status = intval($this->status);
     $bill->somme = $this->somme;
     $bill->child_id = $this->child_id;
     $bill->user_id = $this->user_id;
     $bill->save();
 }
예제 #6
0
파일: Campaigns.php 프로젝트: bitller/nova
 /**
  * Auto determine order number for given client.
  *
  * @param object $campaign
  * @param int $clientId
  * @return int
  */
 public static function autoDetermineOrderNumber($campaign, $clientId)
 {
     $query = Bill::where('campaign_id', $campaign->id)->where('client_id', $clientId)->max('campaign_order');
     if (!$query) {
         return 1;
     }
     return $query + 1;
 }
예제 #7
0
 public function export(Request $request)
 {
     $bill = new Bill();
     $builder = $bill->newQuery();
     $page = $bill->input('page') ?: 0;
     $pagesize = $request->input('pagesize') ?: config('site.pagesize.export', 1000);
     $total = $this->_getCount($request, $builder);
     if (empty($page)) {
         $this->_of = $request->input('of');
         $this->_table = $bill->getTable();
         $this->_total = $total;
         $this->_pagesize = $pagesize > $total ? $total : $pagesize;
         return $this->view('agent-backend.statement.export');
     }
     $data = $this->_getExport($request, $builder);
     return $this->success('', FALSE, $data);
 }
예제 #8
0
 /**
  * Normal user tries to delete all user bills.
  */
 public function test_normal_user_delete_all_user_bills()
 {
     $billIds = ['user_id' => $this->user->id, 'client_id' => $this->client->id];
     // Generate paid bills
     factory(\App\Bill::class, 'paid', 4)->create($billIds);
     // Generate unpaid bills
     factory(\App\Bill::class, 4)->create($billIds);
     $this->actingAs(factory(\App\User::class)->create())->post('/admin-center/users-manager/user/' . $this->user->id . '/delete-all-bills')->assertEquals(8, \App\Bill::where('user_id', $this->user->id)->where('client_id', $this->client->id)->count());
 }
예제 #9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $bill = Bill::findOrFail($id);
     if (policy($bill)->destroy(Auth::user(), $bill)) {
         $bill->delete();
         $successInfo = '成功删除账单 <strong>' . $bill->name . '</strong>。';
         return redirect('bill')->withSuccess($successInfo);
     } else {
         return redirect('bill')->withErrors('你没有足够的权限来执行此操作。');
     }
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     foreach ($this->testBills as $bill) {
         $defaultCategories = $this->user->categories->random(2);
         $categoriesNames = $defaultCategories->pluck('name')->toArray();
         $bill['user_id'] = $this->user->id;
         $bill['made_at'] = Carbon::now()->subDays($bill['made_at']);
         $bill_model = Bill::create($bill);
         $bill_model->syncCategories($categoriesNames);
     }
 }
예제 #11
0
파일: Bill.php 프로젝트: enspdf/billr
 /**
  * loads the bill handling the authentication
  * @param  integer $id bill id
  * @return bill    bill array
  */
 public static function loadBill($id)
 {
     $bill = array();
     $bill = Bill::find($id);
     if (!empty($bill)) {
         if (Auth::id() != $bill['user_id']) {
             return array();
         }
     }
     return $bill;
 }
예제 #12
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //
     $company = Company::find($id);
     $branches = Branch::where("company_id", "=", $company->id)->get();
     $stacks = Invoicingstack::where("company_id", "=", $company->id)->where("status", "=", 0)->get();
     $stack2s = Invoicingstack::where("company_id", "=", $company->id)->get();
     $invoice = Bill::where("company_id", "=", $company->id)->get();
     $invoiceGroup = Bill::where("company_id", "=", $company->id)->groupBy("invoice_date")->get();
     return View("company.companydetail", ['invGp' => $invoiceGroup, 'stacks' => $stacks, 'stack2s' => $stack2s, 'invoices' => $invoice, 'company' => $company, 'branches' => $branches, 'title' => 'Company Detail']);
 }
예제 #13
0
파일: User.php 프로젝트: bitller/nova
 /**
  * Get clients of given user.
  *
  * @param bool $userId
  * @return mixed
  */
 public static function getClients($userId = false)
 {
     // If an user id is not given use the id of current logged in user
     if (!$userId) {
         $userId = Auth::user()->id;
     }
     $clients = Client::where('user_id', $userId)->paginate();
     foreach ($clients as &$client) {
         $client->orders = Bill::where('client_id', $client->id)->count();
     }
     return response($clients)->header('Content-Type', 'application/json');
 }
예제 #14
0
 public function create()
 {
     //帐户余额
     $amount = UserFinance::findOrNew($this->agent->getKey())->money;
     //查找当前用户冻结金额 取出7天奖金
     $freeze_money = Bill::whereRaw("uid = ? and is_dealt = ? and created_at>='?' and event in( 'commission' , 'income')", array($this->agent->getKey(), 1, date("Y-m-d 00:00:00", strtotime('-7 days'))))->sum('value') ?: 0;
     //可取资金
     $usable_money = intval(($amount - $freeze_money) / ($this->site['withdraw_counter_percent'] + 1));
     $this->_user_money = compact('amount', 'freeze_money', 'usable_money');
     //查找银行卡信息
     $this->_bank_cards = (new UserBankcard())->with('bank_name')->newQuery()->where('uid', $this->agent->getKey())->get();
     $keys = 'money,card_id';
     $this->_data = [];
     $this->_validates = $this->getScriptValidate('withdraw.store', $keys);
     return $this->view('agent-backend.withdraw.create');
 }
예제 #15
0
파일: BillsTest.php 프로젝트: bitller/nova
 /**
  * Make ajax request to get paginated bills
  */
 public function testBillsPagination()
 {
     $numberOfBills = 10;
     // Generate one user
     $user = factory(App\User::class)->create();
     // Generate one client
     $client = $user->clients()->save(factory(App\Client::class)->make());
     // Generate bills
     for ($i = 0; $i < $numberOfBills; $i++) {
         $user->bills()->save(factory(App\Bill::class)->make(['client_id' => $client->id]));
     }
     // Paginate results and compare with json response
     $pagination = Bill::select('bills.id', 'bills.campaign_number', 'bills.campaign_year', 'bills.payment_term', 'bills.other_details', 'clients.name as client_name')->where('bills.user_id', $user->id)->orderBy('bills.created_at', 'desc')->join('clients', function ($join) {
         $join->on('bills.client_id', '=', 'clients.id');
     })->paginate(10);
     $this->actingAs($user)->get('/bills/get')->seeJson(['total' => $pagination->total(), 'per_page' => $pagination->perPage(), 'current_page' => $pagination->currentPage(), 'last_page' => $pagination->lastPage(), 'next_page_url' => $pagination->nextPageUrl(), 'prev_page_url' => $pagination->previousPageUrl()]);
 }
예제 #16
0
 public function index()
 {
     $overdueBills = \App\Bill::before(date('Y-m-d'), false);
     $nextUnpaidBills = \App\Bill::next(30, false);
     $nextPaidBills = \App\Bill::next(30, true);
     $lastPaidBills = \App\Bill::before(date('Y-m-d'), true);
     // refactor into REPORTS
     $report = array();
     // get months
     for ($month = 1; $month <= 12; $month++) {
         $startDate = mktime(0, 0, 0, $month, 1, date('Y'));
         $stopDate = mktime(0, 0, 0, $month, date('t', $startDate), date('Y'));
         $bills = \App\Bill::between(date('Y-m-d', $startDate), date('Y-m-d', $stopDate), true);
         $report['months'][] = date('F Y', $startDate);
         $report['amounts'][] = $bills->sum('amount');
     }
     return view('home.index')->with('overdueBills', $overdueBills)->with('nextUnpaidBills', $nextUnpaidBills)->with('nextPaidBills', $nextPaidBills)->with('lastPaidBills', $lastPaidBills)->with('report', json_encode($report));
 }
예제 #17
0
 /**
  * Return array with bill ids and question marks to be used in prepared sql statement.
  *
  * @param array $config
  * @param array $clientIds
  * @return mixed
  */
 protected static function performGetBillDataQuery($config, $clientIds)
 {
     $billIdsQuery = Bill::where('paid', $config['onlyPaidBills'])->whereIn('client_id', $clientIds)->get();
     // Build string with question marks and remove last comma
     $questionMarks = '';
     foreach ($billIdsQuery as $result) {
         $questionMarks .= '?,';
     }
     $questionMarks = substr($questionMarks, 0, -1);
     // Build array with values
     $billIds = [];
     $stop = 2;
     for ($i = 1; $i <= $stop; $i++) {
         foreach ($billIdsQuery as $result) {
             $billIds[] = $result->id;
         }
     }
     return ['billIds' => $billIds, 'questionMarks' => $questionMarks];
 }
예제 #18
0
 public function edit($id)
 {
     $withdraw = Withdraw::find($id);
     //帐户余额
     $amount = UserFinance::findOrNew($withdraw->uid)->money;
     //查找当前用户冻结金额
     $freeze_money = Bill::whereRaw("uid = ? and is_dealt = ? and created_at>='?' and event in( 'commission' , 'income')", array($withdraw->uid, 1, date("Y-m-d 00:00:00", strtotime('-7 days'))))->sum('value') ?: 0;
     //可取资金
     $usable_money = intval(($amount - $freeze_money) / ($this->site['withdraw_counter_percent'] + 1));
     $this->_user_money = compact('amount', 'freeze_money', 'usable_money');
     $withdraw = Withdraw::with(['bankcards'])->find($id);
     if (empty($withdraw)) {
         return $this->failure_noexists();
     }
     $keys = 'audit,note';
     $this->_validates = $this->getScriptValidate('withdraw.audit', $keys);
     $this->_data = $withdraw;
     return $this->view('admin.withdraw.edit');
 }
예제 #19
0
파일: SendSMS.php 프로젝트: enspdf/billr
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $user = User::find($this->user_id);
     $bill = Bill::find($this->bill_id);
     $template = 'emails.sms.notification';
     if ($this->isOverDue) {
         $template = 'emails.sms.notification_overdue';
     }
     if (empty($user)) {
         return false;
     }
     // validate
     if (empty($user['phone_number']) || empty($user['phone_provider'])) {
         return false;
     }
     // Try to send a SMS
     Mail::send($template, ['bill' => $bill], function ($message) use($user) {
         $message->from('*****@*****.**', 'MyBillr Notification');
         //$message->subject('Upcoming Bill');
         $message->to($user['phone_number'] . $user['phone_provider']);
     });
 }
예제 #20
0
파일: BillData.php 프로젝트: bitller/nova
 /**
  * Check if payment term is passed for given bill.
  *
  * @param int $billId
  * @return bool
  */
 public static function paymentTermPassed($billId)
 {
     if (Bill::where('id', $billId)->where('payment_term', '!=', '0000-00-00')->where('payment_term', '<', date('Y-m-d'))->count()) {
         return true;
     }
     return false;
 }
예제 #21
0
 /**
  * Normal user tries to delete all user paid bills.
  */
 public function test_normal_user_delete_all_user_paid_bills()
 {
     // Generate paid bills
     factory(App\Bill::class, 'paid', 4)->create(['user_id' => $this->user->id, 'client_id' => $this->client->id]);
     $this->actingAs(factory(App\User::class)->create())->post('/admin-center/users-manager/user/' . $this->user->id . '/delete-paid-bills')->seeInDatabase('bills', ['user_id' => $this->user->id, 'paid' => 1])->assertEquals(4, \App\Bill::where('user_id', $this->user->id)->where('paid', 1)->count());
 }
예제 #22
0
 public static function SuccessBill()
 {
     $newBill = Bill::join("customers", "customers.id", "=", "bills.customer_id")->select(["bills.*", "customers.id as customerId", "customers.last_name"])->where("bills.status", 1)->paginate(100);
     return $newBill;
 }
예제 #23
0
 /**
  * @param $ids
  */
 public function exportPdf($ids = null)
 {
     $ids = explode(',', substr($ids, 0, -1));
     $ids = array_unique($ids);
     $model = Child::whereIn('id', $ids)->where('user_id', \Auth::user()->id)->get(['id', 'nom_enfant', 'created_at']);
     Excel::create('La liste des Elèves', function ($excel) use($model, $ids) {
         $excel->sheet('La liste des Elèves', function ($sheet) use($model, $ids) {
             foreach ($model as $child) {
                 $child->time = $child->created_at->toDateString();
                 $count = Bill::where('user_id', \Auth::user()->id)->where('child_id', $child->id)->where('status', 0)->count();
                 if ($count == 0) {
                     $child->status = 'Réglée';
                 } else {
                     $child->status = 'Non Réglée';
                 }
                 foreach ($child->classrooms as $cr) {
                     $child->classe = $cr->nom_classe;
                 }
                 unset($child->created_at);
                 unset($child->id);
             }
             // $sheet->setWidth('D',20);
             $sheet->fromModel($model);
             $sheet->setAllBorders('thin');
             $sheet->setFontFamily('OpenSans');
             $sheet->setFontSize(13);
             $sheet->setFontBold(false);
             for ($i = 1; $i <= count($ids) + 1; $i++) {
                 $sheet->setHeight($i, 25);
                 $sheet->row($i, function ($rows) {
                     $rows->setFontColor('#556b7b');
                     $rows->setAlignment('center');
                 });
                 $sheet->cells('A' . $i . ':' . 'D' . $i, function ($cells) {
                     $cells->setValignment('middle');
                     $cells->setFontColor('#556b7b');
                     $cells->setFont(array('family' => 'OpenSans', 'size' => '13', 'bold' => false));
                 });
             }
             // normal header
             $sheet->cells('A1:D1', function ($cells) {
                 $cells->setBackground('#e9f1f3');
                 $cells->setFontColor('#556b7b');
                 $cells->setFont(array('family' => 'OpenSans', 'size' => '15', 'bold' => true));
             });
             $sheet->row(1, array('Nom Elève', 'Date d\'inscription', 'Statut de Paiement', 'Classe'));
         });
     })->export('pdf');
 }
예제 #24
0
 public function financingSuccess()
 {
     $financeArray = Input::get('financeArray');
     $financingDate = Input::get('financingDate');
     $fundingDate = new Carbon($financingDate);
     $lastBill = Bill::orderBy('bill_date', 'desc')->first();
     if (count($lastBill) > 0) {
         $lastBillCarbon = new Carbon($lastBill->bill_date);
         $diffBillsDate = $lastBillCarbon->diffInDays($fundingDate, false);
     } else {
         $diffBillsDate = 1;
     }
     $messageArray = [];
     foreach ($financeArray as $key) {
         $finance = Finance::find($key);
         $registryDate = new Carbon($finance->date_of_registry);
         $diffDate = $registryDate->diffInDays($fundingDate, false);
         if ($diffBillsDate > 0) {
             if ($diffDate >= 0) {
                 if ($finance->type_of_funding === 'Первый платеж') {
                     $deliveryToFinances = $finance->deliveryToFinance;
                     //проверка лимита
                     $relation = $deliveryToFinances->first()->delivery->relation;
                     $usedLimit = 0;
                     $usedLimit = $relation->deliveries()->where('state', false)->where('status', 'Профинансирована')->sum('balance_owed');
                     $limit = $relation->limit;
                     if ($limit) {
                         $limitValue = $limit->value;
                         $freeLimit = $limitValue - $usedLimit;
                         if ($finance->sum <= $freeLimit) {
                             $finance->date_of_funding = $financingDate;
                             $finance->status = 'Подтверждено';
                             if ($finance->save()) {
                                 foreach ($deliveryToFinances as $deliveryToFinance) {
                                     $delivery = $deliveryToFinance->delivery;
                                     $delivery->date_of_funding = $financingDate;
                                     $delivery->status = 'Профинансирована';
                                     // $delivery->stop_commission = true;
                                     $delivery->save();
                                 }
                             }
                             $callback = 'success';
                             $messageShot = 'Успешно!';
                             $message = 'Финансирование для клиента ' . $finance->client . ' подтверждено';
                             array_push($messageArray, ['callback' => $callback, 'message' => $message, 'message_shot' => $messageShot, 'type' => true, 'data' => $key]);
                         } else {
                             $callback = 'danger';
                             $messageShot = 'Ошибка!';
                             $message = 'Превышен лимит для связи. Клиент: ' . $relation->client->name . ' и Дебитор: ' . $relation->debtor->name;
                             array_push($messageArray, ['callback' => $callback, 'message' => $message, 'message_shot' => $messageShot]);
                         }
                     } else {
                         $callback = 'danger';
                         $messageShot = 'Ошибка!';
                         $message = 'Лимит для связи не найден. Клиент: ' . $relation->client->name . ' и Дебитор: ' . $relation->debtor->name;
                         array_push($messageArray, ['callback' => $callback, 'message' => $message, 'message_shot' => $messageShot]);
                     }
                 } else {
                     $finance->date_of_funding = $financingDate;
                     $finance->status = 'Подтверждено';
                     $finance->save();
                     $callback = 'success';
                     $messageShot = 'Успешно!';
                     $message = 'Финансирование для клиента ' . $finance->client . ' подтверждено';
                     array_push($messageArray, ['callback' => $callback, 'message' => $message, 'message_shot' => $messageShot, 'type' => false]);
                 }
             } else {
                 $callback = 'danger';
                 $messageShot = 'Ошибка!';
                 $message = 'Дата реестра превышает дату финансирования';
                 array_push($messageArray, ['callback' => $callback, 'message' => $message, 'message_shot' => $messageShot]);
             }
         } else {
             $callback = 'danger';
             $messageShot = 'Ошибка!';
             $message = 'Финансирование поставки в закрытом месяце- запрещено!';
             array_push($messageArray, ['callback' => $callback, 'message' => $message, 'message_shot' => $messageShot]);
         }
     }
     return $messageArray;
 }
예제 #25
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return Bill::find($id)->residence;
 }
예제 #26
0
    public function statusindex()
    {
        if (\Request::ajax()) {
            $month = \Input::get('month');
            $year = \Input::get('year');
            $status = \Input::get('status');
            if ($status == 0) {
                $bills = Bill::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('status', 0)->where('user_id', \Auth::user()->id)->get();
                foreach ($bills as $bill) {
                    if ($bill->child->photo) {
                        $photo = asset('uploads/' . $bill->child->photo);
                    } else {
                        $photo = asset('images/' . 'avatar4.jpg');
                    }
                    echo '  <tr>
                             <!--<td><div class="minimal single-row">
                                    <div class="checkbox_liste ">
                                        <input value="' . $bill->id . '" type="checkbox"  name="select[]">
                                    </div>
                                </div></td>-->
                            <td>  ' . $bill->id . '</td>
                            <td><img class="avatar" src="' . $photo . '"></td>
                            <td>' . $bill->child->nom_enfant . '</td>
                            <td> ' . $bill->start->format('d-m-Y') . ' </td>
                            <td>  ' . $bill->somme . '  Dhs</td>
                            <td><span class="label label-danger label-mini">
                               Non réglée </span>
                            </td>
                          <!--  <td>
                                <a  href="' . '#' . '" class="actions_icons delete-bill">
                                    <i class="fa fa-trash-o liste_icons"></i></a>
                                <a class="archive-bill" href="' . '#' . '"><i class="fa fa-archive liste_icons"></i>
                                </a>
                            </td>-->

                            <td><a href="' . action('BillsController@details', [$bill->id]) . '"><div  class="btn_details">Détails</div></a></td>
                        </tr>';
                }
            } else {
                $bills = Bill::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('status', 1)->where('user_id', \Auth::user()->id)->get();
                foreach ($bills as $bill) {
                    if ($bill->child->photo) {
                        $photo = asset('uploads/' . $bill->child->photo);
                    } else {
                        $photo = asset('images/no_avatar.jpg');
                    }
                    echo '  <tr>
                              <!--  <td><div class="minimal single-row">
                                    <div class="checkbox_liste ">
                                        <input value="' . $bill->id . '" type="checkbox"  name="select[]">
                                    </div>
                                </div></td>-->
                            <td>  ' . $bill->id . '</td>
                            <td><img class="avatar" src="' . $photo . '"></td>
                            <td>' . $bill->child->nom_enfant . '</td>
                            <td> ' . $bill->start->format('d-m-Y') . ' </td>
                            <td>  ' . $bill->somme . '  Dhs</td>
                            <td><span class="label label-success label-mini">
                                réglée </span>
                            </td>
                           <!-- <td>
                                <a  href="' . '#' . '" class="actions_icons delete-bill">
                                    <i class="fa fa-trash-o liste_icons"></i></a>
                                <a class="archive-bill" href="' . '#' . '"><i class="fa fa-archive liste_icons"></i>
                                </a>
                            </td>-->

                            <td><a href="' . action('BillsController@details', [$bill->id]) . '"><div  class="btn_details">Détails</div></a></td>
                        </tr>';
                }
            }
        }
    }
예제 #27
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $bill = Bill::find($id);
     if ($bill->delete()) {
         return "Bill with Bill no" . $id . "was removed";
     }
     return " Something happend wrong during deletion of the bill no" . $id;
 }
예제 #28
0
 public function DelBill(Request $request, $billID)
 {
     if ($request->ajax()) {
         $bill = Bill::find($billID);
         $bill->delete();
     }
 }
예제 #29
0
 /**
  * Render unpaid bills page of given client.
  *
  * @param int $clientId
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function unpaidBillsOfThisClient($clientId)
 {
     $client = Client::where('id', $clientId)->where('user_id', Auth::user()->id)->first();
     // Make sure client exists
     if (!$client) {
         return redirect('/clients');
     }
     $totalUnpaidBills = Bill::where('paid', 0)->where('client_id', $clientId)->where('user_id', Auth::user()->id)->count();
     return view('client-unpaid-bills')->with('clientId', $clientId)->with('name', $client->name)->with('totalUnpaidBills', $totalUnpaidBills);
 }
예제 #30
0
 public function billsUser()
 {
     $user = Auth::user();
     $result = DB::table('users')->where('users.id', $user->id)->leftjoin('courses', 'users.id', '=', 'courses.assignedOwner')->join('bills', 'courses.id', '=', 'bills.course_id')->select('bills.id')->get(['bills.id']);
     $billIds = array();
     foreach ($result as $bill) {
         array_push($billIds, $bill->id);
     }
     $bills = Bill::findMany($billIds);
     return view('public.userBills')->with('bills', $bills);
 }