Well i missed it. Your previous code $this->$CONT_CEDULA
meant that you access field from $this
where field name is value of $CONT_CEDULA
.
Also try to really refractor yor code, right now it look pretty bad. For example:
for ($indice = 0; $indice < 9; $indice++) {
//echo $strOriginal[$indice],'</br>';
switch ($indice) {
case 0:
$arrProducto[$indice] = $strOriginal[$indice] * 4;
break;
case 1:
$arrProducto[$indice] = $strOriginal[$indice] * 3;
break;
case 2:
$arrProducto[$indice] = $strOriginal[$indice] * 2;
break;
case 3:
$arrProducto[$indice] = $strOriginal[$indice] * 7;
break;
case 4:
$arrProducto[$indice] = $strOriginal[$indice] * 6;
break;
case 5:
$arrProducto[$indice] = $strOriginal[$indice] * 5;
break;
case 6:
$arrProducto[$indice] = $strOriginal[$indice] * 4;
break;
case 7:
$arrProducto[$indice] = $strOriginal[$indice] * 3;
break;
case 8:
$arrProducto[$indice] = $strOriginal[$indice] * 2;
break;
}
}
You can move this to seperate method beacause you have this in two places.
switch ($indice) {
case 0:
case 2:
case 4:
case 6:
case 8:
$arrProducto[$indice] = $strOriginal[$indice] * 2;
if ($arrProducto[$indice] >= 10)
$arrProducto[$indice] -= 9;
//echo $arrProducto[$indice],'</br>';
break;
case 1:
case 3:
case 5:
case 7:
$arrProducto[$indice] = $strOriginal[$indice] * 1;
if ($arrProducto[$indice] >= 10)
$arrProducto[$indice] -= 9;
//echo $arrProducto[$indice],'</br>';
break;
}
modulo ?
$SPM_CONTACTO->CONT_CODIGO = $this->request->getPost("CONT_CODIGO");
$SPM_CONTACTO->CONT_CEDULA = $this->request->getPost("CONT_CEDULA");
$SPM_CONTACTO->CONT_RUCIDE = $this->request->getPost("CONT_RUCIDE");
$SPM_CONTACTO->CONT_NOMBRE = $this->request->getPost("CONT_NOMBRE");
$SPM_CONTACTO->CON_ESTADO = $this->request->getPost("CON_ESTADO");
$SPM_CONTACTO->CONT_TELEFO = $this->request->getPost("CONT_TELEFO");
$SPM_CONTACTO->CONT_DIRECC = $this->request->getPost("CONT_DIRECC");
$SPM_CONTACTO->CONT_AREA = $this->request->getPost("CONT_AREA");
$SPM_CONTACTO->CONT_CARGO = $this->request->getPost("CONT_CARGO");
$SPM_CONTACTO->CONT_TIPOXX = $this->request->getPost("CONT_TIPOXX");
$SPM_CONTACTO->CONT_EMAIL = $this->request->getPost("CONT_EMAIL");
$SPM_CONTACTO->CONT_USUARIO = $this->request->getPost("CONT_USUARIO");
$SPM_CONTACTO->CONT_CLAVE = $this->request->getPost("CONT_CLAVE");
$SPM_CONTACTO->CONT_CLAVEE = sha1($this->request->getPost("CONT_CLAVEE"));
$SPM_CONTACTO->CONT_FECNACI = $fechanacimiento->format('d/m/Y H:i:s');
$SPM_CONTACTO->CONT_FECINSC = $fechainscripcion->format('d/m/Y H:i:s');
$SPM_CONTACTO->CONT_TIPOCODIGO = $this->request->getPost("CONT_TIPOCODIGO");
Instead of doing this you can just do:
$post = $this->request->getPost();
$whiteList = //Some method from our object which will return whitelist array
if (!$SPM_CONTACTO->save($post, $whiteList)) {
// rest of code
}
Also you should create and format date in beforeValidationOnSave method in your model.