public function delete($id) { $this->db->start_transaction(); # remove state related by country $city = new StateModel(); $city->delete_by_country($id); # remove the country itself $condition = array(CountryModel::$primary_key => $id); $this->db->delete(CountryModel::$table_name, $condition); $this->db->complete_transaction(); return $this->db->transaction_status(); }
function afterLoad() { $ui_model = new UserInterestsModel(); //$this->interest = implode(", ", $ui_model -> getInterests($this -> id)); $country_model = new CountryModel(); $country_model->load($this->country_id); $this->country = $country_model->name; $state_model = new StateModel(); $state_model->load($this->state_id); $this->state = $state_model->name; $city_model = new CityModel(); $city_model->load($this->city_id); $this->city = $city_model->name; }
public function ChangeCountryAction() { $request = Project::getRequest(); $country_id = $request->getKeyByNumber(0); if ($country_id) { $info = array(); $state_model = new StateModel(); $info['state_list'] = $state_model->loadByCountry($country_id); $info['change_state_param'] = AjaxRequest::getJsonParam("Social", "ChangeStates", array('#id#')); $this->_view->ChangeCountry($info); $this->_view->ajax(); } else { $response = Project::getAjaxResponse(); $response->block('state_div', true, ''); $response->block('city_div', true, ''); $this->_view->ajax(); } }
public function edit($id = null) { $this->load->model('VisitorModel'); $this->load->model('AddressModel'); $this->load->model('DistrictModel'); $this->load->model('CityModel'); $this->load->model('StateModel'); $address = new AddressModel(); $district = new DistrictModel(); $city = new CityModel(); $state = new StateModel(); $visitor = new VisitorModel(); $objvisitor = $visitor->search($id); $objaddress = $address->search($objvisitor['address']); $objdistrict = $district->search($objaddress['district']); $objcity = $city->search($objdistrict['city']); $objstate = $state->search($objcity['state']); $data['visitor'] = $objvisitor; $data['currentaddress'] = $objaddress; $data['currentdistrict'] = $objdistrict; $data['currentcity'] = $objcity; $data['currentstate'] = $objstate; $data['states'] = $state->listing(); if ($this->isLogged()) { $page = $this->getPage(); switch ($this->session->userdata('role')) { case '1': $this->load->view('public/norole'); break; case '2': $this->load->view('template/user/header', $page); $this->load->view('user/editvisitor', $data); break; } $this->load->view('template/public/footer'); } }
function ChangeCountryAction() { $request = Project::getRequest(); $country_id = $request->getKeyByNumber(0); $info = array(); $state_model = new StateModel(); $info['state_list'] = $state_model->loadByCountry($country_id); $info['change_state_param'] = AjaxRequest::getJsonParam("User", "ChangeState", array('#id#')); $this->_view->ChangeCountry($info); $this->_view->ajax(); }
public function __construct() { parent::__construct(); $supplierModel = new SupplyModel(); $supplierDadosArray = $supplierModel->fetchAll(); $supplyModel = new SupplyModel(); $stateModel = new StateModel(); $nmsupply = array(); $nmsupply[0] = 'Selecione'; $suppliersupply = $supplyModel->getAllSuplly(); foreach ($suppliersupply as $row) { $nmsupply[$row->cdsupply] = $row->nmsupply; } $state = array(); $state[0] = 'Selecione'; $supplierstate = $stateModel->fetchAll(); foreach ($supplierstate as $row) { $state[$row->idstate] = $row->nmstate; } $this->_cdsupplier = new Zend_Form_Element_Text('cdsupplier'); $this->_cdsupplier->setLabel('Código'); $this->_cdsupplier->setAttrib("id", "supplier_cdsupplier"); $this->_cdsupplier->setAttrib("maxlenght", "11"); $this->_cdsupplier->setDecorators($this->_decoratorsRequired); $this->_cdsupplier->setRequired(true); $this->_nmsupplier = new Zend_Form_Element_Text('nmsupplier'); $this->_nmsupplier->setLabel('Razão Social'); $this->_nmsupplier->setAttrib("id", "supplier_nmsupplier"); $this->_nmsupplier->setAttrib("maxlenght", "255"); $this->_nmsupplier->setDecorators($this->_decoratorsRequired); $this->_nmsupplier->setRequired(true); $this->_nmfantasyname = new Zend_Form_Element_Text('nmfantasyname'); $this->_nmfantasyname->setLabel('Nome Fantasia'); $this->_nmfantasyname->setAttrib("id", "supplier_nmfantasyname"); $this->_nmfantasyname->setAttrib("maxlenght", "255"); $this->_nmfantasyname->setDecorators($this->_decoratorsRequired); $this->_nmfantasyname->setRequired(true); $this->_idcnpj = new Zend_Form_Element_Text('idcnpj'); $this->_idcnpj->setLabel('CNPJ'); $this->_idcnpj->setAttrib("id", "supplier_idcnpj"); $this->_idcnpj->setAttrib("class", "mask_cnpj"); $this->_idcnpj->setDecorators($this->_decoratorsRequired); $this->_idcnpj->addFilter(new Zend_Filter_Alnum()); $this->_idcnpj->setRequired(false); $this->_idcep = new Zend_Form_Element_Text('idcep'); $this->_idcep->setLabel('CEP'); $this->_idcep->setAttrib("id", "supplier_idcep"); $this->_idcep->setAttrib("maxlenght", "8"); $this->_idcep->setDecorators($this->_decoratorsRequired); //$this->_idcep->setAttrib("class", "mask_cep"); $this->_idcep->addFilter(new Zend_Filter_Alnum()); $this->_nmstreet = new Zend_Form_Element_Text('nmstreet'); $this->_nmstreet->setLabel('Endereço'); $this->_nmstreet->setAttrib("id", "supplier_nmstreet"); $this->_nmstreet->setAttrib("maxlenght", "290"); $this->_nmstreet->setDecorators($this->_decoratorsRequired); $this->_nmstreet->setRequired(true); $this->_nrnumber = new Zend_Form_Element_Text('nrnumber'); $this->_nrnumber->setLabel('Número'); $this->_nrnumber->setAttrib("id", "supplier_nrnumber"); $this->_nrnumber->setAttrib("maxlenght", "5"); $this->_nrnumber->setAttrib("class", "numeric"); $this->_nrnumber->setDecorators($this->_decoratorsDefault); $this->_nrnumber->setRequired(true); $this->_nmneighborhood = new Zend_Form_Element_Text('nmneighborhood'); $this->_nmneighborhood->setLabel('Bairro'); $this->_nmneighborhood->setAttrib("id", "supplier_nmneighborhood"); $this->_nmneighborhood->setAttrib("maxlenght", "255"); $this->_nmneighborhood->setAttrib("class", "alpha"); $this->_nmneighborhood->setDecorators($this->_decoratorsRequired); $this->_nmneighborhood->setRequired(true); $this->_idcity = new Zend_Form_Element_Text('idcity'); $this->_idcity->setLabel('Cidade'); $this->_idcity->setAttrib("id", "supplier_idcity"); $this->_idcity->setAttrib("maxlenght", "50"); $this->_idcity->setDecorators($this->_decoratorsRequired); $this->_idcity->setRequired(true); $this->_idstate = new Zend_Form_Element_Select('idstate'); $this->_idstate->setLabel('Estado'); $this->_idstate->addMultiOptions($state); $this->_idstate->setAttrib("id", "supplier_idstate"); $this->_idstate->setAttrib("maxlenght", "2"); $this->_idstate->setDecorators($this->_decoratorsRequired); $this->_idstate->setRequired(true); $this->_nmkeyperson = new Zend_Form_Element_Text('nmkeyperson'); $this->_nmkeyperson->setLabel('Vendedor (Contato Comercial)'); $this->_nmkeyperson->setAttrib("id", "supplier_nmkeyperson"); $this->_nmkeyperson->setAttrib("maxlenght", "11"); $this->_nmkeyperson->setDecorators($this->_decoratorsRequired); $this->_nmkeyperson->setRequired(true); $this->_nrphone = new Zend_Form_Element_Text('nrphone'); $this->_nrphone->setLabel('Telefone Comercial'); $this->_nrphone->setAttrib("id", "supplier_nrphone"); $this->_nrphone->setAttrib("class", "numeric"); $this->_nrphone->setAttrib("maxlenght", "11"); $this->_nrphone->setDecorators($this->_decoratorsRequired); $this->_nrphone->setRequired(true); $this->_nrcellphone = new Zend_Form_Element_Text('nrcellphone'); $this->_nrcellphone->setLabel('Telefone Celular'); $this->_nrcellphone->setAttrib("id", "supplier_nrcellphone"); $this->_nrcellphone->setAttrib("maxlenght", "11"); $this->_nrcellphone->setAttrib("class", "numeric"); $this->_nrcellphone->setDecorators($this->_decoratorsDefault); $this->_nrcellphone->setRequired(true); $this->_nmsupply = new Zend_Form_Element_Select('nmsupply'); $this->_nmsupply->setLabel('Nome'); $this->_nmsupply->addMultiOption("", "Selecione"); foreach ($supplierDadosArray as $supplierDado) { $this->_nmsupply->addMultiOption($supplierDado->cdsupply, $supplierDado->nmsupply); } $this->_nmsupply->setAttrib("id", "supplier_nmsupply"); $this->_nmsupply->setAttrib("class", "search_combobox"); $this->_nmsupply->setAttrib("maxlenght", "11"); $this->_nmsupply->setDecorators($this->_decoratorsDefault); $this->_nmsupply->setRequired(true); $this->_qtquantitysupply = new Zend_Form_Element_Text('qtquantitysupply'); $this->_qtquantitysupply->setLabel('Quantidade'); $this->_qtquantitysupply->setAttrib("id", "supplier_qtquantitysupply"); $this->_qtquantitysupply->setAttrib("maxlenght", "11"); // $this->_qtquantitysupply->setAttrib("class", "numeric"); $this->_qtquantitysupply->setDecorators($this->_decoratorsDefault); $this->_qtquantitysupply->setRequired(true); $this->_vlunitsupply = new Zend_Form_Element_Text('vlunitsupply'); $this->_vlunitsupply->setLabel('Preço Unitário (R$)'); $this->_vlunitsupply->setAttrib("id", "supplier_vlunitsupply"); $this->_vlunitsupply->setAttrib("maxlenght", "11"); // $this->_vlunitsupply->setAttrib("class", "numeric"); $this->_vlunitsupply->setDecorators($this->_decoratorsDefault); $this->_vlunitsupply->setRequired(true); $this->_fgmanufacturer = new Zend_Form_Element_Checkbox('fgmanufacturer'); $this->_fgmanufacturer->setLabel('Fabricante'); $this->_fgmanufacturer->setAttrib("id", "supplier_fgmanufacturer"); $this->_fgmanufacturer->setAttrib("value", "1"); $this->_fgmanufacturer->setDecorators($this->_decoratorsDefault); $this->_fgmanufacturer->setRequired(true); $this->_assistance = new Zend_Form_Element_Checkbox('assistance'); $this->_assistance->setLabel('Assistência'); $this->_assistance->setAttrib("id", "supplier_assistance"); $this->_assistance->setAttrib("value", "1"); $this->_assistance->setDecorators($this->_decoratorsDefault); $this->_assistance->setRequired(true); $this->_includesupply = new Zend_Form_Element_Button('includesupply'); $this->_includesupply->setLabel('Adicionar'); $this->_includesupply->setAttrib("id", "supplier_includesupply"); $this->_includesupply->setAttrib("maxlenght", "11"); $this->_includesupply->setDecorators($this->_decoratorsDefault); $this->_includesupply->setRequired(true); $this->_includesupply = new Zend_Form_Element_Button('includesupply'); $this->_includesupply->setLabel("Adicionar"); $this->_includesupply->setDecorators(array(array('ViewHelper'), array('HtmlTag', array('tag' => 'li')))); $this->_includesupply->setAttrib("class", "submit_button"); $this->_includesupply->setAttrib("maxlenght", "11"); $this->_includesupply->setAttrib("onClick", "jqGridSelect();"); }