public function create($data)
 {
     $this->setCurrentState(self::$STATE__FINISH_CREATION_SAVE);
     $this->sweepstakeId = Sweepstake_table::createSweepstake($data);
     $url = SweepstakeManager::createNewSweepstake($this->sweepstakeId);
     Sweepstake_table::updateSweepstake($this->sweepstakeId, array("url" => $url));
     return $this->sweepstakeId;
 }
 private static function getHTMLResponse($model)
 {
     $frontendRoot = Config::getModulesUrl() . "frame_mod_sweepstake_list/frontend/";
     $include = "\n\t\t\t\t<link rel='stylesheet' href='" . $frontendRoot . "css/frame_mod_sweepstake_list.css' type='text/css' />\n\t\t\t\t<link rel='stylesheet' href='" . Config::getBaseURL() . "frontend/lib/table_style1/css/style.css' type='text/css' />";
     $script = "";
     $html = "\n<div ng-app='FrameModSweepstakeList_Module' data-ng-init=\"_MODULE_ID_='" . $model->getModuleId() . "';sweepstakeBaseUrl='" . SweepstakeManager::getEndSweepstakeBaseUrl() . "'\"  ng-controller=\"FrameModSweepstakeList_Controller\">\n<div ng-include=\"'" . $frontendRoot . "html/frame_mod_sweepstake_list.html'\"></div>\n</div>\n\n<SCRIPT LANGUAGE='Javascript' SRC='" . $frontendRoot . "js/frame_mod_sweepstake_list.js'></SCRIPT>";
     $res = new FrameworkResponse();
     $res->setStatus(FrameworkResponse::$STATUS__READY);
     $res->setHtml($html);
     $res->setScript($script);
     $res->setImport($include);
     return $res;
 }
 private static function getHTMLResponse($model)
 {
     $res = new FrameworkResponse();
     $moduleClass = $model->getModuleClassName() . "_Model";
     if ($model->getCurrentState() == $moduleClass::$STATE__START_EDIT) {
         $sweepstakeData = $model->getSweepstakeData();
         $frontendRoot = Config::getModulesUrl() . $model->getModuleDirName() . "/frontend/";
         $include = "<SCRIPT LANGUAGE='Javascript' SRC='" . $frontendRoot . "js/" . $model->getModuleDirName() . ".js'></SCRIPT>\n\t\t\t\t\t\t<link rel='stylesheet' href='" . $frontendRoot . "css/" . $model->getModuleDirName() . ".css' type='text/css' />";
         $script = "\nvar " . self::$jsManagerName . " = new " . $model->getModuleClassName() . "_manager();\n" . self::$jsManagerName . ".startWork( '" . $model->getModuleId() . "', '" . $model->getSweepstakeId() . "', '" . SweepstakeManager::getSweepstakeAppKey() . "' );\n\ndocument.getElementById( 'frameModFbTab_appKey' ).value = '" . $sweepstakeData["app_key"] . "';\ndocument.getElementById( 'frameModFbTab_appSecret' ).value = '" . $sweepstakeData["app_secret"] . "';\ndocument.getElementById( 'frameModFbTab_tabName' ).value = '" . $sweepstakeData["share_tab_name"] . "';\n";
         $html = "\n<div id='frameModFbTab_parentContent'>\n\t<div id='frameModFbTab_step1'>\n\t\t<div style='color: #8888ff; font-weight: bold; padding: 20px;'>Step 1</div>\n\t\t<div style='padding: 2px;'><input type='text' id='frameModFbTab_appKey' placeholder='App Key' style='width: 200px;' /></div>\n\t\t<div style='padding: 2px;'><input type='text' id='frameModFbTab_appSecret' placeholder='App Secret' style='width: 200px;' /></div>\n\t\t<div style='padding: 8px;'><input type='button' id='frameModFbTab_login' value='login' style='width: 100px;' /></div>\n\t\t<div id='frameModFbTab_step1Error'></div>\n\t</div>\n\t<div id='frameModFbTab_step2' style='display: none;'>\n\t\t<div style='color: #8888ff; font-weight: bold; padding: 20px;'>Step 2</div>\n\t\t<div style='padding: 2px;' id='frameModFbTab_pagesListParent'></div>\n\t\t<div style='padding: 2px;'><table><tr><td><input type='file' name='imageField' value='Tab Image' id='frameModFbTab_tabImage' /></td><td>(Tab Image: size 111 x 74 px)</td></tr></table></div>\n\t\t<div style='padding: 2px;'><input type='text' id='frameModFbTab_tabName' placeholder='Tab Name' style='width: 300px;' /></div>\n\t\t<div style='padding: 8px;'><input type='button' id='frameModFbTab_save' value='save' /></div>\n\t\t<div id='frameModFbTab_step2Error'></div>\n\t</div>\n</div>\n\t\t\t";
         $res->setStatus(FrameworkResponse::$STATUS__READY);
         $res->setHtml($html);
         $res->setScript($script);
         $res->setImport($include);
     } else {
         $res->setStatus(FrameworkResponse::$STATUS__CHANGE_MODULE);
     }
     return $res;
 }
    private static function getHTMLResponse($model)
    {
        $res = new FrameworkResponse();
        $moduleClass = $model->getModuleClassName() . "_Model";
        if ($model->getCurrentState() == $moduleClass::$STATE__START) {
            $sweepstakeData = $model->getSweepstakeData();
            $frontendRoot = Config::getModulesUrl() . $model->getModuleDirName() . "/frontend/";
            $include = "<SCRIPT LANGUAGE='Javascript' SRC='" . $frontendRoot . "js/" . $model->getModuleDirName() . ".js'></SCRIPT>\n\t\t\t\t\t\t<link rel='stylesheet' href='" . $frontendRoot . "css/" . $model->getModuleDirName() . ".css' type='text/css' />\n\t\t\t\t\t\t<link rel='stylesheet' href='" . $frontendRoot . "css/style.css' type='text/css' />\n\t\t\t\t\t\t<link rel='stylesheet' href='" . $frontendRoot . "css/theme-1.css' type='text/css' />\n\t\t\t\t\t\t<link rel='stylesheet' href='" . $frontendRoot . "css/uniform.css' type='text/css' />";
            $script = "\nvar " . self::$jsManagerName . " = new " . $model->getModuleClassName() . "_manager();\n" . self::$jsManagerName . ".startWork( '" . $model->getModuleId() . "', '" . $model->getSweepstakeId() . "', '" . SweepstakeManager::getSweepstakeAppKey() . "', " . json_encode($model->getSweepstakeData()) . ", '" . SweepstakeManager::getEndSweepstakeBaseUrl() . "', '" . $model->getUserComeWayId() . "', " . time() . ", 'frameModSweepstakeApp_headerParent', 'frameModSweepstakeApp_parentContent' );\n";
            $html = '
	<!-- Top Area -->
	<div class="wraper-top">
		<div class="fixw">
			<div class="clear">&nbsp;</div><!-- avoid collapsing margins -->
			<div class="head-block">
				<!-- Heading -->
				<h1 id="frameModSweepstakeApp_headerParent"></h1>
				<!-- /Heading -->
			</div>
		</div>
	</div>
	<!-- /Top Area -->
	
	<!-- Form Area -->
	<div class="wraper-mid">
		<div class="clear">&nbsp;</div><!-- avoid collapsing margins -->
		<div class="fixw form-line">
			<div class="form-col-1">
				<div class="form-wrap">
					<div class="clear">&nbsp;</div><!-- avoid collapsing margins -->
					<div class="form-inner">
						<div class="clear">&nbsp;</div><!-- avoid collapsing margins -->
						<div id="frameModSweepstakeApp_parentContent" style="width: 100%, height: 100%; vertical-align: middle; text-align: left;">
					        <!-- Area to add instructions -->
					    </div>		
						<div class="clear">&nbsp;</div><!-- avoid collapsing margins -->
					</div>
				</div>
				<div class="form-bot"></div>
			</div>
			<div class="form-col-2">
				<!-- Form Sidebar Content -->
					&nbsp;
				<!-- /Form Sidebar Content -->
			</div>
			<div class="clear"></div>
		</div>
	</div>
	<!-- /Form Area -->
	
	<!-- Bottom Area -->
	<div class="wraper-bot">
		<div class="clear">&nbsp;</div><!-- avoid collapsing margins -->
		<div class="fixw">
			
		</div>
	</div>
<div style="font-size: 11; padding-right: 20px; padding-top: 20px; text-align: right; font-family: arial; ">Developed by <b>Mher Aghabalyan</b></div>	
	<!-- /Bottom Area -->';
            $res->setStatus(FrameworkResponse::$STATUS__READY);
            $res->setHtml($html);
            $res->setScript($script);
            $res->setImport($include);
        } else {
            $res->setStatus(FrameworkResponse::$STATUS__CHANGE_MODULE);
        }
        return $res;
    }
 public function cloneSweepstake($id)
 {
     $this->setCurrentState(self::$STATE__CLONE);
     $this->sweepstakeId = Sweepstake_table::cloneSweepstake($id);
     $url = SweepstakeManager::createNewSweepstake($this->sweepstakeId);
     Sweepstake_table::updateSweepstake($this->sweepstakeId, array("url" => $url));
     return $this->sweepstakeId;
 }