- <?php 
-   
- namespace octavius\controlador\intranet\persona; 
-   
- /** 
-  * @author PabloV 
-  * @version 1.0 
-  * @created 07-may-2015 12:39:25 
-  */ 
- class PersonaTO { 
-   
-     private $idPersona = ""; 
-     private $strNombres = ""; 
-     private $strApellidoPaterno = ""; 
-     private $strApellidoMaterno = ""; 
-     private $strRut = ""; 
-     private $strDv = ""; 
-     private $Empresa = ""; 
-     private $strImagenPersona = ""; 
-   
-     public function __construct() { 
-   
-     } 
-   
-     public function __destruct() { 
-   
-     } 
-   
-     public function getStrNombres() { 
-         return $this->strNombres; 
-     } 
-   
-     public function getStrApellidoPaterno() { 
-         return $this->strApellidoPaterno; 
-     } 
-   
-     public function getStrApellidoMaterno() { 
-         return $this->strApellidoMaterno; 
-     } 
-   
-     public function getStrRut() { 
-         return $this->strRut; 
-     } 
-   
-     public function getStrDv() { 
-         return $this->strDv; 
-     } 
-   
-     /** 
-      * Devuelve un objeto Empresa con todos sus atributos. 
-      * @return Empresa 
-      */ 
-     public function getEmpresa() { 
-         return $this->Empresa; 
-     } 
-   
-     public function getStrImagenPersona() { 
-         return $this->strImagenPersona; 
-     } 
-   
-     public function setStrNombres($strNombres) { 
-         $this->strNombres = $strNombres; 
-     } 
-   
-     public function setStrApellidoPaterno($strApellidoPaterno) { 
-         $this->strApellidoPaterno = $strApellidoPaterno; 
-     } 
-   
-     public function setStrApellidoMaterno($strApellidoMaterno) { 
-         $this->strApellidoMaterno = $strApellidoMaterno; 
-     } 
-   
-     public function setStrRut($strRut) { 
-         $eliminarElementos = "/[-][0-9]/"; 
-         $eliminarElementos = "/[-][k]/"; 
-         $eliminarElementos = "/[-][K]/"; 
-         $eliminarElementos = "/[-]/"; 
-         $eliminarElementos = "/[.]/"; 
-   
-         $multiplicaciones = array(); 
-         $multiplicaciones[0] = 2; 
-         $multiplicaciones[1] = 3; 
-         $multiplicaciones[2] = 4; 
-         $multiplicaciones[3] = 5; 
-         $multiplicaciones[4] = 6; 
-         $multiplicaciones[5] = 7; 
-   
-         $formula = ""; 
-         $suma = 0; 
-         $contadorMultiplo = 0; 
-         for ($i = strlen($strRut); $i >= 0; $i--) { 
-             if (isset($strRut[$i])) { 
-                 $formula.=$strRut[$i]; 
-             } 
-         } 
-         for ($i = 0; $i < strlen($strRut); $i++) { 
-             if ($i == count($multiplicaciones)) { 
-                 $contadorMultiplo = 0; 
-             } 
-             if (isset($strRut[$i])) { 
-                 $suma = $suma + $multiplicaciones[$contadorMultiplo] * $formula[$i]; 
-             } 
-             $contadorMultiplo++; 
-         } 
-         $resultadoResto = $suma % 11; 
-         $resultadoDigitoVerificador = 11 - $resultadoResto; 
-         switch ($resultadoDigitoVerificador) { 
-             case "11": 
-                 $resultadoDigitoVerificador = 0; 
-                 break; 
-             case "10": 
-                 $resultadoDigitoVerificador = "k"; 
-                 break; 
-         } 
-         $this->setStrDv($resultadoDigitoVerificador); 
-         //echo "El digito verificador es $resultadoDigitoVerificador <br/>"; 
-         // echo "Rut invertido $formula";     
-         $this->strRut = (string) $strRut; 
-     } 
-   
-     public function setStrDv($strDv) { 
-         $this->strDv = $strDv; 
-     } 
-   
-     public function setEmpresa($Empresa) { 
-   
-         $this->Empresa = $Empresa; 
-     } 
-   
-     /** 
-      * http://carluys.blogspot.cl/2013/01/codificar-imagenes-en-base64-con-php.html 
-      * @param type $strImagenPersona 
-      */ 
-     public function setStrImagenPersona($strImagenPersona) { 
-         /** 
-          * $img_src = "image/sample.png";   
-           $imgbinary = fread(fopen($img_src, "r"), filesize($img_src)); 
-           $img_str = base64_encode($imgbinary); 
-           echo '<img src="data:image/jpg;base64,'.base64_encode($imgbinary).'" />'; 
-          */ 
-         $this->strImagenPersona = $strImagenPersona; 
-     } 
-   
-     public function getIdPersona() { 
-         return $this->idPersona; 
-     } 
-   
-     public function setIdPersona($idPersona) { 
-         $this->idPersona = $idPersona; 
-     } 
-   
-     /** 
-      * Metodo que nos permite obtener las propiedades 
-      * de toda la clase. 
-      * @return type 
-      */ 
-     public function getProperties() { 
-     } 
-   
-     /** 
-      * Nos permite obtener todos los atributos del objeto a json, de esta forma 
-      * podemos enviar el objeto json por ajax e interactuar con el por javascript 
-      * --- 
-      * Se agrega una validacion que nos permite identificar si el valor a  agregar es un Objeto 
-      * independiente, si es así, entonces esa propiedad se convierte a json de forma completa. 
-      * if(is_object($value)){ 
-       $object->$name=$value->_toJSON(); <----- aqui. 
-       }else{ 
-       $object->$name = $value; <--- Originalmente solo estaba esto. 
-       } 
-      *  
-      * @return type JSON OBJECT 
-      */ 
-     public function _toJson() { 
-         $properties = $this->getProperties(); 
-         $object = new \StdClass(); 
-         foreach ($properties as $name => $value) { 
-                 $object->$name = $value->_toJson(); 
-             } else { 
-                 $object->$name = $value; 
-             } 
-         } 
-     } 
-   
- } 
-   
- ?>