diff --git a/admin/app.js b/admin/app.js
new file mode 100644
index 00000000..8cdb85cc
--- /dev/null
+++ b/admin/app.js
@@ -0,0 +1,94 @@
+var app = new Vue({
+ el: "#app",
+ data: {
+ showmodaladd: false,
+ showmodaledit: false,
+ showmodaldelete: false,
+ successmessage: "",
+ errormessage: "",
+ datos: [],
+ newDato: {sort :"" , page_id :"" , title_page :"" , link_page :"" , parent_id :""},
+ clickedDato: {}
+
+ },
+ mounted: function () {
+ console.log("mounted");
+ this.getAllDatos();
+ },
+ methods: {
+ getAllDatos: function () {
+ axios.get("app.php?action=read")
+ .then(function (response) {
+ // console.log(response);
+ if (response.data.error) {
+ app.errormessage = response.data.message;
+ } else {
+ app.datos = response.data.datos;
+ }
+ });
+
+ },
+ saveDato: function () {
+ // console.log(app.newDato);
+ var formData = app.toformData(app.newDato);
+ axios.post("app.php?action=create", formData)
+ .then(function (response) {
+
+ // app.newDato={sort :"" , page_id :"" , title_page :"" , link_page :"" , parent_id :""};
+
+ if (response.data.error == true) {
+ app.errormessage = response.data.message;
+ } else {
+ app.successmessage = response.data.message;
+ app.getAllDatos();
+ }
+ });
+ },
+ selectDato: function (dato) {
+ app.clickedDato = dato;
+ },
+ updateDato: function (dato) {
+ var formData = app.toformData(app.clickedDato);
+ axios.post("app.php?action=update", formData)
+ .then(function (response) {
+
+ app.clickedDato = {};
+
+ if (response.data.error) {
+ app.errormessage = response.data.error;
+ } else {
+ app.successmessage = response.data.message;
+ app.getAllDatos();
+ }
+ });
+ },
+ deleteDato: function (dato) {
+ var formData = app.toformData(app.clickedDato);
+ axios.post("app.php?action=delete", formData)
+ .then(function (response) {
+
+ app.clickedDato = {};
+
+ if (response.data.error) {
+ app.errormessage = response.data.message;
+ } else {
+ app.successmessage = response.data.message;
+ app.getAllDatos();
+ }
+ });
+ },
+ toformData: function (obj) {
+ var form_data = new FormData();
+ for (var key in obj) {
+ form_data.append(key, obj[key]);
+ }
+ return form_data;
+ },
+
+ clearMessage: function () {
+ app.successmessage = "";
+ app.errormessage = "";
+ }
+ }
+
+ });
\ No newline at end of file
diff --git a/admin/vuejs_crud.php b/admin/vuejs_crud.php
new file mode 100644
index 00000000..9a848ea8
--- /dev/null
+++ b/admin/vuejs_crud.php
@@ -0,0 +1,660 @@
+query($sql);
+
+ $cname = array();
+ $i = 0;
+ while ($result->field_count > $i) {
+ $nam = $result->fetch_field();
+ if ($i === 0) {
+ $idcol = $nam->name;
+ $whre = $nam->name . " ='$" . $nam->name . "'";
+ $vpost = "$" . $nam->name . " = \$_POST['" . $nam->name . "'];";
+ }
+
+ $cnames[] = $nam->name;
+ $uposts[] = "$" . $nam->name . "= \$_POST['" . $nam->name . "'];" . "\n";
+ if ($i != 0) {
+ $varc[] = $nam->name . ' :""';
+ $cols[] = $nam->name;
+ $varnames[] = "'$" . $nam->name . "'";
+ $upnames[] = $nam->name . " ='$" . $nam->name . "'";
+ $cposts[] = "$" . $nam->name . "= \$_POST['" . $nam->name . "'];" . "\n";
+ }
+ $i = $i + 1;
+ }
+
+ // start joins
+ $ths = array();
+ $qnames = array();
+ $num = $result->field_count;
+ if ($num > 0) {
+ while ($nam = $result->fetch_field()) {
+ $qnames[] = $nam->name;
+ }
+ foreach ($qnames as $qname) {
+ $ths[] = '
' . $qname . ' | ' . "\n";
+ }
+ } else {
+ echo 'This table if it has columns or content.' . '
';
+ }
+
+ function stringUf($cname) {
+ return ucfirst(str_replace('_', ' ', $cname));
+ }
+
+ function getJoin($tbl, $cname) {
+ global $conn;
+ $joinquery = $conn->query("SELECT * FROM table_column_settings WHERE table_name='$tbl' AND col_name='$cname'");
+ if ($joinquery->num_rows > 0) {
+ $resjoin = $joinquery->fetch_assoc();
+ $coln = $resjoin['j_value'];
+ if (!empty($coln)) {
+ return $coln;
+ } else {
+ return $cname;
+ }
+ } else {
+ return $cname;
+ }
+ }
+
+ function getSelect($tbl, $cname) {
+ global $conn;
+ $joinquery = $conn->query("SELECT * FROM table_column_settings WHERE table_name='$tbl' AND col_name='$cname'");
+ if ($joinquery->num_rows > 0) {
+ $resjoin = $joinquery->fetch_assoc();
+ $coln = $resjoin['j_value'];
+ if (!empty($coln)) {
+ return $coln;
+ } else {
+ return $cname;
+ }
+ } else {
+ return $cname;
+ }
+ }
+
+ function optsel($jtable, $jid, $jvalue) {
+ global $conn;
+ $sels = $conn->query("SELECT * FROM $jtable");
+ while ($sel = $sels->fetch_array()) {
+ echo '';
+ }
+ }
+
+ function inpSel($tbl, $cname) {
+ global $conn;
+ $qsl = $conn->query("SELECT * FROM table_column_settings WHERE table_name='$tbl' AND col_name='$cname'");
+ while ($row = $qsl->fetch_array()) {
+ if (!empty($row['joins'])) {
+ $jtable = $row['j_table'];
+ $jvalue = $row['j_value'];
+ $jid = $row['j_id'];
+ echo'' . "\n";
+ } else {
+ echo '';
+ }
+ }
+ }
+
+ function upSel($tbl, $cname) {
+ global $conn;
+ $qsl = $conn->query("SELECT * FROM table_column_settings WHERE table_name='$tbl' AND col_name='$cname'");
+ while ($row = $qsl->fetch_array()) {
+ if (!empty($row['joins'])) {
+ $jtable = $row['j_table'];
+ $jvalue = $row['j_value'];
+ $jid = $row['j_id'];
+ echo'' . "\n";
+ } else {
+ echo '';
+ }
+ }
+ }
+
+ $colcs = array();
+ $ljoins = array();
+ $sql1 = "SELECT * FROM table_column_settings WHERE table_name='$tbl'";
+ $result1 = $conn->query($sql1);
+ $ntq = $result1->num_rows;
+ if ($ntq > 0) {
+ while ($qtb = $result1->fetch_array()) {
+ $colcs[] = getJoin($tbl, $qtb['col_name']);
+ if (empty($qtb['joins'])) {
+ continue;
+ } else {
+ $ljoins[] = $qtb['joins'] . ' ' . $qtb['j_table'] . ' ON ' . $tbl . '.' . $qtb['col_name'] . ' = ' . $qtb['j_table'] . '.' . $qtb['j_id'];
+ }
+ }
+ }
+
+ $rjoin = implode(" ", $ljoins);
+ $joinquery = $conn->query("SELECT * FROM $tbl $rjoin");
+
+// end joins
+
+ $col = implode(" , ", $cols);
+ $varname = implode(" , ", $varnames);
+ $upname = implode(" , ", $upnames);
+ $cli = implode(" , ", $varc);
+ $upost = implode(" ", $uposts);
+ $cpost = implode(" ", $cposts);
+
+ // make file app.js
+ $appfile = 'app.js';
+ $myapp = fopen("$appfile", "w") or die("Unable to open file!");
+ $appcontent = 'var app = new Vue({
+ el: "#app",
+ data: {
+ showmodaladd: false,
+ showmodaledit: false,
+ showmodaldelete: false,
+ successmessage: "",
+ errormessage: "",
+ datos: [],
+ newDato: {' . $cli . '},
+ clickedDato: {}
+
+ },
+ mounted: function () {
+ console.log("mounted");
+ this.getAllDatos();
+ },
+ methods: {
+ getAllDatos: function () {
+ axios.get("app.php?action=read")
+ .then(function (response) {
+ // console.log(response);
+ if (response.data.error) {
+ app.errormessage = response.data.message;
+ } else {
+ app.datos = response.data.datos;
+ }
+ });
+
+ },
+ saveDato: function () {
+ // console.log(app.newDato);
+ var formData = app.toformData(app.newDato);
+ axios.post("app.php?action=create", formData)
+ .then(function (response) {
+
+ // app.newDato={' . $cli . '};
+
+ if (response.data.error == true) {
+ app.errormessage = response.data.message;
+ } else {
+ app.successmessage = response.data.message;
+ app.getAllDatos();
+ }
+ });
+ },
+ selectDato: function (dato) {
+ app.clickedDato = dato;
+ },
+ updateDato: function (dato) {
+ var formData = app.toformData(app.clickedDato);
+ axios.post("app.php?action=update", formData)
+ .then(function (response) {
+
+ app.clickedDato = {};
+
+ if (response.data.error) {
+ app.errormessage = response.data.error;
+ } else {
+ app.successmessage = response.data.message;
+ app.getAllDatos();
+ }
+ });
+ },
+ deleteDato: function (dato) {
+ var formData = app.toformData(app.clickedDato);
+ axios.post("app.php?action=delete", formData)
+ .then(function (response) {
+
+ app.clickedDato = {};
+
+ if (response.data.error) {
+ app.errormessage = response.data.message;
+ } else {
+ app.successmessage = response.data.message;
+ app.getAllDatos();
+ }
+ });
+ },
+ toformData: function (obj) {
+ var form_data = new FormData();
+ for (var key in obj) {
+ form_data.append(key, obj[key]);
+ }
+ return form_data;
+ },
+
+ clearMessage: function () {
+ app.successmessage = "";
+ app.errormessage = "";
+ }
+ }
+
+ });';
+ fwrite($myapp, $appcontent);
+ fclose($myapp);
+ // make file app.php
+ $apifile = 'app.php';
+ $myapi = fopen("$apifile", "w") or die("Unable to open file!");
+ $apicontent = '
+ false);
+
+$action = "read";
+
+if (isset($_GET["action"])) {
+ $action = $_GET["action"];
+}
+
+if ($action == "read") {';
+
+ if ($ntq > 0) {
+ $apicontent .= '$result = $conn->query("SELECT * FROM ' . $tbl . ' ' . $rjoin . '");
+ $datos = array();
+ while ($row = $result->fetch_assoc()) {
+ array_push($datos, $row);
+ }
+
+ $res["datos"] = $datos;
+ ';
+ } else {
+ $apicontent .= ' $result = $conn->query("SELECT * FROM `' . $tbl . '`");
+ $datos = array();
+ while ($row = $result->fetch_assoc()) {
+ array_push($datos, $row);
+ }
+
+ $res["datos"] = $datos;
+ ';
+ }
+ $apicontent .= '
+
+}
+// Create form
+
+if ($action == "create") {
+
+ ' . $cpost . '
+
+ $result = $conn->query("INSERT INTO ' . $tbl . '(' . $col . ') VALUES (' . $varname . ')");
+
+ if ($result) {
+ $res["message"] = "dato agregado exitosamente";
+ } else {
+ $res["error"] = true;
+ $res["message"] = "dato no se agrego exitosamente";
+ }
+
+ // $res["datos"] =$datos;
+}
+// end of create form
+// update form
+
+if ($action == "update") {
+ ' . $upost . '
+
+ $result = $conn->query("UPDATE ' . $tbl . ' SET ' . $upname . ' WHERE ' . $whre . ' ");
+
+ if ($result) {
+ $res["message"] = "dato actualizado con éxito";
+ } else {
+ $res["error"] = true;
+ $res["error"] = "dato no se actualizo con éxito";
+ }
+}
+
+// end of update form
+
+if ($action == "delete") {
+ ' . $vpost . '
+
+ $result = $conn->query("DELETE FROM `' . $tbl . '` WHERE ' . $whre . ' ");
+
+ if ($result) {
+ $res["message"] = "dato borrado exitosamente";
+ } else {
+ $res["error"] = true;
+ $res["message"] = "dato no se borro exitosamente";
+ }
+ // $res["datos"] =$datos;
+}
+
+$conn->close();
+header("content-type:application/json");
+echo json_encode($res);
+die();
+?>
+';
+ fwrite($myapi, $apicontent);
+ fclose($myapi);
+ }
+ ?>
+
+
+
+
+
+
+ query("SELECT * FROM table_config")) {
+ $total_found = mysqli_num_rows($result);
+
+ if ($total_found > 0) {
+ $row = mysqli_fetch_assoc($result);
+ $tableNames = explode(',', $row['table_name']);
+ }
+ }
+ ?>
+
+
+
+
Select a table from your database
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{successmessage}}
+
+
+
{{errormessage}}
+
+
+
+
+
+
+
List of
+
+
+
+
+
+
+
+
+
+
+ Actions |
+ ' . ucfirst(str_replace(' id', '', $remp)) . '' . "\n";
+ }
+ ?>
+
+
+
+
+
+
+
+ |
+ {{dato.' . getJoin($tbl, $cname) . '}}' . "\n";
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
You're going to delete id {{clickedDato.}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+