confirmation.mustache 8.5 KB
<style>
input[type="checkbox"][disabled] {
  cursor: no-drop;
}

#loadingcomparision{

display:none;
}

th,td{
/* text-align: center !important; */
}

</style>

	<div id="loadingcomparision" align="center">
              <img src="{{wwwroot}}/local/mandatoryactivities/pix/loading.gif"/>
     </div>
     
     <div id="successalert">
     
     </div>

  <div id="comparisiontable" style="display:none;">
  		<div id="accordion2">
 			<div class="card">
      			<div class="card-header" style="background-color: rgb(255 255 255);border-bottom:none;">
      				<i id="cccriteria2" class="arrow down" data-toggle="collapse" href="#collapse3" style="cursor:pointer;"></i>&nbsp;&nbsp;
        			<a id="cccriteria2" class="card-link" data-toggle="collapse" href="#collapse3" style="color: black;font-size: medium;">
          			<b>confirm</b>
        			</a>
      			</div>
      				<div id="collapse3" class="collapse show" data-parent="#accordion2">
        				<div class="card-body">
        					<div class="row">
        						<div class="col text-center">
									<table class="activitytable center">
  									<tr>
    								<th style="width:10%">Sl.no</th><th>Activities removed from mandatory</th>
		    						</tr>
		    						<tbody id="removed">
		    			
		    						</tbody>
									</table>
								</div>
			 				</div>
						</div>
    				</div>
    		</div>
		</div>
    	
    	<div id="accordion3">
 			<div class="card">
      			<div class="card-header" style="background-color: rgb(255 255 255);border-bottom:none;">
        			<a id="cccriteria3" class="card-link" data-toggle="collapse" href="#collapse4" style="color: black;font-size: medium;">
        			</a>
      			</div>
    				<div id="collapse4" class="collapse show" data-parent="#accordion3">
        				<div class="card-body">
        					<div class="row">
        						<div class="col text-center">
									<table class="activitytable center">
  									<tr>
    								<th style="width:10%">Sl.no</th><th>Newly Added mandatory activities</th>
		    						</tr>
		    						<tbody id="added">
		    			
		    						</tbody>
									</table>
								</div>
			 				</div>
						</div>
    				</div>
    		</div>
    	</div>
    
    	<div id="accordion4">
 			<div class="card">
      			<div class="card-header" style="background-color: rgb(255 255 255);border-bottom:none;">
        			<a id="cccriteria4" class="card-link" data-toggle="collapse" href="#collapse5" style="color: black;font-size: medium;">
        			</a>
      			</div>
    				<div id="collapse5" class="collapse show" data-parent="#accordion4">
        				<div class="card-body">
        					<div class="row">
        						<div class="col text-center">
									<table class="activitytable center">
  									<tr>
    								<th style="width:10%">Sl.no</th><th>Unchanged activities </th>
		    						</tr>
		    						<tbody id="unchanged">
		    			
		    						</tbody>
									</table>
								</div>
			 				</div>
						</div>
    				</div>
    		</div>
    	</div
    	
    	<div id="accordion5">
			<div class="card">
				<div class="card-header" style="background-color: rgb(255 255 255);border-bottom:none;">
					<i id="cccriteria5" data-toggle="collapse" href="#collapse6" style="cursor:pointer;"></i>&nbsp;&nbsp;
					<a id="cccriteria5" class="card-link" data-toggle="collapse" href="#collapse6" style="color: black;font-size: medium;"></a>
      			</div> 
					<div id="collapse6" class="collapse show" data-parent="#accordion5">
        				<div class="card-body">
        	  				<div class="row">
        						<div class="col text-center">
        							<button type="button" class="btn btn-info" id="previousepagem">Previous page</button>
									<button type="button" class="btn btn-info" id="savemandatoryconfirm">Save Changes</button>
									<button type="button" class="btn btn-info" id="cancelmandatory">Cancel</button></td></tr>
								</div>
			 				</div>
						</div>
    				</div>
			</div>
		</div>
    	
  </div>

