public function Subfamilias()
 {
     $nItems = 0;
     $nErrores = 0;
     $dbLink = mysql_connect("localhost", "root", "albatronic");
     //$query = "TRUNCATE {$this->dbDestino}.ErpFamilias";
     //mysql_query($query);
     $query = "select * from {$this->dbOrigen}.subfamilias";
     $result = mysql_query($query, $dbLink);
     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
         $row = $this->utf($row);
         $f = new Familias($row['IDFamilia']);
         $c = new Familias();
         $c->setFamilia($row['Subfamilia']);
         $c->setInventario($f->getInventario()->getIDTipo());
         $c->setTrazabilidad($f->getTrazabilidad()->getIDTipo());
         $c->setMargenWeb($f->getMargenWeb());
         $c->setMargenMinimo($f->getMargenMinimo());
         $c->setMostrarEnTpv($f->getMostrarEnTpv()->getIDTipo());
         $c->setPublish($row['PublicarWeb'] == 'S' ? 1 : 0);
         $c->setBelongsTo($f->getIDFamilia());
         $c->setObservations($row['IDSubfamilia']);
         $id = $c->create();
         if ($id == NULL) {
             $errores[] = $c->getErrores();
             $nErrores++;
         } else {
             $c->setIDFamilia($id);
             $c->setPrimaryKeyMD5(md5($id));
             $c->save();
             $nItems++;
         }
     }
     //mysql_close($dbLink);
     echo "Subfamilias  {$nItems}<br/>";
     if (count($errores)) {
         echo "<pre>";
         print_r($errores);
         echo "</pre>";
     }
 }