SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

DROP TABLE IF EXISTS `account`;
CREATE TABLE `account` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `parent_id` int(11) NOT NULL DEFAULT 0,
  `code` varchar(10) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `remark` varchar(100) DEFAULT NULL,
  `descr` varchar(100) DEFAULT NULL,
  `lev1` varchar(16) DEFAULT NULL,
  `lev2` varchar(16) DEFAULT NULL,
  `cname` varchar(16) DEFAULT NULL,
  `min` varchar(2) DEFAULT NULL,
  `saldo_normal` varchar(10) DEFAULT NULL,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `sel` tinyint(4) NOT NULL DEFAULT 0,
  `sel2` tinyint(4) NOT NULL DEFAULT 0,
  `level` tinyint(4) NOT NULL DEFAULT 0,
  `col` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'pos amount at report',
  `trx` tinyint(4) NOT NULL DEFAULT 0,
  `seq` tinyint(4) NOT NULL DEFAULT 0,
  `c1` tinyint(4) NOT NULL DEFAULT 0,
  `c2` int(11) NOT NULL DEFAULT 0,
  `c3` int(11) NOT NULL DEFAULT 0,
  `id2` int(11) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `code` (`code`),
  KEY `id_parent_id_code` (`id`,`parent_id`,`code`)
) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

INSERT INTO `account` VALUES ('1','0','N','Neraca','','','0','','','','','1','0','0','0','0','2','0','0','0','0','1','0');
INSERT INTO `account` VALUES ('2','0','RL','Rugi Laba','','','0','','','','','1','0','0','0','0','2','0','0','0','0','2','0');
INSERT INTO `account` VALUES ('3','0','AK','Arus Kas','','','0','','','','','1','0','0','0','0','2','0','0','0','0','3','0');
INSERT INTO `account` VALUES ('4','0','PM','Perubahan Modal','','','0','','','','','1','0','0','0','0','2','0','0','0','0','4','0');
INSERT INTO `account` VALUES ('5','1','10000','Aktiva/Aset','','','0','c10000','','','debet','1','1','0','1','0','2','0','0','0','0','5','1746512969');
INSERT INTO `account` VALUES ('6','1','20000','Liabilitas/Utang/Kewajiban','','','Aset','c20000','','','debet','1','1','0','1','0','2','0','0','0','0','6','1746514847');
INSERT INTO `account` VALUES ('7','5','11000','Aktiva Lancar','','','','c11000','','','','1','1','0','2','0','2','0','0','0','0','7','1746512995');
INSERT INTO `account` VALUES ('8','2','L410','Penerimaan','','','','c5100','','','','1','1','0','1','4','2','1','0','0','0','8','1746540174');
INSERT INTO `account` VALUES ('9','2','L510','Harga Pokok Penjualan','','','','c5200','','','','1','1','0','1','4','2','5','0','0','0','9','1746540166');
INSERT INTO `account` VALUES ('10','2','L620','Beban Administrasi','','','0','c5400','','','','1','1','0','1','4','2','11','0','0','0','10','1746540024');
INSERT INTO `account` VALUES ('11','2','L640','Laba Operasi/Sebelum PPh','','','0','c5500','','','','1','1','0','1','4','2','20','0','0','0','11','1746540102');
INSERT INTO `account` VALUES ('12','43','62106','Kebersihan','','','','','','-','','1','1','0','4','1','1','0','0','0','62','12','1746515614');
INSERT INTO `account` VALUES ('13','5','12000','Aktiva/Aset Tetap','','','','c12000','','','','1','1','0','2','0','2','0','0','0','0','13','1746513204');
INSERT INTO `account` VALUES ('14','6','21100','Utang Dagang','','','','c21100','','','','1','1','0','3','2','1','0','0','0','21','14','1746514790');
INSERT INTO `account` VALUES ('15','1','30000','Equity/Modal','','','','c30000','','','','1','1','0','2','0','2','0','0','0','0','15','1746513749');
INSERT INTO `account` VALUES ('16','5','19999','Total Aktiva','','','','','','','','1','1','0','2','4','2','0','0','0','0','16','1746513437');
INSERT INTO `account` VALUES ('17','1','40000','Penerimaan/Pendapatan','','','','c40000','','','','1','1','0','2','0','2','0','0','0','0','17','1746514605');
INSERT INTO `account` VALUES ('18','1','50000','Harga Pokok Penjualan','','','','c50000','','','','1','1','0','2','0','2','0','0','0','0','18','1746513961');
INSERT INTO `account` VALUES ('19','1','60000','Beban','','','','c60000','','','','1','1','0','2','0','2','0','0','0','0','19','1746513975');
INSERT INTO `account` VALUES ('20','6','21200','Utang Biaya','','','','c22100','','','','1','1','0','3','2','1','0','0','0','21','20','1747195466');
INSERT INTO `account` VALUES ('21','7','11101','Kas & Bank','','','','c11101','','','','1','1','1','3','2','1','0','0','0','11','21','1746513048');
INSERT INTO `account` VALUES ('22','7','11202','Persediaan Barang Dagang','','','','c11202','','','','1','1','0','3','2','1','0','0','0','11','22','1746513100');
INSERT INTO `account` VALUES ('23','7','11201','Piutang','','','','c11201','','','','1','1','1','3','2','1','0','0','0','11','23','1746513080');
INSERT INTO `account` VALUES ('24','7','11203','Perlengkapan','','','','c11203','','','','1','1','0','3','2','1','0','0','0','11','24','1746513117');
INSERT INTO `account` VALUES ('25','7','11205','Biaya/sewa Dibayar Dimuka','','','','c11205','','','','1','1','0','3','2','1','0','0','0','11','25','1746513167');
INSERT INTO `account` VALUES ('26','7','11999','Total Aktiva Lancar','','','','','','','','1','1','0','3','3','2','0','0','0','0','26','1746513371');
INSERT INTO `account` VALUES ('27','13','12101','Tanah','','','','c12101','','','','1','1','1','3','2','1','0','0','0','12','27','1746513223');
INSERT INTO `account` VALUES ('28','13','12301','Kendaraan','','','','c12301','','','','1','1','1','3','2','1','0','0','0','12','28','1746513286');
INSERT INTO `account` VALUES ('29','13','12201','Bangunan','','','','c12201','','','','1','1','1','3','2','1','0','0','0','12','29','1746513246');
INSERT INTO `account` VALUES ('30','13','12401','Peralatan','','','','c12401','','','','1','1','1','3','2','1','0','0','0','12','30','1746513322');
INSERT INTO `account` VALUES ('31','6','29999','Total Utang','','','','','','','','1','1','0','2','3','2','0','0','0','0','31','1746514492');
INSERT INTO `account` VALUES ('32','17','41999','Total Penerimaan/Pendapatan','','','','','','','','1','1','0','3','3','2','0','0','0','0','32','1746514712');
INSERT INTO `account` VALUES ('33','13','12999','Total Aktiva Tetap','','','','','','','','1','1','0','3','3','2','0','0','0','0','33','1746513343');
INSERT INTO `account` VALUES ('34','7','11204','Asuransi Dibayar Dimuka','','','','','','','','1','1','0','3','2','1','0','0','0','11','34','1746513146');
INSERT INTO `account` VALUES ('35','18','51999','Harga Pokok Penjualan','','','','','','','','1','1','0','3','4','2','0','0','0','0','35','1746515217');
INSERT INTO `account` VALUES ('36','15','31100','Setor Modal','','','','c31100','','','','1','1','1','3','2','1','0','0','0','31','36','1746514526');
INSERT INTO `account` VALUES ('37','17','41100','Penjualan','','','','c41100','','','','1','1','0','3','2','1','0','0','0','41','37','1746514631');
INSERT INTO `account` VALUES ('38','17','41200','Retur Penjualan','','','','c41200','','-','','1','1','0','3','2','1','0','0','0','41','38','1746514654');
INSERT INTO `account` VALUES ('39','17','41300','Potongan Penjualan','','','','c41300','','-','','1','1','0','3','2','1','0','0','0','41','39','1746514685');
INSERT INTO `account` VALUES ('40','43','62107','Penyusutan Bangunan','','','','','','-','','1','1','0','4','1','1','0','0','0','62','40','1746515637');
INSERT INTO `account` VALUES ('41','42','61102','Operasional','','','','c61102','','-','','1','1','0','4','1','1','0','0','0','61','41','1746522468');
INSERT INTO `account` VALUES ('42','19','61000','Operasional/Penjualan','','','','c61000','','','','1','1','0','3','0','2','0','0','0','61','42','1746515037');
INSERT INTO `account` VALUES ('43','19','62000','Administrasi','','','','c62000','','','','1','1','0','3','0','2','0','0','0','62','43','1746515136');
INSERT INTO `account` VALUES ('44','43','62999','Total Beban Administrasi','','','','','','','','1','1','0','4','2','2','0','0','0','0','44','1746515669');
INSERT INTO `account` VALUES ('45','3','A','Arus Kas dari Aktivitas Operasional','','','','','','','','1','1','0','1','0','2','0','0','0','0','45','1687098868');
INSERT INTO `account` VALUES ('46','3','B','Arus Kas dari Aktivitas Investasi','','','','','','','','1','1','0','1','0','2','0','0','0','0','46','1687098877');
INSERT INTO `account` VALUES ('47','3','C','Arus Kas dari Aktivitas Pendanaan','','','','','','','','1','1','0','1','0','2','0','0','0','0','47','1687098885');
INSERT INTO `account` VALUES ('48','45','A1','Kas Diterima dari Customer','','','','','','','','1','1','0','2','1','0','0','0','0','0','48','1687244794');
INSERT INTO `account` VALUES ('49','45','A2','Pembayaran kas untuk supplier','','','','','','','','1','1','0','2','1','0','0','0','0','0','49','1687244802');
INSERT INTO `account` VALUES ('50','45','A3','Pembayaran kas untuk beban operasi','','','','','','','','1','1','0','2','1','0','0','0','0','0','50','1687244809');
INSERT INTO `account` VALUES ('51','45','A4','Pembayaran kas untuk bunga','','','','','','','','1','1','0','2','1','0','0','0','0','0','51','1687244820');
INSERT INTO `account` VALUES ('52','45','A5','Pembayaran kas untuk pajak','','','','','','','','1','1','0','2','1','0','0','0','0','0','52','1687244829');
INSERT INTO `account` VALUES ('53','46','B1','Kas diterima dari penjualan aktiva tetap','','','','','','','','1','1','0','2','1','0','0','0','0','0','53','1687446507');
INSERT INTO `account` VALUES ('54','46','B3','Pembayaran kas untuk pembelian aktiva tetap','','','','','','','','1','1','0','2','1','0','0','0','0','0','54','1687447868');
INSERT INTO `account` VALUES ('55','45','A9','Jumlah kas dari aktivitas operasi','jumlah dari A','','','cA9','','','','0','1','0','2','2','0','0','0','0','0','55','1687245302');
INSERT INTO `account` VALUES ('56','46','B9','Jumlah kas untuk aktivitas investasi','Jumlah dari B','','','','','','','1','1','0','2','2','0','0','0','0','0','56','1687244887');
INSERT INTO `account` VALUES ('57','47','C1','Kas diterima dari penyertaan saham','','','','','','','','1','1','0','2','1','0','0','0','0','0','57','1687244897');
INSERT INTO `account` VALUES ('58','47','C2','Kas diterima dari hutang/pinjaman','','','','','','','','1','1','0','2','1','0','0','0','0','0','58','1687446474');
INSERT INTO `account` VALUES ('59','47','C6','Pembayaran kas untuk prive','','','','','','','','1','1','0','2','1','0','0','0','0','0','59','1687244911');
INSERT INTO `account` VALUES ('60','47','C7','Pembayaran kas untuk bunga/bagi hasil','','','','','','','','1','1','0','2','1','0','0','0','0','0','60','1687244922');
INSERT INTO `account` VALUES ('61','47','C8','Pembayaran kas untuk pelunasan hutang/pinjaman jangka panjang','','','','','','','','1','1','0','2','1','0','0','0','0','0','61','1687244932');
INSERT INTO `account` VALUES ('62','47','C9','Jumlah kas dari aktivitas pendanaan','jumlah dari C','','','','','','','1','1','0','2','2','0','0','0','0','0','62','1687244939');
INSERT INTO `account` VALUES ('63','4','PM01','Modal Usaha','=31900','','','cPM01','','','','1','1','0','1','2','0','1','0','0','0','63','1714402115');
INSERT INTO `account` VALUES ('64','63','PM02','Pembayaran Prive','','','','','','','','1','1','0','2','1','0','2','0','0','0','64','1687245025');
INSERT INTO `account` VALUES ('65','63','PM03','Pembayaran Deviden','','','','','','','','1','1','0','2','1','0','3','0','0','0','65','1687245031');
INSERT INTO `account` VALUES ('66','63','PM04','Laba/Rugi Periode Ini','=90000','','','','','','','1','1','0','2','1','0','4','0','0','0','66','1687245036');
INSERT INTO `account` VALUES ('67','4','PM09','Perubahan Modal atau Laba/Rugi Periode Ini','modal awal - prive - deviden -/+ laba/rugi','','','','','','','1','1','0','1','2','0','5','0','0','0','67','1687245042');
INSERT INTO `account` VALUES ('68','19','69999','Total Beban','','','','','','','','1','1','0','3','3','2','0','0','0','0','68','1746515251');
INSERT INTO `account` VALUES ('69','15','31200','Prive/Tarik Modal','','','','c31200','','','','1','1','0','3','2','1','0','0','0','31','69','1746514545');
INSERT INTO `account` VALUES ('70','15','31999','Total Modal','','','','','','','','1','1','0','3','3','2','0','0','0','0','70','1746514569');
INSERT INTO `account` VALUES ('71','79','71000','Pendapatan Bunga','','','','','','','','1','1','0','3','2','1','0','0','0','71','71','1746515699');
INSERT INTO `account` VALUES ('72','121','81100','Beban Bunga','','','','','','-','','1','1','0','3','2','1','0','0','0','81','72','1746515718');
INSERT INTO `account` VALUES ('73','13','12302','Akumulasi Penyusutan Kendaraan','','','','','','','','1','1','0','3','2','1','0','0','0','12','73','1746513396');
INSERT INTO `account` VALUES ('74','43','62104','Asuransi','','','','c62104','','-','','1','1','0','4','2','1','0','0','0','62','74','1746522632');
INSERT INTO `account` VALUES ('75','2','L612','Laba Kotor','a-b','','','c5300','','','','1','1','0','1','4','2','10','0','0','0','75','1746540059');
INSERT INTO `account` VALUES ('76','121','81200','Biaya Bank','','','','','','-','','1','1','0','3','2','1','0','0','0','81','76','1746515741');
INSERT INTO `account` VALUES ('77','13','12202','Aumulasi Penyusutan Bangunan','','','','c12202','','','','1','1','0','3','2','1','0','0','0','12','77','1746513271');
INSERT INTO `account` VALUES ('78','18','51100','Harga Pokok Penjualan','','','','','','','','1','1','0','3','2','1','0','0','0','51','78','1746590212');
INSERT INTO `account` VALUES ('79','1','70000','Pendapatan Lain-lain','','','','','','','','1','0','0','1','0','2','0','0','0','0','79','1746514042');
INSERT INTO `account` VALUES ('80','6','21300','Utang Bank Jangka Panjang','','','','','','','','1','1','0','3','2','1','0','0','0','21','80','1747195478');
INSERT INTO `account` VALUES ('81','13','12402','Akumulasi Penyusutan Peralatan','','','','','','','','1','1','0','3','2','1','0','0','0','12','81','1746522066');
INSERT INTO `account` VALUES ('82','3','D','Arus kas bersih dan saldo akhir periode','jumlah/saldo dari A+B+C','','','','','','','1','1','0','1','2','0','0','0','0','0','82','1687244980');
INSERT INTO `account` VALUES ('83','18','51200','Biaya Pembelian','','','','','','','','1','1','0','3','2','1','0','0','0','51','83','1746526561');
INSERT INTO `account` VALUES ('84','15','31300','Deviden','','','','','','','','1','1','0','3','2','1','0','0','0','31','84','1746531856');
INSERT INTO `account` VALUES ('85','47','C5','Pembayaran kas untuk Deviden','','','','','','','','1','1','0','2','1','0','0','0','0','0','85','1687446730');
INSERT INTO `account` VALUES ('86','1','90000','Total Pasiva','','','','','','','','1','1','0','2','4','2','0','0','0','0','86','1746536810');
INSERT INTO `account` VALUES ('87','6','21400','Utang Pajak','','','','','','','','1','1','0','3','2','1','0','0','0','21','87','1747195514');
INSERT INTO `account` VALUES ('88','46','B2','Kas diterima dari bunga/bagi hasil bank','','','','','','','','1','0','0','0','0','2','0','0','0','0','88','1687447899');
INSERT INTO `account` VALUES ('89','43','62105','Biaya Pajak/Retribusi','','','','','','','','1','1','0','4','2','1','0','0','0','62','89','1747195545');
INSERT INTO `account` VALUES ('96','42','61101','Upah/Gaji','','','','c61101','','-','','1','1','0','4','1','1','0','0','34','61','90','1746518768');
INSERT INTO `account` VALUES ('97','42','61104','Sewa Gedung','','','','c61104','','-','','1','1','0','4','1','1','0','0','34','61','91','1746515341');
INSERT INTO `account` VALUES ('98','42','61105','Penyusutan Kendaraan','','','','c61105','','-','','1','1','0','4','1','1','0','0','34','61','92','1746515369');
INSERT INTO `account` VALUES ('99','42','61103','Marketing','','','','','','-','','1','1','0','4','1','1','0','0','0','61','93','1746515094');
INSERT INTO `account` VALUES ('100','42','61106','Penyusutan Peralatan','','','','c61106','','-','','1','1','0','4','1','1','0','0','34','61','94','1746515402');
INSERT INTO `account` VALUES ('101','42','61199','Total Beban Penjualan','','','','','','','','1','1','0','4','2','2','0','0','0','0','95','1746515445');
INSERT INTO `account` VALUES ('102','43','62101','Upah/Gaji Staf Kantor ','','','','c62101','','-','','1','1','0','4','1','1','0','0','34','62','96','1746515496');
INSERT INTO `account` VALUES ('103','43','62102','Listrik, Air, telp/data','','','','c62102','','-','','1','1','0','4','1','1','0','0','34','62','97','1746515529');
INSERT INTO `account` VALUES ('104','43','62103','Perlengkapan','','','','c62103','','-','','1','1','0','4','1','1','0','0','34','62','98','1746515557');
INSERT INTO `account` VALUES ('106','18','51300','Potongan Pembelian','','','','','','','','1','2','0','3','2','1','0','0','0','51','99','1746622519');
INSERT INTO `account` VALUES ('112','2','L650','Pajak Penghasilan','','','','c5600','','','','1','1','0','1','4','2','0','0','0','0','100','1746540134');
INSERT INTO `account` VALUES ('113','2','L660','Laba/Rugi Bersih Setalah Pajak','','','','c5700','','','','1','1','0','1','4','2','0','0','0','0','101','1746540151');
INSERT INTO `account` VALUES ('121','1','80000','Beban Lain-lain','','','','','','','','1','0','0','2','0','2','0','0','0','0','102','1746514097');
INSERT INTO `account` VALUES ('122','2','L610','Beban Penjualan','','','','','','','','1','1','0','1','4','2','0','0','0','0','103','1746540035');


DROP TABLE IF EXISTS `account_equation`;
CREATE TABLE `account_equation` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `action_at` int(11) NOT NULL DEFAULT 0,
  `transaction_id` int(11) NOT NULL,
  `action_id` int(11) NOT NULL,
  `year` int(11) NOT NULL DEFAULT 0,
  `month` int(11) NOT NULL DEFAULT 0,
  `week` int(11) NOT NULL DEFAULT 0,
  `amount` bigint(20) NOT NULL DEFAULT 0,
  `c11101` bigint(20) NOT NULL DEFAULT 0,
  `c11201` bigint(20) NOT NULL DEFAULT 0,
  `c11202` bigint(20) NOT NULL DEFAULT 0,
  `c11203` bigint(20) NOT NULL DEFAULT 0,
  `c11204` bigint(20) NOT NULL DEFAULT 0,
  `c11205` bigint(20) NOT NULL DEFAULT 0,
  `c12101` bigint(20) NOT NULL DEFAULT 0,
  `c12201` bigint(20) NOT NULL DEFAULT 0,
  `c12202` bigint(20) NOT NULL DEFAULT 0,
  `c12301` bigint(20) NOT NULL DEFAULT 0,
  `c12302` bigint(20) NOT NULL DEFAULT 0,
  `c12401` bigint(20) NOT NULL DEFAULT 0,
  `c12402` bigint(20) NOT NULL DEFAULT 0,
  `c21100` bigint(20) NOT NULL DEFAULT 0,
  `c21200` bigint(20) NOT NULL DEFAULT 0,
  `c21300` bigint(20) NOT NULL DEFAULT 0,
  `c21400` bigint(20) NOT NULL DEFAULT 0,
  `c31100` bigint(20) NOT NULL DEFAULT 0,
  `c31200` bigint(20) NOT NULL DEFAULT 0,
  `c31300` bigint(20) NOT NULL DEFAULT 0,
  `c41100` bigint(20) NOT NULL DEFAULT 0,
  `c41200` bigint(20) NOT NULL DEFAULT 0,
  `c41300` bigint(20) NOT NULL DEFAULT 0,
  `c51100` bigint(20) NOT NULL DEFAULT 0,
  `c51200` bigint(20) NOT NULL DEFAULT 0,
  `c51300` bigint(20) NOT NULL DEFAULT 0,
  `c61101` bigint(20) NOT NULL DEFAULT 0,
  `c61102` bigint(20) NOT NULL DEFAULT 0,
  `c61103` bigint(20) NOT NULL DEFAULT 0,
  `c61104` bigint(20) NOT NULL DEFAULT 0,
  `c61105` bigint(20) NOT NULL DEFAULT 0,
  `c61106` bigint(20) NOT NULL DEFAULT 0,
  `c62101` bigint(20) NOT NULL DEFAULT 0,
  `c62102` bigint(20) NOT NULL DEFAULT 0,
  `c62103` bigint(20) NOT NULL DEFAULT 0,
  `c62104` bigint(20) NOT NULL DEFAULT 0,
  `c62105` bigint(20) NOT NULL DEFAULT 0,
  `c62106` bigint(20) NOT NULL DEFAULT 0,
  `c62107` bigint(20) NOT NULL DEFAULT 0,
  `c71000` bigint(20) NOT NULL DEFAULT 0,
  `c81100` bigint(20) NOT NULL DEFAULT 0,
  `c81200` bigint(20) NOT NULL DEFAULT 0,
  `id2` int(11) NOT NULL DEFAULT 0,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `view` tinyint(4) NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`),
  UNIQUE KEY `transaction_id` (`transaction_id`),
  KEY `id_action_at_cash` (`id`,`action_at`),
  KEY `action_id` (`action_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `action`;
