public function GuardarAlbaranes() { $db = new db(); $db->connect(); $C = new ActiveRecord('albaranes'); $C->fields["fecha"] = $this->fecha; $C->fields["operacion"] = $this->operacion; $C->fields["guia"] = $this->guia; $C->fields["remitente"] = $this->remitente; $C->fields["beneficiario"] = $this->beneficiario; $C->fields["documento"] = $this->documento; $C->fields["pais"] = $this->pais; $C->fields["direccion"] = $this->direccion; $C->fields["ciudad"] = $this->ciudad; $C->fields["telefono"] = $this->telefono; $C->fields["descripcion"] = $this->descripcion; $C->fields["peso"] = $this->peso; $C->fields["comision"] = $this->comision; $C->fields["seguro"] = $this->seguro; $C->fields["iv"] = $this->iv; $C->fields["total"] = $this->total; $C->fields["direccion_agencia"] = $this->direccion_agencia; $C->insert(); $db->close(); }
public function importToDB() { $GLOBALS['FORCE_INSERT_ID'] = true; $rows = fk_post('rows'); $Ar = new ActiveRecord($this->tableName); $tot_importados = 0; if (count($rows) > 0) { foreach ($rows as $lineNo) { $cols = fk_post('txt_' . $lineNo); // Campos importados foreach ($cols as $colNo => $colVal) { // procesar reglas $fieldName = fk_post('col-' . $colNo); $colVal = $this->getVal($colVal, $fieldName); if ($fieldName != '') { $Ar->fields[$fieldName] = utf8_decode($colVal); //echo $colVal; } } // Campos fijos [SOBRE ESCRIBE] foreach ($this->fixedC as $fixedColNo => $FixedColVal) { $Ar->fields[$fixedColNo] = $FixedColVal; } if ($Ar->insert()) { $this->registros_importados++; } } return true; } else { $this->result_message = 'No se importo ningun registro'; return false; } }
public function CrearPerfilPriv() { $db = new db(); $db->connect(); $C = new ActiveRecord('fk_perfiles_privs'); $C->fields['id_usuario'] = $this->id_perfil; $C->fields['id_priv'] = $this->id_priv; $C->fields['access'] = $this->access; $C->insert(); $db->close(); }
/** *@package AppForm *@method createSelectRecords() *@desc allows adding records to a select list from appform *@since v0.3.4 **/ private function createSelectRecords($operation) { //crear opciones de <select> nuevas if ($operation == 'save') { foreach ($this->DbRecord->form_fields as $field => $properties) { $post_field_name = $this->encode_fields ? encode($field) : $field; if ($properties['Type'] == 'select' && fk_post($post_field_name) == 'new') { // if allows adding new if (isset($properties['add_new'])) { // $Ar = new ActiveRecord($properties['add_new']['table_name']); foreach ($properties['add_new']['field'] as $new_field => $new_val) { $Ar->fields[$new_field] = utf8_decode($new_val); } $Ar->insert(); $_POST[$post_field_name] = $Ar->inserted_id(); } } // if allows adding new } // foreach field } // if save }
private function saveLines() { $tableId = $this->tableId; $total = fk_post($tableId . '_tot'); for ($i = 1; $i <= $total; $i++) { $id_rec = fk_post($tableId . '_recId-' . $i); $Ar = new ActiveRecord($this->table_name); if ($id_rec > 0) { //UPDATE //procesar fields to save foreach ($this->fields_to_save as $key => $value_from) { $arr_src = array('{table-id}', '{row-id}'); $arr_repl = array($tableId . '_', '-' . $i); $value = str_replace($arr_src, $arr_repl, $value_from); $Ar->fields[$key] = fk_post($value); } $Ar->fields[$this->record_id_name] = $id_rec; $Ar->display_queries = true; $Ar->update(); } else { //INSERT //procesar fields to save foreach ($this->fields_to_save as $key => $value_from) { $arr_src = array('{table-id}', '{row-id}'); $arr_repl = array($tableId . '_', '-' . $i); $value = str_replace($arr_src, $arr_repl, $value_from); $Ar->fields[$key] = fk_post($value); } $Ar->insert(); } } }
public static function generarConsecutivo($codigo, $increment = true) { // GenerarConsecutivo $Configsys = new ActiveRecord('config_sys'); $tot_contador = $Configsys->find_where('config_code = "' . $codigo . '" '); if ($tot_contador == 0) { // No existe $numero_consecutivo = 1; if ($increment == true) { $Configsys->fields['config_code'] = $codigo; $Configsys->fields['config_value'] = $numero_consecutivo; $Configsys->insert(); } } else { // Si existe $numero_consecutivo = $Configsys->fields['config_value'] + 1; // INCREMENTA if ($increment == true) { $Configsys->fields['config_value'] = $numero_consecutivo; $numero_consecutivo = $Configsys->fields['config_value']; $Configsys->update(); } } return $numero_consecutivo; }
protected function insert() { $this->executePlugins($this, 'before-insert'); $res = parent::insert(); $this->executePlugins($this, 'insert'); $this->executePlugins($this, 'save'); return $res; }