/**
     funcion que elimina de elastix un conjunto de organizacion
     @param $arrOrg array arreglo unidimensional que contiene el id de
                          las organizaciones que se van a eliminar
 */
 function deleteOrganization($arrOrg)
 {
     if (!is_array($arrOrg)) {
         $arrOrg = array($arrOrg);
     }
     $pFax = new paloFax($this->_DB);
     $pEmail = new paloEmail($this->_DB);
     $flag = true;
     $arrDelOrg = $arrIdCode = array();
     $exito = $error = "";
     foreach ($arrOrg as $idOrg) {
         if (preg_match("/^[0-9]+\$/", $idOrg) && $idOrg != 1) {
             //se borra tosod los registros de la organizacion de la base de datos
             //se elimina los correos y los faxes de los usuarios
             if ($this->deleteOrganizationDB($idOrg, $idcode)) {
                 $arrIdCode[] = $idcode;
                 $arrDelOrg[] = $this->errMsg;
             } else {
                 $error .= $this->errMsg . "<br />";
                 $flag = false;
             }
         }
     }
     if (count($arrDelOrg) != 0) {
         $exito = _tr("The organizations with the followings domains where deleted from database: ") . implode(",", $arrDelOrg) . "<br /><br />";
     } else {
         //ninguna de las organizaciones dada pudo ser elminada
         //regresamos y mostramos los errores
         $this->errMsg = $error;
         return false;
     }
     //***************************************************
     //reescribimos los archivos extensions.conf, extensions_globals.conf chan_dahdi_additional.conf con las configuraciones correctas
     $astError = "";
     $pAstConf = new paloSantoASteriskConfig($this->_DB);
     // extensions.conf, extensions_globals.conf
     if (!$pAstConf->writeExtesionConfFile()) {
         $astError = _tr("Error has ocurred to try rewriting asterisk configs file. ") . $pAstConf->errMsg . "<br />";
         $flag = false;
     }
     $sComando = "/usr/bin/elastix-helper asteriskconfig createFileDahdiChannelAdd 2>&1";
     $output = $ret = NULL;
     exec($sComando, $output, $ret);
     if ($ret != 0) {
         $astError .= _tr("Error has ocurred to try rewriting asterisk config file extensions_additional_dahdi.conf") . implode('', $output) . "<br />";
         $flag = false;
     }
     if ($astError != "") {
         $astError = "<br />" . $astError;
     }
     //***************************************************
     //***************************************************
     //reescribimos archivos /var/spool/hylafax/faxDispatch y /etc/init/elastix_fax
     //estos manejan los envios de los faxes al mail y la creacion de la lineas tty para los modems
     //***************************************************
     $fError = "";
     if (!$pFax->writeFilesFax()) {
         $fError = _tr("Error has ocurred to try rewriting fax config file. ") . $pFax->errMsg . "<br />";
         $flag = false;
     }
     //***************************************************
     //***************************************************
     //reescribimos el archivo /etc/postfix/main.cf que contiene los dominios creados en el sistema
     if (!$pEmail->writePostfixMain()) {
         $fError = _tr("Error has ocurred to try rewriting email config file. ") . $pEmail->errMsg . "<br />";
         $flag = false;
     }
     //***************************************************
     //********************************************************************
     //elminamos los archivos de audio,grabaciones,faxes, etc relacionados con la organizacion
     $dError = "";
     foreach ($arrIdCode as $idcode) {
         if (!$this->deleteFilesOrganization($idcode)) {
             $dError .= $this->errMsg;
             $flag = false;
         }
     }
     if ($dError != "") {
         $dError = "<br />" . _tr("Error has ocurred to try delete organizations data:") . "<br />" . $dError;
     }
     //***************************************************
     //***************************************************
     //recargamos lo servicios de fax,email y asterisk para que los cambios hechos en los archivos de
     //configuracion tomen efecto
     $reError = "";
     if (!$this->reloadServices()) {
         $reError .= "<br />" . _tr("Error has ocurred to try reloading Elastix services:") . "<br />";
         $reError .= $this->errMsg;
         $flag = false;
     }
     //***************************************************
     $this->errMsg = $exito . $error . $astError . $fError . $dError . $reError;
     return $flag;
 }