Ignore:
Timestamp:
Apr 12, 2024, 9:43:27 PM (5 weeks ago)
Author:
chronos
Message:
  • Modified: Improved content of email with finance account state.
  • Added: Customer IS action to generate finance email into email queue.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Finance/Manage.php

    r939 r968  
    3737      case 'RegenerateOperation':
    3838        $Output = $this->GenerateOperation('AND (Id='.$_GET['i'].')');
     39        break;
     40      case 'SendPaymentEmail':
     41        $Output = $this->SendPaymentEmail($_GET['i']);
    3942        break;
    4043      default:
     
    171174      $Period = $this->GetBillingPeriod($Member['BillingPeriod']);
    172175
    173       /* Check if need to produce new invoice for customer */
     176      // Check if need to produce new invoice for customer
    174177      if (($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and
    175178        ($Period['From'] > $Member['BillingPeriodLastUnixTime']))
     
    195198        {
    196199          $InvoiceGroupId = INVOICE_GROUP_OUT;
    197         } else {
     200        } else
     201        {
    198202          $InvoiceGroupId = INVOICE_GROUP_IN;
    199203        }
     
    215219          $Output .= $this->SendPaymentEmail($Member['Id']);
    216220        }
    217         /* Update last billing day */
     221        // Update last billing day
    218222        $this->Database->update('Member', '`Id`='.$Member['Id'],
    219223          array('BillingPeriodLastDate' => TimeToMysqlDateTime($Period['To'])));
     
    346350  function SendPaymentEmail(string $MemberId, string $FileId = ''): string
    347351  {
     352    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
     353    $Finance->LoadMonthParameters(0);
     354
     355    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';
    348356    global $Config;
    349357
     
    362370    $DbResult = $this->Database->select('Subject', '*', '`Id`='.$Config['Finance']['MainSubjectId']);
    363371    $MainSubject = $DbResult->fetch_assoc();
     372
     373    $DbResult = $this->Database->select('Company', '*', '`Id`='.$Config['Finance']['MainCompanyId']);
     374    $MainCompany = $DbResult->fetch_assoc();
    364375
    365376    $Period = $this->GetBillingPeriod($Member['BillingPeriod']);
     
    374385    if ($User['Email'] != '')
    375386    {
    376       $Title = 'Pravidelné vyúčtování služeb';
    377       $Content = 'Vyúčtovaní zákazníka <strong>'.$Subject['Name'].'</strong> zastoupeného uživatelem <strong>'.
     387      $Title = 'Pravidelné vyúčtování služeb '.$MainCompany['Name'];
     388      $Content = 'Dobrý den,<br/><br/>'.
     389        'Zasíláme vyúčtování klienta <strong>'.$Subject['Name'].'</strong> zastoupeného uživatelem <strong>'.
    378390        $User['Name'].'</strong> ke dni <strong>'.Core::Cast($this->System)->HumanDate(time()).'</strong>.<br/><br/>'."\n".
    379391        'Vaše aktuální služby: ';
     
    414426      'Pro aktuální informace, prohlížení elektronických dokladů a možnost změny údajů se prosím přihlaste na stránkách '.
    415427      '<a href="https://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'">https://'.
    416       $Config['Web']['Host'].$Config['Web']['RootFolder'].'</a>.<br /><br />'."\n";
    417 
    418       $Content .= '<br />Tento email je generován automaticky. V případě zjištění nesrovnalostí napište zpět.';
     428      $Config['Web']['Host'].$Config['Web']['RootFolder'].'</a>.<br/><br/>'."\n";
     429
     430      $Content .= '<br/>Tento email je generován automaticky. V případě zjištění nesrovnalostí prosím napište zpět.';
     431     
     432      $Content .= '<br/><br/>S pozdravem,<br/>'.$MainCompany['Name'].'<br/><a href="'.$MainSubject['WWW'].'">'.
     433        str_replace(array('https:', '/'), '', $MainSubject['WWW']).'</a>';
     434
    419435      ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->AddItem($User['Name'].' <'.$User['Email'].'>', $Title, $Content,
    420436         $Config['Web']['Admin'].' <'.$Config['Web']['AdminEmail'].'>');
Note: See TracChangeset for help on using the changeset viewer.