2015年7月24日 星期五

scriptcase upload file

中文檔名,不行!
英文檔名,size較小,可以成功,但檔案較大,就不行!
將 php.ini 裡面的
upload_max_filesize = 64M ==> 512M
upload_max_filesize, 
memory_limit, 
post_max_size
max_execution_time

放大後,就可以成功了!

上傳的位置放在 /_lib/file/ 裡面 docnn  nn為id,設定在該form裡面。
他並沒有依照 form 裡面的 Application -> Settings->Document Path 裡的設定放置

如果選擇的是 field datatype -> images(file name),也不會放在 application -> settings -> Image Directory 裡面!

Scriptcase 裡面還是一堆 Bugs!

唉!究竟是我誤解了呢?還是 Bugs!


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

multi-upload 功能似乎僅能適用在 Document(database),也就是儲存在 mysql BLOB裡面才可以。用Filename 似乎不行ㄟ!

但是,我不想把附加的檔案文件放到BLOB中,那樣會讓 database太大,以後會麻煩的。






2015年7月22日 星期三

用MySQL的Trigger 自動產生會員編號

想要自己編會員編號,不想用mysql 的 auto-increment自動編號功能。
而這個編號,可能會在不同的 AP 開放輸入,所以,最好的產生方式,是放在資料庫裡面自動產生,所以,就動了 Trigger 的念頭。

經過研究,寫了下面這段:


CREATE TRIGGER `get_ext_id` BEFORE INSERT ON `members`
 FOR EACH ROW BEGIN

    DECLARE v_last_id , v_new_id INT;

    SELECT members_last_id INTO v_last_id FROM members_last_id;
    SET v_new_id = v_last_id + 1;
    UPDATE members_last_id SET members_last_id = v_new_id;
    SET NEW.members_ext_id = LPAD(v_new_id,10,'0');

END


members_last_id 是另外建立的一個 table,裡面只有一個欄位,也叫做:members_last_id,而且只有一筆記錄,就是記錄著欲產生的會員編號的最後一號。

就這樣,可以自動從資料庫裡面,每當有新增時,就會自動產生會員編號。

2015年7月21日 星期二

Scriptcase 建立文字的會員編號

$tmp_str_id = str_pad({members_id}, 10, '0', STR_PAD_LEFT);
// SQL statement parameters
$update_table  = 'members';      // Table name
$update_where  = "members_id = {members_id}"; // Where clause
$update_fields = array(   // Field list, add as many as needed
     "members_ext_id = '$tmp_str_id'"
 );
// Update record
$update_sql = 'UPDATE ' . $update_table
    . ' SET '   . implode(', ', $update_fields)
    . ' WHERE ' . $update_where;
sc_exec_sql($update_sql);

2015年4月24日 星期五

Scriptcase 裡面,如何取得上層ap的欄位值

如題

只能透過 [session variable]做了。

ScriptCase 的 Form 裡面 --> Fields --> 要的欄位 --> Save Variable:yes --> Variable Name: [xxxxxx]

這樣,就可以在 detail 中使用 該 Session Variable了。


而 sc_master_value('Object', Value) 這個 macro 則是可以 更新 上層ap 欄位的值

Update a data in the Master application in real time according to changes made in a given field of the Detail application.

2015年4月23日 星期四

php 加減

有些數字必須這樣處理,才能加減!
floatval(preg_replace("/[^-0-9\.]/","",$orders_shipment_id));
$total2 = floatval(preg_replace("/[^-0-9\.]/","",$total)) + floatval(preg_replace("/[^-0-9\.]/","",$ship_fees));

2015年4月22日 星期三

Scriptcase裡Form的 master/detail

ScriptCase 的 Form 裡面的 Master/ Detail 是建立一對多的關聯資料,detail 部分,可以連結到 Grid 或是 Form 都可以。

Grid 當然就是只有可以看,不能編輯、修改;而要期待能編輯、新增、修改、刪除,就必須使用 Form 裡面的 Multiple Records / Editable Grid / Editable Grid view ,咦?好像也可以使用 Single Record喔!就是出現時是一筆一筆出來的。

2015年4月20日 星期一

ScriptCase 裡面的 Link

如果Application 是 Form,允許的 Link 有:Application 、 Capture 兩種

Application Link :
  • Application - Used to link our form to any other type of application. This linking type is associated to events of Inclusion and/or alteration, when occurs one of those events the navigation will be effected to the application that we are calling.
Capture Link :
  • Capture - Will be created an icon  beside the field inside the form, when being selected it opens other window showing a search application. In this application that will be opened can do searches and return a value to text field.
  • 選了 Capture 以後,會出現一個欄位選擇,然後選擇一個 Grid 的 Application,此 Grid Application,即是產生來讓使用者選擇欄位值的。
  • 注意:選擇連結Capture 的欄位型態不能是<Select>,能夠是 <text>/<integer>等開放輸入欄位,不能是選擇式的,因為,那功能是一樣的,列出來選擇。我試了,如果是<select>,縱使再建立此 Capture Link 也一樣沒有連結東西,將<select>改成<integer> 就有聯結了!

Form 裡面的 fields 如果是 <select> type 的話,在此欄位旁邊可以加上一個 Link到form的連結,這個Link 就只是 Link 過去 edit 一個Form而已,沒有傳參數過去,同時顯示"EDIT"(中文"更改")的一個button。可以打開該欄位內容的 Form 去更改數值。


如果 Application 是 Grid的話,允許的 Link 有:Application 、 Field、Capture 三種

Application Link :

Field Link :

Capture Link :




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

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