CREATE TABLE `action` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `action_at` int(11) NOT NULL DEFAULT 0,
  `bank` int(11) NOT NULL DEFAULT 0,
  `amount` bigint(20) NOT NULL DEFAULT 0,
  `descr` text DEFAULT NULL,
  `invoice` varchar(75) DEFAULT NULL,
  `pay_to` varchar(50) DEFAULT NULL,
  `pay_from` varchar(50) DEFAULT NULL,
  `debit` varchar(10) DEFAULT NULL,
  `credit` varchar(10) DEFAULT NULL,
  `year` varchar(5) DEFAULT NULL,
  `month` varchar(7) DEFAULT NULL,
  `tgl` date DEFAULT NULL,
  `url_pdf` varchar(150) DEFAULT NULL,
  `img` varchar(150) NOT NULL DEFAULT 'no_img.jpeg',
  `update_at` int(11) NOT NULL DEFAULT 0,
  `reff_trx_id` int(11) NOT NULL DEFAULT 0,
  `reff_sales_id` int(11) NOT NULL DEFAULT 0,
  `seq` int(11) NOT NULL DEFAULT 0,
  `id2` int(11) NOT NULL DEFAULT 0,
  `cat` tinyint(4) NOT NULL DEFAULT 0,
  `inout` tinyint(4) NOT NULL DEFAULT 0,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `st_trx` tinyint(4) NOT NULL DEFAULT 0,
  `cr` tinyint(4) NOT NULL DEFAULT 0,
  `view` tinyint(4) NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`),
  KEY `id_tgl_nilai_akun_tunai` (`id`,`action_at`),
  KEY `bank_amount_debit_credit` (`bank`,`amount`,`debit`,`credit`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `bank`;
CREATE TABLE `bank` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cif` int(11) NOT NULL DEFAULT 0,
  `balance` bigint(20) NOT NULL DEFAULT 0,
  `min_saldo` bigint(20) NOT NULL DEFAULT 0,
  `account_name` varchar(50) DEFAULT NULL,
  `bank_name` varchar(50) DEFAULT NULL,
  `swift_code` varchar(12) DEFAULT NULL,
  `account_number` varchar(100) DEFAULT NULL,
  `currency` varchar(4) DEFAULT NULL,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `del` tinyint(4) NOT NULL DEFAULT 0,
  `sel` tinyint(4) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `account_number` (`account_number`),
  KEY `id_cif_account_number` (`id`,`cif`,`account_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `company`;
CREATE TABLE `company` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(99) DEFAULT NULL,
  `initial` varchar(9) DEFAULT NULL,
  `nib` varchar(25) DEFAULT NULL,
  `npwp` varchar(25) DEFAULT NULL,
  `city` varchar(25) DEFAULT NULL,
  `address` varchar(100) DEFAULT NULL,
  `img` varchar(200) NOT NULL DEFAULT 'no_img.jpeg',
  `postcode` varchar(5) DEFAULT NULL,
  `relation` tinyint(4) NOT NULL DEFAULT 9,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `del` tinyint(4) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `create_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`),
  KEY `id_cif_account_number` (`id`,`address`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `company_relation`;
CREATE TABLE `company_relation` (
  `company_id` int(11) NOT NULL DEFAULT 0,
  `relation` tinyint(4) NOT NULL DEFAULT 0,
  UNIQUE KEY `person_id_relation` (`company_id`,`relation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



DROP TABLE IF EXISTS `cp_filephp_2`;
CREATE TABLE `cp_filephp_2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `modul` varchar(20) DEFAULT NULL,
  `slug` varchar(99) DEFAULT NULL,
  `name` varchar(99) DEFAULT NULL,
  `param` text DEFAULT NULL,
  `method` varchar(99) NOT NULL DEFAULT 'POST',
  `folder` varchar(40) DEFAULT NULL,
  `php` text DEFAULT NULL,
  `body` text DEFAULT NULL,
  `remark` varchar(150) DEFAULT NULL,
  `st` tinyint(4) NOT NULL,
  `type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '1=api,2=non api',
  `del` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1=delete',
  `update_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `folder_slug` (`folder`,`slug`),
  KEY `id_folder_slug` (`id`,`folder`,`slug`),
  KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=172 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

INSERT INTO `cp_filephp_2` VALUES ('1','post','index','item','','GET','a1/','','','','0','1','0','1746796618');
INSERT INTO `cp_filephp_2` VALUES ('10','','header','','','GET','a1/','','','','0','1','0','1746796603');
INSERT INTO `cp_filephp_2` VALUES ('11','','footer','','','GET','a1/','','','','0','1','0','1746796610');
INSERT INTO `cp_filephp_2` VALUES ('12','','inc/inc.filephp','','','GET','a1/','','','','0','1','0','1747094450');
INSERT INTO `cp_filephp_2` VALUES ('19','','app.function','','','GET','a1/','','','','0','1','0','1746796578');
INSERT INTO `cp_filephp_2` VALUES ('23','','inc.ar','','','GET','a1/','','','','0','1','0','1746796505');
INSERT INTO `cp_filephp_2` VALUES ('44','','tes_curl','','','GET','a1/','','','','0','1','0','1746836609');
INSERT INTO `cp_filephp_2` VALUES ('45','','inc.ar.app','','','GET','a1/','','','','0','1','0','1746836928');
INSERT INTO `cp_filephp_2` VALUES ('54','','htmlbeauty','','','GET','a1/','','','','0','1','0','1746877835');
INSERT INTO `cp_filephp_2` VALUES ('60','','ucol','','','GET','a1/api/enuvy/php/','','','','0','1','0','1747763682');
INSERT INTO `cp_filephp_2` VALUES ('78','','inc/inc.fcode','','','GET','a1/','','','','0','1','0','1747183260');
INSERT INTO `cp_filephp_2` VALUES ('79','','htmbeauty','','','GET','a1/','','','','0','1','0','1747266187');
INSERT INTO `cp_filephp_2` VALUES ('86','','inc/inc.t6_js','','','GET','a1/','','','','0','1','0','1747531111');
INSERT INTO `cp_filephp_2` VALUES ('90','','inc/inc.t6_h_page','','','GET','a1/','','','','0','1','0','1747531246');
INSERT INTO `cp_filephp_2` VALUES ('91','','inc/inc.t6_h_tab','','','GET','a1/','','','','0','1','0','1747531360');
INSERT INTO `cp_filephp_2` VALUES ('92','','signup','','','POST','a1/api/enuvy/php/','','','','0','1','0','1747802117');
INSERT INTO `cp_filephp_2` VALUES ('93','','user_update','','','GET','a1/api/enuvy/php/','','','','0','1','0','1747779726');
INSERT INTO `cp_filephp_2` VALUES ('94','','user_events','','','GET','a1/api/enuvy/php/','','','','0','1','0','1747779738');
INSERT INTO `cp_filephp_2` VALUES ('95','','users','','','GET','a1/api/enuvy/php/','','','','0','1','0','1747779765');
INSERT INTO `cp_filephp_2` VALUES ('96','','venue_create','','','GET','a1/api/enuvy/php/','','','','0','1','0','1747779783');
INSERT INTO `cp_filephp_2` VALUES ('97','','venue_all','venue_all','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799431');
INSERT INTO `cp_filephp_2` VALUES ('98','','venue_byid','venue_byid','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799441');
INSERT INTO `cp_filephp_2` VALUES ('99','','venue_update','venue_update','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799500');
INSERT INTO `cp_filephp_2` VALUES ('100','','venue_delete','venue_delete','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799452');
INSERT INTO `cp_filephp_2` VALUES ('101','','venue_imgs','venue_imgs','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799461');
INSERT INTO `cp_filephp_2` VALUES ('102','','venue_img_add','venue_img_add','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799482');
INSERT INTO `cp_filephp_2` VALUES ('103','','venue_img','venue_img','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799491');
INSERT INTO `cp_filephp_2` VALUES ('104','','event_add','event_create','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799526');
INSERT INTO `cp_filephp_2` VALUES ('105','','events','events','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799536');
INSERT INTO `cp_filephp_2` VALUES ('106','','event_byid','event_byid','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799471');
INSERT INTO `cp_filephp_2` VALUES ('107','','event_delete','event_delete','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799547');
INSERT INTO `cp_filephp_2` VALUES ('108','','notification_add','notification_create','','POST','a1/api/enuvy/php/','','','','0','1','0','1747799513');
INSERT INTO `cp_filephp_2` VALUES ('109','','inc/inc.account','','','GET','a1/','','','','0','1','0','1747796344');
INSERT INTO `cp_filephp_2` VALUES ('110','','inc/inc.action','','','GET','a1/','','','','0','1','0','1747796363');
INSERT INTO `cp_filephp_2` VALUES ('111','','inc/inc.company','','','GET','a1/','','','','0','1','0','1747796386');
INSERT INTO `cp_filephp_2` VALUES ('112','','inc/inc.inventory','','','GET','a1/','','','','0','1','0','1747796403');
INSERT INTO `cp_filephp_2` VALUES ('113','','inc/inc.person','','','GET','a1/','','','','0','1','0','1747796412');
INSERT INTO `cp_filephp_2` VALUES ('114','','inc/inc.product','','','GET','a1/','','','','0','1','0','1747796421');
INSERT INTO `cp_filephp_2` VALUES ('115','','inc/inc.sales','','','GET','a1/','','','','0','1','0','1747796432');
INSERT INTO `cp_filephp_2` VALUES ('116','','inc/inc.transaction','','','GET','a1/','','','','0','1','0','1747796443');
INSERT INTO `cp_filephp_2` VALUES ('117','','inc/inc.en_user','','','GET','a1/','','','','0','1','0','1747796497');
INSERT INTO `cp_filephp_2` VALUES ('118','','inc/inc.en_event','','','GET','a1/','','','','0','1','0','1747796518');
INSERT INTO `cp_filephp_2` VALUES ('119','','inc/inc.en_venue','','','GET','a1/','','','','0','1','0','1747796526');
INSERT INTO `cp_filephp_2` VALUES ('120','','login','','','POST','a1/api/enuvy/php/','','','','0','1','0','1747830191');
INSERT INTO `cp_filephp_2` VALUES ('121','','product','','','GET','a1/api/v1/php/','','','','0','1','0','1747971398');
INSERT INTO `cp_filephp_2` VALUES ('122','','inventory','','','GET','a1/api/v1/php/','','','','0','1','0','1747972337');
INSERT INTO `cp_filephp_2` VALUES ('123','','account_edit','','','GET','a1/api/v1/php/','','','','0','1','0','1747988901');
INSERT INTO `cp_filephp_2` VALUES ('124','','account_delete','','','GET','a1/api/v1/php/','','','','0','1','0','1747993070');
INSERT INTO `cp_filephp_2` VALUES ('125','','inc/inc.users','','','GET','a1/','','','','0','1','0','1748040634');
INSERT INTO `cp_filephp_2` VALUES ('126','','login','','','POST','a1/api/v1/php/','','email=navismur@gmail.com&password=jakarta2000','','0','1','0','1748571173');
INSERT INTO `cp_filephp_2` VALUES ('127','','image_upload','','','POST','a1/api/v1/php/','','','','0','1','0','1748681931');
INSERT INTO `cp_filephp_2` VALUES ('128','','upload_image_v1','','','POST','a1/api/v1/php/','','','','0','1','0','1748082486');
INSERT INTO `cp_filephp_2` VALUES ('129','','company','','','GET','a1/api/v1/php/','','','','0','1','0','1748087959');
INSERT INTO `cp_filephp_2` VALUES ('130','','company_edit','','','POST','a1/api/v1/php/','','','','0','1','0','1748089472');
INSERT INTO `cp_filephp_2` VALUES ('131','','company_add','','','POST','a1/api/v1/php/','','','','0','1','0','1748091872');
INSERT INTO `cp_filephp_2` VALUES ('132','','inventory_edit','','','POST','a1/api/v1/php/','','','','0','1','0','1748092407');
INSERT INTO `cp_filephp_2` VALUES ('133','','inventory_add','','','POST','a1/api/v1/php/','','','','0','1','0','1748092507');
INSERT INTO `cp_filephp_2` VALUES ('134','','person','','','GET','a1/api/v1/php/','','','','0','1','0','1748096217');
INSERT INTO `cp_filephp_2` VALUES ('135','','action','','','GET','a1/api/v1/php/','','','','0','1','0','1748130401');
INSERT INTO `cp_filephp_2` VALUES ('136','','transaction_add','','','POST','a1/api/v1/php/','','','','0','1','0','1748227579');
INSERT INTO `cp_filephp_2` VALUES ('137','','api.common.function','','','POST','a1/api/v1/','','email=navismur@gmail.com&password=jakarta2000','','0','1','0','1748392664');
INSERT INTO `cp_filephp_2` VALUES ('138','','inc/inc.journal','','','GET','a1/','','','','0','1','0','1748599572');
INSERT INTO `cp_filephp_2` VALUES ('139','','action_add','','action_at=2025-01-31&cat=2&bank=1&amount=1300000&invoice=j-01&descr=tes+kiri&pay_to=&pay_from=&inout=2','GET','a1/api/v1/php/','','','','0','1','0','1748422751');
INSERT INTO `cp_filephp_2` VALUES ('140','','inc/inc.cp_sphp','','','GET','a1/','','','','0','1','0','1748422989');
INSERT INTO `cp_filephp_2` VALUES ('141','','bank_delete','','','GET','a1/api/v1/php/','','','','0','1','0','1748473077');
INSERT INTO `cp_filephp_2` VALUES ('142','','bank','','','GET','a1/api/v1/php/','','','','0','1','0','1748474265');
INSERT INTO `cp_filephp_2` VALUES ('143','','company_delete','','','GET','a1/api/v1/php/','','','','0','1','0','1748475662');
INSERT INTO `cp_filephp_2` VALUES ('144','','person_add','','','POST','a1/api/v1/php/','','','','0','1','0','1748476129');
INSERT INTO `cp_filephp_2` VALUES ('145','','person_edit','','','POST','a1/api/v1/php/','','','','0','1','0','1748477068');
INSERT INTO `cp_filephp_2` VALUES ('146','','person_delete','','','GET','a1/api/v1/php/','','','','0','1','0','1748477539');
INSERT INTO `cp_filephp_2` VALUES ('147','','product_edit','','','GET','a1/api/v1/php/','','','','0','1','0','1748483839');
INSERT INTO `cp_filephp_2` VALUES ('148','','product_add','','','GET','a1/api/v1/php/','','','','0','1','0','1748483855');
INSERT INTO `cp_filephp_2` VALUES ('150','','product_buy','','','GET','a1/api/v1/php/','','','','0','1','0','1748496946');
INSERT INTO `cp_filephp_2` VALUES ('151','','product_retur','','','POST','a1/api/v1/php/','','','','0','1','0','1748604094');
INSERT INTO `cp_filephp_2` VALUES ('152','','action_cost_add','','','POST','a1/api/v1/php/','','email=navismur@gmail.com&password=jakarta2000','','0','1','0','1748574391');
INSERT INTO `cp_filephp_2` VALUES ('153','','product_sell','','','GET','a1/api/v1/php/','','','','0','1','0','1748579455');
INSERT INTO `cp_filephp_2` VALUES ('154','','sales','','','GET','a1/api/v1/php/','','','','0','1','0','1748595203');
INSERT INTO `cp_filephp_2` VALUES ('155','','fcode','','','GET','a1/api/v1/php/','','','','0','1','0','1748651241');
INSERT INTO `cp_filephp_2` VALUES ('156','','tes_equ_count','','','POST','a1/api/v1/php/','','','','0','1','0','1748780644');
INSERT INTO `cp_filephp_2` VALUES ('157','','journal','','','GET','a1/api/v1/php/','','','','0','1','0','1748666517');
INSERT INTO `cp_filephp_2` VALUES ('158','','action_edit','','action_at=2025-01-31&cat=2&bank=1&amount=1300000&invoice=j-01&descr=tes+kiri&pay_to=&pay_from=&inout=2&id=79','GET','a1/api/v1/php/','','','','0','1','0','1748677549');
INSERT INTO `cp_filephp_2` VALUES ('159','','inc/inc.bank','','','GET','a1/','','','','0','1','0','1748679340');
INSERT INTO `cp_filephp_2` VALUES ('160','','inc/inc.files','','','GET','a1/','','','','0','1','0','1748679354');
INSERT INTO `cp_filephp_2` VALUES ('161','','image_delete','','','POST','a1/api/v1/php/','','','','0','1','0','1748683140');
INSERT INTO `cp_filephp_2` VALUES ('162','','images','','','POST','a1/api/v1/php/','','','','0','1','0','1748683880');
INSERT INTO `cp_filephp_2` VALUES ('163','','inc.common.function','','','GET','a1/','','','','0','1','0','1748687862');
INSERT INTO `cp_filephp_2` VALUES ('164','','start','','','GET','a1/api/v1/php/','','','','0','1','0','1748703036');
INSERT INTO `cp_filephp_2` VALUES ('165','','action_in_add','','','POST','a1/api/v1/php/','','email=navismur@gmail.com&password=jakarta2000','','0','1','0','1748705963');
INSERT INTO `cp_filephp_2` VALUES ('166','','action_delete','','','POST','a1/api/v1/php/','','','','0','1','0','1748739057');
INSERT INTO `cp_filephp_2` VALUES ('167','','inc/inc.trx_title','','','GET','a1/','','','','0','1','0','1748830507');
INSERT INTO `cp_filephp_2` VALUES ('168','','index','','','GET','a1/api/v1/','','','','0','1','0','1748840719');
INSERT INTO `cp_filephp_2` VALUES ('169','','signup','','','GET','a1/api/v1/php/','','','','0','1','0','1749003767');
INSERT INTO `cp_filephp_2` VALUES ('170','','inc/inc.setting','','','GET','a1/','','','','0','1','0','1749600934');
INSERT INTO `cp_filephp_2` VALUES ('171','','password_forgot','','','POST','a1/api/v1/php/','','','','0','1','0','1749958553');


DROP TABLE IF EXISTS `cp_sphp`;
CREATE TABLE `cp_sphp` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `modul` varchar(99) DEFAULT NULL,
  `name` varchar(99) DEFAULT NULL,
  `body` text DEFAULT NULL,
  `is` varchar(10) DEFAULT '0',
  `del` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1=delete',
  `level` tinyint(4) NOT NULL DEFAULT 0,
  `parent` int(11) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `folder_name` (`modul`(20),`name`),
  KEY `id_folder_slug` (`id`,`modul`(20)),
  KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

INSERT INTO `cp_sphp` VALUES ('1','api','api','','php','0','1','0','1748424030');
INSERT INTO `cp_sphp` VALUES ('2','app','app','','php','0','1','0','0');
INSERT INTO `cp_sphp` VALUES ('3','common','common','','php','0','1','0','1748689002');
INSERT INTO `cp_sphp` VALUES ('4','api','transaction_byid','function transaction_byid() {\n  global $ar,$db;\n  $dt=array();\n  $sql="SELECT * from `transaction` where id>0 order by id";\n  $res2=mysqli_query($db,$sql);\n  while($r2=mysqli_fetch_assoc($res2)) {\n    $d=$r2[\'id\'];\n    $dt[$d]=$r2;    \n    if($r2[\'inout\']==2) {\n      $rp="-".ang2($r2[\'amount\']);\n      $col="red";\n    } else {\n      $rp=ang2($r2[\'amount\']);\n      $col="green"; \n    }\n    $dt[$d][\'rp\']=$rp;    \n    $dt[$d][\'col\']=$col;    \n    $dt[$d][\'act_datetime\']=date("Y-m-d H:i:s",$r2[\'action_at\']);\n    $dt[$d][\'act_date\']=date("Y-m-d",$r2[\'action_at\']);\n    $dt[$d][\'act_month\']=date("Y-m",$r2[\'action_at\']);\n    $dt[$d][\'update\']=date("Y-m-d H:i:s",$r2[\'update_at\']);\n  }\n  return $dt;    \n}','php','0','2','1','1748424212');
INSERT INTO `cp_sphp` VALUES ('5','api','transaction_byseq','function transaction_byseq() {\n  global $ar,$db;\n  $dt=array();\n  $sql="SELECT * from `transaction` where id>0 order by id desc";\n  $res2=mysqli_query($db,$sql);\n  $d=0;\n  while($r2=mysqli_fetch_assoc($res2)) {\n    //$d=$r2[\'id\'];\n    $dt[$d]=$r2;    \n    if($r2[\'inout\']==2) {\n      $rp="-".ang2($r2[\'amount\']);\n      $col="red";\n    } else {\n      $rp=ang2($r2[\'amount\']);\n      $col="green"; \n    }\n    $dt[$d][\'rp\']=$rp;    \n    $dt[$d][\'col\']=$col;    \n    $dt[$d][\'image\']=$ar[\'imgurl\']."".$r2[\'img\'];  \n    $dt[$d][\'act_datetime\']=date("Y-m-d H:i:s",$r2[\'action_at\']);\n    $dt[$d][\'act_date\']=date("Y-m-d",$r2[\'action_at\']);\n    $dt[$d][\'act_month\']=date("Y-m",$r2[\'action_at\']);\n    $dt[$d][\'update\']=date("Y-m-d H:i:s",$r2[\'update_at\']);\n    $d++;\n  }\n  return $dt;    \n}','php','0','2','1','1748424234');
INSERT INTO `cp_sphp` VALUES ('6','api','journal_add','function journal_add($transaction_id) {\n  global $ar,$db;\n  $dt=array();\n  $sql = "select * from transaction where id=".$transaction_id;\n  $res = mysqli_query($db, $sql);\n  //echo $sql;\n  $r1 = mysqli_fetch_assoc($res);    \n\n    $sql3 = "select id,id2,id-id2 as k from journal where id-id2>0 order by id2 limit 1";\n    $res3 = mysqli_query($db, $sql3);\n    if(mysqli_num_rows($res3)>0) {\n      $rw3 = mysqli_fetch_assoc($res3);\n      $id2=$rw3[\'id2\'];\n    } else {\n      $sql4 = "select * from journal order by id desc limit 1";\n      $res4 = mysqli_query($db, $sql4);\n      $rw4 = mysqli_fetch_assoc($res4);\n      if(isset($rw4[\'id\']) && $rw4[\'id\']>0) {\n        $id2=$rw4[\'id\']+1;\n      } else {\n        $id2=1;\n      }\n    }\n\n    $idt1=array(\n      \'id\'=>$id2,\n      \'transaction_id\'=>$r1[\'id\'],\n      \'action_at\'=>$r1[\'action_at\'],\n      \'amount\'=>to_numeric($r1[\'amount\']),\n      \'debit\'=>to_numeric($r1[\'amount\']),\n      \'inout\'=>1,\n      \'account_code\'=>$r1[\'debit\'],\n      \'action_id\'=>$r1[\'action_id\'],\n      \'seq\'=>$r1[\'seq\'],\n      \'year\'=>date("Y",$r1[\'action_at\']),\n      \'week\'=>date("W",$r1[\'action_at\']),\n      \'month\'=>date("Ym",$r1[\'action_at\']),\n    ); \n    $udt1=array(\n      \'transaction_id\'=>$r1[\'id\'],\n      \'action_at\'=>$r1[\'action_at\'],\n      \'amount\'=>to_numeric($r1[\'amount\']),\n      \'debit\'=>to_numeric($r1[\'amount\']),\n      \'inout\'=>1,\n      \'account_code\'=>$r1[\'debit\'],\n      \'action_id\'=>$r1[\'action_id\'],\n      \'seq\'=>$r1[\'seq\'],\n      \'year\'=>date("Y",$r1[\'action_at\']),\n      \'week\'=>date("W",$r1[\'action_at\']),\n      \'month\'=>date("Ym",$r1[\'action_at\']),\n      \'update_at\'=>time(),\n    );\n    InsertUpdate($db,"journal",$idt1,$udt1,0); \n    tool_id2("journal"); \n\n    $sql3 = "select id,id2,id-id2 as k from journal where id-id2>0 order by id2 limit 1";\n    $res3 = mysqli_query($db, $sql3);\n    if(mysqli_num_rows($res3)>0) {\n      $rw3 = mysqli_fetch_assoc($res3);\n      $id2=$rw3[\'id2\'];\n    } else {\n      $sql4 = "select * from journal order by id desc limit 1";\n      $res4 = mysqli_query($db, $sql4);\n      $rw4 = mysqli_fetch_assoc($res4);\n      if(isset($rw4[\'id\']) && $rw4[\'id\']>0) {\n        $id2=$rw4[\'id\']+1;\n      } else {\n        $id2=1;\n      }\n    }\n\n    $idt2=array(\n      \'id\'=>$id2,\n      \'action_at\'=>$r1[\'action_at\'],\n      \'seq\'=>$r1[\'seq\'],\n      \'transaction_id\'=>$r1[\'id\'],\n      \'action_id\'=>$r1[\'action_id\'],\n      \'amount\'=>to_numeric($r1[\'amount\']),\n      \'credit\'=>to_numeric($r1[\'amount\']),\n      \'inout\'=>2,\n      \'account_code\'=>$r1[\'credit\'],\n      \'year\'=>date("Y",$r1[\'action_at\']),\n      \'week\'=>date("W",$r1[\'action_at\']),\n      \'month\'=>date("Ym",$r1[\'action_at\']),\n    ); \n    $udt2=array(\n      \'transaction_id\'=>$r1[\'id\'],\n      \'action_id\'=>$r1[\'action_id\'],\n      \'action_at\'=>$r1[\'action_at\'],\n      \'seq\'=>$r1[\'seq\'],\n      \'amount\'=>to_numeric($r1[\'amount\']),\n      \'credit\'=>to_numeric($r1[\'amount\']),\n      \'inout\'=>2,\n      \'account_code\'=>$r1[\'credit\'],\n      \'year\'=>date("Y",$r1[\'action_at\']),\n      \'week\'=>date("W",$r1[\'action_at\']),\n      \'month\'=>date("Ym",$r1[\'action_at\']),\n      \'update_at\'=>time(),\n    );\n    InsertUpdate($db,"journal",$idt2,$udt2,0); \n    tool_id2("journal");  \n    account_equation($r1); \n    $dt[\'message\']="journal & account_equation added";\n    //$dt[\'account_equation\']=account_equation($r1);    \n    //JournalCount(date("Y",$r1[\'action_at\']));\n    return $dt;\n}','php','0','2','1','1748424288');
INSERT INTO `cp_sphp` VALUES ('7','api','action_add_v2','function action_add_v2($js){\n  global $ar,$db;\n  $dt=array();\n\n  $sql3 = "select id,id2,id-id2 as k from `action` where id-id2>0 order by id2 limit 1";\n  $res3 = mysqli_query($db, $sql3);\n  if(mysqli_num_rows($res3)>0) {\n    $rw3 = mysqli_fetch_assoc($res3);\n    $id2=$rw3[\'id2\'];\n  } else {\n    $sql4 = "select * from `action` order by id desc limit 1";\n    $res4 = mysqli_query($db, $sql4);\n    $rw4 = mysqli_fetch_assoc($res4);\n    if(isset($rw4[\'id\']) && $rw4[\'id\']>0) {\n      $id2=$rw4[\'id\']+1;\n    } else {\n      $id2=1;\n    }\n  }\n\n  $idt=array(\n    \'id\'=>$id2,\n    \'action_at\'=>strtotime($js[\'action_at\']),\n    \'descr\'=>$js[\'descr\'],\n    \'cat\'=>$js[\'cat\'],\n    \'inout\'=>$js[\'inout\'],\n    \'bank\'=>$js[\'bank\'],\n    \'amount\'=>$js[\'amount\'],\n    \'year\'=>date("Y",strtotime($js[\'action_at\'])),\n    \'month\'=>date("Ym",strtotime($js[\'action_at\'])),\n    \'tgl\'=>date("Y-m-d",strtotime($js[\'action_at\'])),\n    \'update_at\'=>time(),\n  );\n  if(isset($js[\'pay_to\'])) {\n    $idt[\'pay_to\']=$js[\'pay_to\'];  \n  }\n  if(isset($js[\'pay_from\'])) {\n    $idt[\'pay_from\']=$js[\'pay_from\'];  \n  }\n  if(isset($js[\'invoice\'])) {\n    $idt[\'invoice\']=$js[\'invoice\'];  \n  }\n  if(isset($js[\'reff_sales_id\'])) {\n    $idt[\'reff_sales_id\']=$js[\'reff_sales_id\'];  \n  }\n  Insert($db,"action",$idt,0);  \n  tool_id2("action");\n  $dt[\'action_id\']=$id2;\n  $dt[\'success\']=true;\n  return $dt;\n}','php','0','2','1','1748589472');
INSERT INTO `cp_sphp` VALUES ('8','api','sales_action_v2','function sales_action_v2($js,$v=0) {\n  global $db,$ar;\n  $dt=array();\n/*  \n\ncat=4=jual tunai\n- id1\n- persediaan berkurang //credit: 11202\n- hpp debit //51100\n\n-id2\n- terima cash dr penjualan //debit 11101\n- penjualan bertambah //credit 41100\n\ncat=7=jual kredit\n- id1\n- persediaan berkurang //credit: 11202\n- hpp debit //51100\n\n-id2\n- piutang berambah dr penjualan //debit 11201\n- penjualan bertambah //credit 41100\n\nitem_inout=2 (berkurang)\n\ncat=1, retur dr agen, menambah persediaan, mengurangi piutang\ncat=2, retur ke supplier, mengurangi utang dan persediaan\npersediaan/11202 dan utang dagang 21100\n*/\n\n\n  $sql4 = "select id from `action` order by id desc limit 1";\n  $res4 = mysqli_query($db, $sql4);\n  $r4 = mysqli_fetch_assoc($res4);\n  $id1=$r4[\'id\']+1;\n  $id2=$r4[\'id\']+2;\n\n  //catat penjualan-hpp\n\n  $idt1=array(\n    \'id\'=>$id1,\n    \'action_at\'=>strtotime($js[\'action_at\']),\n    \'pay_from\'=>$js[\'pay_from\'],\n    \'invoice\'=>$js[\'invoice\'],\n    \'reff_sales_id\'=>$js[\'reff_sales_id\'],\n    \'inout\'=>1,\n    \'descr\'=>$js[\'descr\'],\n    \'bank\'=>0,\n    \'cat\'=>$js[\'cat\'],\n    \'amount\'=>$js[\'qty\']*$js[\'hpp\'],\n    \'year\'=>date("Y",strtotime($js[\'action_at\'])),\n    \'month\'=>date("Ym",strtotime($js[\'action_at\'])),\n    \'tgl\'=>date("Y-m-d",strtotime($js[\'action_at\'])),\n    \'update_at\'=>time(),\n  );\n  Insert($db,"action",$idt1,$v);\n  $js1=$js;\n  $js1[\'action_id\']=$id1;\n  $js1[\'debit\']=51100; //hpp\n  $js1[\'credit\']=11202; //persediaan\n  //$dt[\'trx\']=transaction_add_v2($js1);\n  transaction_add_v2($js1);\n\n  $rr[\'descr\'][4]   ="Terima cash dari ";\n  $rr[\'debit\'][4]   =11101;\n  $rr[\'credit\'][4]  =41100;\n  $rr[\'bank\'][4]    =1;\n\n  $rr[\'descr\'][7]   ="Piutang ".$js[\'due_days\']." hari dari ";\n  $rr[\'debit\'][7]   =11201;\n  $rr[\'credit\'][7]  =41100;\n  $rr[\'bank\'][7]    =0;\n\n\n\n  // catat cash-penjuala (jika 4), piutang-penjualan (jika 7)\n  $idt2=array(\n    \'id\'=>$id2,\n    \'action_at\'=>strtotime($js[\'action_at\']),\n    \'pay_from\'=>$js[\'pay_from\'],\n    \'invoice\'=>$js[\'invoice\'],\n    \'reff_sales_id\'=>$js[\'reff_sales_id\'],\n    \'inout\'=>1,\n    \'descr\'=>$rr[\'descr\'][$js[\'cat\']]." ".$js[\'descr\'],\n    \'bank\'=>$rr[\'bank\'][$js[\'cat\']],\n    \'cat\'=>$js[\'cat\'],\n    \'amount\'=>$js[\'qty\']*$js[\'price_per_unit\'],\n    \'year\'=>date("Y",strtotime($js[\'action_at\'])),\n    \'month\'=>date("Ym",strtotime($js[\'action_at\'])),\n    \'tgl\'=>date("Y-m-d",strtotime($js[\'action_at\'])),\n    \'update_at\'=>time(),\n  );\n  Insert($db,"action",$idt2,$v);\n  $js2=$js;\n  $js2[\'action_id\']=$id2;\n  $js2[\'debit\']=$rr[\'debit\'][$js[\'cat\']];\n  $js2[\'credit\']=$rr[\'credit\'][$js[\'cat\']];\n  //$dt[\'trx\']=transaction_add_v2($js2);\n  transaction_add_v2($js2);\n\n  //catat di product_trx\n  $js3[\'action_at\']=strtotime($js[\'action_at\']);\n  $js3[\'inout\']=2;\n  $js3[\'remark\']=$js[\'descr\'];\n  $js3[\'action_id\']=$id1;\n  product_trx($js3);\n  $dt[\'message\']="add transaction succes";\n\n  $udt_41=array(\n    \'action_id_1\'=>$id1,\n    \'action_id_2\'=>$id2,\n  );\n  Update($db,"sales",$udt_41,"id=".$js[\'reff_sales_id\'],$v);\n\n  return $dt;\n}','php','0','2','1','1748768668');
INSERT INTO `cp_sphp` VALUES ('9','api','bank','function bank(){\n  global $ar,$db;\n  $dt=array();\n  $sql2="SELECT * from `bank` where del=0";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_num_rows($res2);\n  $dt[\'count\']=$r2;\n  $dt[\'success\']=true;\n\n  $sql=$sql2." order by id desc";\n  //echo $sql.";<br>";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'data\'][$c]=$r1;    \n      $dt[\'data\'][$c][\'rp\']=ang2($r1[\'amount\']);    \n      $dt[\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n      $c++;\n    }\n  } else {\n    $dt[\'count\']=0;\n    $dt[\'error\']=true;\n    $dt[\'message\']="data action not found";\n  }\n  return $dt;\n  $db->close();\n}','php','0','2','1','1748499497');
INSERT INTO `cp_sphp` VALUES ('10','api','company','function company(){\n  global $ar,$db;\n  $dt=array();\n  $sql2="SELECT * from `company` where del=0";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_num_rows($res2);\n  $dt[\'count\']=$r2;\n  $dt[\'success\']=true;\n\n  $sql=$sql2." order by name";\n  //echo $sql.";<br>";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'data\'][$c]=$r1;    \n      $dt[\'data\'][$c][\'image\']=$ar[\'imgurl\']."".$r1[\'img\'];    \n      $dt[\'data\'][$c][\'as\']=$ar[\'relation\'][$r1[\'relation\']];    \n      $dt[\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n      $c++;\n    }\n  } else {\n    $dt[\'count\']=0;\n    $dt[\'error\']=true;\n    $dt[\'message\']="data action not found";\n  }\n  return $dt;\n  $db->close();\n}','php','0','2','1','1748475588');
INSERT INTO `cp_sphp` VALUES ('11','api','person','function person(){\n  global $ar,$db;\n  $dt=array();\n  $sql2="SELECT * from `person` where del=0";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_num_rows($res2);\n  $dt[\'count\']=$r2;\n  $dt[\'success\']=true;\n\n  $sql=$sql2." order by id";\n  //echo $sql.";<br>";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'data\'][$c]=$r1;    \n      $dt[\'data\'][$c][\'image\']=$ar[\'imgurl\']."".$r1[\'img\'];    \n      $dt[\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n      $c++;\n    }\n  } else {\n    $dt[\'count\']=0;\n  }  \n  return $dt;\n  $db->close();\n}','php','0','2','1','1748477025');
INSERT INTO `cp_sphp` VALUES ('12','api','product','function product(){\n  global $ar,$db;  \n  $dt=array();\n  $dt2=array();\n  //id,name,brand,qty,item_code,price_per_unit,update_at\n  $sql2="SELECT `brand` from `product` where `del`=0 group by `brand` order by `brand`";\n  $res2=mysqli_query($db,$sql2);\n  //$dt[\'count\']=$r2;\n  $count=0;\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r2=mysqli_fetch_assoc($res2)) {\n      $dt[\'data\'][\'by_brand\'][$c][\'brand\']=$r2[\'brand\'];\n      $sql3="SELECT id,name,qty,item_code,price_per_unit,img,update_at from `product` where del=0 and brand=\'".$r2[\'brand\']."\' order by `name`";\n      $res3=mysqli_query($db,$sql3);\n      $d=0;\n      while($r3=mysqli_fetch_assoc($res3)) {\n        $i_img_med=str_replace(\'small\',\'medium\',$r3[\'img\']);\n        $i_img_big=str_replace(\'small\',\'big\',$r3[\'img\']);\n        $dt[\'data\'][\'by_brand\'][$c][\'items\'][$d]=$r3;\n        $dt[\'data\'][\'by_brand\'][$c][\'items\'][$d][\'url_img\']=$ar[\'img_url\'].\'\'.$r3[\'img\'];\n        $dt[\'data\'][\'by_brand\'][$c][\'items\'][$d][\'url_img_medium\']=$ar[\'img_url\'].\'\'.$i_img_med;\n        $dt[\'data\'][\'by_brand\'][$c][\'items\'][$d][\'url_img_big\']=$ar[\'img_url\'].\'\'.$i_img_big;\n        $dt[\'data\'][\'by_brand\'][$c][\'items\'][$d][\'hpp\']=ang2($r3[\'price_per_unit\']);\n        $dt[\'data\'][\'by_brand\'][$c][\'items\'][$d][\'amount\']=ang2($r3[\'price_per_unit\']*$r3[\'qty\']);\n        $dt[\'data\'][\'by_brand\'][$c][\'items\'][$d][\'update\']=date("Y-m-d H:i:s",$r3[\'update_at\']);\n\n        $sql4="SELECT a.id,a.action_id,a.transaction_id,a.item_in,a.item_out,a.`balance`,a.invoice,a.tgl,a.`inout`,b.descr from `product_trx` a JOIN `action` b ON a.action_id=b.id where product_id=".$r3[\'id\']." order by a.action_at,a.action_id ";\n        $res4=mysqli_query($db,$sql4);\n        $e=0;\n        while($r4=mysqli_fetch_assoc($res4)) {\n          $dt[\'data\'][\'by_brand\'][$c][\'items\'][$d][\'trx\'][$e]=$r3;\n          $dt[\'data\'][\'by_brand\'][$c][\'items\'][$d][\'trx\'][$e][\'amount\']=ang2($r3[\'balance\']*$r1[\'price_per_unit\']);\n          $e++;\n        }        \n        $d++;\n        $count++;\n      }\n      $c++;\n    }\n\n    \n    $sql5="SELECT id,name,img,brand,qty,item_code,price_per_unit,update_at from `product` where del=0 order by id";\n    //echo $sql.";<br>";\n    $res5=mysqli_query($db,$sql5);\n    while($r5=mysqli_fetch_assoc($res5)) {\n      $c=$r5[\'id\'];\n\n      $i_img_med=str_replace(\'small\',\'medium\',$r5[\'img\']);\n      $i_img_big=str_replace(\'small\',\'big\',$r5[\'img\']);\n\n      $dt[\'data\'][\'by_id\'][$c]=$r5;\n      $dt[\'data\'][\'by_id\'][$c][\'url_img\']=$ar[\'img_url\'].\'\'.$r5[\'img\'];\n      $dt[\'data\'][\'by_id\'][$c][\'url_img_medium\']=$ar[\'img_url\'].\'\'.$i_img_med;\n      $dt[\'data\'][\'by_id\'][$c][\'url_img_big\']=$ar[\'img_url\'].\'\'.$i_img_big;\n      $dt[\'data\'][\'by_id\'][$c][\'hpp\']=ang2($r5[\'price_per_unit\']);\n      $dt[\'data\'][\'by_id\'][$c][\'amount\']=ang2($r5[\'price_per_unit\']*$r5[\'qty\']);\n      $dt[\'data\'][\'by_id\'][$c][\'update\']=date("Y-m-d H:i:s",$r5[\'update_at\']);\n      $sql6="SELECT a.id,a.action_id,a.transaction_id,a.item_in,a.item_out,a.`balance`,a.invoice,a.tgl,a.`inout`,b.descr from `product_trx` a JOIN `action` b ON a.action_id=b.id where product_id=".$r5[\'id\']." order by a.action_at,a.action_id ";\n      $res6=mysqli_query($db,$sql6);\n      $d=0;\n      while($r6=mysqli_fetch_assoc($res6)) {\n        $dt[\'data\'][\'by_id\'][$c][\'trx\'][$d]=$r6;\n        $dt[\'data\'][\'by_id\'][$c][\'trx\'][$d][\'amount\']=ang2($r6[\'balance\']*$r5[\'price_per_unit\']);\n        $d++;\n      }\n    }\n\n    $dt[\'count\']=$count;\n    $dt[\'success\']=true;\n  } else {\n    $dt[\'count\']=0;\n  }  \n  return $dt;\n  $db->close();\n}','php','0','2','1','1748481911');
INSERT INTO `cp_sphp` VALUES ('13','api','action_byid','function action_byid() {\n  global $ar,$db;\n  $dt=array();\n  $sql="SELECT * from `action` where id>0 order by id";\n  $res2=mysqli_query($db,$sql);\n  while($r2=mysqli_fetch_assoc($res2)) {\n    $d=$r2[\'id\'];\n    $dt[$d]=$r2;    \n    if($r2[\'inout\']==2) {\n      $rp="-".ang2($r2[\'amount\']);\n      $col="red";\n      $p3=$r2[\'pay_to\'];       \n    } else {\n      $rp=ang2($r2[\'amount\']);\n      $col="green"; \n      $p3=$r2[\'pay_from\'];       \n    }\n    $dt[$d][\'rp\']=$rp;    \n    $dt[$d][\'col\']=$col;    \n    $dt[$d][\'p3\']=$p3;    \n    $dt[$d][\'image\']=$ar[\'imgurl\']."".$r2[\'img\'];  \n    $dt[$d][\'act_datetime\']=date("Y-m-d H:i:s",$r2[\'action_at\']);\n    $dt[$d][\'act_date\']=date("Y-m-d",$r2[\'action_at\']);\n    $dt[$d][\'act_month\']=date("Y-m",$r2[\'action_at\']);\n    $dt[$d][\'update\']=date("Y-m-d H:i:s",$r2[\'update_at\']);\n  }\n  return $dt;    \n}','php','0','2','1','1748423982');
INSERT INTO `cp_sphp` VALUES ('14','app','tool_id2','function tool_id2($tbl) {\n  global $db,$ar;\n  $sql = "select * from ".$tbl." order by id";\n  $res = mysqli_query($db, $sql);\n  $id2=1;\n  while($rw = mysqli_fetch_assoc($res)) {\n    $udt=array(\n      \'id2\'=>$id2,\n    );    \n    Update($db,$tbl,$udt,"id=".$rw[\'id\'],0);\n    $id2++;\n  }  \n}','php','0','2','2','1748499552');
INSERT INTO `cp_sphp` VALUES ('15','app','tool_id3','function tool_id3($tbl) {\n  global $db,$ar;\n  \n  $sql4 = "select id from ".$tbl." where id2=id order by id desc limit 1";\n  $res4 = mysqli_query($db, $sql4);\n  $rw4 = mysqli_fetch_assoc($res4);\n  if(isset($rw4) && $rw4[\'id\']>0) {        \n    $sql = "select * from ".$tbl." where id>".$rw4[\'id\']." order by id";\n    $res = mysqli_query($db, $sql);\n    $id2=$rw4[\'id\']+1;\n    while($rw = mysqli_fetch_assoc($res)) {\n      $udt=array(\n          \'id2\'=>$id2,\n      );\n      Update($db,$tbl,$udt,"id=".$rw[\'id\'],0);\n      $id2++;\n    }  \n  }\n}','php','0','2','2','1748499593');
INSERT INTO `cp_sphp` VALUES ('16','app','product_trx_count','function product_trx_count() {\n  global $db,$ar;\n  \n  $sql4 = "select product_id from product_trx group by product_id";\n  $res4 = mysqli_query($db, $sql4);\n  while($rw4 = mysqli_fetch_assoc($res4)) {\n    $sql = "select * from product_trx where product_id=".$rw4[\'product_id\']." order by action_at";\n    $res = mysqli_query($db, $sql);\n    $j[\'balance\']=0;\n    while($r=mysqli_fetch_assoc($res)) {\n      $j[\'balance\']=$j[\'balance\']+$r[\'item_in\']-$r[\'item_out\'];\n      $udt=array(\n        \'balance\'=>$j[\'balance\'],\n      );\n      Update($db,"product_trx",$udt,"id=".$r[\'id\'],0);\n    }\n    $udt=array(\n      \'qty\'=>$j[\'balance\'],\n    );\n    Update($db,"product",$udt,"id=".$rw4[\'product_id\'],0);\n  }\n}','php','0','2','2','1748594290');
INSERT INTO `cp_sphp` VALUES ('17','app','product_trx','function product_trx($js) {\n  global $db,$ar;\n  //$dt=array();\n  //echo "<pre>"; print_r($js); echo "</pre>";\n  //beli=add inout=1; jual=minus; inout=2\n  $sql4 = "select id from product_trx order by id desc limit 1";\n  $res4 = mysqli_query($db, $sql4);\n  $rw4 = mysqli_fetch_assoc($res4);\n  if(isset($rw4) && $rw4[\'id\']>0) {        \n    $id2=$rw4[\'id\']+1;\n  } else {\n    $id2=1;\n  }\n  $idt=array(\n    \'id\'=>$id2,\n    \'action_at\'=>$js[\'action_at\'],\n    \'action_id\'=>$js[\'action_id\'],\n    \'product_id\'=>$js[\'product_id\'],\n    \'item_code\'=>$js[\'item_code\'],\n    \'inout\'=>$js[\'inout\'],\n    \'invoice\'=>$js[\'invoice\'],\n    \'remark\'=>$js[\'descr\'],\n    \'year\'=>date("Y",$js[\'action_at\']),\n    \'month\'=>date("Ym",$js[\'action_at\']),\n    \'tgl\'=>date("Y-m-d",$js[\'action_at\']),\n    \'update_at\'=>time(),\n  );\n  $udt=array(\n    \'action_at\'=>$js[\'action_at\'],\n    \'action_id\'=>$js[\'action_id\'],\n    \'product_id\'=>$js[\'product_id\'],\n    \'item_code\'=>$js[\'item_code\'],\n    \'inout\'=>$js[\'inout\'],\n    \'invoice\'=>$js[\'invoice\'],\n    \'remark\'=>$js[\'descr\'],\n    \'year\'=>date("Y",$js[\'action_at\']),\n    \'month\'=>date("Ym",$js[\'action_at\']),\n    \'tgl\'=>date("Y-m-d",$js[\'action_at\']),\n    \'update_at\'=>time(),\n  );\n  if($js[\'inout\']==1) {\n    $idt[\'item_in\']=$udt[\'item_in\']=$js[\'qty\'];\n  } else {\n    $idt[\'item_out\']=$udt[\'item_out\']=$js[\'qty\'];\n  }\n  InsertUpdate($db,"product_trx",$idt,$udt,0);\n}','php','0','2','2','1748504043');
INSERT INTO `cp_sphp` VALUES ('18','app','JournalCount','function JournalCount($year) {\n  global $db,$ar;\n  $sql6="update account set sel2=0";\n  $res6=mysqli_query($db,$sql6);\n  $sql3="SELECT * from action order by action_at,seq";\n  $res3=mysqli_query($db,$sql3);\n  while($r3=mysqli_fetch_assoc($res3)) {\n      $udt3=array(\n          \'seq\'=>$r3[\'seq\'],\n      );\n      Update($db,"journal",$udt3,"action_id=".$r3[\'id\'],0);\n      Update($db,"transaction",$udt3,"action_id=".$r3[\'id\'],0);\n  }\n  $sql="SELECT account_code from journal group by account_code";\n  $res=mysqli_query($db,$sql);\n  while($r1=mysqli_fetch_assoc($res)) {\n    $sql2="SELECT * from journal where year=".$year." and account_code=\'".$r1[\'account_code\']."\' order by action_at asc, seq asc";\n    //echo $sql2."<br>";\n    $res2=mysqli_query($db,$sql2);\n    $bal=0;\n    $seq2=1;\n    while($r2=mysqli_fetch_assoc($res2)) {\n      $bal=$bal+$r2[\'debit\']-$r2[\'credit\'];\n      $udt=array(\n        \'balance\'=>$bal,\n        \'seq2\'=>$seq2,\n        \'update_at\'=>time(),\n      );\n      Update($db,"journal",$udt,"id=".$r2[\'id\'],1);\n      $seq2++;\n    } \n    $udt4=array(\n      \'sel2\'=>1,\n    );\n    Update($db,"account",$udt4,"code=\'".$r1[\'account_code\']."\'",0);  \n  }  \n}','php','0','2','2','1748499670');
INSERT INTO `cp_sphp` VALUES ('19','app','JournalCount_v2','function JournalCount_v2($year) {\n  global $db,$ar;\n  $sql6="update fcode set sel2=0";\n  $res6=mysqli_query($db,$sql6);\n  $sql3="SELECT * from action order by action_at,seq";\n  $res3=mysqli_query($db,$sql3);\n  while($r3=mysqli_fetch_assoc($res3)) {\n      $udt3=array(\n          \'seq\'=>$r3[\'seq\'],\n      );\n      Update($db,"journal",$udt3,"action_id=".$r3[\'id\'],0);\n      Update($db,"transaction",$udt3,"action_id=".$r3[\'id\'],0);\n  }\n  $sql="SELECT account_code from journal group by account_code";\n  $res=mysqli_query($db,$sql);\n  while($r1=mysqli_fetch_assoc($res)) {\n    $sql2="SELECT * from journal where year=".$year." and account_code=\'".$r1[\'account_code\']."\' order by action_at asc, seq asc";\n    //echo $sql2."<br>";\n    $res2=mysqli_query($db,$sql2);\n    $bal=0;\n    $seq2=1;\n    while($r2=mysqli_fetch_assoc($res2)) {\n      $bal=$bal+$r2[\'debit\']-$r2[\'credit\'];\n      $udt=array(\n        \'balance\'=>$bal,\n        \'seq2\'=>$seq2,\n        \'update_at\'=>time(),\n      );\n      Update($db,"journal",$udt,"id=".$r2[\'id\'],0);\n      $seq2++;\n    } \n    $udt4=array(\n      \'sel2\'=>1,\n    );\n    Update($db,"fcode",$udt4,"code=\'c".$r1[\'account_code\']."\'",0);  \n  }  \n}','php','0','2','2','1748499696');
INSERT INTO `cp_sphp` VALUES ('20','app','ExportfMandiri2','function ExportfMandiri2($id) {\n  global $db,$ar;  \n  $sql4 = "select * from mandiri_mutasi where id=".$id;\n  $res4 = mysqli_query($db, $sql4);\n  $r4 = mysqli_fetch_assoc($res4);\n  //echo "<pre>"; print_r($r4); echo "</pre>";\n  \n  if($r4[\'debit\']==0) {\n      $amount=$r4[\'kredit\'];\n      $inout=2;\n      $payto="Mandiri IDR ".substr($r4[\'rek\'],-3);\n      $payfrom="";\n  } else {\n      $amount=$r4[\'debit\'];\n      $inout=1;\n      $payfrom="Mandiri IDR ".substr($r4[\'rek\'],-3);\n      $payto="";\n  }\n  \n  if($r4[\'payto\']!=\'\') {\n      $payto2=$r4[\'payto\'];\n  } else {\n      $payto2=$payto;\n  }\n\n  $sql3 = "select * from action where bank=1 and amount=".$amount." and tgl=\'".$r4[\'tgl\']."\'";\n  echo $sql3."<br>";\n  $res3 = mysqli_query($db, $sql3);\n  if(mysqli_num_rows($res3)>0) {\n    $r3 = mysqli_fetch_assoc($res3);\n    //echo "<pre>"; print_r($r3); echo "</pre>";\n    $udt=array(\n      \'action_id\'=>$r3[\'id\'],\n    );\n    Update($db,"mandiri_mutasi",$udt,"id=".$r4[\'id\'],1);\n      \n  } else {\n    $sql2 = "select id from action where id2=id order by id desc limit 1";\n    $res2 = mysqli_query($db, $sql2);\n    $r2 = mysqli_fetch_assoc($res2);\n    $id2=$r2[\'id\']+1;\n    $idt=array(\n          \'id\'=>$id2,\n          \'action_at\'=>$r4[\'tgl2\'],\n          \'tgl\'=>$r4[\'tgl\'],\n          \'month\'=>$r4[\'month\'],\n          \'year\'=>$r4[\'year\'],\n          \'descr\'=>$r4[\'keterangan\']." ".$r4[\'remark\'],\n          \'pay_to\'=>$payto2,\n          \'pay_from\'=>$payfrom,\n          \'cat\'=>$inout,\n          \'seq\'=>$r4[\'seq\'],\n          \'inout\'=>$inout,\n          \'bank\'=>$ar[\'manp\'][$r4[\'rek\']],\n          \'amount\'=>$amount,\n          \'st\'=>1,\n          \'update_at\'=>time(),\n    );\n    Insert($db,"action",$idt,1);\n    tool_id3("action");      \n    $udt=array(\n      \'action_id\'=>$id2,\n    );\n    Update($db,"mandiri_mutasi",$udt,"id=".$r4[\'id\'],1);\n  }  \n}','php','0','2','2','1748499718');
INSERT INTO `cp_sphp` VALUES ('21','app','SalesAction','function SalesAction($p,$v=0) {\n  global $db,$ar;\n  //echo "<pre>"; print_r($p); echo "</pre>";\n  $ar[\'act_desc\'][1]=\'Penerimaan tunai atas\';\n  $ar[\'act_bank\'][1]=1;\n  $ar[\'act__cat\'][1]=1;\n\n  $ar[\'act_desc\'][2]=\'Piutang kredit \'.$p[\'days_due_date\'].\' atas\';\n  $ar[\'act_bank\'][2]=0;\n  $ar[\'act__cat\'][2]=7; //piutang\n\n  //cek dulu ref id,\n  $sql1 = "select id,reff_sales_id from `action` where reff_sales_id=".$p[\'id\'];\n  $res1 = mysqli_query($db, $sql1);\n  if(mysqli_num_rows($res1)==0) {\n    //insert\n      $sql4 = "select * from `action` order by id desc limit 1";\n      $res4 = mysqli_query($db, $sql4);\n      $r4 = mysqli_fetch_assoc($res4);\n      $id1=$r4[\'id\']+1;\n      $id2=$r4[\'id\']+2;\n\n      $idt1=array(\n        \'id\'=>$id1,\n        \'action_at\'=>strtotime($p[\'sales_at\']),\n        \'reff_sales_id\'=>$p[\'id\'],\n        \'pay_from\'=>$p[\'buyer\'],\n        \'invoice\'=>$p[\'invoice\'],\n        \'inout\'=>1,\n        \'descr\'=>$p[\'descr\'],\n        \'bank\'=>0,\n        \'cat\'=>4,\n        \'amount\'=>$p[\'qty\']*$p[\'hpp\'],\n        \'year\'=>date("Y",strtotime($p[\'sales_at\'])),\n        \'month\'=>date("Ym",strtotime($p[\'sales_at\'])),\n        \'tgl\'=>date("Y-m-d",strtotime($p[\'sales_at\'])),\n        \'update_at\'=>time(),\n      );\n      Insert($db,"action",$idt1,$v);\n      $idt2=array(\n        \'id\'=>$id2,\n        \'action_at\'=>strtotime($p[\'sales_at\']),\n        \'reff_sales_id\'=>$p[\'id\'],\n        \'pay_from\'=>$p[\'buyer\'],\n        \'invoice\'=>$p[\'invoice\'],\n        \'inout\'=>1,\n        \'descr\'=>$ar[\'act_desc\'][$p[\'cash_credit\']]." ".$p[\'descr\'],\n        \'bank\'=>$ar[\'act_bank\'][$p[\'cash_credit\']],\n        \'cat\'=>$ar[\'act__cat\'][$p[\'cash_credit\']],\n        \'amount\'=>$p[\'qty\']*$p[\'price\'],\n        \'year\'=>date("Y",strtotime($p[\'sales_at\'])),\n        \'month\'=>date("Ym",strtotime($p[\'sales_at\'])),\n        \'tgl\'=>date("Y-m-d",strtotime($p[\'sales_at\'])),\n        \'update_at\'=>time(),\n      );\n      Insert($db,"action",$idt2,$v);\n      $udt_41=array(\n        \'action_id_1\'=>$id1,\n        \'action_id_2\'=>$id2,\n      );\n      Update($db,"sales",$udt_41,"id=".$p[\'id\'],$v);\n      //catat di product_trx\n      $p[\'action_at\']=strtotime($p[\'sales_at\']);\n      $p[\'inout\']=2;\n      $p[\'remark\']=$p[\'descr\'];\n      $p[\'action_id\']=$id1;\n      product_trx($p);\n\n\n  } else {\n    $sql2=$sql1." order by id";\n    $res2 = mysqli_query($db, $sql2);\n    $dt=array();\n    while($r2=mysqli_fetch_assoc($res2)) {\n      $dt[\'id\'][]=$r2[\'id\'];\n    }\n    $udt1=array(\n      \'action_at\'=>strtotime($p[\'sales_at\']),\n      \'reff_sales_id\'=>$p[\'id\'],\n      \'pay_from\'=>$p[\'buyer\'],\n      \'invoice\'=>$p[\'invoice\'],\n      \'inout\'=>1,\n      \'descr\'=>$p[\'descr\'],\n      \'bank\'=>0,\n      \'cat\'=>4,\n      \'amount\'=>$p[\'qty\']*$p[\'hpp\'],\n      \'year\'=>date("Y",strtotime($p[\'sales_at\'])),\n      \'month\'=>date("Ym",strtotime($p[\'sales_at\'])),\n      \'tgl\'=>date("Y-m-d",strtotime($p[\'sales_at\'])),\n      \'update_at\'=>time(),\n    );\n    Update($db,"action",$udt1,"id=".$dt[\'id\'][0],$v);\n    $udt2=array(\n      \'action_at\'=>strtotime($p[\'sales_at\']),\n      \'reff_sales_id\'=>$p[\'id\'],\n      \'pay_from\'=>$p[\'buyer\'],\n      \'invoice\'=>$p[\'invoice\'],\n      \'inout\'=>1,\n      \'descr\'=>$ar[\'act_desc\'][$p[\'cash_credit\']]." ".$p[\'descr\'],\n      \'bank\'=>$ar[\'act_bank\'][$p[\'cash_credit\']],\n      \'cat\'=>$ar[\'act__cat\'][$p[\'cash_credit\']],\n      \'amount\'=>$p[\'qty\']*$p[\'price\'],\n      \'year\'=>date("Y",strtotime($p[\'sales_at\'])),\n      \'month\'=>date("Ym",strtotime($p[\'sales_at\'])),\n      \'tgl\'=>date("Y-m-d",strtotime($p[\'sales_at\'])),\n      \'update_at\'=>time(),\n    );\n    Update($db,"action",$udt2,"id=".$dt[\'id\'][1],$v);\n    $udt_41=array(\n      \'action_id_1\'=>$dt[\'id\'][0],\n      \'action_id_2\'=>$dt[\'id\'][1],\n    );\n    Update($db,"sales",$udt_41,"id=".$p[\'id\'],$v);\n    //catat di product_trx\n    $p[\'action_at\']=strtotime($p[\'sales_at\']);\n    $p[\'inout\']=2;\n    $p[\'remark\']=$p[\'descr\'];\n    $p[\'action_id\']=$dt[\'id\'][0];\n    product_trx($p);\n  }\n}','php','0','2','2','1748499742');
INSERT INTO `cp_sphp` VALUES ('22','app','to_money','function to_money($ang) {\n    $sid = preg_replace("/[^0-9+-]/","",$ang);\n    return $sid;\n}','php','0','2','2','1748499764');
INSERT INTO `cp_sphp` VALUES ('23','app','list_equ_2','function list_equ_2(){\n  global $ar,$db;\n  $dt=array();\n\n  $sql = "select a.*, b.descr as descr,b.seq as seq from account_equation a JOIN `action` b ON a.action_id=b.id where a.st>0 ";\n  \n    $sql .= " and a.`year`=\'".date("Y")."\' ";\n\n  \n  //$sql .= " order by a.".$sortby." asc, a.id asc";\n  $res = mysqli_query($db, $sql);\n    foreach ($ar[\'equ\'] as $k => $v) {\n      $j[$v]=0;\n    }\n\n  while($rw = mysqli_fetch_assoc($res)) {\n    foreach ($ar[\'equ\'] as $k1 => $v1) {\n      $j[$v1]=$j[$v1]+$rw[$v1];\n    } \n  }\n\n  $j[\'aktiva_lancar\']=$j[\'c11\']=$j[\'c11101\']+$j[\'c11201\']+$j[\'c11202\']+$j[\'c11203\']+$j[\'c11204\']+$j[\'c11205\'];\n\n  $j[\'aktiva_tak_lancar\']=$j[\'c12\']=$j[\'c12101\']+$j[\'c12201\']+$j[\'c12202\']+$j[\'c12301\']+$j[\'c12302\']+$j[\'c12401\']+$j[\'c12402\'];\n\n  $j[\'utang\']=$j[\'c21\']=$j[\'c21100\']+$j[\'c22100\']+$j[\'c23100\'];\n\n  $j[\'equity\']=$j[\'c31\']=$j[\'c31100\']+$j[\'c31200\']+$j[\'c31300\'];\n\n  $j[\'pendapatan\']=$j[\'c41\']=$j[\'c41100\']+$j[\'c41200\']+$j[\'c41300\'];\n\n  $j[\'hpp\']=$j[\'c51\']=$j[\'c51100\']+$j[\'c51200\']+$j[\'c51300\'];\n\n  $j[\'beban_penjualan\']=$j[\'c61\']=$j[\'c61101\']+$j[\'c61102\']+$j[\'c61103\']+$j[\'c61104\']+$j[\'c61105\']+$j[\'c61106\'];\n\n  $j[\'beban_administrasi\']=$j[\'c62\']=$j[\'c62101\']+$j[\'c62102\']+$j[\'c62103\']+$j[\'c62104\']+$j[\'c62106\']+$j[\'c62107\'];\n\n  $j[\'pendapatan_lain\']=$j[\'c71\']=$j[\'c71000\'];\n\n  $j[\'beban_lain\']=$j[\'c81\']=$j[\'c81100\']+$j[\'c81200\'];\n\n  $j[\'beban\']=$j[\'beban_penjualan\']+$j[\'beban_administrasi\'];\n\n  $j[\'aktiva\']=$j[\'aktiva_lancar\']+$j[\'aktiva_tak_lancar\'];\n\n  $j[\'laba_kotor\']=$j[\'pendapatan\']+$j[\'hpp\']+$j[\'beban_penjualan\'];\n\n  $j[\'laba_sebelum_pph\']=$j[\'laba_kotor\']+$j[\'beban_administrasi\'];\n\n  $j[\'pph\']=0;\n\n  $j[\'laba_setelah_pph\']=$j[\'laba_bersih\']=$j[\'laba_sebelum_pph\']-$j[\'pph\'];\n\n  $j[\'pasiva\']=$j[\'utang\']+$j[\'equity\']+$j[\'laba_setelah_pph\']; \n  echo "aktiva:<br>".ang2($j[\'aktiva\'])."<br>pasiva:<br>".ang2($j[\'pasiva\'])."<br>Rugi/Laba:<br>".ang2($j[\'laba_bersih\']); \n}','php','0','2','2','1748658706');
INSERT INTO `cp_sphp` VALUES ('24','app','list_equ_3','function list_equ_3(){\n  global $ar,$db;\n  $dt=array();\n\n  $sql = "select a.*, b.descr as descr,b.seq as seq from account_equation a JOIN `action` b ON a.action_id=b.id where a.st>0 ";\n  \n    $sql .= " and a.`year`=\'".date("Y")."\' ";\n\n  \n  //$sql .= " order by a.".$sortby." asc, a.id asc";\n  $res = mysqli_query($db, $sql);\n    foreach ($ar[\'equ\'] as $k => $v) {\n      $j[$v]=0;\n    }\n\n  while($rw = mysqli_fetch_assoc($res)) {\n    foreach ($ar[\'equ\'] as $k1 => $v1) {\n      $j[$v1]=$j[$v1]+$rw[$v1];\n    } \n  }\n\n  foreach ($ar[\'equ\'] as $k1 => $v1) {\n    //$j[$v1]=$j[$v1]+$rw[$v1];\n    $udt=array(\n      \'update_at\'=>time(),\n      \'s2025\'=>$j[$v1],\n    );\n    Update($db,"fcode",$udt,"`code`=\'".$v1."\'",0);\n  }\n  \n\n}','php','0','2','2','1748499813');
INSERT INTO `cp_sphp` VALUES ('25','app','account_equation','function account_equation($trx) {\n  global $db,$ar;\n  $dt=array();\n  $dt[\'src\']=$trx;\n  /*  \n  //cek kolom apa saja yg diupdate\n  $sql = "SELECT `code` from account where code=\'".$trx[\'debit\']."\'"; \n  //echo $sql."<br>";\n  $res = mysqli_query($db,$sql);\n  $r1  = mysqli_fetch_assoc($res);\n\n  $sql2 = "SELECT lev2,min from account where code=\'".$trx[\'credit\']."\'"; \n  $res2 = mysqli_query($db,$sql2);\n  $r2   = mysqli_fetch_assoc($res2);\n  */\n  $col_debit=\'c\'.$trx[\'debit\'];\n  $col_credit=\'c\'.$trx[\'credit\'];\n  \n  $col3_debit=substr($col_debit,0,3);\n  $col3_credit=substr($col_credit,0,3);\n\n  $val_credit=to_numeric($trx[\'amount\']);\n  $val_debit=to_numeric($trx[\'amount\']);\n\n  //beban dr cash\n  if($col_credit==\'c11101\') {\n    //bayar beban\n    if($col3_debit==\'c61\' or $col3_debit==\'c62\' or $col_debit==\'c21100\' or $col_debit==\'c41300\' or $col_debit==\'c31200\') {\n      $val_credit=-to_numeric($trx[\'amount\']);\n      $val_debit=-to_numeric($trx[\'amount\']);\n    }\n    //bayar asset\n    if($col_debit==\'c11202\' or $col_debit==\'c11203\' or $col_debit==\'c11204\' or $col_debit==\'c11205\' or $col_debit==\'c12101\' or $col_debit==\'c12201\' or $col_debit==\'c12301\' or $col_debit==\'c12401\') {\n      $val_credit=-to_numeric($trx[\'amount\']);\n      $val_debit=to_numeric($trx[\'amount\']);\n    }\n\n  } \n\n  //ada piutang yg di bayar\n  if($col_credit==\'c11201\' && $col_debit==\'c11101\') {\n    $val_credit=-to_numeric($trx[\'amount\']);\n    $val_debit=to_numeric($trx[\'amount\']);\n  } \n\n  //ada piutang dg barang dagangan di retur\n  if($col_credit==\'c11201\' && $col_debit==\'c41100\') {\n    $val_credit=-to_numeric($trx[\'amount\']);\n    $val_debit=-to_numeric($trx[\'amount\']);\n  } \n\n  //ada piutang yg di bayar\n  if($col_credit==\'c11202\' && $col_debit==\'c51100\') {\n    $val_credit=-to_numeric($trx[\'amount\']);\n    $val_debit=-to_numeric($trx[\'amount\']);\n  } \n\n  //ada rtur barang pembelian kredit (utang)\n  if($col_credit==\'c11202\' && $col_debit==\'c21100\') {\n    $val_credit=-to_numeric($trx[\'amount\']);\n    $val_debit=-to_numeric($trx[\'amount\']);\n  } \n\n  //bayar biaya dengan utang\n  if($col_credit==\'c22100\') {\n    if($col3_debit==\'c61\' or $col3_debit==\'c62\') {\n      $val_credit=to_numeric($trx[\'amount\']);\n      $val_debit=-to_numeric($trx[\'amount\']);\n    }\n  } \n\n  //penyusutan aset\n  if($col_credit==\'c12202\' or $col_credit==\'c12302\' or $col_credit==\'c12402\') {\n    if($col3_debit==\'c61\' or $col3_debit==\'c62\') {\n      $val_credit=-to_numeric($trx[\'amount\']);\n      $val_debit=-to_numeric($trx[\'amount\']);\n    }\n  } \n\n\n  $sql3 = "select id,id2,id-id2 as k from account_equation where id-id2>0 order by id2 limit 1";\n  $res3 = mysqli_query($db, $sql3);\n  if(mysqli_num_rows($res3)>0) {\n    $rw3 = mysqli_fetch_assoc($res3);\n    $id2=$rw3[\'id2\'];\n  } else {\n    $sql4 = "select * from account_equation order by id desc limit 1";\n    $res4 = mysqli_query($db, $sql4);\n    $rw4 = mysqli_fetch_assoc($res4);\n    if(isset($rw4[\'id\']) && $rw4[\'id\']>0) {\n      $id2=$rw4[\'id\']+1;\n    } else {\n      $id2=1;\n    }\n  }\n  /*\n  foreach ($ar[\'equ\'] as $k => $v) {\n    $udt6=array(\n      $v=>0,\n    );\n    Update($db,"account_equation",$udt6,"transaction_id=".$trx[\'id\'],0);\n  }*/\n  $idt=array(\n    \'id\'=>$id2,\n    \'transaction_id\'=>$trx[\'id\'],\n    \'action_at\'=>$trx[\'action_at\'],\n    \'action_id\'=>$trx[\'action_id\'],\n    \'year\'=>date("Y",$trx[\'action_at\']),\n    \'month\'=>date("Ym",$trx[\'action_at\']),\n    \'week\'=>date("W",$trx[\'action_at\']),\n    \'amount\'=>to_numeric($trx[\'amount\']),\n    $col_debit=>$val_debit,\n    $col_credit=>$val_credit,\n  );\n  $udt=array(\n    \'action_at\'=>$trx[\'action_at\'],\n    \'year\'=>date("Y",$trx[\'action_at\']),\n    \'month\'=>date("Ym",$trx[\'action_at\']),\n    \'week\'=>date("W",$trx[\'action_at\']),\n    \'amount\'=>to_numeric($trx[\'amount\']),\n    $col_debit=>$val_debit,\n    $col_credit=>$val_credit,\n  );\n  InsertUpdate($db,"account_equation",$idt,$udt,0);\n  tool_id2("account_equation");\n  equ_count();\n  $dt[\'idt\']=$idt;\n  $dt[\'udt\']=$udt;\n  return $dt;\n}','php','0','2','2','1748666334');
INSERT INTO `cp_sphp` VALUES ('26','api','start_old','function start_old(){\n  global $ar,$db;\n  $dt=array();\n$dt2=array();\n\n//account_trx\n$sql2="SELECT `id`,`name`,`code`,`c3`,`parent_id` from `account` where trx=1";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'account_trx\'][\'count\']=$r2;\n\n$sql=$sql2." order by `code`";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  $c=0; $d=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $dt[\'account_trx\'][\'data\'][\'all\'][$r1[\'code\']]=$r1;\n    if($r1[\'c3\']<30) {\n      $dt[\'account_trx\'][\'data\'][\'left\'][$c]=$r1;\n      $c++;\n    } else {\n      $dt[\'account_trx\'][\'data\'][\'right\'][$d]=$r1; \n      $d++;     \n    }\n  }\n} else {\n  $dt[\'account_trx\'][\'count\']=0;\n}\n\n$sql2="SELECT * from `account_equation` where id>0";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'account_equation\'][\'count\']=$r2;\n\n$sql=$sql2." order by id";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  $c=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $dt[\'account_equation\'][\'data\'][$c]=$r1;    \n    //$dt[\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n    $c++;\n  }\n} else {\n  $dt[\'account_equation\'][\'count\']=0;\n}\n\n//action\n$sql2="SELECT * from `action` where id>0";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'action\'][\'count\']=$r2;\n\n$sql=$sql2." order by id";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  while($r1=mysqli_fetch_assoc($res)) {\n    $c=$r1[\'id\'];\n    $dt[\'action\'][\'data\'][$c]=$r1;    \n    $dt[\'action\'][\'data\'][$c][\'rp\']=ang2($r1[\'amount\']);    \n    $dt[\'action\'][\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n  }\n} else {\n  $dt[\'action\'][\'count\']=0;\n}\n\n//bank\n$sql2="SELECT * from `bank` where id>0";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'bank\'][\'count\']=$r2;\n\n$sql=$sql2." order by id";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  $c=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $dt[\'bank\'][\'data\'][$c]=$r1;    \n    $dt[\'bank\'][\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n    $c++;\n  }\n} else {\n  $dt[\'bank\'][\'count\']=0;\n}\n\n//company\n$sql2="SELECT * from `company` where id>0";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'company\'][\'count\']=$r2;\n\n$sql=$sql2." order by id";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  $c=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $dt[\'company\'][\'data\'][$c]=$r1;    \n    $dt[\'company\'][\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n    $c++;\n  }\n} else {\n  $dt[\'company\'][\'count\']=0;\n}\n\n//inventory\n$sql2="SELECT * from `inventory` where id>0";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'inventory\'][\'count\']=$r2;\n\n$sql=$sql2." order by id";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  $c=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $dt[\'inventory\'][\'data\'][$c]=$r1;    \n    $dt[\'inventory\'][\'data\'][$c][\'rp\']=ang2($r1[\'amount\']);    \n    $dt[\'inventory\'][\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n    $c++;\n  }\n} else {\n  $dt[\'inventory\'][\'count\']=0;\n}\n\n//journal\n$sql2="SELECT a.*,b.descr from `journal` a JOIN `action` b ON a.action_id=b.id where a.id>0";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'journal\'][\'count\']=$r2;\n\n$sql=$sql2." order by a.action_at desc,a.id desc";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  $c=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $dt[\'journal\'][\'data\'][$c]=$r1;    \n    $dt[\'journal\'][\'data\'][$c][\'rp_debit\']=ang2($r1[\'debit\']);    \n    $dt[\'journal\'][\'data\'][$c][\'rp_credit\']=ang2($r1[\'credit\']);    \n    $dt[\'journal\'][\'data\'][$c][\'rp_balance\']=ang2($r1[\'balance\']);    \n    $dt[\'journal\'][\'data\'][$c][\'rp\']=ang2($r1[\'amount\']);    \n    $dt[\'journal\'][\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n    $c++;\n  }\n} else {\n  $dt[\'journal\'][\'count\']=0;\n}\n\n//person\n$sql2="SELECT * from `person` where id>0";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'person\'][\'count\']=$r2;\n\n$sql=$sql2." order by id";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  $c=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $dt[\'person\'][\'data\'][$c]=$r1;    \n    $dt[\'person\'][\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n    $c++;\n  }\n} else {\n  $dt[\'person\'][\'count\']=0;\n}\n\n//product\n\n$sql2="SELECT id,name,img,brand,qty,item_code,price_per_unit,update_at from `product` where del=0";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'product_byid\'][\'count\']=$r2;\n\n$sql=$sql2." order by id";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  //$c=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $c=$r1[\'id\'];\n    $dt[\'product_byid\'][\'data\'][$c]=$r1;\n    $dt[\'product_byid\'][\'data\'][$c][\'hpp\']=ang2($r1[\'price_per_unit\']);\n    $dt[\'product_byid\'][\'data\'][$c][\'amount\']=ang2($r1[\'price_per_unit\']*$r1[\'qty\']);\n    $dt[\'product_byid\'][\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n    $sql3="SELECT a.id,a.action_id,a.transaction_id,a.item_in,a.item_out,a.`balance`,a.invoice,a.tgl,a.`inout`,b.descr from `product_trx` a JOIN `action` b ON a.action_id=b.id where product_id=".$r1[\'id\']." order by a.action_at,a.action_id ";\n    $res3=mysqli_query($db,$sql3);\n    $d=0;\n    while($r3=mysqli_fetch_assoc($res3)) {\n      $dt[\'product_byid\'][\'data\'][$c][\'trx\'][$d]=$r3;\n      $dt[\'product_byid\'][\'data\'][$c][\'trx\'][$d][\'amount\']=ang2($r3[\'balance\']*$r1[\'price_per_unit\']);\n      $d++;\n    }\n  }\n} else {\n  $dt[\'product_byid\'][\'count\']=0;\n}\n/* */\n\n$sql2="SELECT `brand` from `product` where `del`=0 group by `brand` order by `brand`";\n  $res2=mysqli_query($db,$sql2);\n  //$dt[\'count\']=$r2;\n  $count=0;\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r2=mysqli_fetch_assoc($res2)) {\n      $dt[\'product\'][\'data\'][$c][\'brand\']=$r2[\'brand\'];\n      $sql3="SELECT id,name,qty,item_code,price_per_unit,img,update_at from `product` where del=0 and brand=\'".$r2[\'brand\']."\' order by `name`";\n      $res3=mysqli_query($db,$sql3);\n      $d=0;\n      while($r3=mysqli_fetch_assoc($res3)) {\n        $dt[\'product\'][\'data\'][$c][\'items\'][$d]=$r3;\n        $dt[\'product\'][\'data\'][$c][\'items\'][$d][\'hpp\']=ang2($r3[\'price_per_unit\']);\n        $dt[\'product\'][\'data\'][$c][\'items\'][$d][\'amount\']=ang2($r3[\'price_per_unit\']*$r3[\'qty\']);\n        $dt[\'product\'][\'data\'][$c][\'items\'][$d][\'update\']=date("Y-m-d H:i:s",$r3[\'update_at\']);\n\n        $sql4="SELECT a.id,a.action_id,a.transaction_id,a.item_in,a.item_out,a.`balance`,a.invoice,a.tgl,a.`inout`,b.descr from `product_trx` a JOIN `action` b ON a.action_id=b.id where product_id=".$r3[\'id\']." order by a.action_at,a.action_id ";\n        $res4=mysqli_query($db,$sql4);\n        $e=0;\n        while($r4=mysqli_fetch_assoc($res4)) {\n          $dt[\'product\'][\'data\'][$c][\'items\'][$d][\'trx\'][$e]=$r4;\n          $dt[\'product\'][\'data\'][$c][\'items\'][$d][\'trx\'][$e][\'amount\']=ang2($r4[\'balance\']*$r3[\'price_per_unit\']);\n          $e++;\n        }        \n        $d++;\n        $count++;\n      }\n      $c++;\n    }\n    $dt[\'product\'][\'count\']=$count;\n  } else {\n    $dt[\'product\'][\'count\']=0;\n  }  \n\n\n//[\'sales\']\n$sql2="SELECT * from `sales` where del=0";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'sales\'][\'count\']=$r2;\n\n$sql=$sql2." order by id";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  $c=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $dt[\'sales\'][\'data\'][$c]=$r1;\n    $dt[\'sales\'][\'data\'][$c][\'rp_hpp\']=ang2($r1[\'hpp\']);\n    $dt[\'sales\'][\'data\'][$c][\'rp_price\']=ang2($r1[\'price\']);\n    $dt[\'sales\'][\'data\'][$c][\'rp_amount\']=ang2($r1[\'amount\']);\n    $dt[\'sales\'][\'data\'][$c][\'pay\']=$ar[\'cash_credit\'][$r1[\'cash_credit\']];\n    $dt[\'sales\'][\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n    $c++;\n  }\n} else {\n  $dt[\'sales\'][\'count\']=0;\n}\n\n//[\'transaction\']\n$sql2="SELECT a.*,b.descr,b.invoice from `transaction` a JOIN `action` b ON a.id=b.id where a.id>0";\n$res2=mysqli_query($db,$sql2);\n$r2=mysqli_num_rows($res2);\n$dt[\'transaction\'][\'count\']=$r2;\n\n$sql=$sql2." order by a.action_at desc,a.id desc";\n//echo $sql.";<br>";\n$res=mysqli_query($db,$sql);\nif(mysqli_num_rows($res2)>0) {\n  $c=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $dt[\'transaction\'][\'data\'][$c]=$r1;    \n    $dt[\'transaction\'][\'data\'][$c][\'tgl\']=date("Y-m-d",$r1[\'action_at\']);    \n    $dt[\'transaction\'][\'data\'][$c][\'debit_acc\']=$ar[\'acc_name\'][$r1[\'debit\']];    \n    $dt[\'transaction\'][\'data\'][$c][\'credit_acc\']=$ar[\'acc_name\'][$r1[\'credit\']];    \n    $dt[\'transaction\'][\'data\'][$c][\'rp_amount\']=ang2($r1[\'amount\']);\n    $dt[\'transaction\'][\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n    $c++;\n  }\n} else {\n  $dt[\'transaction\'][\'count\']=0;\n}\n\n//icons\ninclude_once $ar[\'path_core\']."u9/inc.ar.f7icon.php";\n$dt[\'icons\'][\'count\']=count($ar[\'f7_icon\']);\nforeach($ar[\'f7_icon\'] as $k=>$v) {\n  $dt[\'icons\'][\'data\'][$k][\'name\']=$v;\n  $dt[\'icons\'][\'data\'][$k][\'id\']=$k+1;\n}\n\n\n\n$dt2[\'result\']=$dt;\n$dt2[\'status\']=true;\n//echo json_encode($dt2);\n\n\n\n  return $dt2;\n  $db->close();\n}','php','0','2','1','1748571940');
INSERT INTO `cp_sphp` VALUES ('27','api','start','function start(){\n  global $ar,$db;\n  $dt=array();\n  $dt2=array();\n\n  //account_trx ////\n  $sql2="SELECT `id`,`name`,`code`,`c3`,`parent_id` from `account` where trx=1";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_num_rows($res2);\n  $dt[\'account_trx\'][\'count\']=$r2;\n\n  $sql=$sql2." order by `code`";\n  //echo $sql.";<br>";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res2)>0) {\n    $c=0; $d=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'account_trx\'][\'data\'][\'all\'][$r1[\'code\']]=$r1;\n      if($r1[\'c3\']<30) {\n        $dt[\'account_trx\'][\'data\'][\'left\'][$c]=$r1;\n        $c++;\n      } else {\n        $dt[\'account_trx\'][\'data\'][\'right\'][$d]=$r1; \n        $d++;     \n      }\n    }\n  } else {\n    $dt[\'account_trx\'][\'count\']=0;\n  }\n\n  //account_trx\n  $sql2="SELECT `id`,`name`,`code`,`parent` from `fcode` where `code`=\'c61\' or `code`=\'c62\'  or `code`=\'c81\' or `code`=\'c11\' or `code`=\'c21\' or `code`=\'c31\'";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_num_rows($res2);\n\n  $sql=$sql2." order by `code`";\n  //echo $sql.";<br>";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'account_cost\'][\'data\'][$r1[\'code\']]=$r1;\n      $sql3="SELECT `id`,`name`,`code`,`parent` from `fcode` where `parent`=".$r1[\'id\']." and trx=1 and is_cost=1 order by `name`";\n      $res3=mysqli_query($db,$sql3);\n      $d=0;\n      while($r3=mysqli_fetch_assoc($res3)) {\n        $dt[\'account_cost\'][\'data\'][$r1[\'code\']][\'items\'][$d]=$r3;\n        $dt[\'account_cost\'][\'data\'][$r1[\'code\']][\'items\'][$d][\'code\']=substr($r3[\'code\'],1);\n        $d++;        \n      }\n      $c++;\n    }\n  } \n\n  //account_trx\n  $sql2="SELECT `id`,`name`,`code`,`parent` from `fcode` where `code`=\'c31\'  or `code`=\'c71\' or `code`=\'c11\' or `code`=\'c21\' ";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_num_rows($res2);\n\n  $sql=$sql2." order by `code`";\n  //echo $sql.";<br>";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'account_in\'][\'data\'][$r1[\'code\']]=$r1;\n      $sql3="SELECT `id`,`name`,`code`,`parent` from `fcode` where `parent`=".$r1[\'id\']." and trx=1 and is_income=1 order by `name`";\n      $res3=mysqli_query($db,$sql3);\n      $d=0;\n      while($r3=mysqli_fetch_assoc($res3)) {\n        $dt[\'account_in\'][\'data\'][$r1[\'code\']][\'items\'][$d]=$r3;\n        $dt[\'account_in\'][\'data\'][$r1[\'code\']][\'items\'][$d][\'code\']=substr($r3[\'code\'],1);\n        $d++;        \n      }\n      $c++;\n    }\n  } \n\n  //account_trx\n  $sql2="SELECT `id`,`title`,`code` from `trx_title` where `menu`=\'add\' and parent=0 ";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_num_rows($res2);\n\n  $sql=$sql2." order by `code`";\n  //echo $sql.";<br>";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'menu\'][\'data\'][$r1[\'code\']]=$r1;\n      $sql3="SELECT `debit`,`credit`,`cat`,`bank` from `trx_title` where `parent`=".$r1[\'code\']." order by `debit`";\n      $res3=mysqli_query($db,$sql3);\n      $d=0;\n      while($r3=mysqli_fetch_assoc($res3)) {\n        $dt[\'menu\'][\'data\'][$r1[\'code\']][\'items\'][$d]=$r3;\n        $dt[\'menu\'][\'data\'][$r1[\'code\']][\'items\'][$d][\'n_debit\']=$ar[\'acc_name\'][$r3[\'debit\']];\n        $dt[\'menu\'][\'data\'][$r1[\'code\']][\'items\'][$d][\'n_credit\']=$ar[\'acc_name\'][$r3[\'credit\']];\n        $d++;        \n      }\n      $c++;\n    }\n  } \n\n  $dt2[\'result\']=$dt;\n  $dt2[\'status\']=true;\n  //echo json_encode($dt2);\n  return $dt2;\n  $db->close();\n}','php','0','2','1','1750047373');
INSERT INTO `cp_sphp` VALUES ('28','app','sales_add','function sales_add($js){\n  global $ar,$db;\n  $dt=array();\n  $sql3 = "select id,id2,id-id2 as k from `sales` where id-id2>0 order by id2 limit 1";\n  $res3 = mysqli_query($db, $sql3);\n  if(mysqli_num_rows($res3)>0) {\n    $rw3 = mysqli_fetch_assoc($res3);\n    $id1=$rw3[\'id2\'];\n  } else {\n    $sql4 = "select * from `sales` order by id desc limit 1";\n    $res4 = mysqli_query($db, $sql4);\n    $rw4 = mysqli_fetch_assoc($res4);\n    if(isset($rw4[\'id\']) && $rw4[\'id\']>0) {\n      $id1=$rw4[\'id\']+1;\n    } else {\n      $id1=1;\n    }\n  }\n\n  if($js[\'cat\']==7 && $js[\'due_days\']>0) {\n    $due_days=$js[\'due_days\']*24*60*60;\n    $due_date=date("Y-m-d",strtotime($js[\'action_at\'])+$due_days);\n    $cash_credit=2;\n  } else {\n    $due_date=$js[\'action_at\'];\n    $cash_credit=1;\n  }\n\n  $idt=array(\n    \'id\'=>$id1,\n    \'product_id\'=>$js[\'product_id\'],\n    \'hpp\'=>$js[\'hpp\'],\n    \'cash_credit\'=>$cash_credit,\n    \'buyer\'=>$js[\'buyer\'],\n    \'sales\'=>$js[\'sales\'],\n    \'sales_at\'=>strtotime($js[\'action_at\']),\n    \'qty\'=>$js[\'qty\'],\n    \'price\'=>$js[\'price_per_unit\'],\n    \'amount\'=>$js[\'qty\']*$js[\'price_per_unit\'],\n    \'due_date\'=>$due_date,\n    \'invoice\'=>$js[\'invoice\'],\n    \'descr\'=>$js[\'descr\'],\n    \'tgl\'=>$js[\'action_at\'],\n    \'days_due_date\'=>$js[\'due_days\'],\n    \'year\'=>date("Y",strtotime($js[\'action_at\'])),\n    \'month\'=>date("Ym",strtotime($js[\'action_at\'])),\n    \'update_at\'=>time(),\n  );\n  Insert($db,"sales",$idt,0);\n  tool_id2(\'sales\'); \n  $dt[\'message\']="Add sales Successfully";\n  $dt[\'sales_id\']=$id1;\n  $dt[\'success\']=true; \n  return $dt;\n}','php','0','2','2','1748589739');
INSERT INTO `cp_sphp` VALUES ('29','app','equ_count','function equ_count(){\n  global $ar,$db;\n  //$dt=array();\n  $udt1=array(\n  \'s2025\'=>0\n  );\n  Update($db,"fcode",$udt1,"id>0",0);\n  $ar[\'fcode\'][\'level4\']=array(\'b3201\',\'b3202\',\'b3203\',\'b3204\',\'b3205\',\'b3206\',\'b3207\',\'b3208\',\'b3209\',\'b3210\');\n\n  $ar[\'fcode\'][\'level3\']=array(\'b11\',\'b12\',\'b21\',\'b31\',\'b32\',\'b33\',\'c11\',\'c12\',\'c21\',\'c31\',\'c41\',\'c51\',\'c61\',\'c62\',\'c71\',\'c81\');\n  /*\n  $ar[\'fcode\'][\'level2\']=array(\'a01\', \'a02\', \'a03\', \'a04\', \'a05\', \'a06\', \'a07\', \'a08\', \'a09\', \'a10\', \'b11\', \'b12\', \'b21\', \'b33\', \'c1\', \'c2\', \'d1\', \'d2\', \'d3\', \'d4\', \'m1\', \'m2\');\n  */\n  $ar[\'fcode\'][\'level2\']=array(\'a01\', \'a02\', \'a03\', \'a04\', \'a05\', \'a06\', \'a07\', \'a08\', \'a09\', \'a10\', \'b11\', \'b12\', \'b21\', \'b33\',\'b1\',\'b2\', \'c1\', \'c2\');\n\n  $sql = "select a.*, b.descr as descr,b.seq as seq from account_equation a JOIN `action` b ON a.action_id=b.id where a.st>0 ";\n  \n    $sql .= " and a.`year`=\'".date("Y")."\' ";\n\n  \n  //$sql .= " order by a.".$sortby." asc, a.id asc";\n  $res = mysqli_query($db, $sql);\n    foreach ($ar[\'equ\'] as $k => $v) {\n      $j[$v]=0;\n    }\n\n  while($rw = mysqli_fetch_assoc($res)) {\n    foreach ($ar[\'equ\'] as $k1 => $v1) {\n      $j[$v1]=$j[$v1]+$rw[$v1];\n    } \n  }\n\n  $j[\'aktiva_lancar\']=$j[\'c11\']=$j[\'c11101\']+$j[\'c11201\']+$j[\'c11202\']+$j[\'c11203\']+$j[\'c11204\']+$j[\'c11205\'];\n\n  $j[\'aktiva_tak_lancar\']=$j[\'c12\']=$j[\'c12101\']+$j[\'c12201\']+$j[\'c12202\']+$j[\'c12301\']+$j[\'c12302\']+$j[\'c12401\']+$j[\'c12402\'];\n\n  $j[\'utang\']=$j[\'c21\']=$j[\'c21100\']+$j[\'c22100\']+$j[\'c23100\'];\n\n  $j[\'equity\']=$j[\'c31\']=$j[\'c31100\']+$j[\'c31200\']+$j[\'c31300\'];\n\n  $j[\'pendapatan\']=$j[\'c41\']=$j[\'c41100\']+$j[\'c41200\']+$j[\'c41300\'];\n\n  $j[\'hpp\']=$j[\'c51\']=$j[\'c51100\']+$j[\'c51200\']+$j[\'c51300\'];\n\n  $j[\'beban_penjualan\']=$j[\'c61\']=$j[\'c61101\']+$j[\'c61102\']+$j[\'c61103\']+$j[\'c61104\']+$j[\'c61105\']+$j[\'c61106\'];\n\n  $j[\'beban_administrasi\']=$j[\'c62\']=$j[\'c62101\']+$j[\'c62102\']+$j[\'c62103\']+$j[\'c62104\']+$j[\'c62106\']+$j[\'c62107\'];\n\n  $j[\'pendapatan_lain\']=$j[\'c71\']=$j[\'c71000\'];\n\n  $j[\'beban_lain\']=$j[\'c81\']=$j[\'c81100\']+$j[\'c81200\'];\n\n  $j[\'beban\']=$j[\'beban_penjualan\']+$j[\'beban_administrasi\'];\n\n  $j[\'aktiva\']=$j[\'aktiva_lancar\']+$j[\'aktiva_tak_lancar\'];\n\n  $j[\'laba_kotor\']=$j[\'pendapatan\']+$j[\'hpp\']+$j[\'beban_penjualan\'];\n\n  $j[\'laba_sebelum_pph\']=$j[\'laba_kotor\']+$j[\'beban_administrasi\']+$j[\'pendapatan_lain\']+$j[\'beban_lain\'];\n\n  $j[\'pph\']=0;\n\n  $j[\'laba_setelah_pph\']=$j[\'laba_bersih\']=$j[\'laba_sebelum_pph\']-$j[\'pph\'];\n\n  $j[\'pasiva\']=$j[\'utang\']+$j[\'equity\']+$j[\'laba_setelah_pph\']; \n\n  //level4\n  $j[\'b3201\']=$j[\'c41\'];\n  $j[\'b3202\']=$j[\'c51\'];\n  $j[\'b3203\']=$j[\'c61\'];\n  $j[\'b3204\']=$j[\'b3201\']+$j[\'b3202\']+$j[\'b3203\'];\n  $j[\'b3205\']=$j[\'c62\'];\n  $j[\'b3206\']=$j[\'c71\'];\n  $j[\'b3207\']=$j[\'c81\'];\n  $j[\'b3208\']=$j[\'b3204\']+$j[\'b3205\']+$j[\'b3206\']+$j[\'b3207\'];\n  $j[\'b3209\']=$j[\'pph\'];\n  $j[\'b3210\']=$j[\'b3208\']+$j[\'b3209\'];\n\n  //level3;\n  $j[\'b11\']=$j[\'c11\'];\n  $j[\'b12\']=$j[\'c12\'];\n  $j[\'b21\']=$j[\'c21\'];\n  $j[\'b31\']=$j[\'c31\'];\n  $j[\'b32\']=$j[\'b3210\'];\n  $j[\'b33\']=$j[\'c31\']+$j[\'b32\'];\n\n  //level2\n  $j[\'a01\']=$j[\'c41\'];\n  $j[\'a02\']=$j[\'c51\'];\n  $j[\'a03\']=$j[\'c61\'];\n  $j[\'a04\']=$j[\'laba_kotor\'];\n  $j[\'a05\']=$j[\'c62\'];\n  $j[\'a06\']=$j[\'c71\'];\n  $j[\'a07\']=$j[\'c81\'];\n  $j[\'a08\']=$j[\'laba_sebelum_pph\'];\n  $j[\'a09\']=$j[\'pph\'];\n  $j[\'a10\']=$j[\'laba_setelah_pph\'];\n\n  $j[\'b1\']=$j[\'b11\']+$j[\'b12\'];\n  $j[\'b2\']=$j[\'b21\']+$j[\'b33\'];\n\n  $j[\'c1\']=$j[\'c11\']+$j[\'c12\'];\n  $j[\'c2\']=$j[\'pasiva\'];\n\n  foreach ($ar[\'equ\'] as $k1 => $v1) {  \n    $udt=array(\n      \'s2025\'=>$j[$v1],\n    );\n    $dt[\'sql\'][]=Update_v2($db,"fcode",$udt,"code=\'".$v1."\'",1);\n  } \n  foreach ($ar[\'fcode\'][\'level4\'] as $k => $v) {\n    $udt=array(\n      \'s2025\'=>$j[$v],\n    );\n    $dt[\'sql\'][]=Update_v2($db,"fcode",$udt,"code=\'".$v."\'",1);\n  }\n  foreach ($ar[\'fcode\'][\'level3\'] as $k => $v) {\n    $udt=array(\n      \'s2025\'=>$j[$v],\n    );\n    $dt[\'sql\'][]=Update_v2($db,"fcode",$udt,"code=\'".$v."\'",1);\n  }\n  foreach ($ar[\'fcode\'][\'level2\'] as $k => $v) {\n    $udt=array(\n      \'s2025\'=>$j[$v],\n    );\n    $dt[\'sql\'][]=Update_v2($db,"fcode",$udt,"code=\'".$v."\'",1);\n  }\n  $dt[\'count\']=$j;\n  //return $dt; \n  //$dt[\'count\']=$j;\n  //return $dt; \n}','php','0','2','2','1748786406');
INSERT INTO `cp_sphp` VALUES ('30','api','inventory','function inventory(){\n  global $ar,$db;\n  $dt=array();\n  $sql2="SELECT * from `inventory` where id>0";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_num_rows($res2);\n  $dt[\'count\']=$r2;\n  $dt[\'success\']=true;\n  $sql=$sql2." order by id";\n  //echo $sql.";<br>";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'data\'][$c]=$r1;    \n      $dt[\'data\'][$c][\'image\']=$ar[\'imgurl\']."".$r1[\'img\'];    \n      $dt[\'data\'][$c][\'rp\']=ang2($r1[\'amount\']);    \n      $dt[\'data\'][$c][\'date_purchase\']=date("Y-m-d H:i:s",$r1[\'purchase_date\']);\n      $dt[\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n      $c++;\n    }\n  } else {\n    $dt[\'count\']=0;\n    $dt[\'message\']="data not found";\n  }\n  return $dt;\n  $db->close();\n}','php','0','2','1','1748591291');
INSERT INTO `cp_sphp` VALUES ('31','api','sales','function sales(){\n  global $ar,$db;  \n  $dt=array();\n  $sql2="SELECT * from `sales` where del=0";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_num_rows($res2);\n  $dt[\'count\']=$r2;\n  $dt[\'success\']=true;\n\n  $sql=$sql2." order by id";\n  //echo $sql.";<br>";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'data\'][$c]=$r1;\n      $dt[\'data\'][$c][\'tgl\']=date("Y-m-d",$r1[\'sales_at\']);\n      $dt[\'data\'][$c][\'image\']=$ar[\'imgurl\']."".$r1[\'img\'];  \n      $dt[\'data\'][$c][\'rp_hpp\']=ang2($r1[\'hpp\']);\n      $dt[\'data\'][$c][\'rp_price\']=ang2($r1[\'price\']);\n      $dt[\'data\'][$c][\'rp_amount\']=ang2($r1[\'amount\']);\n      $dt[\'data\'][$c][\'pay\']=$ar[\'cash_credit\'][$r1[\'cash_credit\']];\n      $dt[\'data\'][$c][\'update\']=date("Y-m-d H:i:s",$r1[\'update_at\']);\n      $c++;\n    }\n  } else {\n    $dt[\'count\']=0;\n  }\n  return $dt;\n  $db->close();\n}','php','0','2','1','1748676741');
INSERT INTO `cp_sphp` VALUES ('32','app','retur_action','function retur_action($js,$v=0) {\n  global $db,$ar;\n  $dt=array();\n/*  \ncat=1, retur dr agen, menambah persediaan, mengurangi piutang\ncat=2, retur ke supplier, mengurangi utang dan persediaan\npersediaan/11202 dan utang dagang 21100\n*/\n  $rr[\'retur_descr\'][1]="";\n  $rr[\'debit\'][1]      ="41100";\n  $rr[\'credit\'][1]     ="11201";\n\n  $rr[\'retur_descr\'][2]="";\n  $rr[\'debit\'][2]      ="21100";\n  $rr[\'credit\'][2]     ="11202";\n\n  $sql4 = "select id from `action` order by id desc limit 1";\n  $res4 = mysqli_query($db, $sql4);\n  $r4 = mysqli_fetch_assoc($res4);\n  $id1=$r4[\'id\']+1;\n  $id2=$r4[\'id\']+2;\n\n  $idt1=array(\n    \'id\'=>$id1,\n    \'action_at\'=>strtotime($js[\'action_at\']),\n    \'pay_to\'=>$js[\'pay_to\'],\n    \'pay_from\'=>$js[\'pay_from\'],\n    \'invoice\'=>$js[\'invoice\'],\n    \'inout\'=>$js[\'inout\'],\n    \'descr\'=>$js[\'descr\']." ".$rr[\'retur_descr\'][$js[\'inout\']],\n    \'bank\'=>0,\n    \'cat\'=>8,\n    \'amount\'=>$js[\'amount\'],\n    \'year\'=>date("Y",strtotime($js[\'action_at\'])),\n    \'month\'=>date("Ym",strtotime($js[\'action_at\'])),\n    \'tgl\'=>date("Y-m-d",strtotime($js[\'action_at\'])),\n    \'update_at\'=>time(),\n  );\n  Insert($db,"action",$idt1,$v);\n  $js1=$js;\n  $js1[\'action_id\']=$id1;\n  $js1[\'debit\']=$rr[\'debit\'][$js[\'inout\']];\n  $js1[\'credit\']=$rr[\'credit\'][$js[\'inout\']];\n  //$dt[\'trx\']=transaction_add_v2($js1);\n  transaction_add_v2($js1);\n  \n  if($js[\'inout\']==1) {\n    $idt2=array(\n      \'id\'=>$id2,\n      \'action_at\'=>strtotime($js[\'action_at\']),\n      \'pay_to\'=>$js[\'pay_to\'],\n      \'pay_from\'=>$js[\'pay_from\'],\n      \'invoice\'=>$js[\'invoice\'],\n      \'inout\'=>$js[\'inout\'],\n      \'descr\'=>$js[\'descr\']."",\n      \'bank\'=>0,\n      \'cat\'=>8,\n      \'amount\'=>$js[\'amount\'],\n      \'year\'=>date("Y",strtotime($js[\'action_at\'])),\n      \'month\'=>date("Ym",strtotime($js[\'action_at\'])),\n      \'tgl\'=>date("Y-m-d",strtotime($js[\'action_at\'])),\n      \'update_at\'=>time(),\n    );\n    Insert($db,"action",$idt2,$v);\n    $js2=$js;\n    $js2[\'action_id\']=$id2;\n    $js2[\'debit\']=11202;\n    $js2[\'credit\']=51100;\n    //$dt[\'trx\']=transaction_add_v2($js2);\n    transaction_add_v2($js2);\n  }\n\n  //catat di product_trx\n  $js[\'action_at\']=strtotime($js[\'action_at\']);\n  //$js[\'inout\']=2;\n  $js[\'remark\']=$js[\'descr\'];\n  $js[\'action_id\']=$id1;\n  product_trx($js);\n  $dt[\'message\']="add transaction succes";\n  return $dt;\n}','php','0','2','2','1748607404');
INSERT INTO `cp_sphp` VALUES ('33','api','fcode','function fcode(){\n  global $ar,$db;\n  $dt=array();\n\n  $sql1 = "select `id`,`name`,`code`,`remark`,`s2025`,`level` from `fcode` where del=0 and parent=0 and view=1 order by `code`";\n  $res1 = mysqli_query($db, $sql1);\n  $a=0;\n  while($r1 = mysqli_fetch_assoc($res1)) {\n    $dt[\'success\']=true;\n    $dt[\'data\'][$a]=$r1;\n    //echo $r1[\'code\']." (".$r1[\'name\'].")<br>";\n    $sql2 = "select `id`,`name`,`code`,`remark`,`s2025`,`level` from `fcode` where del=0 and parent=".$r1[\'id\']." order by `code`";\n    $res2 = mysqli_query($db, $sql2);\n    $b=0;\n    while($r2 = mysqli_fetch_assoc($res2)) {\n      $dt[\'data\'][$a][\'items\'][$b]=$r2;\n      $dt[\'data\'][$a][\'items\'][$b][\'rp\']=ang2($r2[\'s2025\']);\n\n      //echo "- ".$r2[\'code\']." (".$r2[\'name\'].")<br>";\n      $sql3 = "select `id`,`name`,`code`,`remark`,`s2025`,`level` from `fcode` where del=0 and parent=".$r2[\'id\']." order by `code`";\n      $res3 = mysqli_query($db, $sql3);\n      $c=0;\n      while($r3 = mysqli_fetch_assoc($res3)) {\n        $dt[\'data\'][$a][\'items\'][$b][\'items\'][$c]=$r3;\n        $dt[\'data\'][$a][\'items\'][$b][\'items\'][$c][\'rp\']=ang2($r3[\'s2025\']);\n\n        //echo "- - ".$r3[\'code\']." (".$r3[\'name\'].")<br>";\n        $sql4 = "select `id`,`name`,`code`,`remark`,`s2025`,`level`,`trx` from `fcode` where del=0 and parent=".$r3[\'id\']." order by `code`";\n        $res4 = mysqli_query($db, $sql4);\n        $d=0;\n        while($r4 = mysqli_fetch_assoc($res4)) {\n          $dt[\'data\'][$a][\'items\'][$b][\'items\'][$c][\'items\'][$d]=$r4;\n          $dt[\'data\'][$a][\'items\'][$b][\'items\'][$c][\'items\'][$d][\'cd\']=substr($r4[\'code\'],1);\n          $dt[\'data\'][$a][\'items\'][$b][\'items\'][$c][\'items\'][$d][\'rp\']=ang2($r4[\'s2025\']);\n          //echo "- - - ".$r4[\'code\']." (".$r4[\'name\'].") [".ang2($r4[\'s2025\'])."]<br>";\n          $sql5 = "select `id`,`name`,`code`,`remark`,`s2025`,`level` from `fcode` where del=0 and parent=".$r4[\'id\']." order by `code`";\n          $res5 = mysqli_query($db, $sql5);\n          $e=0;\n          while($r5 = mysqli_fetch_assoc($res5)) {\n            $dt[\'data\'][$a][\'items\'][$b][\'items\'][$c][\'items\'][$d][\'items\'][$e]=$r5;\n            $dt[\'data\'][$a][\'items\'][$b][\'items\'][$c][\'items\'][$d][\'items\'][$e][\'rp\']=ang2($r5[\'s2025\']);\n            //echo "- - - - ".$r5[\'code\']." (".$r5[\'name\'].")<br>";\n            $e++;\n          }   \n          $d++;\n        }   \n        $c++;\n      } \n      $b++;  \n    } \n    $a++;  \n  }   \n  \n  return $dt;\n  $db->close();\n}','php','0','2','1','1748786730');
INSERT INTO `cp_sphp` VALUES ('34','api','tes_equ_count','function tes_equ_count(){\n  global $ar,$db;\n  $dt=array();\n  $sql="update `fcode` set s2025=0";\n  $res=mysqli_query($db,$sql);\n\n  $ar[\'fcode\'][\'level4\']=array(\'b3201\',\'b3202\',\'b3203\',\'b3204\',\'b3205\',\'b3206\',\'b3207\',\'b3208\',\'b3209\',\'b3210\');\n\n  $ar[\'fcode\'][\'level3\']=array(\'b11\',\'b12\',\'b21\',\'b31\',\'b32\',\'b33\',\'c11\',\'c12\',\'c21\',\'c31\',\'c41\',\'c51\',\'c61\',\'c62\',\'c71\',\'c81\');\n  /*\n  $ar[\'fcode\'][\'level2\']=array(\'a01\', \'a02\', \'a03\', \'a04\', \'a05\', \'a06\', \'a07\', \'a08\', \'a09\', \'a10\', \'b11\', \'b12\', \'b21\', \'b33\', \'c1\', \'c2\', \'d1\', \'d2\', \'d3\', \'d4\', \'m1\', \'m2\');\n  */\n  $ar[\'fcode\'][\'level2\']=array(\'a01\', \'a02\', \'a03\', \'a04\', \'a05\', \'a06\', \'a07\', \'a08\', \'a09\', \'a10\', \'b11\', \'b12\', \'b21\', \'b33\',\'b1\',\'b2\', \'c1\', \'c2\');\n\n  $sql = "select a.*, b.descr as descr,b.seq as seq from account_equation a JOIN `action` b ON a.action_id=b.id where a.st>0 ";\n  \n    $sql .= " and a.`year`=\'".date("Y")."\' ";\n\n  \n  //$sql .= " order by a.".$sortby." asc, a.id asc";\n  $res = mysqli_query($db, $sql);\n    foreach ($ar[\'equ\'] as $k => $v) {\n      $j[$v]=0;\n    }\n\n  while($rw = mysqli_fetch_assoc($res)) {\n    foreach ($ar[\'equ\'] as $k1 => $v1) {\n      $j[$v1]=$j[$v1]+$rw[$v1];\n    } \n  }\n\n  $j[\'aktiva_lancar\']=$j[\'c11\']=$j[\'c11101\']+$j[\'c11201\']+$j[\'c11202\']+$j[\'c11203\']+$j[\'c11204\']+$j[\'c11205\'];\n\n  $j[\'aktiva_tak_lancar\']=$j[\'c12\']=$j[\'c12101\']+$j[\'c12201\']+$j[\'c12202\']+$j[\'c12301\']+$j[\'c12302\']+$j[\'c12401\']+$j[\'c12402\'];\n\n  $j[\'utang\']=$j[\'c21\']=$j[\'c21100\']+$j[\'c22100\']+$j[\'c23100\'];\n\n  $j[\'equity\']=$j[\'c31\']=$j[\'c31100\']+$j[\'c31200\']+$j[\'c31300\'];\n\n  $j[\'pendapatan\']=$j[\'c41\']=$j[\'c41100\']+$j[\'c41200\']+$j[\'c41300\'];\n\n  $j[\'hpp\']=$j[\'c51\']=$j[\'c51100\']+$j[\'c51200\']+$j[\'c51300\'];\n\n  $j[\'beban_penjualan\']=$j[\'c61\']=$j[\'c61101\']+$j[\'c61102\']+$j[\'c61103\']+$j[\'c61104\']+$j[\'c61105\']+$j[\'c61106\'];\n\n  $j[\'beban_administrasi\']=$j[\'c62\']=$j[\'c62101\']+$j[\'c62102\']+$j[\'c62103\']+$j[\'c62104\']+$j[\'c62106\']+$j[\'c62107\'];\n\n  $j[\'pendapatan_lain\']=$j[\'c71\']=$j[\'c71000\'];\n\n  $j[\'beban_lain\']=$j[\'c81\']=$j[\'c81100\']+$j[\'c81200\'];\n\n  $j[\'beban\']=$j[\'beban_penjualan\']+$j[\'beban_administrasi\'];\n\n  $j[\'aktiva\']=$j[\'aktiva_lancar\']+$j[\'aktiva_tak_lancar\'];\n\n  $j[\'laba_kotor\']=$j[\'pendapatan\']+$j[\'hpp\']+$j[\'beban_penjualan\'];\n\n  $j[\'laba_sebelum_pph\']=$j[\'laba_kotor\']+$j[\'beban_administrasi\']+$j[\'pendapatan_lain\']+$j[\'beban_lain\'];\n\n  $j[\'pph\']=0;\n\n  $j[\'laba_setelah_pph\']=$j[\'laba_bersih\']=$j[\'laba_sebelum_pph\']-$j[\'pph\'];\n\n  $j[\'pasiva\']=$j[\'utang\']+$j[\'equity\']+$j[\'laba_setelah_pph\']; \n\n  //level4\n  $j[\'b3201\']=$j[\'c41\'];\n  $j[\'b3202\']=$j[\'c51\'];\n  $j[\'b3203\']=$j[\'c61\'];\n  $j[\'b3204\']=$j[\'b3201\']+$j[\'b3202\']+$j[\'b3203\'];\n  $j[\'b3205\']=$j[\'c62\'];\n  $j[\'b3206\']=$j[\'c71\'];\n  $j[\'b3207\']=$j[\'c81\'];\n  $j[\'b3208\']=$j[\'b3204\']+$j[\'b3205\']+$j[\'b3206\']+$j[\'b3207\'];\n  $j[\'b3209\']=$j[\'pph\'];\n  $j[\'b3210\']=$j[\'b3208\']+$j[\'b3209\'];\n\n  //level3;\n  $j[\'b11\']=$j[\'c11\'];\n  $j[\'b12\']=$j[\'c12\'];\n  $j[\'b21\']=$j[\'c21\'];\n  $j[\'b31\']=$j[\'c31\'];\n  $j[\'b32\']=$j[\'b3210\'];\n  $j[\'b33\']=$j[\'c31\']+$j[\'b32\'];\n\n  //level2\n  $j[\'a01\']=$j[\'c41\'];\n  $j[\'a02\']=$j[\'c51\'];\n  $j[\'a03\']=$j[\'c61\'];\n  $j[\'a04\']=$j[\'laba_kotor\'];\n  $j[\'a05\']=$j[\'c62\'];\n  $j[\'a06\']=$j[\'c71\'];\n  $j[\'a07\']=$j[\'c81\'];\n  $j[\'a08\']=$j[\'laba_sebelum_pph\'];\n  $j[\'a09\']=$j[\'pph\'];\n  $j[\'a10\']=$j[\'laba_setelah_pph\'];\n\n  $j[\'b1\']=$j[\'b11\']+$j[\'b12\'];\n  $j[\'b2\']=$j[\'b21\']+$j[\'b33\'];\n\n  $j[\'c1\']=$j[\'c11\']+$j[\'c12\'];\n  $j[\'c2\']=$j[\'pasiva\'];\n\n  foreach ($ar[\'equ\'] as $k1 => $v1) {  \n    $udt=array(\n      \'s2025\'=>$j[$v1],\n    );\n    $dt[\'sql\'][]=Update_v2($db,"fcode",$udt,"code=\'".$v1."\'",1);\n  } \n  foreach ($ar[\'fcode\'][\'level4\'] as $k => $v) {\n    $udt=array(\n      \'s2025\'=>$j[$v],\n    );\n    $dt[\'sql\'][]=Update_v2($db,"fcode",$udt,"code=\'".$v."\'",1);\n  }\n  foreach ($ar[\'fcode\'][\'level3\'] as $k => $v) {\n    $udt=array(\n      \'s2025\'=>$j[$v],\n    );\n    $dt[\'sql\'][]=Update_v2($db,"fcode",$udt,"code=\'".$v."\'",1);\n  }\n  foreach ($ar[\'fcode\'][\'level2\'] as $k => $v) {\n    $udt=array(\n      \'s2025\'=>$j[$v],\n    );\n    $dt[\'sql\'][]=Update_v2($db,"fcode",$udt,"code=\'".$v."\'",1);\n  }\n  $dt[\'count\']=$j;\n  return $dt; \n}','php','0','2','1','1748781864');
INSERT INTO `cp_sphp` VALUES ('35','api','journal','function journal($year=2025){\n  global $ar,$db;\n  $dt=array();\n\n  $sql="SELECT account_code from journal where `year`=".$year." group by account_code";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res)>0) {  \n    $dt[\'success\']=true;\n    $a=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'data\'][$r1[\'account_code\']][\'name\']=$ar[\'acc_name\'][$r1[\'account_code\']];\n      //$dt[\'data\'][\'title\']=$ar[\'acc_name\'][$r1[\'account_code\']];\n      $sql2="SELECT a.*,b.descr,b.img from `journal` a JOIN `action` b ON a.action_id=b.id where a.account_code=\'".$r1[\'account_code\']."\' and a.`year`=".$year." order by seq";\n      $res2=mysqli_query($db,$sql2);\n      $b=0;\n      while($r2=mysqli_fetch_assoc($res2)) {\n    if($r2[\'inout\']==2) {\n      $rp="-".ang2($r2[\'amount\']);\n      $col="red";\n      //$p3=$r2[\'pay_to\'];       \n    } else {\n      $rp=ang2($r2[\'amount\']);\n      $col="green"; \n      //$p3=$r2[\'pay_from\'];       \n    }\n      \n        $dt[\'data\'][$r1[\'account_code\']][\'items\'][$b]=$r2;\n        $dt[\'data\'][$r1[\'account_code\']][\'items\'][$b][\'image\']=$ar[\'imgurl\']."".$r2[\'img\'];  \n        $dt[\'data\'][$r1[\'account_code\']][\'items\'][$b][\'rp\']=$rp;\n        $dt[\'data\'][$r1[\'account_code\']][\'items\'][$b][\'col\']=$col;\n        $dt[\'data\'][$r1[\'account_code\']][\'items\'][$b][\'tgl\']=date("Y-m-d",$r2[\'action_at\']);\n        $dt[\'data\'][$r1[\'account_code\']][\'items\'][$b][\'rp_debit\']=ang2($r2[\'debit\']);\n        $dt[\'data\'][$r1[\'account_code\']][\'items\'][$b][\'rp_credit\']=ang2($r2[\'credit\']);\n        $dt[\'data\'][$r1[\'account_code\']][\'items\'][$b][\'rp_balance\']=ang2($r2[\'balance\']);\n        $b++;\n      }\n      $a++;\n    }\n\n  } else {\n    $dt[\'error\']=true;\n    $dt[\'message\']="data not found";\n  }\n  return $dt;\n  $db->close();\n}','php','0','2','1','1748672889');
INSERT INTO `cp_sphp` VALUES ('36','api','action_byseq','function action_byseq() {\n  global $ar,$db;\n  $dt=array();\n  $sql="SELECT * from `action` where id>0 order by id desc";\n  $res2=mysqli_query($db,$sql);\n  $d=0;\n  while($r2=mysqli_fetch_assoc($res2)) {\n    //$d=$r2[\'id\'];\n    $dt[$d]=$r2;    \n    if($r2[\'inout\']==2) {\n      $rp="-".ang2($r2[\'amount\']);\n      $col="red";\n      $p3=$r2[\'pay_to\'];       \n    } else {\n      $rp=ang2($r2[\'amount\']);\n      $col="green"; \n      $p3=$r2[\'pay_from\'];       \n    }\n    $dt[$d][\'rp\']=$rp;    \n    $dt[$d][\'col\']=$col;    \n    $dt[$d][\'p3\']=$p3;    \n    $dt[$d][\'image\']=$ar[\'imgurl\']."".$r2[\'img\'];  \n    $dt[$d][\'act_datetime\']=date("Y-m-d H:i:s",$r2[\'action_at\']);\n    $dt[$d][\'act_date\']=date("Y-m-d",$r2[\'action_at\']);\n    $dt[$d][\'act_month\']=date("Y-m",$r2[\'action_at\']);\n    $dt[$d][\'update\']=date("Y-m-d H:i:s",$r2[\'update_at\']);\n    $d++;\n  }\n  return $dt;    \n}','php','0','2','1','1748424079');
INSERT INTO `cp_sphp` VALUES ('37','common','UploadImageData','function UploadImageData($POST,$img_data,$modul) {\n    global $db,$ar;\n    //echo "<pre>"; print_r($POST); echo "</pre>";\n    //echo "<pre>"; print_r($FILES); echo "</pre>";\n    if(isset($POST[\'title\']) && ($POST[\'title\']!=\'\')) {\n        $title=$POST[\'title\'];\n    } else {\n        $title="";\n    }\n    if(isset($POST[\'caption\']) && ($POST[\'caption\']!=\'\')) {\n        $caption=$POST[\'caption\'];\n    } else {\n        $caption="";\n    }\n    //get last id\n    $sql2= "select id from `files` order by id desc limit 1";\n    $res2=mysqli_query($db,$sql2);\n    $r2=mysqli_fetch_assoc($res2);\n\n    if(isset($r2[\'id\']) && ($r2[\'id\']>0)) {\n        $iid=$r2[\'id\']+1;\n    } else {\n        $iid=1;\n    }\n\n    //get last seq\n    $sql9= "select seq from `files` where item_id=".$POST[\'id\']." and modul=\'".$modul."\' order by seq desc limit 1";\n    $res9=mysqli_query($db,$sql9);\n    $r9=mysqli_fetch_assoc($res9);\n\n    if(isset($r9[\'seq\']) && ($r9[\'seq\']>0)) {\n        $seq=$r9[\'seq\']+1;\n    } else {\n        $seq=1;\n    }\n\n    $folder_y=$ar[\'img_path\']."".$modul."/".date("y");\n    if (!is_dir($folder_y)) {\n        mkdir($folder_y, 0777, true);\n    }\n    $folder_ym=$folder_y."/".date("m");\n    if (!is_dir($folder_ym)) {\n        mkdir($folder_ym, 0777, true);\n    }\n\n    $folder_ymd=$folder_ym."/".date("d");\n    if (!is_dir($folder_ymd)) {\n        mkdir($folder_ymd, 0777, true);\n    }\n\n    $folder_ymdh=$folder_ymd."/".date("H");\n    if (!is_dir($folder_ymdh)) {\n        mkdir($folder_ymdh, 0777, true);\n    }\n\n    $folder_main=$folder_ymdh."/".$POST[\'id\'];\n\n    if (!is_dir($folder_main)) {\n        mkdir($folder_main, 0777, true);\n    }\n    $folder_seq=$folder_main."/".$seq;\n    if (!is_dir($folder_seq)) {\n        mkdir($folder_seq, 0777, true);\n    }\n\n    $folder_tmp=$folder_seq."/tmp";\n    if (!is_dir($folder_tmp)) {\n        mkdir($folder_tmp, 0777, true);\n    }\n\n    /*$sub_folder=$_POST[\'id\']."/".$seq."/";\n    switch($_POST[\'file_type\']) {\n      case "Image";\n\n    }*/\n\n    $path=date("y")."/".date("m")."/".date("d")."/".date("H")."/".$POST[\'id\'];;\n    $data=$img_data;\n    $image_info = getimagesize($img_data);\n    $extension = (isset($image_info["mime"]) ? explode(\'/\', $image_info["mime"] )[1]: "");\n    $file_name=date("YmdHis").".".$extension;\n\n    $data = str_replace(\'data:image/\'.$extension.\';base64,\', \'\', $data);\n    $data = str_replace(\' \',\'+\',$data);\n    $bin = base64_decode($data);\n    if ($bin === false) {\n      //$dt[\'info\']="convert invalid";  \n    }\n    //$img = imageCreateFromString($bin);\n    //tmp file\n    $tmp_file=$folder_tmp.\'/\'.$file_name;\n    file_put_contents($tmp_file, $bin);\n\n    $sub_folder=$folder_seq."/image";\n    $sub_folder_big=$folder_seq."/image/big";\n    $sub_folder_medium=$folder_seq."/image/medium";\n    $sub_folder_small=$folder_seq."/image/small";\n\n    if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); }\n    if(!is_dir($sub_folder_big)){ mkdir($sub_folder_big, 0755); }\n    if(!is_dir($sub_folder_medium)){ mkdir($sub_folder_medium, 0755); }\n    if(!is_dir($sub_folder_small)){ mkdir($sub_folder_small, 0755); }\n\n    $source_image=$tmp_file;\n    $img_big= $sub_folder_big."/".$file_name;\n    $img_medium= $sub_folder_medium."/".$file_name;\n    $img_small= $sub_folder_small."/".$file_name;\n    //$destination=$ar[\'img_path\']."".$img_url;\n    //resize(640, $destination, $source_image);\n    image_handler($source_image,$img_big,1080,1080,90,false);\n    image_handler($source_image,$img_medium,800,800,90,false);\n    image_handler($source_image,$img_small,150,150,90,false);\n\n    $udata2=array(\n      \'id\'=>$iid,\n      \'seq\'=>$seq,\n      \'modul\'=>$modul,\n      \'item_id\'=>$POST[\'id\'],\n      \'type\'=>\'image\',\n      \'title\'=>gpc($title),\n      \'caption\'=>gpc($caption),\n      \'url_original\'=>"temp/".$file_name,\n      \'create_at\'=>time(),\n      \'path\'=>$path,\n      \'url\'=>$file_name\n      );\n    Insert($db,"files",$udata2,0);\n\n    $udt2=array(\n      \'img\'=>$modul."/".$path."/".$seq."/image/small/".$file_name,\n    );\n    Update($db,$modul,$udt2,"id=".$POST[\'id\']);\n}','php','0','2','3','1748687899');
INSERT INTO `cp_sphp` VALUES ('38','common','genToken','function genToken($length = 10) {\n  $characters = \'abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPRSTUVWXYZ_@!)(^%\';\n  $charactersLength = strlen($characters);\n  $randomString = \'\';\n  for ($i = 0; $i < $length; $i++) {\n      $randomString .= $characters[rand(0, $charactersLength - 1)];\n  }\n  return $randomString;\n}','php','0','2','3','1748687964');
INSERT INTO `cp_sphp` VALUES ('39','common','arCss','function arCss($css) {\n  $cleanCss = [];\n\n  // Remove css comments\n  $clean1 = explode(\'/*\', $css);\n  foreach($clean1 as $clean2) {\n      $clean3 = explode(\'*/\', $clean2);\n      $cleanCss[] = $clean3[count($clean3) -1];\n  }\n  $css = implode(\'\', $cleanCss);\n  $temp = explode(\'}\', $css);\n  $params = [];\n  $type = \'all\';\n  $nextBracketIsNotMediaEnd = false;\n  foreach($temp as $tem2) {\n      $data = explode(\'{\', $tem2);\n      if (count($data) == 1) {\n          if ($nextBracketIsNotMediaEnd) {\n              $nextBracketIsNotMediaEnd = false;\n          } else {\n              $type = \'all\';\n              continue;\n          }\n      }\n      if (count($data) == 3) {\n          $typeTemp = trim($data[0]);\n          if (substr( $typeTemp, 0, 6 ) === "@media" ) {\n              $type = $typeTemp;\n              array_shift($data);\n          } else {\n              $data[1] = $data[0].$data[1];\n              $nextBracketIsNotMediaEnd = true;\n          }\n      }\n      if (count($data) == 2) {\n          $rows = explode(\';\',$data[1]);\n\n          $tempData = [];\n          foreach($rows as $row) {\n              $paramsinline = explode(\':\', $row);\n              if (empty($paramsinline[0]) || empty($paramsinline[1])){\n                  continue;\n              }\n              $tempData[trim($paramsinline[0])] = trim($paramsinline[1]);\n          }\n          $selector = trim($data[0]);\n          if (!empty($tempData)) {\n              if (empty($params[$type][$selector])) {\n                  $params[$type][$selector] = $tempData;\n              } else {\n                  $params[$type][$selector] = array_merge($params[$type][$selector], $tempData);\n              }\n          }\n      }\n  }\n  return $params; \n}','php','0','2','3','1748687993');
INSERT INTO `cp_sphp` VALUES ('40','common','genRandom','function genRandom($length = 10) {\n    $characters = \'1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ\';\n    $charactersLength = strlen($characters);\n    $randomString = \'\';\n    for ($i = 0; $i < $length; $i++) {\n        $randomString .= $characters[rand(0, $charactersLength - 1)];\n    }\n    return $randomString;\n}','php','0','2','3','1748688025');
INSERT INTO `cp_sphp` VALUES ('41','common','genCode','function genCode($length = 10) {\n    $characters = \'abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPRSTUVWXYZ\';\n    $charactersLength = strlen($characters);\n    $randomString = \'\';\n    for ($i = 0; $i < $length; $i++) {\n        $randomString .= $characters[rand(0, $charactersLength - 1)];\n    }\n    return $randomString;\n}','php','0','2','3','1748688046');
INSERT INTO `cp_sphp` VALUES ('42','common','getUserIP','function getUserIP(){\n  $client  = @$_SERVER[\'HTTP_CLIENT_IP\'];\n  $forward = @$_SERVER[\'HTTP_X_FORWARDED_FOR\'];\n  $remote  = $_SERVER[\'REMOTE_ADDR\'];\n\n  if(filter_var($client, FILTER_VALIDATE_IP)){\n      $ip = $client;\n  }\n  elseif(filter_var($forward, FILTER_VALIDATE_IP)){\n      $ip = $forward;\n  }\n  else{\n      $ip = $remote;\n  }\n  return $ip;\n}','php','0','2','3','1748688096');
INSERT INTO `cp_sphp` VALUES ('43','common','emptyDir','function emptyDir($dir) {\n  if (is_dir($dir)) {\n    $scn = scandir($dir);\n    foreach ($scn as $files) {\n      if ($files !== \'.\') {\n        if ($files !== \'..\') {\n          if (!is_dir($dir . \'/\' . $files)) {\n            unlink($dir . \'/\' . $files);\n          } else {\n            emptyDir($dir . \'/\' . $files);\n            rmdir($dir . \'/\' . $files);\n          }\n        }\n      }\n    }\n  }\n}','php','0','2','3','1748688148');
INSERT INTO `cp_sphp` VALUES ('44','common','slug','function slug($text){\n  // replace non letter or digits by -\n  $text = preg_replace(\'~[^pLd]+~u\', \'-\', $text);\n  // transliterate\n  $text = iconv(\'utf-8\', \'us-ascii//TRANSLIT\', $text);\n  // remove unwanted characters\n  $text = preg_replace(\'~[^-w]+~\', \'\', $text);\n  // trim\n  $text = trim($text, \'-\');\n  // remove duplicate -\n  $text = preg_replace(\'~-+~\', \'-\', $text);\n  // lowercase\n  $text = strtolower($text);\n  if (empty($text)) {\n    return \'n-a\';\n  }\n  return $text;\n}','php','0','2','3','1748688192');
INSERT INTO `cp_sphp` VALUES ('45','common','image_resize','function image_resize($newWidth, $targetFile, $originalFile) {\n  $info = getimagesize($originalFile);\n  $mime = $info[\'mime\'];\n\n  switch ($mime) {\n    case \'image/jpeg\':\n      $image_create_func = \'imagecreatefromjpeg\';\n      $image_save_func = \'imagejpeg\';\n      $new_image_ext = \'jpg\';\n      break;\n\n    case \'image/png\':\n      $image_create_func = \'imagecreatefrompng\';\n      $image_save_func = \'imagepng\';\n      $new_image_ext = \'png\';\n      break;\n\n    case \'image/gif\':\n      $image_create_func = \'imagecreatefromgif\';\n      $image_save_func = \'imagegif\';\n      $new_image_ext = \'gif\';\n      break;\n\n    default: \n      throw new Exception(\'Unknown image type.\');\n  }\n\n  $img = $image_create_func($originalFile);\n  list($width, $height) = getimagesize($originalFile);\n  $newHeight = ($height / $width) * $newWidth;\n  $tmp = imagecreatetruecolor($newWidth, $newHeight);\n  imagecopyresampled($tmp, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);\n  if (file_exists($targetFile)) {\n    unlink($targetFile);\n  }\n  $image_save_func($tmp, "$targetFile");\n}','php','0','2','3','1748692193');
INSERT INTO `cp_sphp` VALUES ('46','common','image_resize_w_mark','function image_resize_w_mark($img_src,$img_dst,$new_w,$quality=80,$wmsource=false) {\n  // The getimagesize functions provides an "imagetype" string contstant, which can be passed to the image_type_to_mime_type function for the corresponding mime type\n  $info = getimagesize($img_src);\n  $imgtype = image_type_to_mime_type($info[2]);\n  // Then the mime type can be used to call the correct function to generate an image resource from the provided image\n  switch ($imgtype) {\n  case \'image/jpeg\':\n    $source = imagecreatefromjpeg($img_src);\n    break;\n  case \'image/gif\':\n    $source = imagecreatefromgif($img_src);\n    break;\n  case \'image/png\':\n    $source = imagecreatefrompng($img_src);\n    break;\n  default:\n    die($img_src.\'Invalid image type.\');\n  }\n  // Now, we can determine the dimensions of the provided image, and calculate the width/height ratio\n  $src_w = imagesx($source);\n  $src_h = imagesy($source);\n  $src_ratio = $src_h/$src_w;\n  // Now we can use the power of math to determine whether the image needs to be cropped to fit the new dimensions, and if so then whether it should be cropped vertically or horizontally. We\'re just going to crop from the center to keep this simple.\n  \n  /*\n  if ($tn_w/$tn_h > $src_ratio) {\n  $new_h = $tn_w/$src_ratio;\n  $new_w = $tn_w;\n  } else {\n  $new_w = $tn_h*$src_ratio;\n  $new_h = $tn_h;\n  }\n  */\n  \n  $new_h=$new_w*$src_ratio;\n  $tn_w=$new_w;\n  $tn_h=$new_h;\n  \n  $x_mid = $new_w/2;\n  $y_mid = $new_h/2;\n\n  // Now actually apply the crop and resize!\n  $newpic = imagecreatetruecolor(round($new_w), round($new_h));\n  imagecopyresampled($newpic, $source, 0, 0, 0, 0, $new_w, $new_h, $src_w, $src_h);\n  $final = imagecreatetruecolor($tn_w, $tn_h);\n  imagecopyresampled($final, $newpic, 0, 0, ($x_mid-($tn_w/2)), ($y_mid-($tn_h/2)), $tn_w, $tn_h, $tn_w, $tn_h);\n  // If a watermark source file is specified, get the information about the watermark as well. This is the same thing we did above for the source image.\n  if($wmsource) {\n  $info = getimagesize($wmsource);\n  $imgtype = image_type_to_mime_type($info[2]);\n  switch ($imgtype) {\n    case \'image/jpeg\':\n      $watermark = imagecreatefromjpeg($wmsource);\n      break;\n    case \'image/gif\':\n      $watermark = imagecreatefromgif($wmsource);\n      break;\n    case \'image/png\':\n      $watermark = imagecreatefrompng($wmsource);\n      break;\n    default:\n      die(\'Invalid watermark type.\');\n  }\n  // Determine the size of the watermark, because we\'re going to specify the placement from the top left corner of the watermark image, so the width and height of the watermark matter.\n  $wm_w = imagesx($watermark);\n  $wm_h = imagesy($watermark);\n  // Now, figure out the values to place the watermark in the bottom right hand corner. You could set one or both of the variables to "0" to watermark the opposite corners, or do your own math to put it somewhere else.\n  $wm_x = ($tn_w - $wm_w)/2;\n  $wm_y = ($tn_h - $wm_h)/2;\n  // Copy the watermark onto the original image\n  // The last 4 arguments just mean to copy the entire watermark\n  imagecopy($final, $watermark, $wm_x, $wm_y, 0, 0, $wm_w, $wm_h);\n  }\n  // Ok, save the output as a jpeg, to the specified img_dst path at the desired quality.\n  // You could use imagepng or imagegif here if you wanted to output those file types instead.\n  if(Imagejpeg($final,$img_dst,$quality)) {\n  return true;\n  }\n  // If something went wrong\n  return false;\n}','php','0','2','3','1748693189');
INSERT INTO `cp_sphp` VALUES ('47','common','image_handler','function image_handler($source_image,$destination,$tn_w = 100,$tn_h = 100,$quality = 80,$wmsource = false) {\n  // The getimagesize functions provides an "imagetype" string contstant, which can be passed to the image_type_to_mime_type function for the corresponding mime type\n  $info = getimagesize($source_image);\n  $imgtype = image_type_to_mime_type($info[2]);\n  // Then the mime type can be used to call the correct function to generate an image resource from the provided image\n  switch ($imgtype) {\n  case \'image/jpeg\':\n    $source = imagecreatefromjpeg($source_image);\n    break;\n  case \'image/gif\':\n    $source = imagecreatefromgif($source_image);\n    break;\n  case \'image/png\':\n    $source = imagecreatefrompng($source_image);\n    break;\n  default:\n    die($source_image.\'Invalid image type.\');\n  }\n  // Now, we can determine the dimensions of the provided image, and calculate the width/height ratio\n  $src_w = imagesx($source);\n  $src_h = imagesy($source);\n  $src_ratio = $src_w/$src_h;\n  // Now we can use the power of math to determine whether the image needs to be cropped to fit the new dimensions, and if so then whether it should be cropped vertically or horizontally. We\'re just going to crop from the center to keep this simple.\n  if ($tn_w/$tn_h > $src_ratio) {\n  $new_h = $tn_w/$src_ratio;\n  $new_w = $tn_w;\n  } else {\n  $new_w = $tn_h*$src_ratio;\n  $new_h = $tn_h;\n  }\n  $x_mid = $new_w/2;\n  $y_mid = $new_h/2;\n  // Now actually apply the crop and resize!\n  $newpic = imagecreatetruecolor(round($new_w), round($new_h));\n  imagecopyresampled($newpic, $source, 0, 0, 0, 0, $new_w, $new_h, $src_w, $src_h);\n  $final = imagecreatetruecolor($tn_w, $tn_h);\n  imagecopyresampled($final, $newpic, 0, 0, ($x_mid-($tn_w/2)), ($y_mid-($tn_h/2)), $tn_w, $tn_h, $tn_w, $tn_h);\n  // If a watermark source file is specified, get the information about the watermark as well. This is the same thing we did above for the source image.\n  if($wmsource) {\n  $info = getimagesize($wmsource);\n  $imgtype = image_type_to_mime_type($info[2]);\n  switch ($imgtype) {\n    case \'image/jpeg\':\n      $watermark = imagecreatefromjpeg($wmsource);\n      break;\n    case \'image/gif\':\n      $watermark = imagecreatefromgif($wmsource);\n      break;\n    case \'image/png\':\n      $watermark = imagecreatefrompng($wmsource);\n      break;\n    default:\n      die(\'Invalid watermark type.\');\n  }\n  // Determine the size of the watermark, because we\'re going to specify the placement from the top left corner of the watermark image, so the width and height of the watermark matter.\n  $wm_w = imagesx($watermark);\n  $wm_h = imagesy($watermark);\n  // Now, figure out the values to place the watermark in the bottom right hand corner. You could set one or both of the variables to "0" to watermark the opposite corners, or do your own math to put it somewhere else.\n  $wm_x = ($tn_w - $wm_w)/2;\n  $wm_y = ($tn_h - $wm_h)/2;\n  // Copy the watermark onto the original image\n  // The last 4 arguments just mean to copy the entire watermark\n  imagecopy($final, $watermark, $wm_x, $wm_y, 0, 0, $wm_w, $wm_h);\n  }\n  // Ok, save the output as a jpeg, to the specified destination path at the desired quality.\n  // You could use imagepng or imagegif here if you wanted to output those file types instead.\n  if(Imagejpeg($final,$destination,$quality)) {\n  return true;\n  }\n  // If something went wrong\n  return false;\n}','php','0','2','3','1748688345');
INSERT INTO `cp_sphp` VALUES ('48','common','UploadImage','function UploadImage($POST,$FILES,$modul) {\n  global $db,$ar;\n  if(isset($POST[\'title\']) && ($POST[\'title\']!=\'\')) {\n      $title=$POST[\'title\'];\n  } else {\n      $title="";\n  }\n  if(isset($POST[\'caption\']) && ($POST[\'caption\']!=\'\')) {\n      $caption=$POST[\'caption\'];\n  } else {\n      $caption="";\n  }\n  //get last id\n  $sql2= "select id from `files` order by id desc limit 1";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_fetch_assoc($res2);\n\n  if(isset($r2[\'id\']) && ($r2[\'id\']>0)) {\n      $iid=$r2[\'id\']+1;\n  } else {\n      $iid=1;\n  }\n\n  //get last seq\n  $sql9= "select seq from `files` where item_id=".$POST[\'id\']." and modul=\'".$modul."\' order by seq desc limit 1";\n  echo $sql9."<br>";\n  $res9=mysqli_query($db,$sql9);\n  $r9=mysqli_fetch_assoc($res9);\n\n  if(isset($r9[\'seq\']) && ($r9[\'seq\']>0)) {\n    $seq=$r9[\'seq\']+1;\n  } else {\n    $seq=1;\n  }\n\n  $folder_y=$ar[\'img_path\'].$modul."/".date("y");\n  if (!is_dir($folder_y)) {\n    mkdir($folder_y, 0777, true);\n  }\n  $folder_ym=$folder_y."/".date("m");\n  if (!is_dir($folder_ym)) {\n    mkdir($folder_ym, 0777, true);\n  }\n\n  $folder_ymd=$folder_ym."/".date("d");\n  if (!is_dir($folder_ymd)) {\n    mkdir($folder_ymd, 0777, true);\n  }\n\n  $folder_ymdh=$folder_ymd."/".date("H");\n  if (!is_dir($folder_ymdh)) {\n    mkdir($folder_ymdh, 0777, true);\n  }\n\n  $folder_main=$folder_ymdh."/".$POST[\'id\'];\n  if (!is_dir($folder_main)) {\n    mkdir($folder_main, 0777, true);\n  }\n  $folder_seq=$folder_main."/".$seq;\n  if (!is_dir($folder_seq)) {\n    mkdir($folder_seq, 0777, true);\n  }\n  $folder_tmp=$folder_seq."/tmp";\n  if (!is_dir($folder_tmp)) {\n    mkdir($folder_tmp, 0777, true);\n  }\n\n  /*$sub_folder=$_POST[\'id\']."/".$seq."/";\n  switch($_POST[\'file_type\']) {\n    case "Image";\n\n  }*/\n\n  $path=date("y")."/".date("m")."/".date("d")."/".date("H")."/".$POST[\'id\'];\n  $e_ext=explode("/",$FILES[\'file\'][\'type\']);\n  $file_name=date("YmdHis").".".$e_ext[1];\n\n  if($POST[\'file_type\']==\'image\') {\n    if (move_uploaded_file($FILES[\'file\'][\'tmp_name\'], $folder_tmp.\'/\'. $FILES["file"][\'name\'])) {\n      //echo "Image Card Front Uploaded";\n      //$file_name=date("YmdHis").".jpg";\n\n\n      $sub_folder=$folder_seq."/image";\n      $sub_folder_big=$folder_seq."/image/big";\n      $sub_folder_medium=$folder_seq."/image/medium";\n      $sub_folder_small=$folder_seq."/image/small";\n\n      if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); }\n      if(!is_dir($sub_folder_big)){ mkdir($sub_folder_big, 0755); }\n      if(!is_dir($sub_folder_medium)){ mkdir($sub_folder_medium, 0755); }\n      if(!is_dir($sub_folder_small)){ mkdir($sub_folder_small, 0755); }\n\n      $source_image=$folder_tmp.\'/\'. $FILES["file"][\'name\'];\n      $img_big= $sub_folder_big."/".$file_name;\n      $img_medium= $sub_folder_medium."/".$file_name;\n      $img_small= $sub_folder_small."/".$file_name;\n      //$destination=$ar[\'img_path\']."".$img_url;\n      //resize(640, $destination, $source_image);\n      image_handler($source_image,$img_big,1080,1080,90,false);\n      image_handler($source_image,$img_medium,800,800,90,false);\n      image_handler($source_image,$img_small,150,150,90,false);\n\n      echo $sub_folder_small."<br>";\n\n      $udata2=array(\n        \'id\'=>$iid,\n        \'seq\'=>$seq,\n        \'modul\'=>$modul,\n        \'item_id\'=>$POST[\'id\'],\n        \'type\'=>\'image\',\n        \'title\'=>gpc($title),\n        \'caption\'=>gpc($caption),\n        \'url_original\'=>\'tmp/\'.$FILES["file"][\'name\'],\n        \'create_at\'=>time(),\n        \'path\'=>$path,\n        \'url\'=>$file_name\n        );\n      Insert($db,"files",$udata2,1);\n\n      $udt2=array(\n        \'img\'=>$modul."/".$path."/".$seq."/image/small/".$file_name,\n      );\n      Update($db,$modul,$udt2,"id=".$POST[\'id\'],1);\n    }\n  } else {\n    if (move_uploaded_file($FILES[\'file\'][\'tmp_name\'], $folder_seq.\'/\'.$file_name)) {\n      //echo "Image Card Front Uploaded";\n      $udata2=array(\n        \'id\'=>$iid,\n        \'seq\'=>$seq,\n        \'modul\'=>$modul,\n        \'item_id\'=>$POST[\'id\'],\n        \'type\'=>$POST[\'file_type\'],\n        \'title\'=>gpc($title),\n        \'caption\'=>gpc($caption),\n        \'url_original\'=>\'tmp/\'.$FILES["file"][\'name\'],\n        \'create_at\'=>time(),\n        \'path\'=>$path,\n        \'url\'=>$file_name,\n        );\n      Insert($db,"files",$udata2,0);\n    }\n  }   \n}','php','0','2','3','1748688515');
INSERT INTO `cp_sphp` VALUES ('49','common','CopyUrlImage','function CopyUrlImage($POST,$modul) {\n  global $db,$ar;\n  if(isset($POST[\'title\']) && ($POST[\'title\']!=\'\')) {\n      $title=$POST[\'title\'];\n  } else {\n      $title="";\n  }\n  if(isset($POST[\'caption\']) && ($POST[\'caption\']!=\'\')) {\n      $caption=$POST[\'caption\'];\n  } else {\n      $caption="";\n  }\n  //get last id\n  $sql2= "select id from `files` order by id desc limit 1";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_fetch_assoc($res2);\n\n  if(isset($r2[\'id\']) && ($r2[\'id\']>0)) {\n      $iid=$r2[\'id\']+1;\n  } else {\n      $iid=1;\n  }\n\n\n  //get last seq\n  $sql9= "select seq from `files` where item_id=".$POST[\'id\']." and modul=\'".$modul."\' order by seq desc limit 1";\n  //echo $sql9."<br>";\n  $res9=mysqli_query($db,$sql9);\n  $r9=mysqli_fetch_assoc($res9);\n\n  if(isset($r9[\'seq\']) && ($r9[\'seq\']>0)) {\n      $seq=$r9[\'seq\']+1;\n  } else {\n      $seq=1;\n  }\n\n  $folder_y=$ar[\'img_path\'].$modul."/".date("y");\n  if (!is_dir($folder_y)) {\n      mkdir($folder_y, 0777, true);\n  }\n  $folder_ym=$folder_y."/".date("m");\n  if (!is_dir($folder_ym)) {\n      mkdir($folder_ym, 0777, true);\n  }\n\n  $folder_ymd=$folder_ym."/".date("d");\n  if (!is_dir($folder_ymd)) {\n      mkdir($folder_ymd, 0777, true);\n  }\n\n  $folder_ymdh=$folder_ymd."/".date("H");\n  if (!is_dir($folder_ymdh)) {\n      mkdir($folder_ymdh, 0777, true);\n  }\n\n  $folder_main=$folder_ymdh."/".$POST[\'id\'];\n\n  if (!is_dir($folder_main)) {\n      mkdir($folder_main, 0777, true);\n  }\n  $folder_seq=$folder_main."/".$seq;\n  if (!is_dir($folder_seq)) {\n      mkdir($folder_seq, 0777, true);\n  }\n\n  $folder_tmp=$folder_seq."/tmp";\n  if (!is_dir($folder_tmp)) {\n      mkdir($folder_tmp, 0777, true);\n  }\n\n  $path=date("y")."/".date("m")."/".date("d")."/".date("H")."/".$POST[\'id\'];\n  if($POST[\'url_img_src\']!=\'\') {\n    $info_img = getimagesize($POST[\'url_img_src\']);\n    $e_ext=explode("/",$info_img[\'mime\']);\n    $file_name=date("YmdHis").".".$e_ext[1];\n    $e_url=explode("/",$POST[\'url_img_src\']);\n\n    copyimg($POST[\'url_img_src\'],$folder_tmp."/".$file_name);\n    //echo "Image Card Front Uploaded";\n    //$file_name=date("YmdHis").".jpg";\n\n\n    $sub_folder=$folder_seq."/image";\n    $sub_folder_big=$folder_seq."/image/big";\n    $sub_folder_medium=$folder_seq."/image/medium";\n    $sub_folder_small=$folder_seq."/image/small";\n\n    if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); }\n    if(!is_dir($sub_folder_big)){ mkdir($sub_folder_big, 0755); }\n    if(!is_dir($sub_folder_medium)){ mkdir($sub_folder_medium, 0755); }\n    if(!is_dir($sub_folder_small)){ mkdir($sub_folder_small, 0755); }\n\n    $source_image=$folder_tmp.\'/\'. $file_name;\n    $img_big= $sub_folder_big."/".$file_name;\n    $img_medium= $sub_folder_medium."/".$file_name;\n    $img_small= $sub_folder_small."/".$file_name;\n    //$destination=$ar[\'img_path\']."".$img_url;\n    //resize(640, $destination, $source_image);\n    image_handler($source_image,$img_big,1080,1080,90,false);\n    image_handler($source_image,$img_medium,800,800,90,false);\n    image_handler($source_image,$img_small,150,150,90,false);\n\n    //echo $sub_folder_small."<br>";\n\n    $udata2=array(\n      \'id\'=>$iid,\n      \'seq\'=>$seq,\n      \'modul\'=>$modul,\n      \'item_id\'=>$POST[\'id\'],\n      \'type\'=>\'image\',\n      \'title\'=>gpc($title),\n      \'caption\'=>gpc($caption),\n      \'url_original\'=>\'tmp/\'.$file_name,\n      \'create_at\'=>time(),\n      \'path\'=>$path,\n      \'url\'=>$file_name\n      );\n    Insert($db,"files",$udata2,0);\n    $udt2=array(\n      \'img\'=>$modul."/".$path."/".$seq."/image/small/".$file_name,\n    );\n    Update($db,$modul,$udt2,"id=".$POST[\'id\'],0);\n  }\n}','php','0','2','3','1748688648');
INSERT INTO `cp_sphp` VALUES ('50','common','getDistance','function getDistance($latitude1, $longitude1, $latitude2, $longitude2) {\n  $theta = $longitude1 - $longitude2;\n  $miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));\n  $miles = acos($miles);\n  $miles = rad2deg($miles);\n  $miles = $miles * 60 * 1.1515;\n  $feet = $miles * 5280;\n  $yards = $feet / 3;\n  $kilometers = $miles * 1.609344;\n  $meters = $kilometers * 1000;\n  //return compact(\'miles\',\'feet\',\'yards\',\'kilometers\',\'meters\'); \n  return $kilometers;\n}','php','0','2','3','1748688710');
INSERT INTO `cp_sphp` VALUES ('51','common','to_tgl','function to_tgl($time) {\n  if($time>0) {\n    $tt=date("Y-m-d H:i:s",$time);\n  } else {\n    $tt="";\n  }    \n  return $tt;\n}','php','0','2','3','1748688779');
INSERT INTO `cp_sphp` VALUES ('52','common','to_hp','function to_hp($ang) {\n  $sid = preg_replace("/[^0-9]/","",$ang);\n\n  $awalan=substr($sid,0,2);\n  if($awalan==\'08\') {\n      $newhp="628".substr($sid,2);\n  } else {\n      $newhp=$sid;\n  }\n\n  return $newhp;\n}','php','0','2','3','1748688814');
INSERT INTO `cp_sphp` VALUES ('53','common','NoSpace','function NoSpace($ang) {\n  $sid = preg_replace("/[^A-Za-z0-9]/","",$ang);\n  return $sid;\n}','php','0','2','3','1748688840');
INSERT INTO `cp_sphp` VALUES ('54','common','to_numeric','function to_numeric($ang) {\n  $sid = preg_replace("/[^0-9]/","",$ang);\n  return $sid;\n}','php','0','2','3','1748688862');
INSERT INTO `cp_sphp` VALUES ('55','common','getimg','function getimg($url) {         \n  $headers[] = \'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg\';              \n  $headers[] = \'Connection: Keep-Alive\';         \n  $headers[] = \'Content-type: application/x-www-form-urlencoded;charset=UTF-8\';         \n  $user_agent = \'php\';         \n  $process = curl_init($url);         \n  curl_setopt($process, CURLOPT_HTTPHEADER, $headers);         \n  curl_setopt($process, CURLOPT_HEADER, 0);         \n  curl_setopt($process, CURLOPT_USERAGENT, $user_agent); //check here         \n  curl_setopt($process, CURLOPT_TIMEOUT, 30);         \n  curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);         \n  curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);         \n  $return = curl_exec($process);         \n  curl_close($process);         \n  return $return;     \n}','php','0','2','3','1748688889');
INSERT INTO `cp_sphp` VALUES ('56','common','copyimg','function copyimg($file,$newfile) {\n  if (copy($file, $newfile)) {\n    //echo "<br>Copy <b>$file</b> success!<br>";\n  }else{\n    //echo "<br>Copy <b>$file</b> failed.<br>";\n  }\n}','php','0','2','3','1748695801');
INSERT INTO `cp_sphp` VALUES ('57','common','viewImage','function viewImage($modul,$item_id) {\n  global $db,$ar;\n  $sql2 = "SELECT * FROM `files` WHERE modul=\'".$modul."\' and item_id=\'".$item_id."\' and `type`=\'image\' ";\n  $run2 = mysqli_query($db, $sql2);\n  $ret= "<hr><h3>Images</h3><div class=\'row mb-20 pb-20\'>";\n  while($r2 = mysqli_fetch_assoc($run2)) {\n    $img_small=$modul."/".$r2[\'path\']."/".$r2[\'seq\']."/image/small/".$r2[\'url\'];\n    $img_big=$modul."/".$r2[\'path\']."/".$r2[\'seq\']."/image/big/".$r2[\'url\'];\n    $ret .= \'\n    <div class="col-sm-3 col-lg-2 col-xs-6">\n      <div class="card">\n    \';\n    $ret .= \'<img src="\'.$ar[\'url_img\'].\'\'.$img_small.\'" alt="">\';\n    $ret .= \'\';\n    $ret .= \'\n      </div>\n    </div>\';\n  }\n  $ret .= "</div>";\n  return $ret;\n}','php','0','2','3','1748692136');
INSERT INTO `cp_sphp` VALUES ('58','common','repl_space','function repl_space($text) {\n  $ret = preg_replace(\'!s+!\', \' \', $text);\n  return $ret;\n}','php','0','2','3','1748689052');
INSERT INTO `cp_sphp` VALUES ('59','common','Insert','function Insert($mysqli,$table,$data,$v=0){\n  //global $mysqli;\n  //print_r($data);\n  $fields = array_keys( $data );  \n  $values = array_map( array($mysqli, \'real_escape_string\'), array_values( $data ) );\n  if($v==1) {\n    echo "INSERT INTO `$table`(`".implode("`,`",$fields)."`) VALUES (\'".implode("\',\'", $values )."\');";\n  }\n  //exit;  \n  mysqli_query($mysqli, "INSERT INTO `$table`(`".implode("`,`",$fields)."`) VALUES (\'".implode("\',\'", $values )."\');") or die( mysqli_error($mysqli) );\n}','php','0','2','3','1748692299');
INSERT INTO `cp_sphp` VALUES ('60','common','InsertUpdate','function InsertUpdate($mysqli,$table_name,$i_data,$u_data,$v=0){   \n  $i_fields = array_keys( $i_data );  \n  $i_values = array_map( array($mysqli, \'real_escape_string\'), array_values( $i_data ) );\n\n  $u_fields = array_keys( $u_data );  \n  $u_values = array_map( array($mysqli, \'real_escape_string\'), array_values( $u_data ) );\n\n  $sql = "INSERT INTO `$table_name` (`".implode("`,`",$i_fields)."`) VALUES (\'".implode("\',\'", $i_values )."\') ";    \n\n  // start the actual SQL statement\n  $sql .= " on duplicate key UPDATE ";\n\n  // loop and build the column /\n  $sets = array();\n  foreach($u_data as $column => $value) {\n       $sets[] = "`".$column."`=\'".$value."\'";\n  }\n  $sql .= implode(\', \', $sets);\n\n  if($v==1) {\n    echo $sql.";<br>";\n  }\n  return mysqli_query($mysqli,$sql);\n}','php','0','2','3','1748692370');
INSERT INTO `cp_sphp` VALUES ('61','common','Update','function Update($mysqli,$table_name, $form_data, $where_clause=\'\',$v=0){   \n  $whereSQL = \'\';\n  if(!empty($where_clause)){\n    // check to see if the \'where\' keyword exists\n    if(substr(strtoupper(trim($where_clause)), 0, 5) != \'WHERE\'){\n        // not found, add key word\n      $whereSQL = " WHERE ".$where_clause;\n    } else {\n      $whereSQL = " ".trim($where_clause);\n    }\n  }\n  // start the actual SQL statement\n  $sql = "UPDATE `".$table_name."` SET ";\n  // loop and build the column /\n  $sets = array();\n  foreach($form_data as $column => $value) {\n    $sets[] = "`".$column."` = \'".$value."\'";\n  }\n  $sql .= implode(\', \', $sets);\n  // append the where statement\n  $sql .= $whereSQL;\n  // run and return the query result\n  if($v==1) {\n    echo $sql."<br>";\n  }\n  return mysqli_query($mysqli,$sql);\n}','php','0','2','3','1748692470');
INSERT INTO `cp_sphp` VALUES ('62','common','Delete','function Delete($mysqli,$table_name, $where_clause=\'\'){   \n  $whereSQL = \'\';\n  if(!empty($where_clause)) {\n    // check to see if the \'where\' keyword exists\n    if(substr(strtoupper(trim($where_clause)), 0, 5) != \'WHERE\') {\n      // not found, add keyword\n      $whereSQL = " WHERE ".$where_clause;\n    } else {\n      $whereSQL = " ".trim($where_clause);\n    }\n  }\n  $sql = "DELETE FROM `".$table_name."` ".$whereSQL;\n  return mysqli_query($mysqli,$sql);\n}','php','0','2','3','1748692539');
INSERT INTO `cp_sphp` VALUES ('63','common','Insert_v2','function Insert_v2($mysqli,$table,$data){\n  $dt=array();\n  $fields = array_keys($data);  \n  $values = array_map(array($mysqli,\'real_escape_string\'),array_values($data));\n  $sql="INSERT INTO `$table` (`".implode("`,`",$fields)."`) VALUES (\'".implode("\',\'",$values)."\')";\n  $dt[\'sql\']=$sql;\n  if(mysqli_query($mysqli,$sql)) {\n    $dt[\'result\']="Success";\n  } else {\n    $dt[\'result\']="Error";    \n  }\n  return json_encode($dt);\n}','php','0','2','3','1748692565');
INSERT INTO `cp_sphp` VALUES ('64','common','InsertUpdate_v2','function InsertUpdate_v2($mysqli,$table_name,$i_data,$u_data){   \n  $dt=array();\n  $i_fields = array_keys($i_data);  \n  $i_values = array_map(array($mysqli, \'real_escape_string\'), array_values($i_data));\n\n  $u_fields = array_keys($u_data);  \n  $u_values = array_map(array($mysqli, \'real_escape_string\'), array_values($u_data));\n\n  $sql = "INSERT INTO `$table_name` (`".implode("`,`",$i_fields)."`) VALUES (\'".implode("\',\'", $i_values)."\')";\n\n  // start the actual SQL statement\n  $sql .= " on duplicate key UPDATE ";\n\n  // loop and build the column /\n  $sets = array();\n  foreach($u_data as $column => $value) {\n       $sets[] = "`".$column."`=\'".$value."\'";\n  }\n  $sql .= implode(\', \', $sets);\n  $dt[\'sql\']=$sql.";";\n  // run and return the query result\n  // return mysqli_query($mysqli,$sql);\n  if(mysqli_query($mysqli,$sql)) {\n    $dt[\'result\']="Success";\n  } else {\n    $dt[\'result\']="Error";    \n  }  \n  return json_encode($dt);\n}','php','0','2','3','1748692586');
INSERT INTO `cp_sphp` VALUES ('65','common','Update_v2','function Update_v2($mysqli,$table_name, $form_data, $where_clause=\'\'){   \n  //global $mysqli;\n  // check for optional where clause\n  $whereSQL = \'\';\n  if(!empty($where_clause)){\n    // check to see if the \'where\' keyword exists\n    if(substr(strtoupper(trim($where_clause)), 0, 5) != \'WHERE\'){\n      // not found, add key word\n      $whereSQL = " WHERE ".$where_clause;\n    } else {\n      $whereSQL = " ".trim($where_clause);\n    }\n  }\n  // start the actual SQL statement\n  $sql = "UPDATE `".$table_name."` SET ";\n\n  // loop and build the column /\n  $sets = array();\n  foreach($form_data as $column => $value){\n    $sets[] = "`".$column."` = \'".$value."\'";\n  }\n  $sql .= implode(\', \', $sets);\n\n  // append the where statement\n  $sql .= $whereSQL;\n       \n  $dt[\'sql\']=$sql.";";\n  // run and return the query result\n  // return mysqli_query($mysqli,$sql);\n  if(mysqli_query($mysqli,$sql)) {\n    $dt[\'result\']="Success";\n  } else {\n    $dt[\'result\']="Error";    \n  }  \n  return json_encode($dt);\n}','php','0','2','3','1748692612');
INSERT INTO `cp_sphp` VALUES ('66','common','Delete_v2','function Delete_v2($db,$table_name, $where_clause=\'\'){   \n  $whereSQL = \'\';\n  if(!empty($where_clause)) {\n    if(substr(strtoupper(trim($where_clause)), 0, 5) != \'WHERE\') {\n      $whereSQL = " WHERE ".$where_clause;\n    } else {\n      $whereSQL = " ".trim($where_clause);\n    }\n  }\n  $sql = "DELETE FROM `".$table_name."` ".$whereSQL;\n  $dt[\'sql\']=$sql.";";\n  if(mysqli_query($db,$sql)) {\n    $dt[\'result\']="Success";\n  } else {\n    $dt[\'result\']="Error";    \n  }  \n  return json_encode($dt);\n}','php','0','2','3','1748692682');
INSERT INTO `cp_sphp` VALUES ('67','common','image_upload_v2','function image_upload_v2($POST,$FILES,$modul) {\n  global $db,$ar;\n  if(isset($POST[\'title\']) && ($POST[\'title\']!=\'\')) {\n      $title=$POST[\'title\'];\n  } else {\n      $title="";\n  }\n  if(isset($POST[\'caption\']) && ($POST[\'caption\']!=\'\')) {\n      $caption=$POST[\'caption\'];\n  } else {\n      $caption="";\n  }\n  //get last id\n  $sql2= "select id from `files` order by id desc limit 1";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_fetch_assoc($res2);\n\n  if(isset($r2[\'id\']) && ($r2[\'id\']>0)) {\n      $iid=$r2[\'id\']+1;\n  } else {\n      $iid=1;\n  }\n\n  //get last seq\n  $sql9= "select seq from `files` where item_id=".$POST[\'id\']." and modul=\'".$modul."\' order by seq desc limit 1";\n  echo $sql9."<br>";\n  $res9=mysqli_query($db,$sql9);\n  $r9=mysqli_fetch_assoc($res9);\n\n  if(isset($r9[\'seq\']) && ($r9[\'seq\']>0)) {\n    $seq=$r9[\'seq\']+1;\n  } else {\n    $seq=1;\n  }\n\n  $folder_y=$ar[\'img_path\'].$modul."/".date("y");\n  if (!is_dir($folder_y)) {\n    mkdir($folder_y, 0777, true);\n  }\n  $folder_ym=$folder_y."/".date("m");\n  if (!is_dir($folder_ym)) {\n    mkdir($folder_ym, 0777, true);\n  }\n\n  $folder_ymd=$folder_ym."/".date("d");\n  if (!is_dir($folder_ymd)) {\n    mkdir($folder_ymd, 0777, true);\n  }\n\n  $folder_ymdh=$folder_ymd."/".date("H");\n  if (!is_dir($folder_ymdh)) {\n    mkdir($folder_ymdh, 0777, true);\n  }\n\n  $folder_main=$folder_ymdh."/".$POST[\'id\'];\n  if (!is_dir($folder_main)) {\n    mkdir($folder_main, 0777, true);\n  }\n  $folder_seq=$folder_main."/".$seq;\n  if (!is_dir($folder_seq)) {\n    mkdir($folder_seq, 0777, true);\n  }\n  $folder_tmp=$folder_seq."/tmp";\n  if (!is_dir($folder_tmp)) {\n    mkdir($folder_tmp, 0777, true);\n  }\n\n  /*$sub_folder=$_POST[\'id\']."/".$seq."/";\n  switch($_POST[\'file_type\']) {\n    case "Image";\n\n  }*/\n\n  $path=date("y")."/".date("m")."/".date("d")."/".date("H")."/".$POST[\'id\'];\n  $e_ext=explode("/",$FILES[\'file\'][\'type\']);\n  $file_name=date("YmdHis").".".$e_ext[1];\n\n  if($POST[\'file_type\']==\'image\') {\n    if (move_uploaded_file($FILES[\'file\'][\'tmp_name\'], $folder_tmp.\'/\'. $FILES["file"][\'name\'])) {\n      //echo "Image Card Front Uploaded";\n      //$file_name=date("YmdHis").".jpg";\n\n\n      $sub_folder=$folder_seq."/image";\n      $sub_folder_big=$folder_seq."/image/big";\n      $sub_folder_medium=$folder_seq."/image/medium";\n      $sub_folder_small=$folder_seq."/image/small";\n\n      if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); }\n      if(!is_dir($sub_folder_big)){ mkdir($sub_folder_big, 0755); }\n      if(!is_dir($sub_folder_medium)){ mkdir($sub_folder_medium, 0755); }\n      if(!is_dir($sub_folder_small)){ mkdir($sub_folder_small, 0755); }\n\n      $source_image=$folder_tmp.\'/\'. $FILES["file"][\'name\'];\n      $img_big= $sub_folder_big."/".$file_name;\n      $img_medium= $sub_folder_medium."/".$file_name;\n      $img_small= $sub_folder_small."/".$file_name;\n      //$destination=$ar[\'img_path\']."".$img_url;\n      //resize(640, $destination, $source_image);\n      image_handler($source_image,$img_big,1080,1080,90,false);\n      image_handler($source_image,$img_medium,800,800,90,false);\n      image_handler($source_image,$img_small,150,150,90,false);\n\n      echo $sub_folder_small."<br>";\n\n      $udata2=array(\n        \'id\'=>$iid,\n        \'seq\'=>$seq,\n        \'modul\'=>$modul,\n        \'item_id\'=>$POST[\'id\'],\n        \'type\'=>\'image\',\n        \'title\'=>gpc($title),\n        \'caption\'=>gpc($caption),\n        \'url_original\'=>\'tmp/\'.$FILES["file"][\'name\'],\n        \'create_at\'=>time(),\n        \'path\'=>$path,\n        \'url\'=>$file_name\n        );\n      Insert($db,"files",$udata2,1);\n\n      $udt2=array(\n        \'img\'=>$modul."/".$path."/".$seq."/image/small/".$file_name,\n      );\n      Update($db,$modul,$udt2,"id=".$POST[\'id\'],1);\n    }\n  } else {\n    if (move_uploaded_file($FILES[\'file\'][\'tmp_name\'], $folder_seq.\'/\'.$file_name)) {\n      //echo "Image Card Front Uploaded";\n      $udata2=array(\n        \'id\'=>$iid,\n        \'seq\'=>$seq,\n        \'modul\'=>$modul,\n        \'item_id\'=>$POST[\'id\'],\n        \'type\'=>$POST[\'file_type\'],\n        \'title\'=>gpc($title),\n        \'caption\'=>gpc($caption),\n        \'url_original\'=>\'tmp/\'.$FILES["file"][\'name\'],\n        \'create_at\'=>time(),\n        \'path\'=>$path,\n        \'url\'=>$file_name,\n        );\n      Insert($db,"files",$udata2,0);\n    }\n  }   \n}','php','0','2','3','1748701148');
INSERT INTO `cp_sphp` VALUES ('68','common','image_from_url','function image_from_url($POST,$modul) {\n  global $db,$ar;\n  if(isset($POST[\'title\']) && ($POST[\'title\']!=\'\')) {\n      $title=$POST[\'title\'];\n  } else {\n      $title="";\n  }\n  if(isset($POST[\'caption\']) && ($POST[\'caption\']!=\'\')) {\n      $caption=$POST[\'caption\'];\n  } else {\n      $caption="";\n  }\n  //get last id\n  $sql2= "select id from `files` order by id desc limit 1";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_fetch_assoc($res2);\n\n  if(isset($r2[\'id\']) && ($r2[\'id\']>0)) {\n      $iid=$r2[\'id\']+1;\n  } else {\n      $iid=1;\n  }\n  //get last seq\n  $sql9= "select seq from `files` where item_id=".$POST[\'id\']." and modul=\'".$modul."\' order by seq desc limit 1";\n  //echo $sql9."<br>";\n  $res9=mysqli_query($db,$sql9);\n  $r9=mysqli_fetch_assoc($res9);\n\n  if(isset($r9[\'seq\']) && ($r9[\'seq\']>0)) {\n      $seq=$r9[\'seq\']+1;\n  } else {\n      $seq=1;\n  }\n\n  $folder_y=$ar[\'img_path\'].$modul."/".date("y");\n  if (!is_dir($folder_y)) {\n      mkdir($folder_y, 0777, true);\n  }\n  $folder_ym=$folder_y."/".date("m");\n  if (!is_dir($folder_ym)) {\n      mkdir($folder_ym, 0777, true);\n  }\n\n  $folder_ymd=$folder_ym."/".date("d");\n  if (!is_dir($folder_ymd)) {\n      mkdir($folder_ymd, 0777, true);\n  }\n\n  $folder_ymdh=$folder_ymd."/".date("H");\n  if (!is_dir($folder_ymdh)) {\n      mkdir($folder_ymdh, 0777, true);\n  }\n\n  $folder_main=$folder_ymdh."/".$POST[\'id\'];\n\n  if (!is_dir($folder_main)) {\n      mkdir($folder_main, 0777, true);\n  }\n  $folder_seq=$folder_main."/".$seq;\n  if (!is_dir($folder_seq)) {\n      mkdir($folder_seq, 0777, true);\n  }\n\n  $folder_tmp=$folder_seq."/tmp";\n  if (!is_dir($folder_tmp)) {\n      mkdir($folder_tmp, 0777, true);\n  }\n\n  $path=date("y")."/".date("m")."/".date("d")."/".date("H")."/".$POST[\'id\'];\n  if($POST[\'url_img_src\']!=\'\') {\n    $info_img = getimagesize($POST[\'url_img_src\']);\n    $e_ext=explode("/",$info_img[\'mime\']);\n    $file_name=date("YmdHis").".".$e_ext[1];\n    $e_url=explode("/",$POST[\'url_img_src\']);\n\n    copyimg($POST[\'url_img_src\'],$folder_tmp."/".$file_name);\n    //echo "Image Card Front Uploaded";\n    //$file_name=date("YmdHis").".jpg";\n\n\n    $sub_folder=$folder_seq."/image";\n    $sub_folder_big=$folder_seq."/image/big";\n    $sub_folder_medium=$folder_seq."/image/medium";\n    $sub_folder_small=$folder_seq."/image/small";\n\n    if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); }\n    if(!is_dir($sub_folder_big)){ mkdir($sub_folder_big, 0755); }\n    if(!is_dir($sub_folder_medium)){ mkdir($sub_folder_medium, 0755); }\n    if(!is_dir($sub_folder_small)){ mkdir($sub_folder_small, 0755); }\n\n    $source_image=$folder_tmp.\'/\'. $file_name;\n    $img_big= $sub_folder_big."/".$file_name;\n    $img_medium= $sub_folder_medium."/".$file_name;\n    $img_small= $sub_folder_small."/".$file_name;\n    //$destination=$ar[\'img_path\']."".$img_url;\n    //resize(640, $destination, $source_image);\n    image_handler($source_image,$img_big,1080,1080,90,false);\n    image_handler($source_image,$img_medium,800,800,90,false);\n    image_handler($source_image,$img_small,150,150,90,false);\n\n    //echo $sub_folder_small."<br>";\n\n    $udata2=array(\n      \'id\'=>$iid,\n      \'seq\'=>$seq,\n      \'modul\'=>$modul,\n      \'item_id\'=>$POST[\'id\'],\n      \'type\'=>\'image\',\n      \'title\'=>gpc($title),\n      \'caption\'=>gpc($caption),\n      \'url_original\'=>\'tmp/\'.$file_name,\n      \'create_at\'=>time(),\n      \'path\'=>$path,\n      \'url\'=>$file_name\n      );\n    Insert($db,"files",$udata2,0);\n    $udt2=array(\n      \'img\'=>$modul."/".$path."/".$seq."/image/small/".$file_name,\n    );\n    Update($db,$modul,$udt2,"id=".$POST[\'id\'],0);\n  }\n}','php','0','2','3','1748692878');
INSERT INTO `cp_sphp` VALUES ('69','common','xhr','function xhr($url){\n  global $ar,$db;\n  include_once $ar[\'path_core\']."dom/request.php";\n  $xhr = request($url);\n  return $xhr;\n}','php','0','2','3','1748693264');
INSERT INTO `cp_sphp` VALUES ('70','common','repl_all_space','function repl_all_space($text) {\n  $ret = preg_replace(\'/s|&nbsp;/\', \'\', $text);\n  return $ret;\n}','php','0','2','3','1748693286');
INSERT INTO `cp_sphp` VALUES ('71','common','repl_class','function repl_class($text) {\n  $ret = preg_replace(\'/ class=".*?"/\', \'\', $text);\n  $ret = preg_replace(\'/ style=".*?"/\', \'\', $ret);\n  $ret = preg_replace(\'/ dir=".*?"/\', \'\', $ret);\n  return $ret;\n}','php','0','2','3','1748693304');
INSERT INTO `cp_sphp` VALUES ('74','common','CommaToDot','function CommaToDot($grade) {\n$grade = str_replace(\',\', \'.\', $grade);\nreturn $grade;\n}','php','0','2','3','1748693469');
INSERT INTO `cp_sphp` VALUES ('75','common','ang2','function ang2($l) {\n  $l=number_format($l, 0, \'.\', \',\');\n  return $l;\n}','php','0','2','3','1748693487');
INSERT INTO `cp_sphp` VALUES ('76','common','ang','function ang($l) {\n  $l=number_format($l, 0, \',\', \'.\');\n  return $l;\n}','php','0','2','3','1748693506');
INSERT INTO `cp_sphp` VALUES ('77','common','dec','function dec($l) {\n  $l=number_format($l, 2, \',\', \'.\');\n  return $l;\n}\nfunction dec1($l) {\n  $l=number_format($l, 1, \',\', \'.\');\n  return $l;\n}\nfunction dec2($l) {\n  $l=number_format($l, 2, \',\', \'.\');\n  return $l;\n}','php','0','2','3','1748763715');
INSERT INTO `cp_sphp` VALUES ('78','common','nodec','function nodec($l) {\n  $l=number_format($l, 0, \'\', \'\');\n  return $l;\n}','php','0','2','3','1748695113');
INSERT INTO `cp_sphp` VALUES ('79','common','find_contains','function find_contains($html, $selector, $keyword, $index=-1) {\n    $ret = array();\n    foreach ($html->find($selector) as $e) {\n        if (strpos($e->innertext, $keyword)!==false)\n            $ret[] = $e;\n    }\n\n    if ($index<0) return $ret;\n    return (isset($ret[$index])) ? $ret[$index] : null;\n}','php','0','2','3','1748695153');
INSERT INTO `cp_sphp` VALUES ('80','common','find_contains_v1','function find_contains_v1($html, $selector, $index=-1) {\n    $ret = array();\n    foreach ($html->find($selector) as $e) {\n            $ret[] = $e;\n    }\n\n    if ($index<0) return $ret;\n    return (isset($ret[$index])) ? $ret[$index] : null;\n}','php','0','2','3','1748695173');
INSERT INTO `cp_sphp` VALUES ('81','common','to_char','function to_char($ang) {\n$sid = preg_replace("/[^A-Za-z]/","",$ang);\nreturn $sid;\n}','php','0','2','3','1748695207');
INSERT INTO `cp_sphp` VALUES ('82','common','image_view','function image_view($modul,$item_id) {\n  global $db,$ar;\n  $sql2 = "SELECT * FROM `files` WHERE modul=\'".$modul."\' and item_id=\'".$item_id."\' and `type`=\'image\' ";\n  $run2 = mysqli_query($db, $sql2);\n  $ret= "<hr><h3>Images</h3><div class=\'row mb-20 pb-20\'>";\n  while($r2 = mysqli_fetch_assoc($run2)) {\n    $img_small=$modul."/".$r2[\'path\']."/".$r2[\'seq\']."/image/small/".$r2[\'url\'];\n    $img_big=$modul."/".$r2[\'path\']."/".$r2[\'seq\']."/image/big/".$r2[\'url\'];\n    $ret .= \'\n    <div id="row-\'.$r2[\'id\'].\'" class="col-sm-3 col-lg-2 col-xs-6">\n      <div class="card">\n    \';\n    $ret .= \'<img src="\'.$ar[\'url_img\'].\'\'.$img_small.\'" alt="">\';\n    $ret .= \'\';\n    $ret .= \'\n      </div>\n      <button onClick="imgdel(\'.$r2[\'id\'].\');" class="btn btn-danger btn-xs">Delete</button>\n      \n    </div>\';\n  }\n  $ret .= "</div>";\n  return $ret;\n}','php','0','2','3','1748697036');
INSERT INTO `cp_sphp` VALUES ('83','api','image_delete_byid','function image_delete_byid($js){\n  global $ar,$db;\n  $dt=array();  \n  $sql="SELECT * from `files` where id=".$js[\'id\'];\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res)==1) {\n    $r=mysqli_fetch_assoc($res);\n    $dt[\'success\']=true;\n    $this_path=$ar[\'img_path\']."".$r[\'modul\']."/".$r[\'path\'];\n    $dt[\'r\']=$r;\n    $dt[\'path\']=$this_path;\n    if(is_dir($this_path)) {\n      $dt[\'is_dir\']="exist";\n      emptyDir($this_path);\n      Delete($db,"files","id=".$js[\'id\'],0);\n    }\n  } else {\n    $dt[\'error\']=true;\n    $dt[\'message\']="data not found";\n  }\n  return $dt;\n}','php','0','2','1','1748739802');
INSERT INTO `cp_sphp` VALUES ('84','api','image_delete_byitemid','function image_delete_byitemid($js){\n  global $ar,$db;\n  $dt=array();\n  \n  $sql="SELECT * from `files` where `modul`=\'".$js[\'modul\']."\' and `item_id`=".$js[\'id\'];\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res)==1) {\n    $r=mysqli_fetch_assoc($res);\n    $dt[\'success\']=true;\n    $this_path=$ar[\'img_path\']."".$r[\'modul\']."/".$r[\'path\'];\n    $dt[\'r\']=$r;\n    $dt[\'path\']=$this_path;\n    if(is_dir($this_path)) {\n      $dt[\'is_dir\']="exist";\n      emptyDir($this_path);\n      Delete($db,"files","id=".$r[\'id\'],0);\n    }\n  } else {\n    $dt[\'error\']=true;\n    $dt[\'message\']="data not found";\n  }\n  return $dt;\n}','php','0','2','1','1748741426');
INSERT INTO `cp_sphp` VALUES ('85','api','transaction_add_v2','function transaction_add_v2($js){\n  global $ar,$db;\n  $dt=array();\n  //$dt[\'param\']=$js;\n\n  $sql="SELECT * from `transaction` where `action_id`=\'".$js[\'action_id\']."\'";\n  //$dt[\'sql\'][1]=$sql8;\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res)==0){\n    //belum ada data, insert\n    $sql6 = "SELECT * from `action` where id=".$js[\'action_id\'];\n    $res6 = mysqli_query($db, $sql6);\n    //echo $sql;\n    $r6 = mysqli_fetch_assoc($res6); \n\n\n    $sql3 = "select id,id2,id-id2 as k from `transaction` where id-id2>0 order by id2 limit 1";\n    $res3 = mysqli_query($db, $sql3);\n    if(mysqli_num_rows($res3)>0) {\n      $rw3 = mysqli_fetch_assoc($res3);\n      $id1=$rw3[\'id2\'];\n    } else {\n      $sql4 = "select * from `transaction` order by id desc limit 1";\n      $res4 = mysqli_query($db, $sql4);\n      $rw4 = mysqli_fetch_assoc($res4);\n      if(isset($rw4[\'id\']) && $rw4[\'id\']>0) {\n        $id1=$rw4[\'id\']+1;\n      } else {\n        $id1=1;\n      }\n    }\n\n    $idt=array(\n      \'id\'=>$id1,\n      \'action_at\'=>$r6[\'action_at\'],\n      \'action_id\'=>$js[\'action_id\'],\n      \'year\'=>date("Y",$r6[\'action_at\']),\n      \'month\'=>date("Ym",$r6[\'action_at\']),\n      \'seq\'=>$r6[\'seq\'],\n      \'cat\'=>$r6[\'cat\'],\n      \'inout\'=>$r6[\'inout\'],\n      \'debit\'=>$js[\'debit\'],\n      \'credit\'=>$js[\'credit\'],\n      \'amount\'=>to_numeric($r6[\'amount\']),\n      \'st\'=>1,\n      \'update_at\'=>time(),\n    );\n    Insert($db,"transaction",$idt,0);\n    tool_id2(\'transaction\');\n\n    $dt[\'success\']=true;\n    $dt[\'message\']="Add transaction successfull"; \n\n    $udt=array(\n      \'st_trx\'=>1,\n    );\n    Update($db,"action",$udt,"id=".$js[\'action_id\'],0);  \n    journal_add($id1); \n\n    $dt[\'data\'][\'transaction\'][\'byid\']=transaction_byid();\n    $dt[\'data\'][\'transaction\'][\'byseq\']=transaction_byseq();\n    $dt[\'data\'][\'action\'][\'byid\']=action_byid();\n    $dt[\'data\'][\'action\'][\'byseq\']=action_byseq();\n\n  } else {\n    $r1=mysqli_fetch_assoc($res);\n    //sudah ada data, update\n    $sql6 = "SELECT * from `action` where id=".$js[\'action_id\'];\n    $res6 = mysqli_query($db, $sql6);\n    //echo $sql;\n    $r6 = mysqli_fetch_assoc($res6); \n\n    $udt=array(\n      \'st_trx\'=>1,\n    );\n    Update($db,"action",$udt,"id=".$js[\'action_id\'],0);  \n\n    $udt2=array(\n      \'debit\'=>$js[\'debit\'],\n      \'credit\'=>$js[\'credit\'],\n      \'amount\'=>$r6[\'amount\'],\n      \'update_at\'=>time(),\n    );\n    Update($db,"transaction",$udt2,"id=".$r1[\'id\'],0);\n    tool_id2("journal"); \n    $dt[\'journal\']=journal_add($r1[\'id\']);     \n    \n    $dt[\'data\'][\'transaction\'][\'byid\']=transaction_byid();\n    $dt[\'data\'][\'transaction\'][\'byseq\']=transaction_byseq();\n    $dt[\'data\'][\'action\'][\'byid\']=action_byid();\n    $dt[\'data\'][\'action\'][\'byseq\']=action_byseq();\n    $dt[\'success\']=true;\n    $dt[\'message\']="This transaction update successfully";        \n  }\n\n  JournalCount_v2(date("Y"));\nlist_equ_3();\n\n  return $dt;\n  $db->close();\n}','php','0','2','1','1748593709');


DROP TABLE IF EXISTS `fcode`;
CREATE TABLE `fcode` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(99) DEFAULT NULL,
  `code` varchar(10) DEFAULT '0',
  `remark` varchar(99) DEFAULT NULL,
  `del` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1=delete',
  `level` tinyint(4) NOT NULL DEFAULT 0,
  `trx` tinyint(4) NOT NULL DEFAULT 0,
  `parent` int(11) NOT NULL DEFAULT 0,
  `s2024` bigint(20) NOT NULL DEFAULT 0,
  `s2025` bigint(20) NOT NULL DEFAULT 0,
  `s2026` bigint(20) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `sel2` tinyint(4) NOT NULL DEFAULT 0,
  `is_cost` tinyint(4) NOT NULL DEFAULT 0,
  `is_income` tinyint(4) NOT NULL DEFAULT 0,
  `view` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `id_folder_slug` (`id`),
  KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=114 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

INSERT INTO `fcode` VALUES ('1','Laba/Rugi','a','','0','1','0','0','0','0','0','1746835276','0','0','0','1');
INSERT INTO `fcode` VALUES ('2','Neraca','c','','0','1','0','0','0','0','0','1746834282','0','0','0','1');
INSERT INTO `fcode` VALUES ('3','Arus Kas','d','','0','4','0','0','0','0','0','1746835126','0','0','0','0');
INSERT INTO `fcode` VALUES ('4','Perubahan Modal','m','','0','1','0','0','0','0','0','1746931121','0','0','0','1');
INSERT INTO `fcode` VALUES ('5','Aktiva','c1','','0','2','0','2','0','0','0','1747185578','0','0','0','0');
INSERT INTO `fcode` VALUES ('6','Pasiva','c2','','0','2','0','2','0','0','0','1747185607','0','0','0','0');
INSERT INTO `fcode` VALUES ('7','Aktiva/Aset Lancar','c11','','0','3','0','5','0','0','0','1747185635','0','0','0','0');
INSERT INTO `fcode` VALUES ('8','Aktiva/Aset Tetap','c12','','0','3','0','5','0','0','0','1747185678','0','0','0','0');
INSERT INTO `fcode` VALUES ('9','Pendapatan/Penjualan','c41','','0','3','0','6','0','0','0','1747185770','0','0','0','0');
INSERT INTO `fcode` VALUES ('10','Utang/Kuwajiban/Liabilitas','c21','','0','3','0','6','0','0','0','1747185776','0','0','0','0');
INSERT INTO `fcode` VALUES ('11','Beban Lain-lain','c81','','0','3','0','6','0','0','0','1747185780','0','0','0','0');
INSERT INTO `fcode` VALUES ('12','Pendapatan Lain-lain','c71','','0','3','0','6','0','0','0','1747185786','0','0','0','0');
INSERT INTO `fcode` VALUES ('13','Beban Administrasi','c62','','0','3','0','6','0','0','0','1747185787','0','0','0','0');
INSERT INTO `fcode` VALUES ('14','Beban Penjualan','c61','','0','3','0','6','0','0','0','1747185788','0','0','0','0');
INSERT INTO `fcode` VALUES ('15','Modal/Equity','c31','','0','3','0','6','0','0','0','1747185789','0','0','0','0');
INSERT INTO `fcode` VALUES ('16','Harga Pokok Penjualan','c51','','0','3','0','6','0','0','0','1747185796','0','0','0','0');
INSERT INTO `fcode` VALUES ('17','Biaya dibayar dimuka','c11204','','0','4','1','7','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('19','Perlengkapan','c11203','','0','4','1','7','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('20','Persediaan Barang Dagangan','c11202','','0','4','1','7','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('21','Piutang','c11201','','0','4','1','7','0','0','0','1749009712','0','1','1','0');
INSERT INTO `fcode` VALUES ('22','Kas ','c11101','','0','4','1','7','0','0','0','1749009712','1','0','0','0');
INSERT INTO `fcode` VALUES ('23','Peralatan','c12401','','0','4','1','8','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('24','Akumulasi Penyusutan Kendaraan','c12302','','0','4','1','8','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('25','Kendaraan','c12301','','0','4','1','8','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('26','Akumulasi Penyusutan Bangunan','c12202','','0','4','1','8','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('27','Bangunan','c12201','','0','4','1','8','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('28','Tanah','c12101','','0','4','1','8','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('29','Akumulasi Penyusutan Peralatan','c12402','','0','4','1','8','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('30','Utang bank jangka panjang','c21300','','0','4','1','10','0','0','0','1749009712','0','1','1','0');
INSERT INTO `fcode` VALUES ('31','Utang biaya','c21200','','0','4','1','10','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('32','Utang dagang','c21100','','0','4','1','10','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('33','Deviden','c31300','','0','4','1','15','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('34','Modal ditarik/Prive','c31200','','0','4','1','15','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('35','Modal Disetor','c31100','','0','4','1','15','0','0','0','1749009712','1','0','1','0');
INSERT INTO `fcode` VALUES ('36','Penjualan','c41100','','0','4','1','9','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('37','Retur Penjualan','c41200','','0','4','1','9','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('38','Potongan Penjualan','c41300','','0','4','1','9','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('39','Harga Pokok Penjualan','c51100','','0','4','1','16','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('40','Biaya langsung pembelian','c51200','','0','4','1','16','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('41','Potongan Pembelian','c51300','','0','4','1','16','0','0','0','1749009712','0','0','0','0');
INSERT INTO `fcode` VALUES ('42','Upah/gaji staff toko','c61101','','0','4','1','14','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('43','Opersional Penjualan','c61102','','0','4','1','14','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('44','Marketing','c61103','','0','4','1','14','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('45','Sewa Bangunan/Toko','c61104','','0','4','1','14','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('46','Penyusutan Kendaraan','c61105','','0','4','1','14','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('47','Penyusutan Peralatan','c61106','','0','4','1','14','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('48','Upah/gaji staff kantor','c62101','','0','4','1','13','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('49','Listrik/Air/Telp/Internet','c62102','','0','4','1','13','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('50','Perlengkapan','c62103','','0','4','1','13','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('51','Asuransi','c62104','','0','4','1','13','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('52','Kebersihan','c62106','','0','4','1','13','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('53','Penyusutan Bangunan','c62107','','0','4','1','13','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('54','Pendapatan Bunga','c71000','','0','4','1','12','0','0','0','1749009712','0','0','1','0');
INSERT INTO `fcode` VALUES ('55','Beban Bunga','c81100','','0','4','1','11','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('56','Biaya Bank','c81200','','0','4','1','11','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('57','Pendapatan/Penjualan','a01','=c41','0','2','0','1','0','0','0','1747187880','0','0','0','0');
INSERT INTO `fcode` VALUES ('58','Harga Pokok Penjualan','a02','=c51','0','2','0','1','0','0','0','1747187890','0','0','0','0');
INSERT INTO `fcode` VALUES ('59','Beban Penjualan','a03','=c61','0','2','0','1','0','0','0','1747187891','0','0','0','0');
INSERT INTO `fcode` VALUES ('60','Laba Kotor','a04','=a01+a02+a03','0','2','0','1','0','0','0','1747187892','0','0','0','0');
INSERT INTO `fcode` VALUES ('61','Beban Administrasi','a05','=c62','0','2','0','1','0','0','0','1747187893','0','0','0','0');
INSERT INTO `fcode` VALUES ('62','Laba/Rugi Operasional Sebelum Pajak','a08','=a04+a05+a06+a07','0','2','0','1','0','0','0','1747187894','0','0','0','0');
INSERT INTO `fcode` VALUES ('63','Pajak','a09','0','0','2','0','1','0','0','0','1747187895','0','0','0','0');
INSERT INTO `fcode` VALUES ('64','Laba/Rugi Bersih/Setelah Pajak','a10','=a8-a09','0','2','0','1','0','0','0','1747187896','0','0','0','0');
INSERT INTO `fcode` VALUES ('65','Arus Kas dari aktivitas operasional','d1','','0','2','0','3','0','0','0','1747188065','0','0','0','0');
INSERT INTO `fcode` VALUES ('66','Arus Kas dari aktivitas investasi','d2','','0','2','0','3','0','0','0','1747188072','0','0','0','0');
INSERT INTO `fcode` VALUES ('67','Arus Kas dari aktivitas pendanaan','d3','','0','2','0','3','0','0','0','1747188073','0','0','0','0');
INSERT INTO `fcode` VALUES ('68','Arus Kas bersih/saldo akhir','d4','','0','2','0','3','0','0','0','1747188074','0','0','0','0');
INSERT INTO `fcode` VALUES ('69','Kas Diterima dari customer','d11','','0','3','0','65','0','0','0','1747188171','0','0','0','0');
INSERT INTO `fcode` VALUES ('70','Pembayaran kas untuk supplier','d12','','0','3','0','65','0','0','0','1747188192','0','0','0','0');
INSERT INTO `fcode` VALUES ('71','Pembayaran kas untuk beban operasi','d13','','0','3','0','65','0','0','0','1747188193','0','0','0','0');
INSERT INTO `fcode` VALUES ('72','Pembayaran kas untuk bunga','d14','','0','3','0','65','0','0','0','1747188194','0','0','0','0');
INSERT INTO `fcode` VALUES ('73','Pembayaran kas untuk pajak','d15','','0','3','0','65','0','0','0','1747188195','0','0','0','0');
INSERT INTO `fcode` VALUES ('74','Jumlah kas dari aktivitas operasi','d19','','0','3','0','65','0','0','0','1747188196','0','0','0','0');
INSERT INTO `fcode` VALUES ('75','Kas diterima dari penjualan aktiva','d21','','0','3','0','66','0','0','0','1747188387','0','0','0','0');
INSERT INTO `fcode` VALUES ('76','Kas diterima dari bunga/bagi hasil bank','d22','','0','3','0','66','0','0','0','1747188389','0','0','0','0');
INSERT INTO `fcode` VALUES ('77','Pembayaran kas untuk pembelian aktiva tetap','d23','','0','3','0','66','0','0','0','1747188390','0','0','0','0');
INSERT INTO `fcode` VALUES ('78','Jumlah kas untuk aktivitas investasi','d29','','0','3','0','66','0','0','0','1747188392','0','0','0','0');
INSERT INTO `fcode` VALUES ('79','Kas diterima dari penyertaan saham','d31','','0','3','0','67','0','0','0','1747188517','0','0','0','0');
INSERT INTO `fcode` VALUES ('80','Kas diterima dari hutang/pinjaman','d32','','0','3','0','67','0','0','0','1747188520','0','0','0','0');
INSERT INTO `fcode` VALUES ('81','Pembayaran kas untuk deviden','d33','','0','3','0','67','0','0','0','1747188521','0','0','0','0');
INSERT INTO `fcode` VALUES ('82','Pembayaran kas untuk prive','d34','','0','3','0','67','0','0','0','1747188522','0','0','0','0');
INSERT INTO `fcode` VALUES ('83','Pembayaran kas untuk bunga/bagi hasil','d35','','0','3','0','67','0','0','0','1747188523','0','0','0','0');
INSERT INTO `fcode` VALUES ('84','Pembayaran kas untuk pelunasan hutang/pinjaman','d36','','0','3','0','67','0','0','0','1747188524','0','0','0','0');
INSERT INTO `fcode` VALUES ('85','Jumlah kas dari aktivitas pendanaan','d39','','0','3','0','67','0','0','0','1747188525','0','0','0','0');
INSERT INTO `fcode` VALUES ('86','Modal Usaha','m1','','0','2','0','4','0','0','0','1747188662','0','0','0','0');
INSERT INTO `fcode` VALUES ('87','Perubahan Modal atau Laba/Rugi Periode Ini','m2','','0','2','0','4','0','0','0','1747188665','0','0','0','0');
INSERT INTO `fcode` VALUES ('88','Pembayaran prive','m11','','0','3','0','86','0','0','0','1747188732','0','0','0','0');
INSERT INTO `fcode` VALUES ('89','Pembayaran Deviden','m12','','0','3','0','86','0','0','0','1747188735','0','0','0','0');
INSERT INTO `fcode` VALUES ('90','Laba/Rugi Periode Ini','m13','','0','3','0','86','0','0','0','1747188736','0','0','0','0');
INSERT INTO `fcode` VALUES ('91','Persamaan Akuntansi','b','','0','1','0','0','0','0','0','1747191258','0','0','0','0');
INSERT INTO `fcode` VALUES ('92','Aktiva','b1','=c1','0','1','0','91','0','0','0','1747191314','0','0','0','0');
INSERT INTO `fcode` VALUES ('93','Pasiva','b2','=c2','0','1','0','91','0','0','0','1747191322','0','0','0','0');
INSERT INTO `fcode` VALUES ('94','Aktiva/Aset Lancar','b11','=c11','0','2','0','92','0','0','0','1747191733','0','0','0','0');
INSERT INTO `fcode` VALUES ('95','Aktiva/Aset Tetap','b12','=c12','0','2','0','92','0','0','0','1747191737','0','0','0','0');
INSERT INTO `fcode` VALUES ('96','Utang/Kewajiban/Liabilitas','b21','=c21','0','2','0','93','0','0','0','1747191789','0','0','0','0');
INSERT INTO `fcode` VALUES ('97','Ekuitas','b33','','0','2','0','93','0','0','0','1747191850','0','0','0','0');
INSERT INTO `fcode` VALUES ('98','Modal Disetor','b31','=c31','0','3','0','97','0','0','0','1747191926','0','0','0','0');
INSERT INTO `fcode` VALUES ('99','Laba/Rugi Berjalan','b32','=c41+c61+c62+c81+c71','0','3','0','97','0','0','0','1747191930','0','0','0','0');
INSERT INTO `fcode` VALUES ('100','Pendapatan','b3201','=c41=a1','0','4','0','99','0','0','0','1747192039','0','0','0','0');
INSERT INTO `fcode` VALUES ('101','Harga Pokok Penjualan','b3202','=c51=a2','0','4','0','99','0','0','0','1747192116','0','0','0','0');
INSERT INTO `fcode` VALUES ('102','Beban Penjualan','b3203','=c61=a3','0','4','0','99','0','0','0','1747192119','0','0','0','0');
INSERT INTO `fcode` VALUES ('103','Laba/Rugi Kotor','b3204','=a04','0','4','0','99','0','0','0','1747192123','0','0','0','0');
INSERT INTO `fcode` VALUES ('104','Beban Administrasi','b3205','=c62','0','4','0','99','0','0','0','1747192125','0','0','0','0');
INSERT INTO `fcode` VALUES ('105','Laba/Rugi Operasional Sebelum Pajak','b3208','=a06','0','4','0','99','0','0','0','1747192176','0','0','0','0');
INSERT INTO `fcode` VALUES ('106','Pajak','b3209','=a07','0','4','0','99','0','0','0','1747192179','0','0','0','0');
INSERT INTO `fcode` VALUES ('107','Laba/Rugi Bersih/Setelah Pajak','b3210','=a08','0','4','0','99','0','0','0','1747192180','0','0','0','0');
INSERT INTO `fcode` VALUES ('108','Pendapatan Lain-lain','a06','=c71','0','2','0','1','0','0','0','1747193454','0','0','0','0');
INSERT INTO `fcode` VALUES ('109','Beban Lain-lain','a07','=c81','0','2','0','1','0','0','0','1747193458','0','0','0','0');
INSERT INTO `fcode` VALUES ('110','Utang pajak','c21400','','0','4','1','10','0','0','0','1749009712','0','1','0','0');
INSERT INTO `fcode` VALUES ('111','Pendapatan Lain-lain','b3206','=c71','0','4','0','99','0','0','0','1747194700','0','0','0','0');
INSERT INTO `fcode` VALUES ('112','Beban Lain-lain','b3207','=c81','0','4','0','99','0','0','0','1747194703','0','0','0','0');
INSERT INTO `fcode` VALUES ('113','Beban Pajak/Retribusi','c62105','','0','4','1','13','0','0','0','1749009712','0','1','0','0');


DROP TABLE IF EXISTS `files`;
CREATE TABLE `files` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `item_id` int(11) NOT NULL DEFAULT 0,
  `seq` int(11) NOT NULL DEFAULT 0,
  `modul` varchar(20) DEFAULT NULL,
  `type` varchar(20) DEFAULT NULL,
  `title` varchar(100) DEFAULT NULL,
  `caption` varchar(200) DEFAULT NULL,
  `url` varchar(200) DEFAULT NULL,
  `url_src` varchar(200) DEFAULT NULL,
  `url_original` varchar(200) DEFAULT NULL,
  `path` varchar(200) DEFAULT NULL,
  `create_at` int(11) NOT NULL DEFAULT 0,
  `width` int(11) NOT NULL DEFAULT 0,
  `height` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `id_item_id_modul` (`id`,`item_id`,`modul`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

INSERT INTO `files` VALUES ('1','1','1','users','image','','','20250604112006.jpeg','','temp/20250604112006.jpeg','25/06/04/11/1','1749010806','0','0');


DROP TABLE IF EXISTS `inventory`;
CREATE TABLE `inventory` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) DEFAULT NULL,
  `brand` varchar(200) DEFAULT NULL,
  `qty` int(11) NOT NULL DEFAULT 0,
  `unit` varchar(10) DEFAULT NULL,
  `remark` varchar(200) DEFAULT NULL,
  `position` varchar(200) DEFAULT NULL,
  `group` varchar(50) DEFAULT NULL,
  `code` varchar(10) DEFAULT NULL,
  `condition` varchar(200) DEFAULT NULL,
  `img` varchar(200) NOT NULL DEFAULT 'no_img.jpeg',
  `purchase_date` int(11) NOT NULL,
  `will_age` int(11) NOT NULL DEFAULT 10,
  `transaction_id` int(11) NOT NULL DEFAULT 0,
  `action_id` int(11) NOT NULL DEFAULT 0,
  `price_per_unit` bigint(20) NOT NULL DEFAULT 0,
  `value` bigint(20) NOT NULL DEFAULT 0,
  `amount` bigint(20) NOT NULL DEFAULT 0,
  `create_at` int(11) NOT NULL DEFAULT 0,
  `create_by` int(11) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `update_by` int(11) NOT NULL DEFAULT 0,
  `id2` int(11) NOT NULL DEFAULT 0,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `view` tinyint(4) NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`),
  KEY `id_nama_nilai` (`id`,`name`,`value`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `journal`;
CREATE TABLE `journal` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `inout` tinyint(4) NOT NULL DEFAULT 0,
  `transaction_id` int(11) NOT NULL DEFAULT 0,
  `action_id` int(11) NOT NULL DEFAULT 0,
  `action_at` int(11) NOT NULL DEFAULT 0,
  `year` int(11) NOT NULL DEFAULT 0,
  `month` int(11) NOT NULL DEFAULT 0,
  `week` int(11) NOT NULL DEFAULT 0,
  `seq` int(11) NOT NULL DEFAULT 0,
  `seq2` int(11) NOT NULL DEFAULT 0,
  `debit` bigint(20) NOT NULL DEFAULT 0,
  `credit` bigint(20) NOT NULL DEFAULT 0,
  `amount` bigint(20) NOT NULL DEFAULT 0,
  `balance` bigint(20) NOT NULL DEFAULT 0,
  `account_code` varchar(10) DEFAULT NULL,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `id2` int(11) NOT NULL DEFAULT 0,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `view` tinyint(4) NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`),
  UNIQUE KEY `transaction_id_inout` (`transaction_id`,`inout`),
  KEY `id_tgl_nilai_akun_tunai` (`id`,`transaction_id`,`debit`,`account_code`),
  KEY `action_id` (`action_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `mandiri_mutasi`;
CREATE TABLE `mandiri_mutasi` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `text` varchar(250) DEFAULT NULL,
  `seq` int(11) NOT NULL DEFAULT 0,
  `tgl` date NOT NULL,
  `tgl2` int(11) NOT NULL DEFAULT 0,
  `debit` int(11) NOT NULL DEFAULT 0,
  `kredit` int(11) NOT NULL DEFAULT 0,
  `saldo` int(11) NOT NULL DEFAULT 0,
  `remark` varchar(200) DEFAULT NULL,
  `keterangan` varchar(200) DEFAULT NULL,
  `action_id` int(11) NOT NULL DEFAULT 0,
  `year` varchar(5) DEFAULT NULL,
  `month` varchar(7) DEFAULT NULL,
  `payto` varchar(50) DEFAULT NULL,
  `st` tinyint(4) NOT NULL DEFAULT 0,
  `inout` tinyint(4) NOT NULL DEFAULT 0,
  `bank` tinyint(4) NOT NULL DEFAULT 0,
  `rek` varchar(40) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `id_seq_st` (`id`,`seq`,`st`),
  KEY `tgl_tgl2_debit_kredit_saldo` (`tgl`,`tgl2`,`debit`,`kredit`,`saldo`),
  KEY `year_month_seq` (`year`,`month`,`seq`)
) ENGINE=InnoDB DEFAULT CHARSET=utf32 COLLATE=utf32_general_ci;



