HMGSCRIPT R42

Moderator: Rathinagiri

User avatar
mol
Posts: 2828
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 118 times
Been thanked: 62 times
Contact:

Re: HMGSCRIPT R42

Post by mol » Tue Mar 08, 2016 6:49 am

My application is almost ready. This preview uses XML files as database. There was simplest way to start without database server.
I'll translate some code to English and post sample.

User avatar
mol
Posts: 2828
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 118 times
Been thanked: 62 times
Contact:

Post by mol » Tue Mar 08, 2016 8:47 am

Uff!
Translated!
Sorry for bad English :) ! (but still English :D :D :D)

This application is created for our motorcycle club to help to calculate finances.
Members are obligated to pay annual payment - now it's 240.
This money is spent for current affairs and for events.
Sometimes we have sponsors, so their payments are counted too.

Event changes total club finance when it's settled.

YOu can try this app at:
http://www.molsystemy.pl/hmg/finanse/finanseklubu.php


PS. I didnt thought it would be so easy to start this work with hmgscript! Many thanks Roberto!

User avatar
serge_girard
Posts: 1832
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 272 times
Been thanked: 63 times
Contact:

Post by serge_girard » Tue Mar 08, 2016 8:53 am

Nice job Marek!

Still XML or MySQL?

Serge

User avatar
bpd2000
Posts: 947
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 118 times
Been thanked: 42 times

Post by bpd2000 » Tue Mar 08, 2016 9:24 am

serge_girard wrote:Nice job Marek!

Still XML or MySQL?

Serge
+1
BPD
Convert Dream into Reality through HMG

User avatar
mol
Posts: 2828
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 118 times
Been thanked: 62 times
Contact:

Post by mol » Tue Mar 08, 2016 9:49 am

XML for now. This will be small database in this case. Switching to mysql will be easy because I have only four functions to communicate with database.
XML is hard to manipulate, I think.

User avatar
serge_girard
Posts: 1832
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 272 times
Been thanked: 63 times
Contact:

Post by serge_girard » Tue Mar 08, 2016 9:57 am

Yes, manipulating XML is not an option!

S

User avatar
mol
Posts: 2828
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 118 times
Been thanked: 62 times
Contact:

Post by mol » Tue Mar 08, 2016 10:19 am

Most complicated PHP function to save member payment :-D

Code: Select all

<?PHP
include('./ustawienia.php');
?>

<?PHP

$nPoprawaDanych =  $_REQUEST["nPoprawa"] +0;
$IdKlubowicza =  $_REQUEST["IdKlubowicza"];
$dDataSkladki =  $_REQUEST["dData"];
$nSkladka =  $_REQUEST["nSkladka"]+0.00;
$nRozliczony =  $_REQUEST["nRozliczony"]+0;
$nRokFinansowy =  $_REQUEST["nRokFinansowy"]+0;
$nPierwotnaSkladka =  $_REQUEST["nPierwotnaSkladka"]+0;

/*
$nPoprawaDanych =  0;
$IdKlubowicza =  'Izabela';
$dDataSkladki =  "2016-03-07";
$nSkladka =  500.54;
$nRozliczony =  0;
$nRokFinansowy =  2016;
$nPierwotnaSkladka =  0;
*/


$Skladki = simplexml_load_file($PlikBazyDanychSkladki);
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;

// aktualizacja salda w bieżącym roku
$szukam = '/Skladki/Salda/Saldo[RokFinansowy=' . $nRokFinansowy .']';
$OdszukaneSaldo = $Skladki->xpath($szukam);
if(!$OdszukaneSaldo)
{
	$NoweSaldo = $Skladki->Salda->addchild('Saldo');
	$NoweSaldo->RokFinansowy = $nRokFinansowy;
	$NoweSaldo->WplatyBiezacyRok = $nSkladka;
	$NoweSaldo->WplatyPoprzedniRok = 0;
	$NoweSaldo->WplatyNastepnyRok = 0;
}
else
{
	$OdszukaneSaldo[0]->WplatyBiezacyRok = $OdszukaneSaldo[0]->WplatyBiezacyRok + $nSkladka - $nPierwotnaSkladka;
}

