Coding Cheatsheets - Learn web development code and tutorials for Software developers which will helps you in project. Get help on JavaScript, PHP, XML, and more.

Post Page Advertisement [Top]

Function
function admin_update($table=NULL,$id=NULL) {
       
         $id = convert_uudecode(base64_decode($id));
         $status = $this->$table->findById($id);
         $data[$table]['id'] = $id;
         if($status[$table]['status']=='Inactive')
         {
             $this->$table->updateAll(array($table.'.status'=>'"Active"'),array($table.'.id'=>$id));
         }
         else
         {
             $this->$table->updateAll(array($table.'.status'=>'"Inactive"'),array($table.'.id'=>$id));
             $this->$table->updateAll(array($table.'.admin_status'=>'"Inactive"'),array($table.'.id'=>$id));
         }
        $this->Session->write('success','Status has been updated');
        $this->redirect($this->referer());
    }
CTP
<?php $memId = base64_encode(convert_uuencode($mems['Member']['id'])); ?>

                                       
                                       
                                          <?php if($mems['Member']['status']=='Active') {?>
                                           <a title="Make Inactive"   href="<?php echo HTTP_ROOT."admin/Users/updatePhotographerStatus/".'Member'.'/'.$memId; ?>"> Update </a>
                                         <?php } else {?>
                                         <a title="Make Active" class="updateStatus btn_no_text btn ui-corner-all tooltip ui-state-hover"  href="<?php echo HTTP_ROOT."admin/Users/updatePhotographerStatus/".'Member'.'/'.$memId; ?>"> Update </a>

Note: Change onlyTable Name

No comments:

Post a Comment

Bottom Ad [Post Page]