private function confrontDateOfBirth() { if (isset($this->dateToConfront)) { return $this->date->diffInDays($this->dateToConfront) == 0; } return true; }
/** * show Business. * * @param Business $business Business to show * @param BusinessFormRequest $request Business form Request * * @return Response Rendered view for Business show */ public function show(Business $business) { logger()->info(__METHOD__); logger()->info(sprintf('businessId:%s', $business->id)); $this->authorize('manage', $business); // BEGIN session()->set('selected.business', $business); $notifications = Notifynder::entity(Business::class)->getNotRead($business->id, 20); Notifynder::entity(Business::class)->readAll($business->id); $this->time->timezone($business->timezone); // Build Dashboard Report $dashboard['appointments_active_today'] = $business->bookings()->active()->ofDate($this->time->today())->get()->count(); $dashboard['appointments_canceled_today'] = $business->bookings()->canceled()->ofDate($this->time->today())->get()->count(); $dashboard['appointments_active_tomorrow'] = $business->bookings()->active()->ofDate($this->time->tomorrow())->get()->count(); $dashboard['appointments_active_total'] = $business->bookings()->active()->get()->count(); $dashboard['appointments_served_total'] = $business->bookings()->served()->get()->count(); $dashboard['appointments_total'] = $business->bookings()->get()->count(); $dashboard['contacts_registered'] = $business->contacts()->count(); $dashboard['contacts_subscribed'] = $business->contacts()->whereNotNull('user_id')->count(); $time = $this->time->toTimeString(); return view('manager.businesses.show', compact('business', 'notifications', 'dashboard', 'time')); }
<?php date_default_timezone_set('Asia/Taipei'); require __DIR__ . '/bootstrap.php'; //引用carbon require 'vendor/autoload.php'; use Carbon\Carbon; setlocale(LC_TIME, 'Chinese'); $Carbon = new \Carbon\Carbon(); $Carbon->setLocale('zh'); // connect to dabase try { $dsn = 'mysql:host=localhost;port=33060;dbname=mysql;charset=utf8'; $pdo = new PDO($dsn, 'root', 'root'); } catch (PDOException $e) { echo "Error: " . $e->getMessage() . "<br/>"; die; } /* try { $dsn = 'mysql:host='.DB_HOST.';port='.DB_PORT.';dbname='.DB_DATABASE.';charset='.DB_CHARSET; $pdo = new PDO($dsn, DB_USERNAME, DB_PASSWORD); } catch (PDOException $e) { echo "Error: ".$e->getMessage()."<br/>"; die(); } */ ?> <!DOCTYPE html> <html lang="en">
public function busquedaPaginada(Request $request) { $page = $request->input('page'); $difunto = $request->input('difunto'); $fecha = $request->input('fecha'); $parroquia = $request->input('parroquia'); $inhumacion = $request->input('inhumacion'); $query = VDifuntos::where(function ($query) use($difunto, $fecha, $parroquia, $inhumacion) { if ($difunto != '') { $query->where('nombre', 'like', "%{$difunto}%"); } if ($fecha != '') { $query->where('fallecimiento', $fecha); } if ($inhumacion != '') { $query->where('inhumacion', $inhumacion); } if ($parroquia != '') { $query->where('parroquia_difunto', $parroquia); } }); $difuntos = $query->skip(10 * ($page - 1))->take(10)->get(); foreach ($difuntos as $difunto) { //Formateamos las fechas inhumacion y fallecimiento $finh = new \Carbon\Carbon($difunto->inhumacion); $ffall = new \Carbon\Carbon($difunto->fallecimiento); echo ' <tr class="difunto' . $difunto->id . '">'; echo "<td>{{$difunto->nombre}}</td>\n <td>{{$ffall->format('j-m-Y')}}</td>\n <td>{{$finh->format('j-m-Y')}}</td>\n <td>{{$difunto->edad}}</td>\n <td>{{$difunto->domicilio}}</td>\n <td>{{$difunto->numero}}</td>\n <td>{{$difunto->calle}}</td>\n <td>{{$difunto->parroquia_difunto}}</td>"; echo '<td style = "width: 100px" > <div style = "float: right" > <a data - toggle = "tooltip" title = "Editar" onclick = "" style = "margin-right: 10px; color:#03A9F4;" > <i class="fa fa-pencil-square-o fa-lg fa-border" ></i ></a > <a data - toggle = "tooltip" title = "Borrar" style = "margin-right: 10px; color: #F44336" onclick = "borrar(' . $difunto->id . ')" ><i class="fa fa-eraser fa-lg fa-border " ></i ></a > </div > </td > </tr >'; } }
/** * Check if the opening is open at a given timestamp. * * @param Carbon\Carbon $time * @return bool */ public function isOpenAt($time) { return $time->between($this->opensAt(), $this->closesAt()) || $time->copy()->addWeek()->between($this->opensAt(), $this->closesAt()); }
public function getUpdatedAtAttribute($date) { return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('Y-m-d'); }
protected function calculateClosesAt() { $this->closesAt = $this->opensAt->copy()->addSeconds($this->length); }
/** * Get last period of fiscal year and first period of the next fiscal year * * @param array $input * An array as follows: array(id => $id); * * @return array * An array as follows: array( 'id' = $id, 'month' => $month, 'end_date' => $endDate) */ public function getBalanceAccountsClosingPeriods(array $input) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); $fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($organizationId); if ($fiscalYearId == $input['id']) { return json_encode(array('info' => $this->Lang->get('decima-accounting::period-management.invalidFiscalYear'))); } $period = json_decode($this->getLastPeriodOfFiscalYear($input), true); $FiscalYear = $this->FiscalYear->byId($input['id']); $FiscalYear = $this->FiscalYear->byYearAndByOrganization($FiscalYear->year + 1, $organizationId); $period2 = $this->Period->firstPeriodbyOrganizationAndByFiscalYear($this->AuthenticationManager->getCurrentUserOrganizationId(), $FiscalYear->id)->toArray(); $period2['endDate'] = $this->Carbon->createFromFormat('Y-m-d', $period2['end_date'])->format($this->Lang->get('form.phpShortDateFormat')); unset($period2['end_date']); $period2['month'] = $period2['month'] . ' - ' . $this->Lang->get('decima-accounting::period-management.' . $period2['month']); return json_encode(array('id0' => $period['id'], 'month0' => $period['month'], 'endDate0' => $period['endDate'], 'id1' => $period2['id'], 'month1' => $period2['month'], 'endDate1' => $period2['endDate'], 'fiscalYearId' => $FiscalYear->id)); }
/** * Respond to all messages that contain the bot name as long as we haven't * already reacted in the last 30 minutes. * * @param DanGreaves\SlackBot\Entities\Message $message * @return void */ public function shouldReact(Message $message) { return $message->mentionsMe() && (!$this->lastMessageSentAt || $this->lastMessageSentAt->lt(Carbon::now()->subMinutes(30))); }
/** * Add Results to the Current Interval Set * * @param array */ public function addResults(array $data) { $this->results[] = array('data' => $data, 'intervalStart' => $this->currentTime->copy(), 'intervalEnd' => $this->currentTime->copy()->addSeconds($this->intervalTime)); }
/** * Update an existing journal voucher * * @param array $input * An array as follows: array( 'id' => $id, 'date'=>$date, 'manual_reference'=>$manualReference, 'remark'=>$remark, * 'system_reference_type'=>$systemTeferenceType, 'system_reference_field'=>$systemReferenceField, 'system_reference_id'=>$systemReferenceId, * 'is_editable'=>$isEditable, 'status'=>$status, 'voucher_type_id'=>$voucherTypeId * ); * * @return JSON encoded string * A string as follows: * In case of success: {"success" : form.defaultSuccessUpdateMessage} */ public function updateJournalVoucher(array $input) { $fieldLabels['voucher_type'] = $input['voucher_type']; $fieldLabels['document_type_label'] = $input['document_type_label']; $fieldLabels['supplier_label'] = $input['supplier_label']; $fieldLabels['client_label'] = $input['client_label']; $fieldLabels['employee_label'] = $input['employee_label']; unset($input['_token'], $input['voucher_type'], $input['status_label'], $input['period_label'], $input['document_type_label'], $input['supplier_label'], $input['client_label'], $input['employee_label']); $input = eloquent_array_filter_for_update($input); $input['date'] = $this->Carbon->createFromFormat($this->Lang->get('form.phpShortDateFormat'), $input['date'])->format('Y-m-d'); if (isset($input['document_date']) && !empty($input['document_date'])) { $input['document_date'] = $this->Carbon->createFromFormat($this->Lang->get('form.phpShortDateFormat'), $input['document_date'])->format('Y-m-d'); } $periodIsChanged = $periodIsClosed = $newPeriodIsClosed = false; $this->DB->transaction(function () use(&$input, &$Period, &$periodIsChanged, &$periodIsClosed, &$newPeriodIsClosed, $fieldLabels) { $JournalVoucher = $this->JournalVoucher->byId($input['id']); $unchangedJournalVoucherValues = $JournalVoucher->toArray(); $Period = $this->Period->byId($JournalVoucher->period_id); if ($Period->is_closed) { $periodIsClosed = true; return; } if ($JournalVoucher->period_id != $input['period_id']) { $periodIsChanged = true; return; } $Period = $this->Period->byId($input['period_id']); if ($Period->is_closed) { $newPeriodIsClosed = true; return; } $this->JournalVoucher->update($input, $JournalVoucher); $diff = 0; foreach ($input as $key => $value) { if ($unchangedJournalVoucherValues[$key] != $value) { $diff++; if ($diff == 1) { $Journal = $this->Journal->create(array('journalized_id' => $JournalVoucher->id, 'journalized_type' => $this->JournalVoucher->getTable(), 'user_id' => $this->AuthenticationManager->getLoggedUserId(), 'organization_id' => $this->AuthenticationManager->getCurrentUserOrganizationId())); } if ($key == 'voucher_type_id') { $VoucherType = $this->VoucherType->byId($value); $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.voucherType'), 'field_lang_key' => 'decima-accounting::journal-management.voucherType', 'old_value' => $VoucherType->name, 'new_value' => $fieldLabels['voucher_type']), $Journal); } else { if ($key == 'document_type_id') { if (!empty($unchangedJournalVoucherValues[$key])) { $DocumentType = $this->DocumentType->byId($unchangedJournalVoucherValues[$key]); $documentType = $DocumentType->name; } else { $documentType = ''; } $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.' . camel_case($key)), 'field_lang_key' => 'decima-accounting::journal-management.' . camel_case($key), 'old_value' => $documentType, 'new_value' => $fieldLabels['document_type_label']), $Journal); } else { if ($key == 'supplier_id') { if (!empty($unchangedJournalVoucherValues[$key])) { $Supplier = $this->Supplier->byId($unchangedJournalVoucherValues[$key]); $supplier = $Supplier->name; } else { $supplier = ''; } $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.' . camel_case($key)), 'field_lang_key' => 'decima-accounting::journal-management.' . camel_case($key), 'old_value' => $supplier, 'new_value' => $fieldLabels['supplier_label']), $Journal); } else { if ($key == 'client_id') { if (!empty($unchangedJournalVoucherValues[$key])) { $Client = $this->Client->byId($unchangedJournalVoucherValues[$key]); $client = $Client->name; } else { $client = ''; } $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.' . camel_case($key)), 'field_lang_key' => 'decima-accounting::journal-management.' . camel_case($key), 'old_value' => $client, 'new_value' => $fieldLabels['client_label']), $Journal); } else { if ($key == 'employee_id') { if (!empty($unchangedJournalVoucherValues[$key])) { $Employee = $this->Employee->byId($unchangedJournalVoucherValues[$key]); $employee = $Employee->names . ' ' . $Employee->surnames; } else { $employee = ''; } $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.' . camel_case($key)), 'field_lang_key' => 'decima-accounting::journal-management.' . camel_case($key), 'old_value' => $employee, 'new_value' => $fieldLabels['employee_label']), $Journal); } else { if ($key == 'status') { $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.' . camel_case($key)), 'field_lang_key' => 'decima-accounting::journal-management.' . camel_case($key), 'old_value' => $this->Lang->get('decima-accounting::journal-management.' . $unchangedJournalVoucherValues[$key]), 'new_value' => $this->Lang->get('decima-accounting::journal-management.' . $value)), $Journal); } else { if ($key == 'date' || $key == 'document_date') { $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.' . camel_case($key)), 'field_lang_key' => 'decima-accounting::journal-management.' . camel_case($key), 'old_value' => $this->Carbon->createFromFormat('Y-m-d', $unchangedJournalVoucherValues[$key], 'UTC')->format($this->Lang->get('form.phpShortDateFormat')), 'new_value' => $this->Carbon->createFromFormat('Y-m-d', $value, 'UTC')->format($this->Lang->get('form.phpShortDateFormat'))), $Journal); } else { $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.' . camel_case($key)), 'field_lang_key' => 'decima-accounting::journal-management.' . camel_case($key), 'old_value' => $unchangedJournalVoucherValues[$key], 'new_value' => $value), $Journal); } } } } } } } } } }); if ($periodIsClosed) { return json_encode(array('success' => false, 'info' => $this->Lang->get('decima-accounting::journal-management.closedPeriodValidationMessage3', array('period' => $this->Lang->get('decima-accounting::period-management.' . $Period->month))))); } if ($periodIsChanged) { return json_encode(array('success' => false, 'info' => $this->Lang->get('decima-accounting::journal-management.changedPeriodValidationMessage', array('period' => $this->Lang->get('decima-accounting::period-management.' . $Period->month))))); } if ($newPeriodIsClosed) { return json_encode(array('success' => false, 'fieldValidationMessages' => array('date' => $this->Lang->get('decima-accounting::journal-management.closedPeriodValidationMessage', array('period' => $this->Lang->get('decima-accounting::period-management.' . $Period->month)))))); } return json_encode(array('success' => $this->Lang->get('form.defaultSuccessUpdateMessage'))); }