2023年9月23日 星期六

如何判斷現在FORM是在 insert mode? 還是 update mode?

只要用  if (empty({primary_key})) 就可以知道是否為新增模式了。

如果 {promary_key} 是空白的,那麼就是在新增模式;反之,就是更新模式。

以上。

2023年9月11日 星期一

MySQL 裡面,數字與字串做是否相等的判斷

 


如果 2308 與 '2308',一個是數字,一個是字串,這兩個相比較,是否相等?

測試結果是:在mysql 裡面,是相等的。

2023年9月1日 星期五

ER-Model identifying relationships 與 non-identifying relationships的差別

https://www.geeksforgeeks.org/difference-between-identifying-and-non-identifying-relationships/

https://matthung0807.blogspot.com/2018/03/er-model-identifying-relationships-non.html


結論:簡單說:

實的關聯 (identifying relationships):一個是母表 vs 子表,外部關聯鍵 foreign key的值,是不能為NULL,一定要有值!

虛的關聯 (non-identifying relationships):foreign key 可以為 NULL

2023年8月27日 星期日

發現很好的SC sniplets 參考網站 https://asdw.de/en/category/scriptcase-sniplets-en/

https://asdw.de/en/category/scriptcase-sniplets-en/


今天紀錄一篇:

一、如何將[儲存]按鈕,複製一個放在 FORM 的任何位置。

https://asdw.de/en/add-new-save-button-anywhere-on-scriptcase-form/

1. 建立一個 Label 的新欄位{save_it},然後將他放在自己希望的位置。

2. 在 OnLoad Event 中,寫上下面這段程式碼:

{save_it} = '<a href="javascript: nm_atualiza (\'alterar\');" id="sc_b_upd_t" onclick="nm_atualiza (\'alterar\');; return false;" class="scButton_default" title="Update record" style="vertical-align: middle; display:inline-block;">Click to save</a>';


這樣就好了。


二、Place Button at any place of Scriptcase Form / Grid

https://asdw.de/en/place-button-at-any-place-of-scriptcase-form-grid/
要在FORM/GRID 的上面、下面 TOOLBAR 的位置,建立一個按鈕,是很簡單的事情。
但有時候,我們會希望將按鈕放在 FORM 裡面 / GRID的 ROW 裡面。
怎麼做?

1. 建立一個 動作的 LINK(如果點擊這個按鈕)

最簡單的方法是,用 SC 的 Macro:

sc_make_link(Application, Parameters)

example:

$string_link = sc_make_link(grid_images, ref_object_type='contact';ref_object_id={id});


2. 建立一個 Label 欄位

例如:名稱為: {edit_picture}

3. 在 OnLoad Event 中設定值給該欄位:

{edit_pictures} = '<a href="' . $string_link . '" class="scButton_small" title="Edit the picture" style="vertical-align: middle; display:inline-block;">' . {lang_contact_edit_pictures} . '</a>';


三、Save the data of a Scriptcase form via Ajax Event or PHP

https://asdw.de/en/save-the-data-of-a-scriptcase-form-via-ajax-event-or-php/


有時候,需要儲存紀錄,而不要讓用戶去按儲存或加入等按鈕。怎麼辦?

1. 建立一個小小的 Javascript Method 在 SC 的FORM:

Programming > Javascript Methods > New Method

The name of that method in our sample is:  ‘speichere’

The code of the method is only one line:

nm_atualiza ('alterar');


2. 設定使用者執行儲存的情境,例如用戶離開某一個欄位:

To save the content use the Ajax-event OnBlur or OnChange.

Sample: Save the data of the form when the user exits the field CityName:

在該AJAX EVENT 的定義中,使用這個程式碼:

sc_ajax_javascript('speochere', array());

這是 SC 的 macro,在 PHP 程式中呼叫 Javascript 的 method ,來儲存資料。

(我正在傷腦筋,如何在 Dashboard 中,一個 左邊的 Widget 執行程式完畢,然後呼叫讓右邊的 Widget 自動 reload,這個好像可以用。試試

哇!sc_ajax_javascript()只用在 FORM/CONTROL/CALANDAR,我的是 GRID!!不能用!哀!)



2023年8月20日 星期日

程式撰寫編碼,以可讀性為最高優先,一些較少用、非直觀的語法,盡量不要用,以PHP的 AND/&&、OR/|| 為例

PHP 的 邏輯運算元:AND/&&、OR/|| 這是常使用的運算元

而,AND 與 && 都是 AND 運算,有差別嗎?

有,其運算的優先次序不同。

&& 的運算次序高於 = , = 高於 AND

OR 一樣。

為了便於可讀性,我們建議一律使用可讀性高的表示法

如果有多個運算元在一起的運算式,就使用()來明確的表示優先次序,不要使用 && 這類不容易閱讀的運算元。


2023年8月18日 星期五

SC 的 sc_include_library()、sc_url_library() MACRO

SC 做好一些現成的 Macros 可以使用。其中:

sc_include_library("Target", "Library Name", "File", "include_once", "Require")

This macro includes a PHP file from a library in the application. You must have a library created in Scriptcase to make use of this macro. To create a library, go to "Tools -> Libraries".

Parameter
Description
TargetTells you what the scope of the library. It can be "sys" for libraries of Public scope or "prj" for libraries of the Project scope.
Library NameName given to the library at the time of creation.
FileThe absolute path within the library.
include_once (optional)Make sure that the file will only be included once. If not informed, this value is set as "true".
Require (optional)If the file or library does not exist, the application to be executed and returns an error. If not informed, the value is set as "true".

 

 

