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
 /**
  * Sets up the configuration for the model, and loads databse from Multi Tenant Site
  *
  * @param Model $model Model using this behavior.
  * @param array $config Configuration options.
  * @return void
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     // usar el correspondiente al tenant
     //debug( Router::$_requests );
     if (CakeSession::started()) {
         $currentTenant = MtSites::getSiteName();
         if ($currentTenant) {
             // listar sources actuales
             $sources = ConnectionManager::enumConnectionObjects();
             //copiar del default
             $tenantConf = $sources['default'];
             // colocar el nombre de la base de datos
             $tenantConf['database'] = $tenantConf['database'] . "_" . $currentTenant;
             // crear la conexion con la bd
             $confName = 'tenant_' . $currentTenant;
             ConnectionManager::create($confName, $tenantConf);
             // usar tenant para este model
             $this->useDbConfig = $confName;
         }
     }
     // ahora construir el Model
     parent::__construct($id, $table, $ds);
 }
示例#3
0
 public static function dumpTenantDB($data = null)
 {
     App::uses('ConnectionManager', 'Model');
     $slug = $data['Site']['alias'];
     $tenantDB = MtSites::getTenantDbName($slug);
     // 1) Primero se corrobora si se puede crear la base de datos, sino se puede promover la desinstalacion del site
     $create_tenant = ConnectionManager::getDataSource('default')->query("CREATE DATABASE " . $tenantDB);
     if (!empty($create_tenant)) {
         throw new CakeException('No se pudo crear la base de datos del tenant: ' . $tenantDB . '. Verifique que su usuario de conexión tenga los permisos suficientes. Tal vez la base de datos ya exista.');
     }
     MtSites::connectDatasourceWithCurrentTenant($slug);
     $datasource = MtSites::getTenantDataSourceName($slug);
     $tenantType = $data['Site']['type'];
     return self::loadFileSchema($tenantType, $datasource);
 }
示例#4
0
 /**
  * Edit the current logged in user
  *
  * Extend the plugin and implement your custom logic here, mostly thought to be
  * used as a dashboard or profile page like method.
  *
  * See the plugins documentation for how to extend the plugin.
  *
  * @return void
  */
 public function my_edit()
 {
     if (!$this->Auth->loggedIn()) {
         throw new ForbiddenException(__("You must be logged in"));
     }
     $user = $this->Auth->user();
     if ($this->request->is('post') || $this->request->is('put')) {
         if ($this->User->save($this->request->data)) {
             $this->Session->setFlash(__('Se ha guardado la información correctamente'));
             MtSites::loadSessionData();
         } else {
             $this->Session->setFlash(__('El usuario no pudo ser guardado. Por favor, intente nuevamente.'));
         }
     } else {
         $this->request->data['User'] = $user;
     }
     $socialProfiles = $this->User->SocialProfile->find('all', array('recursive' => -1, 'conditions' => array('SocialProfile.user_id' => $user['id'])));
     $this->set("socialProfiles", $socialProfiles);
 }