/** * Funzione che trasforma un array in un oggetto tabella * @param type $array * @return \Tabella */ private function getArrayTabella($array) { $result = new Tabella(); $result->setId($array->ID); $result->setNomeTabella($array->nome); $result->setStartRows($array->start_rows); $result->setEndRows($array->end_rows); $result->setStepRows($array->step_rows); $result->setStartCols($array->start_cols); $result->setEndCols($array->end_cols); $result->setStepCols($array->step_cols); $result->setAnte($array->ante); return $result; }
/** * Funzione che fa da listener al form di generazione tabella * Ha lo scopo di salvare nel database tutti i campi possibili generati */ public function listenerFormGenerazioneTabella() { //si suppone che il listener sia contenuto esternamente da un if //che guarda se il genera-tabella-articolo è stato istanziato //Elaboro i dati $startRows = isset($_POST['startRows']) ? intval($_POST['startRows']) : null; $endRows = isset($_POST['endRows']) ? intval($_POST['endRows']) : null; $stepRows = isset($_POST['stepRows']) ? intval($_POST['stepRows']) : null; $startCols = isset($_POST['startCols']) ? intval($_POST['startCols']) : null; $endCols = isset($_POST['endCols']) ? intval($_POST['endCols']) : null; $stepCols = isset($_POST['stepCols']) ? intval($_POST['stepCols']) : null; $prezzoIniziale = isset($_POST['prezzo-iniziale']) ? floatval($_POST['prezzo-iniziale']) : null; $incremento = isset($_POST['incremento']) ? $_POST['incremento'] : null; $nameTable = isset($_POST['nameTable']) ? strip_tags($_POST['nameTable']) : null; $ante = isset($_POST['ante']) ? strip_tags($_POST['ante']) : null; if ($startRows == null || $endRows == null || $stepRows == null || $startCols == null || $endCols == null || $stepCols == null || $nameTable == null || $ante == null) { echo '<p class="error">non tutti i campi sono stati compilati<p>'; return false; } //Salvo le informazioni della tabella generando un oggetto Tabella $tabella = new Tabella(); $tabella->setNomeTabella($nameTable); $tabella->setStartRows($startRows); $tabella->setEndRows($endRows); $tabella->setStepRows($stepRows); $tabella->setStartCols($startCols); $tabella->setEndCols($endCols); $tabella->setStepCols($stepCols); $tabella->setAnte($ante); $tabella->setPrezzoIniziale($prezzoIniziale); $tabella->setIncremento($incremento); //salvo l'oggetto nel database if (!$this->tPrezzi->saveTabellaArticolo($tabella)) { echo '<p class="error">salvataggio non andato a buon fine<p>'; return false; } return true; }