Ex: Including a file from a library:
sc_include_library("prj", "phpqrcode", "qrlib.php", true, true);



這是 External Library。
剛才試了 自己建 treeview 這個 Library,
裡面有一個 .css、一個 .js、 一個 .php、還有一個 images/tree/... 裡面的一個些圖檔

在 css 中,會用到這些圖檔,如下:
ul#n_0 {
padding-left: 0px !important;
background-image: url(images/tree/blank.gif) !important;
}

注意,那個 url(images/tree/blank.gif) 的 相對位址 images ,就直接在 Library 裡面建立 images/tree/ 的資料夾放置那些圖檔。

在SC 程式中要引用的時候,用法:

<link rel="stylesheet" type="text/css" href="<?php echo sc_url_library('prj', 'treeview', 'treeview.css'); ?>">
<script type="text/javascript" src="<?php echo sc_url_library('prj', 'treeview', 'tree.js'); ?>"></script>

這樣用。

另外,還有一個:

sc_include_library("prj", "treeview", "treeview_m.class.php", true, true);

我使用smarty 也是用這個:

// SMARTY

// Start output buffering
ob_start();
// run code in x.php file
// ...
// echo "<html><hrad></head><body>hello world!</body></html>";

sc_include_library("sys", "smarty", "Smarty.class.php", true, true);
// NOTE: Smarty has a capital 'S'
// require_once('Smarty.class.php');
$smarty = new Smarty();

$v_66shop_link = get_66shop_link_url("guest");

$smarty->assign('v_66shop_link_url',$v_66shop_link);

//** un-comment the following line to show the debug console
//$smarty->debugging = true;

$smarty->display('../_Designs/hongfu/index.html');
//echo $smarty->fetch('c:/temp/matrix_adm/html/index.html');

// saving captured output to file
// file_put_contents('c:/temp/filename.htm', ob_get_contents());
// end buffering and displaying page
ob_end_flush();

這兩個  Library 的用法,注意一下。






2023年8月15日 星期二

MySQL bit(1) 邏輯欄位 配合 View 後,竟然變了!

在資料庫表單中,經常有 Yes/No 的欄位,例如:是否已經繳款?是否審核通過?等。
原本,按理說,這樣的邏輯是否資料值的欄位,只要用 bit(1) 就足夠了。所以,我原本也就是用 bit(1) 來記錄就可以了。

結果在昨天設計SC時,由於需要使用到 VIEW,也就是SC是透過VIEW的方式來建立 GRID,(這另外說),結果 bit(1) 欄位值在 VIEW 的後面,都變成 True !連 False 也變成 True!造成程式跑出來當然就錯了!這不算是 SC的坑,但是 MySQL + VIEW 的坑了!我只好將 bit(1),改成 tinyint(1) 來記錄 0/1,這樣修改資料表結構以後,程式就完全正常了!

在這裡紀錄一下,一個小坑!

2023年8月13日 星期日

SC的坑們!這裡蒐集SC的坑!.......GRID GRID/Summary 模組,EXPORT PDF無法產生 Summary

使用工具,總是會有一些坑!

碰到了坑,就只好想辦法轉彎、變通!

沒辦法,因為是使用別人設計的工具,而且SC是有名的反應慢!反應一個BUG,可能不會收到回應,沒有信息;縱使有回應,也要等個幾個月,才有改!上次,我反應的問題,就等了快一年吧!這也是我一直會遲疑使用SC的原因之一!但也不能總是在等,應該用他來賺錢了!所以,想好合約書上的條款,規避可能的坑!

今天就出現坑了!

要產生獎金報表的程式,GRID是獎金明細,而SUMMARY模組可以產生個別總和的總結報表,這是一個非常棒的功能,在螢幕上產生的結果都很好,輸出要到 PDF、PRINT,也正確!(在我的LOCAL 開發環境上正常)!

坑要來了!

佈署到服務主機以後,輸出 SUMMARY 的 PDF,就出問題了!應該是產生 SUMMARY,但卻輸出了明細內容!試了設定的幾種排列組合!都失敗!

最後,嘗試這樣:複製出一個新的APPLICATION,而只有 SUMMARY模組,然後輸出PDF看看,因為內容只有SUMMARY,還好,好哩家在!終於在服務主機上看到期待的結果!

所以,只好這樣來避開坑了:

1. 設計兩個GRID APP,一個只有 SUMMARY、一個只有 GRID DETAIL,然後,各自產生各自的輸出 PDF,

2. 在這兩個 APP 彼此之間,再另行設計一個切換的按鈕,相互切換,看起來就好像是同一支程式APP一樣!唉!其實是為了避開無法正確產生SUMMARY PDF的坑而這樣做的!

坑!搞了好久!記錄下來,供以後使用!



另一個坑!紀錄:

年月輸入表單(APP A),呼叫 子程式總結列表(APP S),然後在 APP S 裡,做一個按鈕連結到 明細列表子程式 APP D。

如果在 APP D,也做一個連結按鈕 連結到 總結列表子程式(APP S),在開發環境中測試是可以正常運作的,但是一佈署到服務主機上,就不行了!產生"無效的數據"的錯誤訊息,這個訊息是跟權限有關的!不知道為何會這樣!只好把 APP D上連到 APPS 的連結拿掉,然後修改 APP D的 退回按鈕,退回到 APP S,這樣就解決了!

