Example #1
0
 public function getDelete($id)
 {
     $regions = Regions::find($id);
     $regions->delete();
     Session::flash('message', 'The records are deleted successfully');
     return Redirect::to('regions');
 }
Example #2
0
 public function mapgrid($data)
 {
     $this->view->module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
     $this->view->controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
     $this->view->action = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
     if (isset($data['records'])) {
         // Name of the table, useful for the jQuery pager
         $this->view->name = !empty($data['name']) ? $data['name'] : "table_" . rand(1, 50);
         // Index of the table
         $this->view->id = !empty($this->view->fields[0]) && is_numeric($data['records'][0][$this->view->fields[0]]) ? $data['records'][0][$this->view->fields[0]] : "0";
         foreach ($data['records'] as &$record) {
             $name = "";
             $regionid = intval($record['region_id']);
             if ($regionid != 0) {
                 $objregion = Regions::find($regionid);
                 $name = $objregion->name;
             }
             $record['region'] = $name;
         }
         unset($record);
         // All the records
         $this->view->records = $data['records'];
         // If these options are true a link appear for each row in a table
         $this->view->edit = !empty($data['edit']) ? $data['edit'] : false;
         $this->view->delete = !empty($data['delete']) ? $data['delete'] : false;
         // If you need more action use this parameter Array{'url'=>'name'}
         $this->view->actions = !empty($data['actions']) ? $data['actions'] : false;
     } else {
         $this->view->records = "";
     }
     // Path of the template
     return $this->view->render('partials/mapgrid.phtml');
 }
Example #3
0
 public function isValid($value, $context = null)
 {
     $value = intval($value);
     if ($value != 0) {
         $countryid = intval($context['country_id']);
         if ($countryid == 0) {
             $this->_error(self::COUNTRYIDEMPTY);
             return false;
         }
         $region = Regions::find($value);
         if ($region->country_id != $countryid) {
             $this->_error(self::REGIONIDNOTVALID);
             return false;
         }
     }
     return true;
 }
 /**
  * POST Form for doDelete the specified resource.
  *
  * @return Response
  */
 public function doDelete()
 {
     $aData = Input::all();
     if (isset($aData['id'])) {
         $region = Regions::find($aData['id']);
         $region->delete();
         return Redirect::route('region-list')->with('message', 'Область успешно удалена');
     }
     return Redirect::route('region-list')->with('message', 'Произошла ошибка удаления');
 }