/** * Returns a URL based on provided parameters. * * Can only add query strings for array URLs. * * @param string|array|null $url URL. * @param bool $full If true, the full base URL will be prepended to the result * @return string Full translated URL with base path. */ public function buildComplete($url = null, $full = false) { if (is_array($url)) { $url = $this->addQueryStrings($url); } return parent::build($url, $full); }
public function index() { if (strpos(UrlHelper::build('/', true), 'dev') == false) { $this->set('files', []); $this->set('stats', []); return; } $files = []; $dev_folders_to_check = ['../src', '../plugins', '../webroot', '../config']; $prod_folders_to_check = ['../../production/src', '../../production/plugins', '../../production/webroot', '../../production/config']; $d = 0; foreach ($dev_folders_to_check as $folder) { $dir = new Folder($folder); $tree = $dir->tree(null, ['.htaccess', 'error_log'])[1]; sort($tree); foreach ($tree as $entry) { $file = new File($entry); preg_match('/.*development(.*)/', $entry, $filename); $filename = $filename[1]; $files[$filename]['dev_date'] = Time::createFromTimestamp(round($file->lastChange() / 60) * 60); $d++; } } $ud = $d; // Unique Files Dev. Will Subtract 1 for each file match. $nd = 0; // Newer Files Dev. $p = 0; $up = 0; $np = 0; foreach ($prod_folders_to_check as $folder) { $dir = new Folder($folder); $tree = $dir->tree(null, ['.htaccess', 'error_log'])[1]; sort($tree); foreach ($tree as $entry) { $file = new File($entry); preg_match('/.*production(.*)/', $entry, $filename); $filename = $filename[1]; $date = Time::createFromTimestamp(round($file->lastChange() / 60) * 60); $files[$filename]['prod_date'] = $date; if (isset($files[$filename]['dev_date'])) { $ud--; if ($date < $files[$filename]['dev_date']) { $nd++; } elseif ($date > $files[$filename]['dev_date']) { $np++; } else { unset($files[$filename]); } } else { $up++; } $p++; } } $stats = ['files_dev' => $d, 'files_prod' => $p, 'unique_dev' => $ud, 'unique_prod' => $up, 'newer_dev' => $nd, 'newer_prod' => $np]; $this->set('files', $files); $this->set('stats', $stats); }
/** * Returns a URL based on provided parameters. * * @param string|array|null $url URL. * @param bool $full If true, the full base URL will be prepended to the result * @return string Full translated URL with base path. */ public function complete($url = null, $full = false) { if (is_array($url)) { // Add query strings if (!isset($url['?'])) { $url['?'] = []; } $url['?'] += $this->request->query; } return parent::build($url, $full); }
/** * Set the full base URL recursivelly for all the menu and their children. * * @param array $menu Given menu * @return array $menus */ protected function _setFullBaseUrl(array $menu = []) { $menu = array_map(function ($v) { $url = Hash::get($v, 'url'); $children = Hash::get($v, 'children'); if ($url) { $v['url'] = UrlHelper::build($url, true); } if (is_array($children)) { $v['children'] = $this->_setFullBaseUrl($children); } return $v; }, $menu); return $menu; }
public function upgradeInvoicemail($auth, $invdet) { $users = TableRegistry::get('Users'); $invoices = TableRegistry::get('Invoices'); $user = $users->find()->hydrate(false)->where(['id' => $auth['User']['id']])->first(); $invoice = $invoices->find()->hydrate(false)->where(['id' => $invdet['id']])->first(); $ind_details_string = ''; if (isset($invoice)) { // get the relevant dates, for upgrades and new subscriptions $daybeforeupgradedate = date('d M Y', strtotime('-1 days', strtotime($invoice["invoice_date"]))); $todaysdate = date('d M Y', time()); $daysremaining = $invoice["billing_period_days"] - $invoice["days_used"]; $ind_details_string .= '<table class="invoice-table" style="border:2px solid #000000;"> <thead> <tr> <th><a href="http://www.marketingconnex.com" title="MarketingConnex"><img src="' . UrlHelper::build("/img/logos/logo-marketing-connex.png", true) . '" class="img-responsive" width="300px" height="auto"/></a></th> <th> </th> <th> </th> <th> </th> <th style="text-align: right; text-transform: uppercase; font-size: 14px;">' . __("Invoice") . '</th> </tr> <tr> <th style="font-size: 10px; text-align: left;">' . $this->portal_settings["site_name"] . '</th> <th> </th> <th> </th> <th> </th> <th> </th> </tr> <tr> <th style="font-size: 10px; text-align: left;">VAT Reg No: ' . $this->portal_settings["VAT_ID"] . '</th> <th> </th> <th> </th> <th> </th> <th> </th> </tr> </thead> <tbody> <tr> <td> </td> <td style="text-align: right"><strong>' . __("Invoice No") . ' : </strong></td> <td colspan="3">' . $invoice["invoice_number"] . '</td> </tr> <tr> <td> </td> <td style="text-align: right"><strong>' . __("Invoice Date") . ' : </strong></td> <td colspan="3">' . date("d/m/Y", strtotime($invoice["invoice_date"])) . '</td> </tr> <tr> <td> </td> <td style="text-align: right"><strong>' . __("Your VAT ID") . ' : </strong></td> <td colspan="3">' . $invoice["vat_number"] . '</td> </tr> <tr> <td> </td> <td style="text-align: right"><strong>' . __("Customer Service") . ' : </strong></td> <td colspan="3"><a href="' . $this->portal_settings["site_email"] . '" title="' . __("Send an email to") . ' ' . $this->portal_settings["site_email"] . '">' . $this->portal_settings["site_email"] . '</a></td> </tr> <tr> <td><strong>Bill to:</strong></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>' . $invoice["primary_manager"] . '</td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>' . $invoice["company_name"] . '</td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>' . $invoice["company_address"] . '</td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>' . $invoice["company_city"] . '</td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>' . $invoice["company_state"] . '</td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>' . $invoice["company_postcode"] . '</td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>' . $invoice["company_country"] . '</td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td colspan="5" style="border-bottom: 2px solid #eeeeee;"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr>'; if ($invoice["invoice_type"] != "Other") { $ind_details_string .= '<tr> <td><strong>*** ' . $invoice["invoice_type"] . ' ***</strong></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr>'; } $ind_details_string .= '<tr> <td><strong>' . __("Transactions this billing period") . '</strong></td> <td><strong>' . __("Description") . '</strong></td> <td> </td> <td> </td> <td> </td> </tr>'; if ($invoice["balance_credit"] != 0) { $ind_details_string .= '<tr> <td>' . $invoice["old_package"] . '</td> <td>' . $invoice["title"] . ' (' . h(date('d M Y', strtotime($invoice["sub_start_date"]))) . ' - '; if ($invoice["days_used"] == 0) { $ind_details_string .= h(date('d M Y', strtotime($invoice["sub_start_date"]))); } else { $ind_details_string .= $daybeforeupgradedate . ')'; } $ind_details_string .= '</td> <td width="75" style="text-align: right;">' . number_format($invoice["old_package_price"] - $invoice["balance_credit"], 2, '.', ',') . '</td> <td width="75"> </td> <td> </td> </tr> <tr> <td>' . $invoice["new_package"] . '</td> <td>' . $invoice["title"] . ' (' . h(date('d M Y', strtotime($invoice["upgrade_date"]))) . ' - ' . h(date('d M Y', strtotime($invoice["sub_end_date"]))) . ')</td> <td width="75" style="text-align: right;">' . number_format($invoice["adjusted_package_price"] + $invoice["discount"], 2, '.', ',') . '</td> <td width="75"> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td width="75" style="border-top: 1px solid #999999;"> </td> <td width="75" style="text-align: right;">' . number_format($invoice["old_package_price"] - $invoice["balance_credit"] + ($invoice["adjusted_package_price"] + $invoice["discount"]), 2, '.', ',') . '</td> <td> </td> </tr>'; } else { $ind_details_string .= '<tr> <td>' . $invoice["description"] . '</td> <td>' . $invoice["title"] . ' (' . h(date('d M Y', strtotime($invoice["sub_start_date"]))) . ' - ' . h(date('d M Y', strtotime($invoice["sub_end_date"]))) . ')</td> <td width="75"> </td> <td width="75" style="text-align: right;">' . number_format($invoice["package_price"], 2, '.', ',') . '</td> <td> </td> </tr>'; } if ($invoice["discount"] != 0) { $ind_details_string .= '<tr> <td>Discount</td> <td> </td> <td> </td> <td style="text-align: right;">- ' . number_format($invoice["discount"], 2, '.', ',') . '</td> <td> </td> </tr>'; } if ($invoice["fee"] != 0) { $ind_details_string .= '<tr> <td>Other fees and charges</td> <td> </td> <td> </td> <td style="text-align: right;">' . number_format($invoice["fee"], 2, '.', ',') . '</td> <td> </td> </tr>'; } if ($invoice["balance_credit"] != 0) { $ind_details_string .= '<tr> <td>' . __("Amount of previous subscription paid on") . ' ' . h(date('d M Y', strtotime($invoice["sub_start_date"]))) . ' ' . __("excluding fees") . '</td> <td> </td> <td width="75"> </td> <td width="75" style="text-align: right;">' . number_format(0 - $invoice["old_package_price"], 2, '.', ',') . '</td> <td> </td> </tr> <tr> <td><strong>' . __("Total transactions this billing period") . '</strong></td> <td> </td> <td> </td> <td style="text-align: right; border-top: 1px solid #999999;"><strong>' . number_format($invoice["subtotal"], 2, '.', ',') . '</strong></td> <td> </td> </tr>'; } else { $ind_details_string .= '<tr> <td><strong>' . __("Total transactions this billing period") . '</strong></td> <td> </td> <td> </td> <td style="text-align: right; border-top: 1px solid #999999;"><strong>' . number_format($invoice["subtotal"], 2, '.', ',') . '</strong></td> <td> </td> </tr>'; } $ind_details_string .= '<tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr>'; if ($invoice["vat"] != 0) { $ind_details_string .= '<tr> <td> </td> <td>' . __("Subtotal") . '</td> <td> </td> <td style="text-align: right;">' . number_format($invoice["subtotal"], 2, '.', ',') . '</td> <td>' . $invoice['currency'] . '</td> </tr> <tr> <td> </td> <td>' . __("VAT") . ' @ ' . number_format($invoice["vat_perc"], 2, '.', ',') . '%</td> <td> </td> <td style="text-align: right; border-bottom: 1px solid #999999;">' . number_format($invoice["vat"], 2, '.', ',') . '</td> <td> </td> </tr>'; } $ind_details_string .= '<tr> <td> </td> <td><strong>' . __('Total amount due') . '</strong></td> <td> </td> <td style="text-align: right;"><strong>' . number_format($invoice["amount"], 2, '.', ',') . '</strong></td> <td><strong>' . $invoice['currency'] . '</strong></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr>'; if ($invoice["comments"] != '') { $ind_details_string .= '<tr> <td><strong>' . __("Additional Notes") . '</strong></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td colspan="5">' . $invoice["comments"] . '</td> </tr>'; } $ind_details_string .= '<tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </tbody> <tfoot> <tr> <td colspan="5" style="text-align: center; font-size: 10px;">' . $this->portal_settings["site_address"] . '</td> </tr> </tfoot> </table>'; } $msg = '<p>' . __("Hi") . ' [CUSTOMER_NAME],</p> <p>' . __("Thank you for your request to upgrade your subscription package on") . ' [SITE_NAME].</p> <p>' . __("Your new package is now active. Please find your invoice details below.") . '</p> <p>' . __("Thanks and regards,") . '</p> <p> </p> <p>' . __("Customer Support") . '</p> <p><strong>[SITE_NAME]</strong></p> <p> </p> <p> </p> [INVOICE_DETAILS]'; $msg = str_replace('[CUSTOMER_NAME]', $user['first_name'] . ' ' . $user['last_name'], $msg); $msg = str_replace('[SITE_NAME]', $this->portal_settings['site_name'], $msg); $msg = str_replace('[INVOICE_DETAILS]', $ind_details_string, $msg); $fgemail = new Email('default'); $fgemail->sender($this->portal_settings['site_email'], $this->portal_settings['site_name']); $fgemail->from([$this->portal_settings['site_email'] => $this->portal_settings['site_name']])->to($user['email'])->subject(__('Subscription package upgraded on') . $this->portal_settings['site_name'])->emailFormat('both')->send($msg); /* * UPGRADE - Send e-mail to administrator */ $admins = $users->find()->hydrate(false)->where(['role' => 'admin', 'status' => 'Y']); $amsg = '<p>' . __("Hi ,") . '</p> <p>' . __("The vendor [CUSTOMER_NAME] has upgraded their subscription on") . ' [SITE_NAME].</p> <p>' . __("Please find the invoice details below.") . '</p> <p>' . __("Thanks and regards,") . '</p> <p> </p> <p><strong>[SITE_NAME]</strong></p> <p> </p> <p> </p> [INVOICE_DETAILS]'; $amsg = str_replace('[CUSTOMER_NAME]', $user['first_name'] . ' ' . $user['last_name'], $amsg); $amsg = str_replace('[SITE_NAME]', $this->portal_settings['site_name'], $amsg); $amsg = str_replace('[INVOICE_DETAILS]', $ind_details_string, $amsg); $ademail = new Email('default'); $ademail->sender($this->portal_settings['site_email'], $this->portal_settings['site_name']); foreach ($admins as $admin) { $ademail->from([$user['email'] => $this->portal_settings['site_name']])->to($admin['email'])->subject(__('Subscription upgrade on ') . $this->portal_settings['site_name'])->emailFormat('both')->send($amsg); } return true; }