這個在開發環境上跑可以,而佈署到服務主機上就掛了!這種坑!SC好像還不少喔!

在此紀錄一下!


再一個小坑: (2023/08/14)

產生GRID總結報表(單獨的 SUMMARY 模組),結果HEADR右上角的日期格式是:dd/mm/YYYY,跟我PROJECT設定的Locale 格式不一樣,這又是一個SC的不一致的地方!算一個小坑吧!正常的 GRID 模組都正確,目前看到就這個錯誤!只好自己在 HEADER 設定那裏的 DATE,改為 VALUE,然後自己在 EVENT onScriptInit 裡寫一段: [sys_date] = date("Y/m/d");然後在 APPLICATION 的 Global Value 中將 sys_date 設為 output,這樣就完成了!規避一個小坑!

在此紀錄一下。



==============

今天(2023/09/13) 有另一個坑,也搞了好久,終於解決了!

我將過去跑得順利的 sc_samples8 本來是要安裝在 VPS上面,可是一直解壓縮有問題,所以,見乾脆回來DEDICATE 主機這裡。以前有安裝,而且跑得順利,想說在安裝回去,應該很快!

結果,samples 一安裝完畢以後,一跑就 500 Internal Error,給你當了!

有些APPLICATION可以跑,有些無法跑!很奇怪。

我原本一直在 SERVER 主機的設定上去傷腦筋!extension? php.ini? .htaccess?試了很久,還是一樣!

搞到晚上了,查YOUTUBE視頻,有一個說明 Internal Error 500 怎麼處理?

1. 找 PHP 的 error LOG

2. 修改 php.ini 的 error display 為 On

然後,就看到 Error Message了!

竟然是 php 程式錯誤!

我在 Local 上跑得很正常呀!

查了一下,就是 php 8.1 版本不再支援的舊寫法

Fatal error: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /home/ddnews/domains/samples.alfredlin015.com/public_html/samples/new_data_entry/new_data_entry_apl.php on line 8060

再比對一下程式,samples 是 SC 公司做的,它裡面有了 internal library scwebsite.php 有改寫,所有就copy samples9 的版本到我整理用的 samples8 去,再重新  Generate、deployee ,就成功了!

唉!浪費了一整天的時間再解決這個問題,終於解決了!

紀錄一下!


====================

2023/10/23 周一

今天又一個坑!還無法解決!

合會出現的會員手機畫面,希望能窄一點

於是企圖修改 theme template

結果改了半天,都不能修改

改了 padding 為 0px 儲存以後,還是一樣!

真是夠了!

唉!

一個大坑!

-----------------------

解決方案:

----------------------

最後,只好,用右鍵點出檢查,查閱SC產生的 class/id 相對的CSS檔案,然後去copy出來,貼到onScriptInit Event 去進行修改,在這裡去蓋掉.ccs檔案的設定。

這一招,前面用過,目前也只能先這樣了!

在 WordPress 的 Theme 裡,也是有自訂 CSS 裡面,用這招來蓋掉WP所設定好的CSS!






2023年8月8日 星期二

ScriptCase Grid 的 Quick Search

在 ScriptCase 的 GRID 中,使用 Qucik Search 是很簡單,又直觀的一種 Search 功能,
但是今天發現,如果 Field 是單純的 欄位,沒有 Lookup 的選項設定在上面,那麼要搜尋結果都可以運作得正常,而一旦設為 LookUp 設定以後,就無法正常搜尋了!

剛才實際測試了一下,確實是如此的。

這是一個坑!
紀錄一下。

2023年8月6日 星期日

SC FORM Application如果只有一筆資料,且 Toolbar沒有 navigation,就沒有資料顯示!

這個倒是很奇怪的現象!

如果 FORM 的 TOOLBAR 沒有 Navigation (上一頁、下一頁等),就沒有紀錄顯示!

這個要查一查?真的是這樣嗎?

2023年8月5日 星期六

SC Security 的 LOGIN - sec_logged.php 開 modal 視窗的問題

原本 SC 所附的 Security 模組裡面的 sc_logged.php 的程式裡面,如果沒有正常登出,再度登入時,會出現沒有登出,是否要登出的警告畫面,這個畫面的程式,就是 sc_logged ,是在 Login裡面的 internal library 裡面的 sc_logged.php 函數庫裡面的第一個函數裡:

  3|     function sc_logged($user, $ip = '')
  4|     {
  5|         $str_sql = "SELECT date_login, ip FROM acc_logged WHERE login = ". sc_sql_injection($user) ." AND sc_session <> ".sc_sql_injection('_SC_FAIL_SC_');
  6|
  7|         sc_select(data, $str_sql);
  8|
  9|     if({data} === FALSE || !isset($data->fields[0]))
 10|         {
 11|             $ip = ($ip == '') ? $_SERVER['REMOTE_ADDR'] : $ip;
 12|             sc_logged_in($user, $ip);
 13|             return true;
 14|         }
 15|         else
 16|         {
 17|             sc_reset_apl_conf("acc_sec_logged");
 18|             sc_apl_status("acc_sec_logged", 'on');
 19|             sc_redir("acc_sec_logged", user=$user, 'modal',"F",300,300);
 20|             return false;
 21|         }
 22|     }

