<?php
namespace admin\view;

class Newsletter {
  
  public function editEmail( $id = '' )
  {
		$id ? $value = 'Zapisz' : $value = 'Dodaj';

		$out = \admin\view\PagePanel::show( false, $value, true, 'Newsletter - emaile' );

		$dbedit = new \DataEdit( 'pp_newsletter_emails', 'id', $id );
		$dbedit -> addPosition( 'email', 'Email', 'text' );
    $dbedit -> addPosition( 'enabled',  'Aktywny',  'radio', '', \System::getComboYesNo() );
		$out .= $dbedit -> draw();

		return $out;    
  }

  public function showEmailList()
  {    
		$out = \admin\view\PagePanel::show( true, false, false, 'Newsletter - emaile'  );

		$dbrowse = new \DataBrowse( 'pp_newsletter_emails' );
		$dbrowse -> addPosition( 'email', 'Email', '', '', '', 'email' );
    $dbrowse -> addPosition( 'enabled', 'Aktywny',  '', \System::getComboYesNo() );
		$dbrowse -> addPositionSimple( 'edytuj',  '', './?rw=edit' );
		$dbrowse -> addPositionSimple( 'usuń',    '', '', \System::deleteAction() );
		$dbrowse -> setParam( 'id' );
		$dbrowse -> addSort( 'email ASC' );
		$dbrowse -> addLp();
		$dbrowse -> addFiltr( 'email', 'Email' );
    $dbrowse -> addFiltr( 'enabled',  'Aktywny', \System::getComboYesNo() );
		$out .= $dbrowse -> draw();

		return $out;
  }
}
