HMGSCRIPT R42
Moderator: Rathinagiri
Re: HMGSCRIPT R42
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.
I'll translate some code to English and post sample.
Re: HMGSCRIPT R42
Uff!
Translated!
Sorry for bad English
! (but still English
)
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!
Translated!
Sorry for bad English
![Smile :)](./images/smilies/icon_e_smile.gif)
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
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!
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: HMGSCRIPT R42
Nice job Marek!
Still XML or MySQL?
Serge
Still XML or MySQL?
Serge
There's nothing you can do that can't be done...
Re: HMGSCRIPT R42
+1serge_girard wrote:Nice job Marek!
Still XML or MySQL?
Serge
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
Re: HMGSCRIPT R42
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.
XML is hard to manipulate, I think.
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: HMGSCRIPT R42
Yes, manipulating XML is not an option!
S
S
There's nothing you can do that can't be done...
Re: HMGSCRIPT R42
Most complicated PHP function to save member payment
![Very Happy :-D](./images/smilies/icon_e_biggrin.gif)
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);
}
?>
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: HMGSCRIPT R42
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
我在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
Re: HMGSCRIPT R42
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:
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
//}