這行,原本是只有
sc_redir("acc_sec_logged", user=$user,'modal');

這樣開出來的 視窗,如果是大螢幕,還好,但,如果是手機小螢幕,就超過螢幕看不到了。
所以,我將 長寬 增加設定為: 300(heught), 300(width)
中間那個 "F",不要漏了!
意思,看SC 的 手冊 HELP

以上。

SC 的 LANGUAGE設定發布到Server時,在第二個選項中

 如果有修改了  Language,要重新發布要 Server 上去,發布時的選項,要加上第二個 Common Files。

第一個 Production 裡沒有這個 Language

以上。

SC 的 應用程式連結,資料庫主關鍵的欺騙技巧

今天在做SC應用程式時,發生一個狀況

做一個GRID Application,其中的一個契約單號欄位,希望他能夠建立一個連結關連到該契約單號的編輯表單應用程式(FORM APPLICATION)。該 FORM Application 的主關鍵欄位為 id 內碼,而我有另外建一個ext_id,是給用戶看的外部單號,那也是唯一的關鍵欄位。當使用 GRID Application 建立 連結時,SC 是自動抓取被連結的 PK,或是 有 SQL WHERE 裡面的 [v_parameter]Global Variable。因為,我那個契約單的PK是 id,不是 ext_id,但是我在 GRID 上顯示且要連結的是 ext_id,所以,建立起來時,SC會自動抓取 id,而不是 ext_id,因此就會連結不上!我必須要到契約單的 FORM 去把 PK改成 ext_id,然後,再重新在 GRID 跑一次 建立 連結,這樣SC就會抓 ext_id,而成功的建立了連結。

我原本想,這樣就完美了。

所以,契約單這邊的 FORM就繼續保留 ext_id為PK。

但是,後來,因為這個 ext_id,是我另外寫程式自動產生流水號的編碼,所以在 INSERT 時會是空白的,這樣的程式,在原本是 id 內碼為PK的情形下,都沒有問題,跑得很順利,沒有錯誤。但因為設 ext_id 為PK,結果就一直跑出 該單號 不能為 空白的錯誤,我一直嘗試把自動給值的程式加在 EVENT onValidate/ onBeforeInsert 等看能否在SC檢查PK不能為空白之前就餵給他值,這樣就可以解決!但,都失敗了!SC還是一直給我錯誤:該PK欄位不能為空白!試了很多不同的途徑,還是都無法繞過SC的檢查!最後,還是把PK 還給 id,這樣FORM本身所有的問題都沒問題了!

但是,前面,因為為了給 GRID Application 建立外部連結而關連到這支 FORM的連結,而還抓得到嗎?結果,一試!GRID 的連結,還是跑得很正常,因為他是抓 ext_id!

換句話說:以後,我可以用這個方式,來避開SC的建立連結的限制。

也就是,像今天這樣意外的經驗:

1. 原本 契約單的 FORM 的 PK是內碼 id,可以暫時 修改為 要被 GRID 建立外部連結的程式要去抓取的 ext_id (他也必須是唯一的ALT KEY),這樣讓 GRID 連結程式可以抓得到,然後自動產生。

2. 建好以後,再去 FORM 的 PK,還原為原本的 內碼 id,這樣原本設計好的 FORM 也沒有改變!只是還原而已,馬照跑舞照跳,一切跟過去一樣!

這樣就好像是暫時欺騙一下SC的GRID建立連結的程式,讓他得以建立起連結,然後再改回來!

SC GRID的建立連結要抓取PK的設計,那也是要保證程式的邏輯抓取到是唯一的正確性而這樣設計。SC只設計了 PK,還有在 SQL WHERE 裡面的 Global Variable,兩種,他還沒有設計還可以自動抓 其他也是唯一的ALT KEY的選項,那我們只好這樣先騙騙他,然後再去改回來就好了!

以上記錄一下。


2023年8月3日 星期四

SC 呼叫 sc_redir()

 sc_redir()這個函數,用來將程式導向另一個應用程式

sc_redir( )語法:

sc_redir(Application, Parameter01; Parameter02; Target, Error, height_modal, width_modal)


舉例:

sc_redir(grid_bi_bonus_rec_accountant_yymm_report,v_yymm={yymm});

sc_redir("grid_bi_bonus_rec_accountant_yymm_report",v_yymm={yymm});

經過實際測試,上面這兩者都可以。

第一個參數: application_name,可以加引號,也可以不加引號!Scriptcase 的一些參數是否加引號的規則,有時很奇怪!不大統一!總是要讓人去測試摸索一下,才能確定!

第二個以後的參數,是傳給導向的 Application 的參數,上例: v_yymm={yymm}

注意語法,這裡不能加引號。還有 v_yymm 是一個跨應用程式的 通用變數(Global Variable),SC使用時,通常是要加 "[]" 中括號,但是這裡不能加中括號,加了會產生不可預期的錯誤!我剛才搞了好久!原來是不能加中括號。而導向到被導向的 Application 時,要被使用,就要加中括號了,這是一般SC的標準用法!

結論:SC的 Macro 函數,在使用這些參數上,是否加引號,不大一致,有些可以,有些不可以,不大一致,這有點頭大,等於是要把他的HELP 範例中看清楚,才能正確使用!

這點不大好!

SC 如果發生"數據無效"之類的錯誤訊息,如何處理?

