示例#1
0
文件: lib.php 项目: anilch/Personel
    /**
     * @method update_plan
     * @todo Update the details of the existing plans
     * @param  $plan(array)
     * */
    function update_plan($planid, $newplan) {
        global $DB, $CFG;
        $hierarchy = new hierarchy();
        $planupdate = new school();
        $oldplan = $DB->get_record('local_curriculum_plan', array('id' => $planid));
        $currenturl = "{$CFG->wwwroot}/local/curriculum/index.php";
        //check if the parentid is the same as that of new parentid
        if ($newplan->parentid != $oldplan->parentid) {
            $newparentid = $newplan->parentid;
            $newplan->parentid = $oldplan->parentid;
        }
        $now = date("d-m-Y");
        $now = strtotime($now);
        $newplan->timemodified = $now;

        $updated = $DB->update_record('local_curriculum_plan', $newplan);

        if (isset($newparentid)) {
            $updatedplan = $DB->get_record('local_curriculum_plan', array('id' => $planid));
            $newparentid = isset($newparentid) ? $newparentid : 0;
            //if the new parentid is different then update 
            $updated = $planupdate->update_school($updatedplan, $newparentid, 'local_curriculum_plan');
        }
        return $updated;
      
    }