<script>

 $(document).ready(function(){
	
		$(document).on('click', '#savemandatory', function(){
		
		$('#madatorysection').css("display", "none");
		$('#loadingcomparision').css("display", "block");
		
			var checkedids=[];
			
			$('input:checkbox.checkboxesavilable:checked').each(function () {
       			checkedids.push($(this).attr("data-cmid"));
  			});
	
			var rootPath = M.cfg.wwwroot;
            var arg = { action:'getcomparision',
						checked:checkedids,
						course : {{courseid}},
						mandatory:'{{mandatoryids}}'};
            
            $.ajax({
					url: rootPath+"/local/mandatoryactivities/ajax.php",
					type: "POST",
					data : arg,
					success: function(obj){
					
						var removedcmids=obj.removed;
						var newlyaddedcmids=obj.newlyadded;
						var unchangedcmids=obj.unchanged;
						
							$('#loadingcomparision').css("display", "none");
							$('#comparisiontable').css("display", "block");
							
					
							if(removedcmids.length > 0){
						
								var tablecontent1="";var i;
							
								for (i = 0; i < removedcmids.length; i++) {
									var slno=i+1;
  									tablecontent1 += "<tr id='removedrows'><td>"+slno+"</td><td>"+removedcmids[i].name+"</td></tr>";
								}
					
								$('[id=removedrows]').remove();
								$("#removed").append(tablecontent1);
					
							}else{
					
								tablecontent1 += "<tr id='removedrows'><td colspan='2'>No Activities </td></tr>";
								$('[id=removedrows]').remove();
								$("#removed").append(tablecontent1);
							}
					
					
							if(newlyaddedcmids.length > 0){
					
								var tablecontent2="";var i;
							
								for (i = 0; i < newlyaddedcmids.length; i++) {
									var slno=i+1;
  									tablecontent2 += "<tr id='addedrows'><td>"+slno+"</td><td>"+newlyaddedcmids[i].name+"</td></tr>";
								}
								
								$('[id=addedrows]').remove();
								$("#added").append(tablecontent2);
					
							}else{
					
								tablecontent2 += "<tr id='addedrows'><td colspan='2'>No Activities </td></tr>";
								$('[id=addedrows]').remove();
								$("#added").append(tablecontent2);
							}
					
					
							if(unchangedcmids.length > 0){
					
								var tablecontent3="";var i;
							
								for (i = 0; i < unchangedcmids.length; i++) {
									var slno=i+1;
  									tablecontent3 += "<tr id='unchangedrows'><td>"+slno+"</td><td>"+unchangedcmids[i].name+"</td></tr>";
								}
							
								$('[id=unchangedrows]').remove();
								$("#unchanged").append(tablecontent3);
					
							}else{
					
								tablecontent3 += "<tr id='unchangedrows'><td colspan='2'>No Activities </td></tr>";
								$('[id=unchangedrows]').remove();
								$("#unchanged").append(tablecontent3);
							}
				},
				error: function(){

				}
			});

	//	$('#accordion1').css("display", "none");

	});
	
	$(document).on('click', '#cccriteria2', function(){
				$('#cccriteria3').click();
				$('#cccriteria4').click();
				$('#cccriteria5').click();

				var vals=$('#cccriteria2').hasClass('down');
				if(vals){
					$('#cccriteria2').removeClass('down');
					$('#cccriteria2').addClass('right');
				}else{
					$('#cccriteria2').removeClass('right');
					$('#cccriteria2').addClass('down');
				}
	});
		

		$(document).on('click', '#savemandatoryconfirm', function(){
		
				var cmids=[];
				var rootPath = M.cfg.wwwroot;
				
				$('#loadingcomparision').css("display", "block");
				$('#comparisiontable').css("display", "none");
				
				$.each($("input[type='checkbox']:checked"), function(){
               		cmids.push($(this).attr("data-cmid"));
            	});
            	
            	var arg = {
				action:'savemandatoryids',
				cmids :cmids,
				course : {{courseid}}				
				};
            
            $.ajax({
					url: rootPath+"/local/mandatoryactivities/ajax.php",
					type: "POST",
					data : arg,
					success: function(obj){
					
					$('#loadingcomparision').css("display", "none");
					
					var alerttags='<div class="alert alert-success"><strong>Successfully Ssved</strong></div>';
					$('#successalert').append(alerttags);
					
					 setTimeout(function(){
					  var redirecturl=rootPath+"/local/mandatoryactivities/editsettings.php?courseid="+{{courseid}};
					location.replace(redirecturl);
					  }, 1500);
					
				},
				error: function(){
			
					//var redirecturl=rootPath+"local/coursecompletion/index.php?courseid="+{{courseid}};
					//location.replace(redirecturl);
				}
			});
		});

		
		$(document).on('click', '#previousepagem', function(){
		
		$('#comparisiontable').css("display", "none");
		$('#madatorysection').css("display", "block");
		
		
		});



		
 });
 		
</script>