在自己LOCAL開發環境中,執行很正常,可是一上傳發布到SERVER上跑,就出現 "數據無效"的錯誤信息。經過了解,可能是 安全 Security 方面的問題。

解決方法:

從新 上傳 開啟 LOGIN 以及 跟 Security 相關的設定檢查好,我這次連 _lib 執行環境都重新上傳發布,才解決了問題!

紀錄一下。

2023年7月9日 星期日

要記得 SQL 如果有 SUM等函數,要加上 IFNULL(sum(num_field), 0)

要記得 SQL 如果有 SUM等函數,要加上 IFNULL(sum(num_field), 0) 

否則,就會產生 NULL 的可能,導致後面如果有再拿資料處理的時候,就會發生錯誤。

記得喔!


SELECT IFNULL(sum(c_profit),0) as v_sum_profit, count(*) as v_count, IFNULL(sum(c_profit)/count(*),0) as v_avg 

FROM max_orders 

WHERE date(updated_at_in_ms)='2023-07-08' 

and state='done' 

and side='sell';

2023年7月3日 星期一

SC 如果有需要區分Local Server 及 線上 Server,可以這樣判斷

 if ($_SERVER['SERVER_NAME'] == '127.0.0.1') {

$img_dir = "http://127.0.0.1:8091/scriptcase/file/doc/splay/".{products_code}."/prod/";

$img_dir_desc = "http://127.0.0.1:8091/scriptcase/file/doc/splay/".{products_code}."/desc/";

$img_dir_main = "http://127.0.0.1:8091/scriptcase/file/img/splay/".{products_code}."/";

} else {

$img_dir      = "https://shopadmin.splaything.com/_lib/file/doc/splay/".{products_code}."/prod/";

$img_dir_desc = "https://shopadmin.splaything.com/_lib/file/doc/splay/".{products_code}."/desc/";

$img_dir_main = "https://shopadmin.splaything.com/_lib/file/img/splay/".{products_code}."/";

}


2023年6月27日 星期二

SC 裡面所有的圖片都設為 Responsive 響應式,這個搞了好久,解決方案這麼簡單!

先參考這一篇:

https://alfredwebdesign.blogspot.com/2022/06/scriptcase-sccss.html

內容複製如下:

可以在 Application 的 Events 裡面的 onScriptInit 裡面添加 CSS 的定義,就可以修改掉 原本 SC的CSS設定,例如:希望將 GRID 的表格底部的訊息隱藏起來,不要出現,可以使用 網頁檢查 的方式,查到該信息的 ID 為:sc_grid_sumario

那段 html 為:

<tr id="sc_grid_sumario"> .....</tr>

所以,就可以在 onScriptInit 這個 Event 裡面,這樣改:

?>
<style>
#sc_grid_sumario {
  display: none;
}
</style>
<?php


註:

onScriptInit 會加在 <HTML><HEAD>............[加在這裡]</HEAD>  

onApplicationInit 會加在 [加在這裡]<HTML<HEAD>............</HEAD>


找到將 img 設為 responsive 的 CSS 為:

img {
    max-width: 100%;
    height: auto;
}
所以,就在 onScriptInit Event 中,加上:
?>
<style>
img {
    max-width: 100%;
    height: auto;
}
</style>
<?php
就這樣,所有的 img 就都可以 responsive 了!
這麼簡單!喔~~~搞了好久!
原本的想法還在想要用 Bootstrap 外部程式庫的方式引入,再來想如何將 class = "img-fluid" 加到該欄位!

2023年6月24日 星期六

SC 的 Search

SC 已經做好幾種不同的 Search 模組功能,可以直接套用,功能強大。

如果只是在 Grid 列表中提供搜尋,就用 

1. Grid Modules 

  •     只要一個 Grid 就可以了,其他的 Search、Detail、Summary、Chart 都可以關閉掉。

2. Grid -> Search -> Quick Search -> Setting->QuickSearch layout 選擇 Simplified 以及下面的設定,這樣就可以了



一、Search Application

範例: samples/Search_Application/search01

Search01 是一個 Search Application

裡面只有一個輸入欄位: companyname

欄位右邊有一個 放大鏡連結,可以 呼叫 search01_01

是一個 Grid Application

這個連結屬於: Capture Link

第二個連結,就是 Edit Link,連結到一個 Form search01_02

帶出選擇的 companyid 的那筆 Form 來編輯。



二、GRID 裡面附的 SERACH

1. QUICK SEARCH 快速搜尋。允許在不同的欄位間搜尋資料。

• 在 工具按鈕列 ToolBar 上

• 跨欄位資料間搜尋

• 文字欄位中輸入搜尋資料

• 可以有以下幾種不同的選項形式:

○ 簡單型快速搜尋 / 擴充型快速搜尋

○ 搜尋結果是否粗體?

○ 是否保留 與 進階搜尋結果合併?

○ 放大鏡圖示 放在 格裡裡面?還是 外面?

○ 在簡單型快速搜尋時,顯示 下拉式<欄位選單>

○ 個別欄位的選項設定

2. Advanced Search 進階搜尋 :

• 搜尋更多的進階設定


3. Dynamic Search 動態搜尋


4. Refined Search 出現在螢幕左邊的 像591租屋網搜尋的Search


SC 表單中設計一個 [同上] 的 CheckBox,點擊打勾後,自動代入同上欄位的值

方法一:

例如:有兩個欄位

