<?php
class PackagesController extends AppController{
public $name="Packages";
public $helpers = array('Html', 'Form', 'Session');
public $uses=array('Package');
//Created by anil:this function is use for add package
function addpackage(){
if($this->request->is('post')){
$this->Package->create();
if ($this->Package->save($this->request->data)) {
$this->Session->setFlash('Your post has been saved.');
$this->redirect('packageshow');
} else {
$this->Session->setFlash('Unable to add your post.');
}
}
}
//Created by anil:this function is use for show package
function packageshow(){
$packageusers=$this->Package->find('all');
$this->set('packageuser',$packageusers);
}
//Created by anil:this function is use for delete package
function deletepackage($id=null){
$this->Package->delete($id);
$this->Session->setFlash('The User deleted successfully', true);
$this->redirect(array('action'=>'packageshow'));
}
//Created by anil:this function is use for edit package
function editpackage($id=null){
$useredit=array();
$useredit=$this->data;
$useredit['Package']['id']=$this->data['Package']['id'];
if(!empty($this->data)){
$this->Package->save($useredit);
$this->redirect('packageshow');
}else{
$this->data=$this->Package->read(null,$id);
}
}
}
?>
*********************************View_packageshow*****************************************
<?php echo $this->Form->create('Package',array('action'=>'packageshow')); ?> <legend><b>Show Package Details</b></legend> <table width='100%' align='left' border='0' style="font-family: verdana; font-size: 12px;padding-left:5px;"> <tr> <td>Name</td><td>Price</td><td>Status</td><td>Createdate</td><td>No of Votes</td><td>Action</td> <td><span><?php echo $this->Html->link('Add User',array('action'=>'addpackage'),array('escape'=>false));?><span></td> </tr> <?php foreach($packageuser as $val){?> <tr> <td><?php echo $val['Package']['name'];?></td> <td><?php echo $val['Package']['price'];?></td> <td><?php echo $val['Package']['status'];?></td> <td><?php echo $val['Package']['createdate'];?></td> <td><?php echo $val['Package']['noofvotes'];?></td> <td><?php echo $this->Html->link('Delete',array('action'=>'deletepackage',$val['Package']['id']),array('escape'=>false));?></td> <td><?php echo $this->Html->link('Edit',array('action'=>'editpackage',$val['Package']['id']),array('escape'=>false));?></td> </tr> <?php }?> </table>
***************************************View_addpackege****************************<?php echo $this->Form->create('Package',array('action'=>'addpackage')); ?>
<fieldset>
<legend>Add Packages</legend>
<table width='100%' align='left' border='0' style="font-family: verdana; font-size: 12px;padding-left:5px;">
<tr>
<td></td>
</tr>
<tr>
<td colspan='2' > </td>
</tr>
<tr>
<td>Name</td>
<td>
<?php echo $this->Form->text('name',array('id'=>'uname')); ?>
</td>
</tr>
<tr>
<td>price</td>
<td>
<?php echo $this->Form->text('price',array('id'=>'uprice')); ?>
</td>
</tr>
<tr>
<td>status</td>
<td>
<?php echo $this->Form->text('status',array('id'=>'ustatus')); ?>
</td>
</tr>
<tr>
<td>create date</td>
<td>
<?php echo $this->Form->text('createdate',array('id'=>'udate')); ?>
</td>
</tr>
<tr>
<td>Number of Votes</td>
<td>
<?php echo $this->Form->text('noofvotes',array('id'=>'uvotes')); ?>
</td>
</tr>
<tr>
<td>
<td><?php echo $this->Form->submit('submit', array('label'=>false,'id'=>'height','size'=>'20px'));?></td>
</td>
</tr>
</table>
<?php echo $this->Form->end();?>
</td></tr></tbody></table>
</fieldset>
******************************View_edit*****************************************
<?php echo $this->Form->create('Package',array('action'=>'editpackage')); ?> <?php echo $this->Form->input('id');?> <fieldset> <legend>Edit User</legend> <table width='100%' align='left' border='0' style="font-family: verdana; font-size: 12px;padding-left:5px;"> <tr> <td></td> </tr> <tr> <td colspan='2' > </td> </tr> <tr> <td>Name</td> <td><?php echo $this->Form->input('Package.name', array('label'=>false,'size'=>'20px'));?></td> </tr> <tr> <td>Price</td> <td><?php echo $this->Form->input('Package.price', array('label'=>false,'id'=>'age','size'=>'20px'));?></td> </tr> <tr> <td>Status</td> <td><?php echo $this->Form->input('Package.status', array('label'=>false,'id'=>'height','size'=>'20px'));?></td> </tr> <tr> <td>Create date</td> <td><?php echo $this->Form->input('Package.createdate', array('label'=>false,'id'=>'height','size'=>'20px'));?></td> </tr> <tr> <td>No of Votes</td> <td><?php echo $this->Form->input('Package.noofvotes', array('label'=>false,'id'=>'height','size'=>'20px'));?></td> </tr> <tr> <td> </td> <td><?php echo $this->Form->submit('submit', array('label'=>false,'id'=>'height','size'=>'20px'));?></td> <td></td> </tr> </table> <?php echo $this->Form->end();?> </td></tr></tbody></table> </fieldset>
*************************************Model************************************
<?php class Package extends AppModel { var $name = 'Package'; }
!!___________________________________5____________________________________________!!
*******************************Validation**************************************
<?php
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {
public $validate = array(
'username' => array(
'required' => array(
'rule' => '/^[a-z0-9]{3,}$/i',
'message' => 'A username not less than 3 digit'
),
'isUnique'=>array(
'rule'=>'isUnique',
'message'=>'Username allready exist'
),
),
'password' => array(
'required' => array(
'rule' => array('between', 5, 15),
'message'=>'Passwords must be between 5 and 15 characters long'
)
),
'role' => array(
'valid' => array(
'rule' => array('inList', array('admin', 'author')),
'message' => 'Please enter a valid role',
'allowEmpty' => false
)
),
'mobno'=>array(
'required' => array(
'rule' => array('minLength', '8'),
'message'=>'Minimum 10 characters long'
)
),
'email' => array(
'required' => array(
'rule' =>'email',
'message' =>'Please enter a valid email address.'
),
'isUnique'=>array(
'rule'=>'isUnique',
'message'=>'email allready exist'
),
),
'born' =>array(
'rule'=>'date',
'message'=>'Enter a valid date',
'allowEmpty'=>true
),
'message' => array(
'alphaNumeric'=>array(
'rule'=>'alphaNumeric',
'required'=>true,
'message'=>'Alphabets and numbers only'
),
'between'=>array(
'rule'=>array('between', 5, 15),
'message'=>'Between 5 to 15 characters'
),
),
);
}
/*function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
return true;
}*/
?>
*************************************Model************************************
<?php class Package extends AppModel { var $name = 'Package'; }
!!_________________________________________6_____________________________________!!
*******************email send in cake*****************
$to = $User['User']['email'];
$username =$User['User']['username'];
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail();
$email->template('password_reset_email', false);
$email->emailFormat('html');
$email->to($to);
$email->from(user@gmail.com');
$email->subject(ok: thanks');
$email->viewVars(array('value' =>$new_pass,'username'=>$username));
$email->send();
************************************corephp********************************
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment