first commit

This commit is contained in:
2024-12-12 15:33:18 +01:00
commit 2c8998663e
3360 changed files with 777573 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<?php
namespace view;
class Cron
{
public static function main_view()
{
$tpl = new \Tpl;
return $tpl -> render( 'cron/main-view' );
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace view;
class Messages {
public function drawMessages()
{
$tpl = new \Savant3;
$tpl -> _messages = \factory\Messages::getMessages();
return $tpl -> fetch( 'other/massages' );
}
}
?>

View File

@@ -0,0 +1,33 @@
<?php
namespace view;
class Page
{
public static function unlogged()
{
$tpl = new \Tpl;
return $tpl -> render( 'page/unlogged-layout' );
}
public function show()
{
global $user;
if ( !\S::get_session( 'user' ) and \S::get( 'p' ) != 'cron' )
return \view\Page::unlogged();
$tpl = new \Savant3;
$tpl -> _content = \controls\Page::getContent();
$tpl -> _alert = \S::get_session( 'alert' );
$tpl -> _messages = \view\Messages::drawMessages();
$tpl -> _user = $user;
if ( $user['type'] == 'client' or $user['type'] == 'worker' )
return $tpl -> fetch( 'client/main-layout' );
if ( $user['type'] == 'reseller' )
return $tpl -> fetch( 'reseller/main-layout' );
else
return $tpl -> fetch( 'page/main-layout' );
}
}
?>

View File

@@ -0,0 +1,20 @@
<?php
namespace view;
class PagePanel {
public function show( $add = false , $save = false , $cancel = false , $form = 'formularz' , $back = false , $update = false , $save_ajax = false, $checkbox = false )
{
$tpl = new \Savant3();
$tpl -> _add = $add;
$tpl -> _save = $save;
$tpl -> _cancel = $cancel;
$tpl -> _id_form = $form;
$tpl -> _back = $back;
$tpl -> _update = $update;
$tpl -> _save_ajax = $save_ajax;
$tpl -> _checkbox = $checkbox;
return $tpl -> fetch( 'other/page-panel' );
}
}
?>

View File

@@ -0,0 +1,139 @@
<?php
namespace view;
class Ranker
{
public function drawReportsForm()
{
$tpl = new \Savant3;
$tpl -> _sites = \factory\Ranker::getSites();
return $tpl -> fetch( 'ranker/reports' );
}
public function drawSummary( $month = '', $year = '' )
{
if ( $month ) \S::set_session( 'drawSitesList:month', $month );
if ( $year ) \S::set_session( 'drawSitesList:year', $year );
$month = \S::get_session( 'drawSitesList:month' );
$year = \S::get_session( 'drawSitesList:year' );
if ( !$month ) $month = date( 'm' );
if ( !$year ) $year = date( 'Y' );
$tpl = new \Savant3;
$tpl -> _profit = \factory\Ranker::getMonthProfit( $month, $year );
$tpl -> _clients = \factory\Ranker::getClientsSitesSummary( $month, $year );
$tpl -> _month = $month;
$tpl -> _year = $year;
return $tpl -> fetch( 'ranker/summary' );
}
public function phrase_costs_edit( $site_id, $phrase_id )
{
$tpl = new \Savant3;
$tpl -> site_id = $site_id;
$tpl -> phrase = \factory\Ranker::getPhrase( $phrase_id );
$tpl -> prices = \factory\Ranker::getPhrasePrices( $phrase_id );
return $tpl -> fetch( 'ranker/phrase-costs-edit' );
}
public function drawClientEdit( $id = '' )
{
$tpl = new \Savant3;
$tpl -> _client = \factory\Ranker::getClient( $id );
$tpl -> _sites = \factory\Ranker::getSites();
return $tpl -> fetch( 'ranker/client-edit' );
}
public function drawClientList()
{
$tpl = new \Tpl;
return $tpl -> render( 'ranker/client-list' );
$out = \view\PagePanel::show( true, false, false, 'Dodaj klienta' );
$type[0] = 'klient';
$type[1] = 'reseller';
$dbrowse = new \DataBrowse( 'pro_rr_clients' );
$dbrowse -> addPosition( 'login', 'Login', '', '', '', true );
$dbrowse -> addPosition( 'password', 'Hasło', '', '', '', true );
$dbrowse -> addPosition( 'enabled', 'Aktywny', '', \S::getComboYesNo(), 'text-align: center;' );
$dbrowse -> addPosition( 'last_logged', 'Ost. logowanie', '', '', 'text-align: center;', 'last_logged' );
$dbrowse -> addPosition( 'type', 'Typ', '', $type, 'text-align: center;' );
$dbrowse -> addPositionSimple( 'edytuj' , 'Edytuj' , './?rw=edit' );
$dbrowse -> addPositionSimple( 'usuń' , 'Usuń' , '' , \S::deleteAction() );
$dbrowse -> setParam( 'id' );
$dbrowse -> addSort( 'last_logged DESC' );
$dbrowse -> addLp();
$dbrowse -> addFiltr( 'login', 'Login' );
$dbrowse -> addFiltr( 'enabled', 'Aktywny', \S::getComboYesNo() );
$dbrowse -> addFiltr( 'type', 'Typ', $type );
$dbrowse -> addMenu( $out );
return $dbrowse -> draw();
}
public function phrase_edit( $site_id, $phrase_id = '' )
{
$tpl = new \Tpl;
$tpl -> site_id = $site_id;
$tpl -> phrase = \factory\Ranker::getPhrase( $phrase_id );
$tpl -> sites = \factory\Ranker::getSites();
return $tpl -> render( 'ranker/phrase-edit' );
}
public static function main_view( $id = '', $month = '', $year = '' )
{
global $user;
if ( $user['type'] != 'admin' )
return false;
if ( $id !== null )
\S::set_session( 'ranker:main_view:id', $id );
if ( $month )
\S::set_session( 'ranker:main_view:month', $month );
if ( $year )
\S::set_session( 'ranker:main_view:year', $year );
if ( !$month and !\S::get_session( 'ranker:main_view:month' ) )
{
$month = date( 'm' );
\S::set_session( 'ranker:main_view:month', $month );
}
if ( !$year and !\S::get_session( 'ranker:main_view:year' ) )
{
$year = date( 'Y' );
\S::set_session( 'ranker:main_view:year', $year );
}
$month = \S::get_session( 'ranker:main_view:month' );
$year = \S::get_session( 'ranker:main_view:year' );
$id = \S::get_session( 'ranker:main_view:id' );
if ( !$id )
$id = \factory\Ranker::first_site_id();
$site = \factory\Ranker::site_details( $id );
$tpl = new \Tpl;
$tpl -> day_profit = \factory\Ranker::day_profit();
$tpl -> month_profit = \factory\Ranker::getMonthProfit( $month, $year );
$tpl -> sites = \factory\Ranker::sites_list();
$tpl -> phrases = \factory\Ranker::site_phrases_details( $site['id'], $month, $year, '', '', $user['login'] );
$tpl -> next_site_id = \factory\Ranker::next_site_id( $site['id'] );
$tpl -> prev_site_id = \factory\Ranker::prev_site_id( $site['id'] );
$tpl -> majestic = \factory\Ranker::majestic( $site['id'] );
$tpl -> semstorm = \factory\Ranker::semstorm( $site['id'] );
$tpl -> comments = \factory\Ranker::site_comments( $site['id'], $month, $year );
$tpl -> site = $site;
$tpl -> month = $month;
$tpl -> year = $year;
$tpl -> sites_to_confirm = \factory\Ranker::sites_to_confirm();
return $tpl -> render( 'ranker/main-view' );
}
}
?>

View File

@@ -0,0 +1,85 @@
<?php
namespace view;
class RankerClients
{
public static function site_edit( $site_id )
{
$tpl = new \Savant3;
$tpl -> _site = \factory\Ranker::getSite( $site_id, 'ASC', true );
return $tpl -> fetch( 'client/site-edit' );
}
public function drawReportsForm()
{
global $user;
$tpl = new \Savant3;
$tpl -> _sites = \factory\RankerClients::getSites( $user['id'] );
return $tpl -> fetch( 'client/reports' );
}
public function drawSummary( $month = '', $year = '' )
{
global $user;
if ( $month ) \S::set_session( 'drawSitesList:month', $month );
if ( $year ) \S::set_session( 'drawSitesList:year', $year );
$month = \S::get_session( 'drawSitesList:month' );
$year = \S::get_session( 'drawSitesList:year' );
if ( !$month ) $month = date( 'm' );
if ( !$year ) $year = date( 'Y' );
$tpl = new \Savant3;
$tpl -> _sites = \factory\RankerClients::getSitesSummary( $month, $year, $user['id'], $user['login'] );
$tpl -> _month = $month;
$tpl -> _year = $year;
return $tpl -> fetch( 'client/ranker-summary' );
}
public function main_view( $id, $month = '', $year = '' )
{
global $user;
if ( $id !== null )
\S::set_session( 'ranker:main_view:id', $id );
if ( $month )
\S::set_session( 'ranker:main_view:month', $month );
if ( $year )
\S::set_session( 'ranker:main_view:year', $year );
if ( !$month and !\S::get_session( 'ranker:main_view:month' ) )
{
$month = date( 'm' );
\S::set_session( 'ranker:main_view:month', $month );
}
if ( !$year and !\S::get_session( 'ranker:main_view:year' ) )
{
$year = date( 'Y' );
\S::set_session( 'ranker:main_view:year', $year );
}
$month = \S::get_session( 'ranker:main_view:month' );
$year = \S::get_session( 'ranker:main_view:year' );
$id = \S::get_session( 'ranker:main_view:id' );
$site = \factory\RankerClients::getClientSite( $id, $user['id'] );
$tpl = new \Tpl;
$tpl -> sites = \factory\RankerClients::getClientSites( $user['id'] );
$tpl -> phrases = \factory\Ranker::getSitePhrases( $site['id'], $month, $year, false, $user['reseller_id'], $user['login'] );
$tpl -> comments = \factory\Ranker::site_comments( $site['id'], $month, $year );
$tpl -> site = $site;
$tpl -> month = $month;
$tpl -> year = $year;
$tpl -> next_site_id = \factory\RankerClients::getNextClientSiteId( $site['id'], $user['id'] );
$tpl -> prev_site_id = \factory\RankerClients::getPrevClientSiteId( $site['id'], $user['id'] );
return $tpl -> render( 'client/site-list' );
}
}
?>

View File

@@ -0,0 +1,101 @@
<?php
namespace view;
class RankerReseller {
public function drawReportsForm()
{
global $user;
$tpl = new \Savant3;
$tpl -> _sites = \factory\RankerReseller::getSites( $user['id'] );
return $tpl -> fetch( 'reseller/reports' );
}
public function drawSummary( $month = '', $year = '' )
{
global $user;
if ( $month ) \S::set_session( 'drawSitesList:month', $month );
if ( $year ) \S::set_session( 'drawSitesList:year', $year );
$month = \S::get_session( 'drawSitesList:month' );
$year = \S::get_session( 'drawSitesList:year' );
if ( !$month ) $month = date( 'm' );
if ( !$year ) $year = date( 'Y' );
$tpl = new \Savant3;
$tpl -> _sites = \factory\RankerReseller::getSitesSummary( $month, $year, $user['id'], $user['reseller_id'] );
$tpl -> _sites_res = \factory\RankerReseller::getSitesSummary( $month, $year, $user['id'], $user['id'] );
$tpl -> _month = $month;
$tpl -> _year = $year;
return $tpl -> fetch( 'reseller/ranker-summary' );
}
public function phraseEdit( $site_id, $phrase_id = '', $reseller_id )
{
$tpl = new \Savant3;
$tpl -> _site_id = $site_id;
$tpl -> _reseller_id = $reseller_id;
$tpl -> _phrase = \factory\Ranker::getPhrase( $phrase_id, $reseller_id);
return $tpl -> fetch( 'reseller/phrase-edit' );
}
public function editCosts( $site_id, $phrase_id, $reseller_id )
{
$tpl = new \Savant3;
$tpl -> _site_id = $site_id;
$tpl -> _reseller_id = $reseller_id;
$tpl -> _phrase = \factory\Ranker::getPhrase( $phrase_id );
$tpl -> _prices = \factory\Ranker::getPhrasePrices( $phrase_id, $reseller_id );
return $tpl -> fetch( 'reseller/costs-edit' );
}
public function drawSitesList( $id, $month = '', $year = '' )
{
global $user;
if ( $id ) \S::set_session( 'drawSitesList:id', $id );
if ( $month ) \S::set_session( 'drawSitesList:month', $month );
if ( $year ) \S::set_session( 'drawSitesList:year', $year );
$month = \S::get_session( 'drawSitesList:month' );
$year = \S::get_session( 'drawSitesList:year' );
$id = \S::get_session( 'drawSitesList:id' );
if ( !$month ) $month = date( 'm' );
if ( !$year ) $year = date( 'Y' );
$site = \factory\RankerClients::getClientSite( $id, $user['id'] );
$tpl = new \Savant3;
$tpl -> _sites = \factory\RankerClients::getClientSites( $user['id'] );
$tpl -> _phrases = \factory\Ranker::getSitePhrases( $site['id'], $month, $year, false, $user['reseller_id'], $user['login'] );
$tpl -> _phrases_reseller = \factory\Ranker::getSitePhrases( $site['id'], $month, $year, false, $user['id'], $user['login'] );
$tpl -> _site = $site;
$tpl -> _month = $month;
$tpl -> _year = $year;
$tpl -> _next_site_id = \factory\RankerClients::getNextClientSiteId( $site['id'], $user['id'] );
$tpl -> _prev_site_id = \factory\RankerClients::getPrevClientSiteId( $site['id'], $user['id'] );
return $tpl -> fetch( 'reseller/site-list' );
}
public function drawClientEdit( $id = '' )
{
global $user;
$tpl = new \Savant3;
$tpl -> _reseller_id = $user['id'];
$tpl -> _client = \factory\Ranker::getClient( $id );
$tpl -> _sites = \factory\RankerClients::getClientSites( $user['id'] );
return $tpl -> fetch( 'reseller/client-edit' );
}
public static function drawClientList()
{
$tpl = new \Tpl;
return $tpl -> render( 'reseller/client-list' );
}
}
?>

View File

@@ -0,0 +1,12 @@
<?php
namespace view;
class Settings {
public function drawSettings()
{
$tpl = new \Savant3;
return $tpl -> fetch( 'other/settings' );
}
}
?>