一個參加人姓名,一個繳款人姓名。輸入完參加人資料以後,有一個 CheckBox 打勾勾,同參加人,如果打勾的話,繳款人就不用重複輸入了,直接帶入參加人資料為繳款人資料。

這樣就額外加一個自訂欄位: same_check,欄位型態為CheckBox

然後在 Ajax Events 裡面,建立一個新的 Events:same_check_onClick,參數為:same_check

same_check 設定有一個值為"S"

在 Ajax Events same_check_onClick:

if ({same_check} == 'S') {

{payer_mem_ext_id} = {attender_mem_ext_id};

} else {

{payer_mem_ext_id} = "";

}

這一個方法,出來的效果比較理想。滑鼠一點擊CheckBox,如果是On,就會帶入值,如果Off,就會清空,這樣的效果較好。


方法二:

另一個以前設計的方法,是一個 Button,用 JavaScript 的方式完成。

Field:

增加一個 自訂 Field {same_addr_btn1}

JavaScript function sameaddress1()

$("select[name$='members_com_addr_country_id']" ).val($("select[name$='members_legal_addr_country_id']").val());

$("input[name$='members_com_addr_state']" ).val($("input[name$='members_legal_addr_state']").val());

$("input[name$='members_com_addr_city']" ).val($("input[name$='members_legal_addr_city']").val());

$("input[name$='members_com_addr_postcode']" ).val($("input[name$='members_legal_addr_postcode']").val());

$("input[name$='members_com_addr_street1']" ).val($("input[name$='members_legal_addr_street1']").val());

$("input[name$='members_com_addr_street2']" ).val($("input[name$='members_legal_addr_street2']").val());


Event OnLoad

{same_addr_btn1}="<button type='button' onclick='sameaddress1()'>Same Address</button>";

2023年6月19日 星期一

如何在 ScriptCase 中 Debug?

ScriptCase 的 Application -> Setting ->Notification Settings 裡面有 Debug Mode、還有一些是否顯示錯誤的選項可以設定,在這裡將他們打開,執行時就會出現錯誤訊息。

尤其是 SQL 的錯誤訊息,這樣才能除錯!


另外,我自己寫了一個 SQL procedure: system_log("log text"),可以將信息寫到 system_log 這個 table裡面。

system_log table 是要另外獨立建立的。

這個可以用來記錄自己要記錄的流水信息 LOG。

2023年6月18日 星期日

MySQL utf8 / utf8mb4?

MySQL資料庫,現在新的資料庫,最好都直接用 utf8mb4 了!

collate 用 utf8mb4_unicode_ci

當建立一個新的專案的時候,要先留意把這個資料庫的字元設定好,全部一致,這樣可以減少很多後面的一大堆麻煩!


2023年6月16日 星期五

ScriptCase 中,關於影像圖片檔案的處理

ScriptCase 的表單欄位 Form Fields 型態裡面,有兩種影像欄位: Image(Database)、Image(File Name)。

存在 Database 的,就是存在 MySQL的 Image (BLOB) 欄位,這種欄位型態,我沒有用過,我認為那是將 Image 的內容直接存在資料庫的欄位中,不論是存進去或讀出來都有其獨特的方法,沒有辦法直接用網頁或瀏覽器職讀取內容,這很麻煩,不好用,所以我不用。我都使用 FileName 檔案的型態,儲存圖檔名稱在某個特定的子目錄底下,這樣使用檔案總管之類的工具就可以很輕易的看到該圖檔內容。

所以,在 SC裡面的 Image (FileName),就會有檔案名稱,以及子目錄等設定必須做。

在資料庫裏面,該欄位則直接是存 檔案名稱,另外子目錄則是可以設定。

最基本的圖檔目錄設定是在:Application Setting 中設定。

然後,個別紀錄的檔案則再在 Subdirectory for local storage 這裡設定。

這個設定,可以用 global/local 變數、或欄位數值等來做為子目錄路徑(path)。


2023年5月20日 星期六

了解一下 Scriptcase 的資料夾結構(目錄結構)

由於 Scriptcase 是一個程式產生器,他被設計得極其複雜。經常會有許多不可預期的 BUGS、說明文件缺乏、技術支援不足(技術支援還要額外付費!)等!令人又愛又恨!

站在使用工具的角度來看,Scriptcase 是一個好用但有缺陷的工具,我們使用的人,就要充分了解這個工具的特性、長處、缺點。

了解SC的目錄結構,有助於我們對工具的了解。

參考這篇:

https://medium.com/mestre-scriptcase/entendendo-a-estrutura-de-pastas-do-scriptcase-4eb15a759589

https://miro.medium.com/v2/resize:fit:640/format:webp/1*wyNN2WDB4REdB_w4AEd0Tw.png

其中:

app/

Stores everything generated by the project, from application source code to libraries, themes, langs and other assets. This directory is only for a preview of what is being developed, not for backups or production purposes.

The structure of this folder is defined as:

<nome do projeto>: Applications source code.
<nome do projeto>/_lib/buttons: Button theme.
<nome do projeto>/_lib/chart: Graphic themes.
<nome do projeto>/_lib/css: Application themes.
<nome do projeto>/_lib/font: Report PDF and Captcha fonts.
<nome do projeto>/_lib/friendly_url: Application friendly URLs.
<nome do projeto>/_lib/googlefonts: Google Fonts of the themes.
<nome do projeto>/_lib/img: Screenshots of applications.