DROP TABLE IF EXISTS `network`;
CREATE TABLE `network` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(60) DEFAULT NULL,
  `initial` varchar(60) DEFAULT NULL,
  `email` varchar(90) DEFAULT NULL,
  `password` varchar(200) DEFAULT NULL,
  `modul` varchar(200) DEFAULT NULL,
  `modul2` varchar(200) DEFAULT NULL,
  `modul3` varchar(200) DEFAULT NULL,
  `reff` varchar(200) DEFAULT NULL,
  `address` varchar(200) DEFAULT NULL,
  `city` varchar(50) DEFAULT NULL,
  `wa` varchar(30) DEFAULT NULL,
  `phone` varchar(30) DEFAULT NULL,
  `role` tinyint(4) DEFAULT NULL,
  `web` varchar(90) DEFAULT NULL,
  `fb` varchar(90) DEFAULT NULL,
  `ig` varchar(90) DEFAULT NULL,
  `linkedin` varchar(90) DEFAULT NULL,
  `tw` varchar(90) DEFAULT NULL,
  `nik` varchar(90) DEFAULT NULL,
  `img` varchar(90) DEFAULT NULL,
  `remark` varchar(200) DEFAULT NULL,
  `parent_id` int(11) NOT NULL,
  `create_at` int(11) NOT NULL,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `update_by` int(11) NOT NULL DEFAULT 0,
  `last_login` int(11) NOT NULL,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `fav` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `wa` (`wa`),
  KEY `id_name_email` (`id`,`name`,`email`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `network_login`;
CREATE TABLE `network_login` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `network_id` int(11) NOT NULL DEFAULT 0,
  `ip` varchar(20) DEFAULT NULL,
  `action` varchar(20) DEFAULT NULL,
  `action_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `id_item_id_ip` (`id`,`ip`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

INSERT INTO `network_login` VALUES ('1','1','103.136.58.207','login','1717905596');


DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(99) DEFAULT NULL,
  `initial` varchar(9) DEFAULT NULL,
  `email` varchar(90) DEFAULT NULL,
  `city` varchar(25) DEFAULT NULL,
  `phone` varchar(25) DEFAULT NULL,
  `nik` varchar(25) DEFAULT NULL,
  `npwp` varchar(25) DEFAULT NULL,
  `address` varchar(100) DEFAULT NULL,
  `img` varchar(200) NOT NULL DEFAULT 'no_img.jpeg',
  `postcode` varchar(5) DEFAULT NULL,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `relation` tinyint(4) NOT NULL DEFAULT 0,
  `del` tinyint(4) NOT NULL DEFAULT 0,
  `company_id` int(11) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `create_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`),
  KEY `id_cif_account_number` (`id`,`address`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `person_relation`;
CREATE TABLE `person_relation` (
  `person_id` int(11) NOT NULL DEFAULT 0,
  `relation` tinyint(4) NOT NULL DEFAULT 0,
  UNIQUE KEY `person_id_relation` (`person_id`,`relation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



DROP TABLE IF EXISTS `product`;
CREATE TABLE `product` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) DEFAULT NULL,
  `brand` varchar(200) DEFAULT NULL,
  `qty` int(11) NOT NULL DEFAULT 0,
  `remark` varchar(200) DEFAULT NULL,
  `item_code` varchar(10) DEFAULT NULL,
  `img` varchar(200) NOT NULL DEFAULT 'no_img.jpeg',
  `price_per_unit` bigint(20) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `id2` int(11) NOT NULL DEFAULT 0,
  `del` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `id_nama_nilai` (`id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `product_trx`;
CREATE TABLE `product_trx` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `action_at` int(11) NOT NULL DEFAULT 0,
  `product_id` int(11) NOT NULL DEFAULT 0,
  `action_id` int(11) NOT NULL DEFAULT 0,
  `transaction_id` int(11) NOT NULL DEFAULT 0,
  `item_in` int(11) NOT NULL DEFAULT 0,
  `item_out` int(11) NOT NULL DEFAULT 0,
  `balance` int(11) NOT NULL DEFAULT 0,
  `invoice` varchar(20) DEFAULT NULL,
  `remark` varchar(200) DEFAULT NULL,
  `year` varchar(5) DEFAULT NULL,
  `month` varchar(7) DEFAULT NULL,
  `item_code` varchar(7) DEFAULT NULL,
  `tgl` date DEFAULT NULL,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `inout` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `action_id` (`action_id`),
  KEY `id_tgl_nilai_akun_tunai` (`id`,`action_at`),
  KEY `bank_amount_debit_credit` (`product_id`,`balance`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `report`;
CREATE TABLE `report` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `year` int(11) NOT NULL DEFAULT 0,
  `account` int(11) NOT NULL,
  `parent` int(11) NOT NULL,
  `code` varchar(10) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `amount` bigint(20) NOT NULL DEFAULT 0,
  `c1` bigint(20) NOT NULL,
  `c2` bigint(20) NOT NULL,
  `c3` bigint(20) NOT NULL,
  `c4` bigint(20) NOT NULL,
  `remark` varchar(100) DEFAULT NULL,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `level` tinyint(4) NOT NULL DEFAULT 0,
  `trx` tinyint(4) NOT NULL DEFAULT 0,
  `seq` tinyint(4) NOT NULL,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `id2` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `year_account` (`year`,`account`),
  KEY `id_tgl_nilai_akun_tunai` (`id`,`code`),
  KEY `account` (`account`),
  KEY `parent` (`parent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `sales`;
CREATE TABLE `sales` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sales_at` int(11) NOT NULL DEFAULT 0,
  `action_id_1` int(11) NOT NULL DEFAULT 0,
  `action_id_2` int(11) NOT NULL DEFAULT 0,
  `qty` int(11) NOT NULL DEFAULT 0,
  `hpp` int(11) NOT NULL DEFAULT 0,
  `price` int(11) NOT NULL DEFAULT 0,
  `amount` bigint(20) NOT NULL DEFAULT 0,
  `descr` text DEFAULT NULL,
  `invoice` varchar(75) DEFAULT NULL,
  `buyer` varchar(50) DEFAULT NULL,
  `sales` varchar(50) DEFAULT NULL,
  `year` varchar(5) DEFAULT NULL,
  `month` varchar(7) DEFAULT NULL,
  `tgl` date DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `days_due_date` tinyint(4) NOT NULL DEFAULT 0,
  `url_pdf` varchar(150) DEFAULT NULL,
  `img` varchar(200) NOT NULL DEFAULT 'no_img.jpeg',
  `update_at` int(11) NOT NULL DEFAULT 0,
  `product_id` int(11) NOT NULL DEFAULT 0,
  `company_id` int(11) NOT NULL DEFAULT 0,
  `person_id` int(11) NOT NULL DEFAULT 0,
  `seq` int(11) NOT NULL DEFAULT 0,
  `id2` int(11) NOT NULL DEFAULT 0,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `cash_credit` tinyint(4) NOT NULL DEFAULT 1 COMMENT '1=cash;2=credit',
  `del` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `id_tgl_nilai_akun_tunai` (`id`,`sales_at`),
  KEY `bank_amount_debit_credit` (`amount`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `setting`;
CREATE TABLE `setting` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(50) DEFAULT NULL,
  `content` text DEFAULT NULL,
  `del` tinyint(4) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `title` (`title`),
  KEY `id_cif_account_number` (`id`,`title`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `transaction`;
CREATE TABLE `transaction` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `action_at` int(11) NOT NULL,
  `action_id` int(11) NOT NULL,
  `debit` varchar(10) DEFAULT NULL,
  `credit` varchar(10) DEFAULT NULL,
  `year` varchar(5) DEFAULT NULL,
  `month` varchar(7) DEFAULT NULL,
  `amount` bigint(20) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `seq` int(11) NOT NULL DEFAULT 0,
  `id2` int(11) NOT NULL DEFAULT 0,
  `cat` tinyint(4) NOT NULL DEFAULT 0,
  `inout` tinyint(4) NOT NULL DEFAULT 0,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `view` tinyint(4) NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`),
  UNIQUE KEY `action_id` (`action_id`),
  KEY `id_tgl_nilai_akun_tunai` (`id`,`action_at`,`amount`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `trx_title`;
CREATE TABLE `trx_title` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` int(11) DEFAULT NULL,
  `menu` varchar(12) DEFAULT NULL,
  `title` varchar(100) DEFAULT NULL,
  `debit` varchar(12) DEFAULT NULL,
  `credit` varchar(12) DEFAULT NULL,
  `del` tinyint(4) NOT NULL DEFAULT 0,
  `cat` tinyint(4) NOT NULL DEFAULT 0,
  `bank` tinyint(4) NOT NULL DEFAULT 0,
  `level` tinyint(4) NOT NULL DEFAULT 0,
  `position` tinyint(4) NOT NULL DEFAULT 0,
  `parent` int(11) NOT NULL DEFAULT 0,
  `inout` int(11) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `id_cif_account_number` (`id`,`title`)
) ENGINE=InnoDB AUTO_INCREMENT=134 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

INSERT INTO `trx_title` VALUES ('1','101','add','Biaya Dengan Tunai','','11101','0','1','2','1','1','0','2','0');
INSERT INTO `trx_title` VALUES ('2','102','add','Saldo Utang Dagang','','21100','0','5','0','1','2','0','2','0');
INSERT INTO `trx_title` VALUES ('3','103','add','Saldo Piutang Dagang','','41100','0','7','0','1','2','0','2','0');
INSERT INTO `trx_title` VALUES ('4','104','add','Bayar Utang Dagang','','11101','0','2','1','1','1','0','2','0');
INSERT INTO `trx_title` VALUES ('5','105','product','beli persediaan secara kredit','','','0','0','0','1','0','0','0','0');
INSERT INTO `trx_title` VALUES ('6','106','product','beli persediaan tunai','','','0','0','0','1','0','0','0','0');
INSERT INTO `trx_title` VALUES ('7','107','product','retur ke supplier','','','0','0','0','1','0','0','0','0');
INSERT INTO `trx_title` VALUES ('8','108','add','Modal Ditarik','','11101','0','2','1','1','1','0','2','0');
INSERT INTO `trx_title` VALUES ('9','109','add','Bagi Hasil','','11101','0','2','1','1','3','0','2','0');
INSERT INTO `trx_title` VALUES ('10','110','add','Potongan Biaya Bank','','11101','0','2','1','1','1','0','2','0');
INSERT INTO `trx_title` VALUES ('11','111','add','Bunga Bank','','11101','0','2','1','1','1','0','2','0');
INSERT INTO `trx_title` VALUES ('12','112','add','Potongan Penjualan','','11101','0','2','1','1','1','0','2','0');
INSERT INTO `trx_title` VALUES ('13','113','add','Biaya Dengan Utang','','21200','0','2','0','1','1','0','2','0');
INSERT INTO `trx_title` VALUES ('14','114','add','Penyusutan Kendaraan','','21200','0','2','0','1','3','0','2','0');
INSERT INTO `trx_title` VALUES ('15','115','add','Penyusutan Peralatan','','21200','0','2','0','1','3','0','2','0');
INSERT INTO `trx_title` VALUES ('16','116','add','Penyusutan Bangunan','','21200','0','2','0','1','3','0','2','0');
INSERT INTO `trx_title` VALUES ('17','117','add','Biaya Dibayar Dimuka','','21200','0','2','1','1','1','0','2','0');
INSERT INTO `trx_title` VALUES ('18','118','add','Beban Pajak dengan Kas','','11101','0','2','1','1','3','0','2','0');
INSERT INTO `trx_title` VALUES ('19','119','add','Beban Pajak dengan utang','','21200','0','2','0','1','3','0','2','0');
INSERT INTO `trx_title` VALUES ('20','120','add','Hitung Biaya Dimuka','','11204','0','2','1','1','1','0','2','0');
INSERT INTO `trx_title` VALUES ('22','201','add','Modal Disetor','11101','','0','1','1','1','2','0','1','0');
INSERT INTO `trx_title` VALUES ('23','202','add','Pendapatan Bunga Bank','11101','','0','1','1','1','1','0','1','0');
INSERT INTO `trx_title` VALUES ('24','203','add','Utang Bank Jangka Panjang','11101','','0','1','1','1','1','0','1','0');
INSERT INTO `trx_title` VALUES ('25','204','add','Pembayaran Piutang dari Agen','11101','','0','1','1','1','1','0','1','0');
INSERT INTO `trx_title` VALUES ('26','205','product','jual tunai','','','0','0','0','1','0','0','0','0');
INSERT INTO `trx_title` VALUES ('27','206','product','jual kredit','','','0','0','0','1','0','0','0','0');
INSERT INTO `trx_title` VALUES ('28','207','product','retur (penjualan) dari agen','','','0','0','0','1','0','0','0','0');
INSERT INTO `trx_title` VALUES ('29','208','add','Potongan Pembelian','11101','','0','1','1','1','1','0','1','0');
INSERT INTO `trx_title` VALUES ('90','','','','61101','11101','0','2','1','2','0','101','0','0');
INSERT INTO `trx_title` VALUES ('91','','','','61102','11101','0','2','1','2','0','101','0','0');
INSERT INTO `trx_title` VALUES ('92','','','','61103','11101','0','2','1','2','0','101','0','0');
INSERT INTO `trx_title` VALUES ('93','','','','62101','11101','0','2','1','2','0','101','0','0');
INSERT INTO `trx_title` VALUES ('94','','','','62102','11101','0','2','1','2','0','101','0','0');
INSERT INTO `trx_title` VALUES ('95','','','','62103','11101','0','2','1','2','0','101','0','0');
INSERT INTO `trx_title` VALUES ('96','','','','62106','11101','0','2','1','2','0','101','0','0');
INSERT INTO `trx_title` VALUES ('97','','','','11202','21100','0','5','0','2','0','102','0','0');
INSERT INTO `trx_title` VALUES ('98','','','','11201','41100','0','7','0','2','0','103','0','0');
INSERT INTO `trx_title` VALUES ('99','','','','21100','11101','0','2','1','2','0','104','0','0');
INSERT INTO `trx_title` VALUES ('100','','','','11202','21101','0','5','0','2','0','105','0','0');
INSERT INTO `trx_title` VALUES ('101','','','','11202','11101','0','2','1','2','0','106','0','0');
INSERT INTO `trx_title` VALUES ('102','','','','21101','11202','0','8','0','2','0','107','0','0');
INSERT INTO `trx_title` VALUES ('103','','','','31200','11101','0','2','1','2','0','108','0','0');
INSERT INTO `trx_title` VALUES ('104','','','','31300','11101','0','2','1','2','0','109','0','0');
INSERT INTO `trx_title` VALUES ('105','','','','81200','11101','0','2','1','2','0','110','0','0');
INSERT INTO `trx_title` VALUES ('106','','','','81100','11101','0','2','1','2','0','111','0','0');
INSERT INTO `trx_title` VALUES ('107','','','','41300','11101','0','2','1','2','0','112','0','0');
INSERT INTO `trx_title` VALUES ('108','','','','61101','21200','0','2','0','2','0','113','0','0');
INSERT INTO `trx_title` VALUES ('109','','','','61102','21200','0','2','0','2','0','113','0','0');
INSERT INTO `trx_title` VALUES ('110','','','','61103','21200','0','2','0','2','0','113','0','0');
INSERT INTO `trx_title` VALUES ('111','','','','62101','21200','0','2','0','2','0','113','0','0');
INSERT INTO `trx_title` VALUES ('112','','','','62102','21200','0','2','0','2','0','113','0','0');
INSERT INTO `trx_title` VALUES ('113','','','','62103','21200','0','2','0','2','0','113','0','0');
INSERT INTO `trx_title` VALUES ('114','','','','62106','21200','0','2','0','2','0','113','0','0');
INSERT INTO `trx_title` VALUES ('115','','','','61105','12302','0','2','0','2','0','114','0','0');
INSERT INTO `trx_title` VALUES ('116','','','','61106','12402','0','2','0','2','0','115','0','0');
INSERT INTO `trx_title` VALUES ('117','','','','62107','12202','0','2','0','2','0','116','0','0');
INSERT INTO `trx_title` VALUES ('118','','','','11204','11101','0','2','1','2','0','117','0','0');
INSERT INTO `trx_title` VALUES ('119','','','','62105','11101','0','2','1','2','0','118','0','0');
INSERT INTO `trx_title` VALUES ('120','','','','62105','21400','0','2','0','2','0','119','0','0');
INSERT INTO `trx_title` VALUES ('121','','','','62104','11204','0','2','1','2','0','120','0','0');
INSERT INTO `trx_title` VALUES ('122','','','','61104','11204','0','2','1','2','0','120','0','0');
INSERT INTO `trx_title` VALUES ('123','','','','11101','31100','0','1','1','2','0','201','0','0');
INSERT INTO `trx_title` VALUES ('124','','','','11101','71000','0','1','1','2','0','202','0','0');
INSERT INTO `trx_title` VALUES ('125','','','','11101','21300','0','1','1','2','0','203','0','0');
INSERT INTO `trx_title` VALUES ('126','','','','11101','11201','0','1','1','2','0','204','0','0');
INSERT INTO `trx_title` VALUES ('127','','','','11101','41100','0','4','1','2','0','205','0','0');
INSERT INTO `trx_title` VALUES ('128','','','','51100','11202','0','4','0','2','0','205','0','0');
INSERT INTO `trx_title` VALUES ('129','','','','11201','41100','0','4','0','2','0','206','0','0');
INSERT INTO `trx_title` VALUES ('130','','','','51100','11202','0','4','0','2','0','206','0','0');
INSERT INTO `trx_title` VALUES ('131','','','','11202','11201','0','9','0','2','0','207','0','0');
INSERT INTO `trx_title` VALUES ('132','','','','41200','51100','0','9','0','2','0','207','0','0');
INSERT INTO `trx_title` VALUES ('133','','','','11101','51300','0','1','1','2','0','208','0','0');


DROP TABLE IF EXISTS `user_address`;
CREATE TABLE `user_address` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` int(11) NOT NULL DEFAULT 0,
  `seq` int(11) NOT NULL DEFAULT 0,
  `label` varchar(50) DEFAULT NULL,
  `city` varchar(50) DEFAULT NULL,
  `no` varchar(50) DEFAULT NULL,
  `postcode` varchar(6) DEFAULT NULL,
  `rw` varchar(3) DEFAULT NULL,
  `rt` varchar(3) DEFAULT NULL,
  `address` varchar(200) DEFAULT NULL,
  `name` varchar(40) DEFAULT NULL,
  `kel` varchar(40) DEFAULT NULL,
  `kec` varchar(40) DEFAULT NULL,
  `latlng` varchar(40) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `gmap` varchar(100) DEFAULT NULL,
  `remark` varchar(100) DEFAULT NULL,
  `default` tinyint(4) NOT NULL DEFAULT 0,
  `del` tinyint(4) NOT NULL DEFAULT 0,
  `create_at` int(11) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `id_item_id_modul` (`id`,`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `user_login`;
CREATE TABLE `user_login` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` int(11) NOT NULL DEFAULT 0,
  `ip` varchar(20) DEFAULT NULL,
  `browser` varchar(190) DEFAULT NULL,
  `log_at` timestamp NULL DEFAULT NULL,
  `create_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `id_item_id_modul` (`id`,`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

INSERT INTO `user_login` VALUES ('1','1','103.136.58.233','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36','2025-06-14 13:31:08','1749882668');
INSERT INTO `user_login` VALUES ('2','1','103.136.58.233','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36','2025-06-14 13:36:25','1749882985');
INSERT INTO `user_login` VALUES ('3','1','103.136.58.233','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36','2025-06-14 14:00:01','1749884401');
INSERT INTO `user_login` VALUES ('4','1','2404:c0:2050::6eda:3','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36','2025-06-14 14:16:19','1749885379');
INSERT INTO `user_login` VALUES ('5','1','103.136.58.233','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36','2025-06-16 10:15:10','1750043710');
INSERT INTO `user_login` VALUES ('6','1','103.136.58.233','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36','2025-06-16 10:15:52','1750043752');
INSERT INTO `user_login` VALUES ('7','1','103.136.58.233','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36','2025-06-16 10:22:48','1750044168');
INSERT INTO `user_login` VALUES ('8','1','103.136.58.233','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36','2025-06-16 10:35:34','1750044934');
INSERT INTO `user_login` VALUES ('9','1','103.136.58.233','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36','2025-06-16 10:37:25','1750045045');
INSERT INTO `user_login` VALUES ('10','1','103.136.58.233','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36','2025-08-14 12:42:38','1755150158');
INSERT INTO `user_login` VALUES ('11','1','103.136.58.233','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36','2025-08-14 12:49:22','1755150562');


DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `firstname` varchar(50) DEFAULT NULL,
  `lastname` varchar(50) DEFAULT NULL,
  `fullname` varchar(99) DEFAULT NULL,
  `password` varchar(50) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `email` varchar(50) NOT NULL,
  `img` text NOT NULL DEFAULT 'users/user.png',
  `ip` varchar(20) DEFAULT NULL,
  `token` text DEFAULT NULL,
  `del_reason` text DEFAULT NULL,
  `terms` tinyint(4) NOT NULL DEFAULT 0,
  `del` tinyint(4) NOT NULL DEFAULT 0,
  `email_verified` tinyint(4) NOT NULL DEFAULT 0,
  `create_at` int(11) NOT NULL,
  `update_at` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`),
  KEY `id_firstname_lastname_email` (`id`,`firstname`,`lastname`,`email`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

INSERT INTO `users` VALUES ('1','Navis','Murbiyanto','Navis Murbiyanto','96457fa50d3a5aeb8f294e6b6fcfb5d1','6287781217347','navismur@gmail.com','users/25/06/04/11/1/1/image/small/20250604112006.jpeg','','PLXBdED)!xW)xnMhyrVcxvtkiSTh!NKsF@mGpqTksmfUSzrrz)@CzVLwyFpcVec(MwjHUdauthbuYRu!JmGkUvYsLtWAGVYZvKJpKNWJZsAfyDDZ^pUEyCAFe!Lq!ZhAS','tes doang dr node js','0','0','0','1734754340','1748482396');


