foreach ($_POST['sources'] as $s) { $sources[] = new address_city($s); } //end foreach } $country = false; if (isset($_POST['address_country'][0]) && $_POST['address_country'][0] != "" && $_POST['address_country'][0] != ID_UNDEFINED) { $country = new address_country($_POST['address_country'][0]); //var_dump($country); $ari->t->assign("address_country_selected", $country->get("id")); } else { $errores[] = "NO_COUNTRY"; } $state = false; if (isset($_POST['address_state'][0]) && $_POST['address_state'][0] != "" && $_POST['address_state'][0] != ID_UNDEFINED) { $state = new address_state($_POST['address_state'][0]); $ari->t->assign("address_state_id", $state->get('id')); $ari->t->assign("address_state_name", $state->get('name')); } else { $errores[] = "NO_STATE"; } if (!isset($_POST['destiny'])) { $errores[] = "NO_DESTINY_OPTION"; } else { //verifico si el destino es uno nuevo o existente if ($_POST['destiny'] == ID_UNDEFINED) { //destino nuevo $destiny = new address_city(ID_UNDEFINED); $destiny->set("state", $state); $destiny->set("status", USED); if (isset($_POST['new_name'])) {
if (isset($_POST['new_name'])) { $new_name = OOB_validatetext::inputHTML($_POST['new_name']); $ari->t->assign("new_name", $new_name); $destiny->set("name", $new_name); //$errores[] = "INVALID_DESTINY_NEW"; } //var_dump($destiny);exit; if (!$destiny->isValid()) { $errores[] = "INVALID_OBJECT"; } $new_state = true; } else { //destino existente //$destiny = new address_state($_POST['destiny']); if (isset($_POST['address_state'][0]) && $_POST['address_state'][0] != "" && $_POST['address_state'][0] != ID_UNDEFINED) { $destiny = new address_state($_POST['address_state'][0]); //$ari->t->assign("address_city_id", ID_UNDEFINED); $ari->t->assign("address_state_id", $destiny->get('id')); $ari->t->assign("address_state_name", $destiny->get('name')); //$ari->t->assign("address_country_selected", $destiny->get('country')->get('id')); } else { $errores[] = "NO_DESTINY_EXISTS"; } $new_state = false; } } if (count($errores) == 0) { $ari->db->StartTrans(); if ($new_state) { $destiny->store(); }