Esempio n. 1
0
 /**
  * Borra registro, verificando que no haya problemas de integridad referencial
  *
  * @return true if successful otherwise returns false
  */
 function delete($oid = null)
 {
     $key = $this->getKeyName();
     if ($oid) {
         $this->{$key} = $oid;
     }
     $id = $this->{$key};
     // Verificar que no haya productos con ese id de registro
     if ($id) {
         // Verificar que no haya productos con ese id de categoría
         $query = 'SELECT product_id FROM #__cp_plans_info WHERE category_id = ' . $id . ' LIMIT 1';
         $this->_db->setQuery($query);
         $obj = $this->_db->loadObject();
         if ($obj) {
             $this->setError(JText::sprintf('CP.PLANCATEGORY_ERROR_DELETE_EXISTS_RELATED_PRODUCTS', $id));
             return false;
         }
     }
     return parent::delete($oid);
 }
Esempio n. 2
0
 /**
  * Borra registro, verificando que no haya problemas de integridad referencial
  *
  * @return true if successful otherwise returns false
  */
 function delete($oid = null)
 {
     $key = $this->getKeyName();
     if ($oid) {
         $this->{$key} = $oid;
     }
     $id = $this->{$key};
     // Verificar que no haya productos con ese id de registro
     if ($id) {
         $query = 'SELECT product_id FROM #__cp_hotels_param1 WHERE param1_id = ' . $id;
         $this->_db->setQuery($query);
         $obj = $this->_db->loadObject();
         if ($obj) {
             $this->setError(JText::sprintf('CP.HOTELPARAM1_ERROR_DELETE_EXISTS_RELATED_PRODUCTS', $id));
             return false;
         }
     }
     return parent::delete($oid);
 }
Esempio n. 3
0
 /**
  * Borra registro, verificando que no haya problemas de integridad referencial
  *
  * @return true if successful otherwise returns false
  */
 function delete($oid = null)
 {
     $key = $this->getKeyName();
     $id = $this->{$key};
     if ($oid) {
         $this->{$key} = $oid;
     }
     $id = $this->{$key};
     $this->load($id, false);
     $result = parent::delete($oid);
     // Precalcular precios y disponibilidad
     if ($result && $this->product_id) {
         // Determina si el precio desde de la disponibilidad se calcula por las vigencias o
         // se toma de la configuración del tarifario. Colocar en 1 para usar las vigencias.
         $calculatePrices = 0;
         $query = 'CALL GenerateTransfersRateResumeById(' . $this->product_id . ', CURDATE(), ADDDATE(CURDATE(), 365), ' . $calculatePrices . ')';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             $result = false;
         }
     }
     return $result;
 }
Esempio n. 4
0
 /**
  * Borra registro, verificando que no haya problemas de integridad referencial
  *
  * @return true if successful otherwise returns false
  */
 function delete($oid = null)
 {
     $key = $this->getKeyName();
     if ($oid) {
         $this->{$key} = $oid;
     }
     $id = $this->{$key};
     // Verificar que no haya productos con ese id de registro
     if ($id) {
         $modelProducts =& JModel::getInstance('producttype', 'CatalogoPlanesModel');
         $productTypes = $modelProducts->getActiveProductTypesInfo();
         if (is_array($productTypes)) {
             $queries = array();
             foreach ($productTypes as $type) {
                 $queries[] = '(SELECT product_id FROM #__cp_' . $type->product_type_code . '_rate WHERE season_id = ' . $id . ' LIMIT 1)';
             }
             $query = implode(' UNION ALL ', $queries);
             $this->_db->setQuery($query);
             $obj = $this->_db->loadObject();
             if ($obj) {
                 $this->setError(JText::sprintf('CP.SEASON_ERROR_DELETE_EXISTS_RELATED_RATES', $id));
                 return false;
             }
         }
     }
     return parent::delete($oid);
 }
Esempio n. 5
0
 /**
  * Borra registro, verificando que no haya problemas de integridad referencial
  *
  * @return true if successful otherwise returns false
  */
 function delete($oid = null)
 {
     $key = $this->getKeyName();
     if ($oid) {
         $this->{$key} = $oid;
     }
     $id = $this->{$key};
     if ($id) {
         $tableName = $this->getTableName();
         // Verificar que no haya regiones con ese id de país
         $table =& JTable::getInstance('region', 'Table');
         $foreignKeyTable = $table->getTableName();
         $query = 'SELECT a.country_id FROM ' . $tableName . ' a ';
         $query .= 'JOIN ' . $foreignKeyTable . ' b ON a.country_id = b.country_id';
         $query .= ' WHERE a.country_id = ' . $id . ' GROUP BY a.country_id';
         $this->_db->setQuery($query);
         $obj = $this->_db->loadObject();
         if ($obj) {
             $this->setError(JText::sprintf('CP.COUNTRY_ERROR_DELETE_EXISTS_RELATED_REGION', $id));
             return false;
         }
         // Verificar que no haya ciudades con ese id de país
         $table =& JTable::getInstance('city', 'Table');
         $foreignKeyTable = $table->getTableName();
         $query = 'SELECT a.country_id FROM ' . $tableName . ' a ';
         $query .= 'JOIN ' . $foreignKeyTable . ' b ON a.country_id = b.country_id';
         $query .= ' WHERE a.country_id = ' . $id . ' GROUP BY a.country_id';
         $this->_db->setQuery($query);
         $obj = $this->_db->loadObject();
         if ($obj) {
             $this->setError(JText::sprintf('CP.COUNTRY_ERROR_DELETE_EXISTS_RELATED_CITY', $id));
             return false;
         }
         // Verificar que no haya productos con ese id de país
         $modelProducts =& JModel::getInstance('producttype', 'CatalogoPlanesModel');
         $productTypes = $modelProducts->getActiveProductTypesInfo();
         if (is_array($productTypes)) {
             $queries = array();
             foreach ($productTypes as $type) {
                 $queries[] = '(SELECT product_id FROM #__cp_' . $type->product_type_code . '_info WHERE country_id = ' . $id . ' LIMIT 1)';
             }
             $query = implode(' UNION ALL ', $queries);
             $this->_db->setQuery($query);
             $obj = $this->_db->loadObject();
             if ($obj) {
                 $this->setError(JText::sprintf('CP.COUNTRY_ERROR_DELETE_EXISTS_RELATED_PRODUCTS', $id));
                 return false;
             }
         }
     }
     return parent::delete($oid);
 }