HMGSCRIPT R42

Moderator: Rathinagiri

User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMGSCRIPT R42

Post by mol »

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: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMGSCRIPT R42

Post by mol »

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: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: HMGSCRIPT R42

Post by serge_girard »

Nice job Marek!

Still XML or MySQL?

Serge
There's nothing you can do that can't be done...
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: HMGSCRIPT R42

Post by bpd2000 »

serge_girard wrote:Nice job Marek!

Still XML or MySQL?

Serge
+1
BPD
Convert Dream into Reality through HMG
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMGSCRIPT R42

Post by mol »

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: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: HMGSCRIPT R42

Post by serge_girard »

Yes, manipulating XML is not an option!

S
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMGSCRIPT R42

Post by mol »

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: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: HMGSCRIPT R42

Post by serge_girard »

Terrible...!

S
There's nothing you can do that can't be done...
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: HMGSCRIPT R42

Post by huiyi_ch »

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
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMGSCRIPT R42

Post by mol »

Hi guys!
I want to refresh this topic.
I had to change database to mysql because of series of disasters with XML files.

I'm interesting if Roberto is working with this project or its dead?

Maybe sb. know how to detect mobile or desktop browser to switch to dedicated theme?
I've tried to use such a code, but it does not work:

Code: Select all

// from http://mobiforge.com/developing/story/lightweight-device-detection-php
$mobile_browser = '0';
 
if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
    $mobile_browser++;
}
 
if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
    $mobile_browser++;
}    
 
$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
$mobile_agents = array(
    'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
    'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
    'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
    'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
    'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
    'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
    'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
    'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
    'wapr','webc','winw','winw','xda ','xda-');
 
if (in_array($mobile_ua,$mobile_agents)) {
    $mobile_browser++;
}
 
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'OperaMini') > 0) {
    $mobile_browser++;
}
 
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows') > 0) {
    $mobile_browser = 0;
}
 
//if ($mobile_browser > 0) {
//   // do something
//}
//else {
//   // do something else
//}   
Post Reply