Inside the directory <nome do projeto>/_lib/imgwe have the following file structure:

img/grp__NM__bg__NM__*: Project-level background images.
img/grp__NM__btn__NM__*: Images of project-level buttons.
img/grp__NM__ico__NM__*: Project-level icons.
img/grp__NM__img__NM__*: General images at project level.
img/grp__NM__menu_img__NM__*: Project-level menu images.
img/grp__NM__helpcase__NM__*: Helpcase images at project level.
img/scriptcase__NM__bg__NM__*: Background images at Scriptcase level.
img/scriptcase__NM__btn__NM__*: Images of buttons at Scriptcase level.
img/scriptcase__NM__ico__NM__*: Scriptcase level icons.
img/scriptcase__NM__img__NM__*: General images at Scriptcase level.
img/scriptcase__NM__menu_img__NM__*: Menu images at Scriptcase level.
img/sys__NM__bg__NM__*: Public level background images.
img/sys__NM__btn__NM__*: Public level button images.
img/sys__NM__ico__NM__*: Public level icons.
img/sys__NM__img__NM__*: General images at public level.
img/sys__menu_img__NM__*: Screenshots of the public menu.
img/usr__NM__bg__NM__*: User-level background images.
img/usr__NM__btn__NM__*: Images of user-level buttons.
img/usr__NM__ico__NM__*: User-level icons.
img/usr__NM__img__NM__*: General user-level images.
img/usr__NM__menu_img__NM__*: User-level menu screenshots.

Back in the directory <nome do projeto>/_lib/we have this structure:

js: Notifications Javascript messages.
lang: Application messages.
lib: Scriptcase Assets.
libraries: Project external libraries.

We will not <nome do projeto>/_lib/librariessee the following:

grp: Project level.
scriptcase: Scriptcase level.
sys: Public level.
usr: User level.

Going back to <nome do projeto>/_lib/, this is the structure:

menuicons: Menu icons.
oauth: Google Calendar key.
profile_api.conf.php: Project APIs.

backup/
Stores all exports that were imported into Scriptcase, from projects to general backup. In this directory we find backup/scriptcase that serves to create copies of the Scriptcase database. This procedure is only applied for standard installations done in SQLite.

devel/
Stores all files used by Scriptcase for project development . It also consists of storing all assets saved at the Scriptcase, project, user and public level.

The structure of this folder is defined as:

[SCRIPTCASE]
devel/conf/scriptcase/nm_scriptcase.db : Scriptcase's SQLite database when installed by default.
devel/conf/scriptcase/scriptcase.config.php: Scriptcase administrative settings.
devel/conf/scriptcase/fix.php: Fixes executed by Scriptcase.

Note: Fixes are Scriptcase scripts executed after certain updates, in order to update old applications with new features.

devel/conf/scriptcase/api: Profiles of Scriptcase APIs.
devel/conf/scriptcase/chart: Theme profiles for Scriptcase graphics.
devel/conf/scriptcase/css: CSS and Scriptcase Fonts.
devel/conf/scriptcase/googlefonts: Google Fonts from Scriptcase.
devel/conf/scriptcase/hotkeys: Scriptcase shortcut key profiles.
devel/conf/scriptcase/img: Scriptcase images.
img/bg: Scriptcase background images.
img/btn: CSS for Scriptcase buttons.
img/ico: Scriptcase icons.
img/img: General images of Scriptcase.
devel/conf/scriptcase/lib: Scriptcase internal libraries.
devel/conf/scriptcase/libraries: Scriptcase external libraries.
devel/conf/scriptcase/lookup_def: Scriptcase manual lookup profiles.
devel/conf/scriptcase/menu: Scriptcase menu themes.
devel/conf/scriptcase/precodes: Inserts Code of Scriptcase events.
devel/conf/scriptcase/schema: Scriptcase project themes.
devel/conf/scriptcase/schemas: Old Graphics, HTML Editors and Scriptcase Menu Icons.
schemas/charts: Old Scriptcase graphics themes.
schemas/editor_html: Profiles of Scriptcase HTML editors.
schemas/menu: Scriptcase menu icon themes. devel/conf/scriptcase/snippets: Profiles of Scriptcase snippets.
devel/conf/scriptcase/tpl: Scriptcase HTML Templates.
tpl/header: Scriptcase header HTML templates.
tpl/footer: Scriptcase footer HTML templates.
tpl/free: Free format HTML templates from Scriptcase.
tpl/helpcase: Scriptcase Helpcase headers HTML templates.
devel/conf/scriptcase/securitymodule: Scriptcase security module profiles.

[PROJECT]
devel/conf/grp/<nome do projeto>/api : Project API profiles.
devel/conf/grp/<nome do projeto>/chart: Theme profiles for project graphics.
devel/conf/grp/<nome do projeto>/googlefonts: Google Fonts for the project.
devel/conf/grp/<nome do projeto>/hotkeys: Project shortcut key profiles.
devel/conf/grp/<nome do projeto>/img: Project images.
img/bg: Project background images.
img/btn: Project buttons CSS.
img/ico: Project icons.
img/img: General images of the project.
devel/conf/grp/<nome do projeto>/lib: Project internal libraries.
devel/conf/grp/<nome do projeto>/libraries: Project external libraries.
devel/conf/grp/<nome do projeto>/lookup_def: Project manual lookup profiles.
devel/conf/grp/<nome do projeto>/menu: Project menu themes.
devel/conf/grp/<nome do projeto>/schema: Themes of the project's projects.
devel/conf/grp/<nome do projeto>/schemas: Old Graphics, HTML Editors and Project Menu Icons.
schemas/charts: Project old graphics themes.
schemas/editor_html: Profiles of the project's HTML editors.
schemas/menu: Design menu icon themes.
devel/conf/grp/<nome do projeto>/snippets: Project snippet profiles.
devel/conf/grp/<nome do projeto>/tpl: Project HTML templates.
tpl/header: Project header HTML templates.
tpl/footer: Project footer HTML templates.
tpl/free: HTML templates of free project formats.
tpl/helpcase: Project Helpcase header HTML templates.
devel/conf/grp/<nome do projeto>/securitymodule: Project security module profiles.

