Silnik WKHTMLTOPDF: https://wkhtmltopdf.org/downloads.html
Plugin CakePDF: https://github.com/FriendsOfCake/CakePdf
Silnik WKHTMLTOPDF: https://wkhtmltopdf.org/downloads.html
Plugin CakePDF: https://github.com/FriendsOfCake/CakePdf
$products_table = $this->fetchTable("Products");
Mechanizm przeglądania w aplikacji plików graficznych i pdf
Exportuje dane z tabeli do pliku csv
Wyliczanie wartości całkowitej ze wszystkich podrzędnych modeli.
Czytaj dalej total calculated – wyliczanie podrzędnych wartości
Utworzenie etykiety do złożonych list
get
$article = $articles->get($id, contain: ['Comments']);
$this->paginate = [ 'limit' => 200, 'maxLimit' => 200, 'sortableFields' => [ 'date', 'netto', 'brutto', 'termin_platnosci', 'is_payed', 'Brands.name', 'Projects.number', 'numer', 'position', 'Companies.name', 'Companies.nip', 'Companies.bank_number', ], 'order' => ['CostInvoices.date' => 'DESC'] ];
Auth finder do akceptacji logowania
Referer – redirect – queryParams
if($this->request->referer()) { return $this->redirect($this->request->referer()); } else { return $this->redirect(['action' => 'articles', '?' => $this->request->getQueryParams()]); }
get Table object
$project = $this->fetchTable("Projects")->get($id); // załaduj Model
URL
let url = new URL(location.href); $('#s_brand_id').on('change', function(){ var s_brand_id = $(this).val(); if(s_brand_id) { url.searchParams.set('s_brand_id', s_brand_id); } else { url.searchParams.delete('s_brand_id'); } location.href = url.toString(); });
$s_brand_id = (int) $this->request->getQuery('s_brand_id', null); if($s_brand_id) { $query->where(['brand_id' => $s_brand_id]); } $this->set(compact('s_brand_id'));
$article->user_id = $this->request->getAttribute('identity')->getIdentifier(); $this->request->getAttribute('authentication');
Wywołanie findera
public function tags(...$tags) { $articles = $this->Articles->find('tagged', tags: $tags)->all(); }
Pobranie największej/najwcześniejszej lub namniejszej/najpóźniejszej wartości
protected $_accessible = [ ...... 'schedule_first_date' => true, // Pierwsza data w harmonogramie 'schedule_last_date' => true, // Ostatnia data w harmonogramie ]; // Dla projektu pobiera ostatnią datę z harmonogramu (schedules - tablica powiązanych rekordów) protected function _getScheduleLastDate() { if (isset($this->_fields['schedule_last_date'])) { return $this->_fields['schedule_last_date']; } if (empty($this->schedules)) { return ; } $last_day = (new Collection($this->schedules))->max('date_to')->date_to; return $last_day; } // Dla projektu pobiera ostatnią datę z harmonogramu (schedules) protected function _getScheduleFirstDate() { if (isset($this->_fields['schedule_first_date'])) { return $this->_fields['schedule_first_date']; } if (empty($this->schedules)) { return ; } $first_fday = (new Collection($this->schedules))->min('date_from')->date_from; return $first_fday; }
Tabela powinna posiadać parent_id
Controller / index
$query = $this->EventTypes->find()->find('threaded')->all(); $eventTypes = $this->paginate($query); $this->set(compact('eventTypes'));
Czytaj dalej Tabele z elementami podrzędnymi – pogrupowanymi
Table – def. Parents
$this->belongsTo('Parent', [ 'className' => 'EventTypes', 'foreignKey' => 'parent_id' ]);
Controller – sortowanie po powiązanych modelach
$this->paginate = [ 'sortableFields' => [ 'Posts.title', 'Authors.name', ], ];
Jeden z kontrolerów używa bazy danych na zdalnym serwerze
Model obsługi Ajax
Wgranie pliku na serwer
$project= $this->fetchTable("Projects")->get($id); // zamiast loadModel
Pobiera kurs NBP i wypełnia pole w aplikacji
Entity – usuwanie spacji, zamiana przecinków na kropki
protected function _setNetto($netto) { $netto = str_replace(',', '.', $netto); return trim($netto); } protected function _setBrutto($brutto) { $brutto = str_replace(',', '.', $brutto); return trim($brutto); }
Kontroler – pobieranie sumy pozycji
$query = $this->Invoices->find(); $query->enableAutoFields() ->select([ 'total_netto' => $query->func()->sum('Positions.netto'), 'total_brutto' => $query->func()->sum('Positions.brutto'), 'total_pos' => $query->func()->count('Positions.id') ]); $query->leftJoinWith('Positions'); $query->group(['Invoices.id']); $query->order(['Invoices.id' => 'DESC']) ->all();
View /
<?= number_format($brutto, 2, ".", " ") ?>
Korzystanie z Modułu OCR