Creati nuovi banner lunghi Aumentate numero notizie ansa Aumentate numero notizie cronaca in homepage fix mobile articolo per show player video modifica amministrazione per show player mobile
144 lines
5.4 KiB
PHP
144 lines
5.4 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 02/mar/2016
|
|
*/
|
|
|
|
require_once(dirname(__FILE__)."/../load.php");
|
|
|
|
GUIHandler::generateHtmlHeaders(array(),true);
|
|
|
|
if (!AdminLoginManager::isLogged()){
|
|
GUIHandler::redirect("admin/login.php");
|
|
}
|
|
else if (!AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_BANNER)){
|
|
GUIHandler::redirect("admin/listBanner.php");
|
|
}
|
|
|
|
MenuGenerator::generateMenu();
|
|
HTMLHelper::generateAdminHead();
|
|
|
|
|
|
try{
|
|
$error = "";
|
|
$bannerId = PostHandler::get("id");
|
|
|
|
$banner = null;
|
|
if (!is_null($bannerId) && strcmp("",$bannerId)!=0){
|
|
$banner = GlobalVariables::get("dao")->getFirst("BannerModel",array("id"=>$bannerId));
|
|
}
|
|
if (is_null($banner)){
|
|
GUIHandler::redirect("admin/listBanner.php");
|
|
}
|
|
|
|
|
|
if(array_key_exists("action", $_POST) && strcmp(PostHandler::get("action"), "save")==0){
|
|
$banner->customer = PostHandler::get("customer");
|
|
$banner->link = PostHandler::get("link");
|
|
// $banner->start = new Mongodate(strtotime(PostHandler::get("dateStart")));
|
|
// $banner->end = new Mongodate(strtotime(PostHandler::get("dateEnd")));
|
|
|
|
$banner->start = new MongoDB\BSON\UTCDateTime( strtotime(PostHandler::get("dateStart")) * 1000 );
|
|
$banner->end = new MongoDB\BSON\UTCDateTime( strtotime(PostHandler::get("dateEnd")) * 1000);
|
|
|
|
if (strcmp("",PostHandler::get("position"))==0){
|
|
throw new GUIException("Selezionare una posizione per il banner");
|
|
}
|
|
$banner->position = PostHandler::get("position");
|
|
|
|
$banner->categories = array();
|
|
|
|
$general = PostHandler::get("categories_".BannerModel::GENERAL_CATEGORY);
|
|
if (!is_null($general) && strcasecmp($general, BannerModel::GENERAL_CATEGORY)==0){
|
|
$banner->categories[] = BannerModel::GENERAL_CATEGORY;
|
|
}
|
|
foreach (NotiziaModel::$NOTIZIE_CATEGORY as $category=>$data){
|
|
$val = PostHandler::get("categories_".$category);
|
|
if (!is_null($val) && strcasecmp($val, $category)==0){
|
|
$banner->categories[] = $category;
|
|
}
|
|
}
|
|
|
|
GlobalVariables::get("dao")->save($banner);
|
|
GUIHandler::redirectPost("admin/homeBanner.php",array("id"=>$banner->id));
|
|
}
|
|
|
|
}catch(GUIException $ex){
|
|
$error = $ex->getMessage();
|
|
}catch (Exception $exec){
|
|
$msg = LogModel::fromException($exec);
|
|
GlobalVariables::get("dao")->save($msg);
|
|
$error = "Si è verificato un errore inatteso durante l'esecuzione della pagina. Contattare il supporto tecnico comunicando il seguente codice di erore '".$msg->getCode()."'";
|
|
|
|
}
|
|
|
|
?>
|
|
<div>
|
|
<?php
|
|
if(strcmp($error, "")!=0){
|
|
?>
|
|
<div style="font-size: 16px; color:red;">
|
|
<?php echo $error;?>
|
|
</div>
|
|
<?php
|
|
}
|
|
?>
|
|
<div>
|
|
<form enctype="multipart/form-data" id="loadFile" method="POST">
|
|
<input type="hidden" name="id" value="<?php echo $bannerId;?>" />
|
|
<input type="hidden" name="action" value=""/>
|
|
<div>
|
|
<span class="label">Posizione:</span>
|
|
<select name="position">
|
|
<option disabled selected style="display:none;">Seleziona Posizione</option>
|
|
<option <?php echo $banner->position==BannerModel::POSITION_HEAD?"selected":"";?> value="<?php echo BannerModel::POSITION_HEAD;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_HEAD]["label"];?></option>
|
|
<option <?php echo $banner->position==BannerModel::POSITION_BODY?"selected":"";?> value="<?php echo BannerModel::POSITION_BODY;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_BODY]["label"];?></option>
|
|
<option <?php echo $banner->position==BannerModel::POSITION_LONG?"selected":"";?> value="<?php echo BannerModel::POSITION_LONG;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_LONG]["label"];?></option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<span class="label">Cliente:</span>
|
|
<input type="text" name="customer" value="<?php echo $banner->customer;?>" />
|
|
</div>
|
|
<div>
|
|
<span class="label">Link:</span>
|
|
<input type="text" name="link" value="<?php echo $banner->link;?>" />
|
|
</div>
|
|
<div>
|
|
<span class="label">Data inizio:</span>
|
|
<input type="text" id="datepickerStart" name="dateStart" value="<?php echo date("d-m-Y",$banner->start->toDateTime()->getTimestamp());?>">
|
|
</div>
|
|
<div>
|
|
<span class="label">Data fine:</span>
|
|
<input type="text" id="datepickerEnd" name="dateEnd" value="<?php echo date("d-m-Y",$banner->end->toDateTime()->getTimestamp());?>">
|
|
</div>
|
|
<div><span class="label"> </span><b>Categorie</b></div>
|
|
<?php
|
|
echo '<div><span class="label">Generale</span><input type="checkbox" name="categories_'.BannerModel::GENERAL_CATEGORY.'" value="'.BannerModel::GENERAL_CATEGORY.'" '.(in_array(BannerModel::GENERAL_CATEGORY, $banner->categories)?'checked="checked"':"").' /><br/>';
|
|
foreach (NotiziaModel::$NOTIZIE_CATEGORY as $category=>$data){
|
|
echo '<div><span class="label">'.$data["label"].'</span><input type="checkbox" name="categories_'.$category.'" value="'.$category.'" '.(in_array($category, $banner->categories)?'checked="checked"':"").' /><br/>';
|
|
}
|
|
?>
|
|
|
|
</form>
|
|
<div class="formBtns">
|
|
<a href="#" id="submit" >Salva</a>
|
|
<a href="#" id="back" >Annulla</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(event){
|
|
$("#submit").click(function(event){
|
|
$("form#loadFile input[type=hidden][name=action]").val("save");
|
|
$("form#loadFile").submit();
|
|
});
|
|
|
|
$("#back").click(function(event){
|
|
openPagePost('homeBanner.php',[{name:'id',value:'<?php echo $bannerId;?>'}]);
|
|
});
|
|
|
|
$("#datepickerStart").datepicker({dateFormat:"dd-mm-yy"});
|
|
$("#datepickerEnd").datepicker({dateFormat:"dd-mm-yy"});
|
|
});
|
|
</script>
|