Moving data to a new table

Hello

Im a newbie with Yii, im creating an online travel application which shall be approved by an admin. I have an application table in my DB, created an identical table in the same DB named approved. I would like some help on how to move the data entered into the application table to the approved table upon the admin clicking the approve button.

Thanks :)

why ? (the whole table duplication) is sufficient as adding a new field on the current table, named "STATUS" with boolean or numeric values as "1=approved 0=not-approved" ? This would be a very dramatic bad db design, you are forced to do that and the status field is not sufficient ?

bluyell

oh!!! The thing is, the user enters new data on a form which takes the data to the application table (pending approval), what im trying to do is when the admin approves that application, the data there is moved out into another table and out of the list of pending applications which can be seen by the admin on front end of the site. do u have any suggestion on how i could get that going?

your “Application”'s objects, all them belongs to a “Class”, but, some of this objects are in status “Ready for admin” and, some others “Not Ready for admin”. then:

usingUML:

Thank you very much Bluyell, it all makes sense now, i got one more question, how do i get the applicant to be sent an approval email notification once their application is approved. I have looked around and found a couple of extensions I can use but i seem not be able to get it working.

thanks

yes you can activate it using an email, again via action, and you dont need an extension, because you are a programmer, and you must do that yourself !

First at all you application object muest exists obviously, in state ‘not approved’, then, look at diagram at top, when you notify the new application record to your admin, then include a full action URL that automatically when called then activate the record.

"hello admin you have new pending approval, click here: http://www.yourserver.com/index.php?r=application/approvebyemail&id=123"

in your application controller:




public function actionApprovedByEmail($id) {

    $model = $this->loadModel($id);

    $model->status = 1; // approved

    $model->save();

    $this->redirect("index.php?r=application/approvedsuccessfull");

}




public function actionApproveSuccessfull() {

    $this->renderText("<h1>Hello admin, the application was successfully approved</h1><p>Thanks !</p>");

}

<br class="Apple-interchange-newline">