if ($nPoprawaDanych==1)
{
		$szukam = '/Skladki/Klubowicze/Operacje[Id=' . $nIdSkladki .']';
		$OdszukanaOperacja = $Skladki->xpath($szukam);
		if(!$OdszukanaOperacja)
		{
			echo 'Błędny identyfikator operacji finansowej. Operacja nie została zapisana!';
			return ;
		}

		
		//$OdszukanaOperacja[0]->Data = $dDataSkladki;
		//$OdszukanaOperacja[0]->Przychod = $nPrzychod;
		//$OdszukanaOperacja[0]->Rozchod = $nRozchod;
		
		$dom->loadXML($Skladki->asXML());
		$dom->save($PlikBazyDanych);
		echo 'OK';
		
}
else
	{
	$szukam = '/Skladki/Klubowicze/Klubowicz[Id="' . $IdKlubowicza .'"]';
	echo "szukam klubowicza: " .$szukam . "\n";
	$Klubowicz = $Skladki->xpath($szukam);
	echo $Klubowicz[0];
	if(!$Klubowicz)
	{
		$Klubowicze = $Skladki->Klubowicze;
		$Klubowicz = $Klubowicze->addchild('Klubowicz');
		$Klubowicz->Id = $IdKlubowicza;
		$Lata = $Klubowicz->addchild('LataSkladkowe');
		$Rok = $Lata->addchild('RokSkladkowy');
		$Rok->Rok = $nRokFinansowy ;
		$Rok->Suma = $nSkladka ;
		$Rok->Rozliczony = $nRozliczony;
		$Wplaty = $Rok->addchild('Wplaty');
		$Wplata = $Wplaty->addchild('Wplata');
		$Wplata->Data = $dDataSkladki;
		$Wplata->Kwota = $nSkladka;
	}
	else
	{
		$szukam = '/Skladki/Klubowicze/Klubowicz[Id="' . $IdKlubowicza .'"]/LataSkladkowe/RokSkladkowy[Rok=' . $nRokFinansowy . ']' ;
		$Rok = $Skladki->xpath($szukam);
		if(!$Rok)
		{
			$Lata = $Klubowicz[0]->LataSkladkowe;
			$Rok = $Lata->addchild('RokSkladkowy');
			$Rok->Rok = $nRokFinansowy ;
			$Rok->Suma = $nSkladka ;
			$Rok->Rozliczony = $nRozliczony;
			$Wplaty = $Rok->addchild('Wplaty');
			$Wplata = $Wplaty->addchild('Wplata');
			$Wplata->Data = $dDataSkladki;
			$Wplata->Kwota = $nSkladka;
		}
		else
		{
			$Rok[0]->Suma = $Rok[0]->Suma + $nSkladka;
			$Rok[0]->Rozliczony = $nRozliczony;
			$Wplaty = $Rok[0]->Wplaty;
			$Wplata = $Wplaty->addchild('Wplata');
			$Wplata->Data = $dDataSkladki;
			$Wplata->Kwota = $nSkladka;
		}
	}
	
	$dom->loadXML($Skladki->asXML());
	$dom->save($PlikBazyDanychSkladki);
	}
?>

User avatar
serge_girard
Posts: 1832
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 272 times
Been thanked: 63 times
Contact:

Post by serge_girard » Tue Mar 08, 2016 11:07 am

Terrible...!

S

huiyi_ch
Posts: 57
Joined: Sat May 21, 2016 5:27 am
Has thanked: 1 time
Been thanked: 7 times

Post by huiyi_ch » Sun Sep 03, 2017 2:51 am

Hi friends,
我在HMGSCRIPT文档中未能找到一个上传文件的对象或控件.
请问,如何使用HMGSCRIPT上传文件到服务器?有上传文件到服务器的例子吗?

I failed to find an object or control for uploading files in the HMGSCRIPT document.
How do I use HMGSCRIPT to upload files to the server? Is there an example of uploading files to the server?

Best regards, Huiyi

Post Reply