Yii Framework Forum: Moving data to a new table - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Moving data to a new table Rate Topic: -----

#1 User is offline   Felix27 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 07-May 12

Posted 07 May 2012 - 05:38 PM

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 :)
0

#2 User is offline   bluyell 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 222
  • Joined: 28-October 11

Posted 07 May 2012 - 06:48 PM

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 ?
0

#3 User is offline   Felix27 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 07-May 12

Posted 07 May 2012 - 07:30 PM

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?
0

#4 User is offline   bluyell 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 222
  • Joined: 28-October 11

Posted 07 May 2012 - 10:50 PM

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:

Posted Image

0

#5 User is offline   Felix27 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 07-May 12

Posted 08 May 2012 - 07:06 AM

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
0

#6 User is offline   bluyell 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 222
  • Joined: 28-October 11

Posted 08 May 2012 - 11:10 AM

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">
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users