示例#1
0
        // Current tab
        $currenttab = 'upload';
        //adding tabs
        $instance->report_tabs($currenttab);

        echo $OUTPUT->box(get_string('uploadtabdes', 'local_admission'));
        echo '<div style="float:right;"><a href="sample.php?format=csv"><button>' . get_string('sample_excel', 'local_departments') . '</button></a></div>';
        echo '<div style="float:right;"><a href="help.php"><button>' . get_string('dept_manual', 'local_departments') . '</button></a></div>';

        $mform1->display();
        echo $OUTPUT->footer();
        die;
    }
} else {//if not empty of variable $iid,it get the content from the csv content
    $cir = new csv_import_reader($iid, 'uploadadmission');
    $filecolumns = uu_validate_admission_upload_columns($cir, $STD_FIELDS, $PRF_FIELDS, $returnurl);
}
// Print the header
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('uploadadmissionsresult', 'local_admission'));
$optype = 'UU_ADMISSION_ADDNEW';
// verification moved to two places: after upload and into form2
$admissionsnew = 0;
$admissionsupdated = 0;
$admissionsuptodate = 0; //not printed yet anywhere
$admissionserrors = 0;
$admissionsskipped = 0;
// init csv import helper
$cir->init();
$linenum = 1; //column header is first line
// init upload progress tracker------this class used to keeping track of code(each rows and columns)-------------
示例#2
0
function local_batches_upload_preview($cir,$previewrows=10){
     global $DB,$CFG,$USER;
    // preview table data    
     $returnurl = new moodle_url('/local/batches/bulk_enroll.php');
    //$STD_FIELDS = array('firstname', 'middlename', 'lastname', 'gender', 'dob', 'birthcountry', 'birthplace', 'fathername', 'pob', 'region', 'town', 'current_home_no', 'current_country', 'phone', 'email', 'howlong', 'same', 'permenant_country', 'permenant_home_no', 'state', 'city', 'pincode', 'contactname', 'primary_school', 'primary_year', 'primary_score', 'primary_place', 'undergraduate_in', 'ugname', 'ug_year', 'ug_score', 'ug_place', 'graduate_in', 'graduate_name', 'graduate_year', 'graduate_score', 'graduate_place', 'examname', 'hallticketno', 'score', 'no_of_months', 'reason', 'description','typeofstudent', 'typeofapplication', 'previousstudent', 'serviceid', 'typeofprogram');
    $STD_FIELDS = array('firstname', 'middlename', 'lastname', 'gender', 'dob','region','category', 'current_country', 'phone', 'email', 'otherphone','city', 'pincode',   'typeofapplication',  'serviceid', 'fatheremail','address');

    $PRF_FIELDS = array();
   
    $result = '';    

    $enrollablecount = 0;
    $createdgroupscount = 0;
    $createdgroupingscount = 0;
    $createdgroups = '';
    $createdgroupings = '';

    
    $filecolumns = uu_validate_admission_upload_columns($cir, $STD_FIELDS, $PRF_FIELDS, $returnurl);
    
    
    $data = array();
    $cir->init();
    $linenum = 1; //column header is first line
    $noerror = true; // Keep status of any error.
    while ($linenum <= $previewrows and $fields = $cir->next()) {
	$linenum++;
	$rowcols = array();
	$rowcols['line'] = $linenum;
	foreach($fields as $key => $field) {
	    $rowcols[$filecolumns[$key]] = s(trim($field));
	}
	//$rowcols['status'] = array();
	//   
	//if (isset($rowcols['username'])) {
	//    $stdusername = clean_param($rowcols['username'], PARAM_USERNAME);
	//    if ($rowcols['username'] !== $stdusername) {
	//	$rowcols['status'][] = get_string('invalidusernameupload');
	//    }
	//    if ($userid = $DB->get_field('user', 'id', array('username'=>$stdusername, 'mnethostid'=>$CFG->mnet_localhost_id))) {
	//	$rowcols['username'] = html_writer::link(new moodle_url('/user/profile.php', array('id'=>$userid)), $rowcols['username']);
	//    }
	//} else {
	//  //  $rowcols['status'][] = get_string('missingusername');
	//}
    
	if (isset($rowcols['email'])) {
	    if (!validate_email($rowcols['email'])) {
		//$rowcols['status'][] = get_string('invalidemail');
	    }
	    if ($DB->record_exists('user', array('email'=>$rowcols['email']))) {
		//$rowcols['status'][] = $stremailduplicate;
	    }
	}
    
	if (isset($rowcols['city'])) {
	    $rowcols['city'] = $rowcols['city'];
	}
	//// Check if rowcols have custom profile field with correct data and update error state.
	//$noerror = uu_check_custom_profile_data($rowcols) && $noerror;
	//$rowcols['status'] = implode('<br />', $rowcols['status']);
	$data[] = $rowcols;
    }
    if ($fields = $cir->next()) {
	$data[] = array_fill(0, count($fields) + 2, '...');
    }
    $cir->close();
    
    $table = new html_table();
    $table->id = "uupreview";
    $table->attributes['class'] = 'generaltable';
    $table->tablealign = 'center';
    $table->summary = get_string('uploaduserspreview', 'tool_uploaduser');
    $table->head = array();
    $table->data = $data;
    
    $table->head[] = get_string('uucsvline', 'tool_uploaduser');
    foreach ($filecolumns as $column) {
	$table->head[] = $column;
    }
    $table->head[] = get_string('status');
    
    echo html_writer::tag('div', html_writer::table($table), array('class'=>'flexible-wrap'));    
    
}