Untitled

mail@pastecode.io avatar
unknown
php
2 months ago
1.8 kB
1
Indexable
Never
private function hitung_komisi_piutang($notransaksi, $tanggal){
		$strSQLHeader = "SELECT tbl_ikhd.*, tbl_byrpiutangdt.notrsmasuk, tbl_byrpiutanghd.tanggal AS tgl_lunas FROM tbl_ikhd 
		LEFT JOIN tbl_byrpiutangdt ON tbl_ikhd.notransaksi = tbl_byrpiutangdt.notrsmasuk
		LEFT JOIN tbl_byrpiutanghd ON tbl_byrpiutangdt.notransaksi = tbl_byrpiutanghd.notransaksi
		WHERE (tbl_ikhd.notransaksi = :notransaksi)";

		$strSQLDetail = "SELECT * FROM tbl_ikdt WHERE (notransaksi = :notransaksi)";

		$data = new XData(AppConfig::$PAGE_CONN);
		
		$data->SetSQL($strSQLHeader);
		$data->AddParameter(':notransaksi', $notransaksi);
		$header = null;
		$_error_header = "";
		$hRes = $data->ExceuteQuery($header, $_error_header);
		if(!$hRes){
			return;
		}

		$data->SetSQL($strSQLDetail);
		$data->AddParameter(':notransaksi', $notransaksi);
		$detail = null;
		$_error_detail = "";
		$dRes = $data->ExceuteQuery($detail, $_error_detail);
		if(!$dRes){
			return;
		}

		$header['tgl_lunas'] = $tanggal;

		$row_header = [];
		$row_detail = [];
		$row_header[] = $header;
		$row_detail[] = $detail;

		$komisi1 = $header["komisi1"];
		$komisi2 = $header["komisi2"];
		$komisi3 = $header["komisi3"];
		$komisi4 = $header["komisi4"];
		
		$sb = new XSQLBuilder(AppConfig::$PAGE_CONN);

		$kms = new KomisiSales($row_header, $row_detail);
		$kms->getKomisiSales($komisi, $komisi2, $komisi3, $komisi4);
		$sb->BeginCommand(XSQLBuilder::UPDATE_CMD, 'tbl_ikhd');
		$sb->AddCmdParameter("komisi1",  $komisi1);
		$sb->AddCmdParameter("komisi2",  $komisi2);
		$sb->AddCmdParameter("komisi3",  $komisi3);
		$sb->AddCmdParameter("komisi4",  $komisi4);
        $sb->AddCondParameter("notransaksi", "=", $notransaksi , " ");
        $sb->EndCommand();
	}
Leave a Comment