Пример #1
0
		  if(($frecord->active==0||$frecord->active==3) && ($frecord->trainerid==$USER->id || is_siteadmin())){
		    $session_active.='<span  class="knowmore cpointer" onclick="cancelbatch('.$frecord->id.');">Cancel</span>';
		  }else if(($frecord->active==1) && ($frecord->trainerid==$USER->id || is_siteadmin())){
			     $session_active.='<span  class="knowmore cpointer" onclick="cancelbatch('.$frecord->id.');">Cancel</span>';
				$close=$DB->record_exists('facetoface', array('id'=>$frecord->id,'active'=>8));
			  if(!$close){
			   $session_active.=$completion_button;
			  }
		  }else{
			   $session_active.='';
		  }
		  
		  
	 }elseif((($diff>0||$diff==0)&&!empty($batch_lastsession_date))){
		
		  $batch_firstsession_date=condition_for_hold_button($frecord->id);/* This function returns
												                     *firstsession start date and present date */
			   $now = time(); // or your date as well
			   $datediff_fs = strtotime(date("d M,Y",$batch_firstsession_date->timestart)) - $now;
					
			   $diff_fs= floor($datediff_fs/(60*60*24)) ; /* This condition checked date difference between
				 									*firstsession start date and present date */
			   //$session_active='';
		  if(($frecord->active==0)&& ($frecord->trainerid==$USER->id || is_siteadmin())){
		     //$session_active='';
		    if(($diff_fs>0||$diff_fs==0)&&$frecord->active==0){
			   //$session_active.='<span  class="knowmore cpointer" onclick="activatebatch('.$frecord->id.');">Notify</span>';
			}
			 $session_active.='<span  class="knowmore cpointer" onclick="cancelbatch('.$frecord->id.');">Cancel</span>';
		  }
		  else if(($frecord->active==1) && ($frecord->trainerid==$USER->id || is_siteadmin())){
Пример #2
0
/**
 *get a record to the facetoface ace2face table script
 * @param object $frecord 
*/
function batch_first_session_firstdate($frecord){//*This function for batch_buttons_conditions*//		
    global $DB, $OUTPUT,$USER,$CFG;
     $batch_firstsession_date=condition_for_hold_button($frecord->id);/* This function returns
												                     *firstsession start date and present date */
     $now = time(); // or your date as well
     $datediff_fs =  userdate("%d/%m/%Y",$batch_firstsession_date->timestart) - $now;
         
     //$diff_fs= floor($datediff_fs/(60*60*24)) ; /* This condition checked date difference between
     //                                    *firstsession start date and present date */
     return $datediff_fs;
}
Пример #3
0
/**
 *get a record to the facetoface ace2face table script
 * @param object $frecord 
*/
public function batch_last_session_date_show_actions($frecord,$modcontext,$cm){//*This function for batch_buttons_conditions*//		
     global $DB, $OUTPUT,$USER,$CFG,$PAGE;
     
        /* 0 indicates batch status is new
         * 1 indicates batch status is active
         * 2 indicates batch status is canceled
         * 3 indicates batch status is hold
         * 8 indicates batch status is completed
         */
         $batch_lastsession_date=mark_completion_button($frecord->id);/* This function returns
	 											                     *last session finish date and present date */
         $batch_firstsession_date=condition_for_hold_button($frecord->id);/* This function returns
												                     *firstsession start date and present date */
         $diff =  batch_last_session_lastdate($frecord); /* This function checked date difference between
	
	 											  *last session finish date and present date */
         $diff_fs=batch_first_session_firstdate($frecord);/* This condition checked date difference between
				 									*firstsession start date and present date */
        
       
        $completion_button=$this->view_session_completion_button($frecord);//*This function returns when completion button enable*//
        $buttons=array();//Right side buttons of batch
        
        $edit=html_writer::link(new moodle_url('/course/modedit.php', array('update' => $cm->id,'sr'=>0, 'sesskey' => sesskey())),
									'<span  class="knowmore cpointer" >'.get_string('edit', 'facetoface').'</span>');
        $delete=html_writer::link(new moodle_url('/course/mod.php', array('delete' => $cm->id,'sr'=>0, 'sesskey' => sesskey())),
											  '<span  class="knowmore cpointer" >'.get_string('delete', 'facetoface').'</span>'
											  , array('id' => 'deleteconfirm' . $cm->id . '')).
        html_writer::script("Y.on('click', M.util.tmahendra_show_confirm_dialog, '#deleteconfirm$cm->id', null, {'message':'" . get_string('deletef2f', 'facetoface',$frecord->name) . "','callbackargs':{'id':'','extraparams':'delete=$cm->id&tsr=0'}});");
        $session_adding='';
        
        $assigned_users_status=$DB->get_record_sql("SELECT * FROM {local_batch_courses} where batchid=$frecord->id");
            
        if($assigned_users_status->testid!=0){
          //$course_completion_check1=$DB->record_exists_sql("SELECT * FROM {course_completion_criteria} cc,{course} c Where c.id=$assigned_users_status->courseid and c.id=cc.course and c.enablecompletion=1 AND module  IS NOT NULL AND moduleinstance=$assigned_users_status->testid");
             $course_completion_check=$DB->record_exists_sql("SELECT * FROM {course_completion_criteria} cc,{course} c 
                                                             Where
                                                             c.id=$assigned_users_status->courseid and c.id=cc.course and c.enablecompletion=1
                                                             AND (cc.module  IS NOT NULL)
                                                             AND cc.moduleinstance in (SELECT id FROM {course_modules} where course=$assigned_users_status->courseid and instance=$assigned_users_status->testid)");
             if($course_completion_check==1){
                 $course_completion_check=0;
             }else{
                 $course_completion_check=1;
             }
         }else{
          $course_completion_check=0;
         }
         if($course_completion_check==1){
            $Notify='<span  class="knowmore cpointer" ><a id="show'.$frecord->id.'" class="'.$frecord->id.'_open cpointer" style="color:#fff !important;text-decoration: none !important;">'.get_string('notify', 'facetoface').'</a></span>';
         }else{
            $Notify = html_writer::tag('a','<span  class="knowmore cpointer" >'.get_string('notify', 'facetoface').'</span>', array('href' => "$CFG->wwwroot/mod/facetoface/batchstatus.php?type=active&id=$frecord->id", 'id' => 'active'.$frecord->id.''))
             .html_writer::script("Y.on('click', M.util.tmahendra_show_confirm_dialog, '#active$frecord->id', null, {'message':'" . get_string('notify_info', 'mod_facetoface',$frecord->name) . "','callbackargs':{'id':$frecord->id,'extraparams':'&type=active'}});");
         }
       
         $Cancel = html_writer::tag('a','<span  class="knowmore cpointer" >'.get_string('cancel', 'facetoface').'</span>', array('href' => "$CFG->wwwroot/mod/facetoface/batchstatus.php?type=cancel&id=$frecord->id", 'id' => 'cancel'.$frecord->id.''))
        .html_writer::script("Y.on('click', M.util.tmahendra_show_confirm_dialog, '#cancel$frecord->id', null, {'message':'" . get_string('cancel_info', 'mod_facetoface',$frecord->name) . "','callbackargs':{'id':$frecord->id,'extraparams':'&type=cancel'}});");
        //$Hold='<span class="knowmore cpointer" onclick="deactivatebatch('.$frecord->id.');">'.get_string('hold', 'facetoface').'</span>';
       
       $Hold = html_writer::tag('a','<span  class="knowmore cpointer" >'.get_string('hold', 'facetoface').'</span>', array('href' => "$CFG->wwwroot/mod/facetoface/batchstatus.php?type=deactivate&id=$frecord->id", 'id' => 'deactivate'.$frecord->id.''))
         .html_writer::script("Y.on('click', M.util.tmahendra_show_confirm_dialog, '#deactivate$frecord->id', null, {'message':'" . get_string('hold_info', 'mod_facetoface',$frecord->name) . "','callbackargs':{'id':$frecord->id,'extraparams':'&type=deactivate'}});");     
        //$Release_Hold='<span class="knowmore cpointer" onclick="releasebatch('.$frecord->id.');">'.get_string('release_hold', 'facetoface').'</span>';
      
        $Release_Hold = html_writer::tag('a','<span  class="knowmore cpointer" >'.get_string('release_hold', 'facetoface').'</span>', array('href' => "$CFG->wwwroot/mod/facetoface/batchstatus.php?type=release&id=$frecord->id", 'id' => 'release'.$frecord->id.''))
             .html_writer::script("Y.on('click', M.util.tmahendra_show_confirm_dialog, '#release$frecord->id', null, {'message':'" . get_string('releasehold_info', 'mod_facetoface',$frecord->name) . "','callbackargs':{'id':$frecord->id,'extraparams':'&type=release'}});");     
       
       $sql="SELECT * FROM {facetoface} where id=$frecord->id";
            $batch_end_date=$DB->get_record_sql($sql);
            $now = time(); // or your date as well
            $diff_fend =  userdate("%d/%m/%Y",$batch_end_date->enddate) - $now;
                 
            $diff_fends=  floor($diff_fend/(60*60*24)) ; /* This condition checked date difference between
                                                *facetofcae end date and present date */
       
       //echo $frecord->name."<br/>".$diff_fends."<br/>";
        $close=$DB->record_exists('facetoface', array('id'=>$frecord->id,'active'=>8));
        
        $session_active='';//Right side custom buttons of batch
        if((!$close) && ($frecord->active!=2)){
            
         $session_active=$Notify;
        }
         //echo $diff."<br/>".$frecord->name."<br/>";
     if(($diff>0)||(empty($batch_lastsession_date))){
         
		 if($frecord->active==0 || $frecord->active==3){
			   //if($frecord->active==0){
					$buttons[] = $edit;
		       //}
			       $buttons[] = $delete;
			   if(has_capability('moodle/course:manageactivities', $modcontext)){
			       $buttons = implode('',$buttons);
			   }
			   if(($frecord->active==3) && ($frecord->trainerid==$USER->id || is_siteadmin())){
            
                    $session_active .=$Release_Hold;
                    $session_active .=$Cancel;
                }
		  }
          elseif(($frecord->active==0)&& ($frecord->trainerid==$USER->id || is_siteadmin())){
			 $session_active.=$Cancel;
		  }elseif(($frecord->active==1) && ($frecord->trainerid==$USER->id || is_siteadmin())){
			 
			  if(($diff_fs>0||$diff_fs==0)||(empty($batch_firstsession_date))){
			     $session_active.=$Hold;
			  }
			  $session_active .=$Cancel;
			  if(!$close){
			       $session_active.=$completion_button;
			  }
			  
		  }elseif((($frecord->active==8)&& ($diff_fends >= -10)) && ($frecord->trainerid==$USER->id || is_siteadmin())){
            
            $session_active.=$completion_button;
          }
		  
	 }elseif(($diff<0||$diff==0)){
	
          if($frecord->active==0 || $frecord->active==3){
				$buttons[] = $edit;
			    $buttons[] = $delete;
			   if(has_capability('moodle/course:manageactivities', $modcontext)){
			     $buttons = implode('',$buttons);
				
			   }
			   
		   }
            elseif(($frecord->active==0||$frecord->active==3) && ($frecord->trainerid==$USER->id || is_siteadmin())){
		      $session_active.=$Cancel;
		    }else if(($frecord->active==1) && ($frecord->trainerid==$USER->id || is_siteadmin())){
			      $session_active.=$Cancel;
			  if(!$close){
			       $session_active.=$completion_button;
			  }
		  }elseif((($frecord->active==8)&& ($diff_fends >= -10)) && ($frecord->trainerid==$USER->id || is_siteadmin())){
            
            $session_active.=$completion_button;
          }
     }
     if(empty($buttons)){
            $buttons ='';
     }
     return $session_active.' '.$session_adding.' '.$buttons;

}