<?php

//////////////////////////////////////////////////////////////
//===========================================================
// categories_theme.php
//===========================================================
// SOFTACULOUS 
// Version : 1.1
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       10th Jan 2009
// Time:       21:00 hrs
// Site:       http://www.softaculous.com/ (SOFTACULOUS)
// ----------------------------------------------------------
// Please Read the Terms of use at http://www.softaculous.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Inc.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('SOFTACULOUS')){

	die('Hacking Attempt');

}

function no_autoupgrade_theme(){

global $theme, $globals, $user, $l, $langs, $skins, $error, $saved, $categories, $iscripts, $scripts, $top, $no_autoupgrade, $noautoupgrade_catwise, $noautoupgrade_scripts;

softheader(__('$0 - Disable Auto Upgrade For Scripts', array(APP)));

echo '<div class="container-fluid">
	<div class="container my-4">
		<div class="sai-page-title text-center">
			<h2>'.__('Disable Auto Upgrade').'</h2>
		</div>
	</div>
</div>';

error_handle($error);

if(!empty($saved)){
	echo '<div class="container-fluid">
	<div class="alert alert-success text-center"><i class="fas fa-check sai_icons mr-2"></i>
	'.__('The settings were saved successfully.').'</div>';
}

echo '<form accept-charset="'.$globals['charset'].'" name="reordercat" method="post" action="" class="form-horizontal">

<script language="javascript" type="text/javascript"><!-- // --><![CDATA[

ids1 = new Array('.implode(', ', array_keys($noautoupgrade_scripts)).');

function checkallsoftware(checker){	
	for(x in ids1){
		
		$_("scripts_"+ids1[x]).checked = checker.checked;
		
		//change td background color
		changebg(ids1[x],"scripts_");
	}	
};

function selectchkbox(id,type){
	if($_(type+id).checked){
		$_(type+id).checked = false;
	}else{
		$_(type+id).checked = true;
	}
	
	//change td background color
	changebg(id,type);
}

function changebg(id,type){
	try{
		if($_(type+id).checked){
			$("#td_"+id).addClass("script_selected");			
		}else{
			$("#td_"+id).removeClass("script_selected");
		}
	}catch(e){}
};

function checkall(){
	
	// for scripts
	for(x in ids1){	
		changebg(ids1[x],"scripts_");
	}
	
};

addonload("checkall();");

// ]]></script>';

/*  $reseller $user*/
echo '<div class="container-fluid">
	<link href="'.$globals['mirror_images'].'sprites/20.css" rel="stylesheet" type="text/css" />
	<div class="row">
		<div class="col-12">
			<div class="sai-card p-3 mb-3">
				<div class="sai_main_head">
					<h2 class="sai-heading mb-2">'.__('Global Setting for All Auto Upgradable Scripts').'</h2>
					<hr class = "sai_main_head_hr"/>
				</div>

				<div class="sai_form">
					<div class="row">
						<div class="col-8">
							<div class="form-group">
								<input type="checkbox" id="softpath" name="disable_autoupgrade" size="30" '.POSTchecked('disable_autoupgrade', @$no_autoupgrade['disable_autoupgrade']).' />
								<label for="softpath" class="sai-label">'.__('Disable Auto Upgrade').'</label>
								<span class="sai_exp2 mb-3 d-block">'.__('If enabled no installation(s) will be auto upgraded and users will not get an option to enable auto upgrade from enduser panel.').'</span>
								<label for="uptime" class="sai-label d-block">'.__('Set Server load limit').'</label>
								<span class="sai_exp2 mb-1 d-block">'.__('For e.g. you can set value as 5, Now when Softaculous will try to upgrade an installation(s) it will check the load time and if it is lower than the value ONLY than it will upgrade.').'</span>
								<input type="text" name="uptime" class="form-control mb-3" id="uptime" size="40" value="'.POSTval('uptime', $no_autoupgrade['uptime']).'">						
								<label class="sai-label d-block">'.__('Note').': </label>
								<p class="sai_exp2">'.__('If NO value is provided then $0 will use its own formula to calculate the load time and try to upgrade installation(s).<br />Formula will be calculated as : <strong>load = Uptime_of_server / Number_of_cores;</strong> <br />And if load is less than 0.70, ONLY then $0 will try to upgrade the installation(s).', array(APP)).'</p>
							</div>
						</div>
					</div>									
				</div>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<div class="sai-card p-3 mb-3">
				<div class="sai_main_head">
					<h2 class="sai-heading mb-2">'.__('Scripts').'</h2>
					<hr class = "sai_main_head_hr"/>
				</div>
				<div class="form-group">
					<label class="sai-label d-block">'.__('Select the scripts for disabling Auto upgrade').'</label>
					<input type="checkbox" id="checkallsoftwares" class="mr-1" onclick="checkallsoftware(this)"/>
					<span class="sai_exp2"><label class="sai-label" for="checkallsoftwares">'.__('Select All').': </label></span>
				</div>
				<div class="sai_form">';
					foreach($noautoupgrade_catwise as $ak => $av){
						
						echo '<div class="sai_main_head mt-5">
							<h2 class="sai-heading mb-2">'.strtoupper($ak).' Apps</h2>
						</div>';
						foreach($av as $kk => $vv){
							
							if(empty($av[$kk])) continue;
							echo '<h3 class="sai-heading script_cat mt-4 mb-3">'.$l['cat_'.$ak.'_'.$kk].'</h3>
							<hr class = "sai_main_head_hr"/>';
								$i = 0;
								$j = count($vv);
								foreach($vv as $k => $v){
									
									//var_dump($k);
									//var_dump($v);
									if(is_int($i/$j)){
										echo '<div class="row mb-2">';
									}
						
									echo '<div class="col-6 col-lg-3 mb-3" id="td_'.$k.'">
										<input type="checkbox" id="scripts_'.$k.'" name="scripts_'.$k.'" '.POSTchecked('scripts_'.$k, $no_autoupgrade['scripts'][$k]).' class="d-inine-block mr-1" onclick="changebg(\''.$k.'\',\'scripts_\');"/>
									
										<div class="sp20_'.$v['softname'].' d-inline-block align-middle"></div>
										<a href="javascript:void(0)" style="text-decoration: none; " onclick="selectchkbox(\''.$k.'\',\'scripts_\');">
										<label class="sai-label">'.$v['name'].'</label></a>
									</div>';															
								$i++;		
																
									if(is_int($i/$j)){	
										echo '</div>';					
									}																								
								}
							}
						}					
					echo '<p align="center"><input type="submit" name="save" value="'.__('Save').'" class="flat-butt"></p>
				</div>
			</div>
		</div>
	</div>	
</div>';
softfooter();

}

?>