public function edit($advanced = null)
 {
     if ($this->request->is('put') || $this->request->is('post')) {
         if (!empty($this->request->data['Afip']['tipo_factura_id'])) {
             $tipoFactId = $this->request->data['Afip']['tipo_factura_id'];
             $TipoFact = Classregistry::init('Risto.TipoFactura')->find('first', array('conditions' => array('TipoFactura.id' => $tipoFactId), 'recursive' => -1));
             $this->request->data['Restaurante']['tipofactura_name'] = $TipoFact['TipoFactura']['name'];
             $this->request->data['Printers']['default_tipo_factura_codename'] = $TipoFact['TipoFactura']['codename'];
         }
         if (TenantSettings::write($this->data)) {
             MtSites::loadConfigFiles();
             $this->Session->setFlash(__('Se han guardado los cambios de configuración'));
         } else {
             $this->Session->setFlash(__('Error al guardar los cambios de configuración'), 'Risto.flash_error');
         }
     }
     $this->request->data = TenantSettings::read();
     if (empty($this->request->data['Geo']['currency_code']) && !empty($this->request->data['Config']['currency_code'])) {
         $this->request->data['Geo']['currency_code'] = $this->request->data['Config']['currency_code'];
     }
     $printers = Classregistry::init('Printers.Printer')->find('list');
     $fiscal_printer = Classregistry::init('Printers.Printer')->read(null, Configure::read('Printers.fiscal_id'));
     $ivaResponsabilidades = Classregistry::init('Risto.IvaResponsabilidad')->find('list');
     $tipoFacturas = Classregistry::init('Risto.TipoFactura')->find('list');
     $mozos = Classregistry::init('Mesa.Mozo')->find('list', array('fields' => array('id', 'numero_y_nombre')));
     $currencyCodes = $this->currencyCodes;
     $this->set(compact('printers', 'fiscal_printer', 'ivaResponsabilidades', 'tipoFacturas', 'mozos', 'currencyCodes'));
     if ($advanced) {
         $this->render('edit_' . $advanced);
     }
 }
示例#2
0
 public static function copyTenantSettingFile($data = array())
 {
     $site_slug = $data['Site']['alias'];
     $defaultSettingsConfig = array('name' => 'default', 'datasource' => Configure::read('Risto.dataSourceType'), 'persistent' => false);
     $installSettingsIniPath = App::pluginPath('Install') . 'Config' . DS . 'TenantInstallFiles' . DS . $data['Site']['type'] . DS;
     $IniSetting = new IniReader($installSettingsIniPath);
     $settings = $IniSetting->read('settings.ini');
     $settings['Config']['timezone'] = $data['Site']['timezone'];
     $settings['Site']['ip'] = $data['Site']['ip'];
     $settings['Site']['name'] = $data['Site']['name'];
     $settings['Site']['alias'] = $data['Site']['alias'];
     $settings['Geo'] = GeoPlugin::locate($data['Site']['ip']);
     unset($settings['Geo']['currency_symbol']);
     // el simbolo me rompe el settings.ini file
     TenantSettings::write($settings, $site_slug);
     return true;
 }