[PUBLIC]
devel/conf/sys/api : Public API profiles.
devel/conf/sys/chart: Theme profiles for public graphics.
devel/conf/sys/googlefonts: Public Google Fonts.
devel/conf/sys/hotkeys: Public hotkey profiles.
devel/conf/sys/img: Public images.
img/bg: Public background images.
img/btn: CSS for public buttons.
img/ico: Public icons.
img/img: Public general images.
devel/conf/sys/lib: Public internal libraries.
devel/conf/sys/libraries: Public external libraries.
devel/conf/sys/lookup_def: Public manual lookup profiles.
devel/conf/sys/menu: Public menu themes.
devel/conf/sys/schema: Themes of public projects.
devel/conf/sys/schemas: Old Graphics, HTML Editors and Public Menu Icons.
schemas/charts: Public old graphics themes.
schemas/editor_html: Profiles of public HTML publishers.
schemas/menu: Public menu icon themes.
devel/conf/sys/snippets: Public snippet profiles.
devel/conf/sys/tpl: Public HTML templates.
tpl/header: Public header HTML templates.
tpl/footer: Public footer HTML templates.
tpl/free: Public free format HTML templates.
devel/conf/sys/securitymodule: Public security module profiles.

[USER]
devel/conf/usr/<nome do usuário>/api : User API profiles.
devel/conf/usr/<nome do usuário>/chart: Theme profiles for user graphics.
devel/conf/usr/<nome do usuário>/googlefonts: User's Google Fonts.
devel/conf/usr/<nome do usuário>/hotkeys: User hotkey profiles.
devel/conf/usr/<nome do usuário>/img: User images.
img/bg: User background images.
img/btn: CSS for user buttons.
img/ico: User icons.
img/img: General user images.
devel/conf/usr/<nome do usuário>/lib: Internal user libraries.
devel/conf/usr/<nome do usuário>/libraries: External user libraries.
devel/conf/usr/<nome do usuário>/lookup_def: User manual lookup profiles.
devel/conf/usr/<nome do usuário>/menu: User menu themes.
devel/conf/usr/<nome do usuário>/schema: User project themes.
devel/conf/usr/<nome do usuário>/schemas: Old Graphics, HTML Editors and User Menu Icons.
schemas/charts: User old graphics themes.
schemas/editor_html: User HTML editor profiles.
schemas/menu: User menu icon themes.
devel/conf/usr/<nome do usuário>/snippets: User snippet profiles.
devel/conf/usr/<nome do usuário>/tpl: User HTML templates.
tpl/header: User header HTML templates.
tpl/footer: User footer HTML templates.
tpl/free: Free user format HTML templates.
devel/conf/usr/<nome do usuário>/securitymodule: User security module profiles.

doc/
Stores Scriptcase documentation.

examples/
Stores all Scriptcase example projects along with their CREATE TABLE for SQLite and MySQL .

file/
Stores files imported by the Document (File Name) and Image (File Name) fields . This directory is for testing in development only. For advanced publishing, it is recommended that the paths defined for production are applied during publishing.
For typical publishing, the paths are in _lib/file.

log/
Stores the logs generated by Scriptcase. For folder exceptions below, the log is generated in scriptcase/tmp .

The structure of this folder is defined as:
log/iface: User actions in Scriptcase.
log/upd: Automatic updates
log/fix.log: Fixes executed after update.

prod/
Stores production environment. Used to connect what is generated in scriptcase/app and generate a production environment during project publication.

The structure of this folder is defined as:

prod/cep: Files for searching CEP type fields.
Note: Only available in pt_br installation.
prod/third: Third-party libraries used by generated applications.

tmp/
Stores temporary files created during use. Files range from interface errors to data exports in generated applications.

config_.php: Scriptcase database access settings. For standard installations the database is SQLite and is located atscriptcase/devel/conf/scriptcase/nm_scriptcase.db

Note : For security reasons, you need to rename this file to config.phpaccess it through the browser.

diagnosis.php: Diagnosis of the Scriptcase environment containing general server information, from PHP parameters to databases available for connection.

info.php: General PHP information used by diagnostics.

If you found this article helpful, go to the 👏 button and click as many times as you enjoyed reading this post. This will certainly go a long way. Feel free to leave a comment/suggestion. You can also find us on Facebook , Instagram and Youtube . Together for a better Scriptcase!



如何判斷現在FORM是在 insert mode? 還是 update mode?

只要用  if (empty({primary_key})) 就可以知道是否為新增模式了。 如果 {promary_key} 是空白的,那麼就是在新增模式;反之,就是更新模式。 以上。