count_empty_timestart(); $emptytimeend=$badiuecd->count_empty_timeend(); $filltimestart=0; $filltimemend=0; if($exec=='filltimestart'){$filltimestart=$badiuecd->fill_empty_timestart_with_timecreated($limit);} if($exec=='filltimeend'){$filltimemend=$badiuecd->fill_empty_timeend_with_timestart($dayadd,$limit);} echo "
Total de inscricao sem data de inicio: $emptytimestart"; echo "
Total de inscricao sem data de encerramento: $emptytimeend"; if($exec=='filltimestart'){echo "
Total de inscricao com data de inicio alterado para data de cadastro: $filltimestart";} if($exec=='filltimeend'){echo "
Total de inscricao com data de encerramento alterado em $dayadd dias a partir da data de inicio: $filltimemend";} class badiu_enrol_changedate { public function count_empty_timestart() { global $CFG,$DB; $sql="SELECT COUNT(id) AS countrecord FROM {$CFG->prefix}user_enrolments WHERE timestart =0 "; $r=$DB->get_record_sql($sql); return $r->countrecord; } public function get_enrol_timecreated_empty_timestart($limit=500) { global $CFG,$DB; $sql="SELECT id,timecreated FROM {$CFG->prefix}user_enrolments WHERE timestart = 0 "; $rows=$DB->get_records_sql($sql,null,0, $limit); return $rows; } public function fill_empty_timestart_with_timecreated($limit=500) { global $CFG,$DB; $enerols=$this->get_enrol_timecreated_empty_timestart($limit); $result=0; foreach ($enerols as $enrol) { $timestart=$enrol->timecreated; $id=$enrol->id; $timemodified=time(); $sql = "UPDATE {$CFG->prefix}user_enrolments SET timestart=$timestart ,timemodified=$timemodified WHERE id = $id "; $r= $DB->execute($sql); if($r){$result++;} } return $result; } public function count_empty_timeend() { global $CFG,$DB; $sql="SELECT COUNT(id) AS countrecord FROM {$CFG->prefix}user_enrolments WHERE timeend =0"; $r=$DB->get_record_sql($sql); return $r->countrecord; } public function get_enrol_timestart_empty_timeend($limit=500) { global $CFG,$DB; $sql="SELECT id,timestart FROM {$CFG->prefix}user_enrolments WHERE timestart > 0 AND timeend = 0 "; $rows=$DB->get_records_sql($sql,null,0, $limit); return $rows; } public function fill_empty_timeend_with_timestart($dayadd=90,$limit=500) { global $CFG,$DB; $enerols=$this->get_enrol_timestart_empty_timeend($limit); $result=0; foreach ($enerols as $enrol) { $timeend=$enrol->timestart+($dayadd*86400); $id=$enrol->id; $timemodified=time(); $sql = "UPDATE {$CFG->prefix}user_enrolments SET timeend=$timeend,timemodified=$timemodified WHERE id = $id "; $r= $DB->execute($sql); if($r){$result++;} } return $result; } } ?>