var cls_others=(function(){ this.init=function(){ var mobj=this; this.btn_bind(); } this.btn_bind=function(){ } this.init(); var re={ //MODAL OBJ 'modal_obj':function(obj_name,gl_name){ this.obj_name=obj_name; this.gl_name=gl_name; $(this.obj_name).find('.modal-dialog').css('width','80%'); this.show=function(){ $(this.obj_name).modal('show'); } this.hide=function(){ $(this.obj_name).modal('hide'); } this.loading=function(){ $(this.obj_name).find('.modal-title').html('Loading'); $(this.obj_name).find('.modal-body').html('資料讀取中請稍候...'); } this.set_content=function(content){ $(this.obj_name).find('.modal-body').html(content); } this.set_title=function(content){ $(this.obj_name).find('.modal-title').html(content); } this.footer_close_btn=function(){ var close_fun=this.gl_name+'.hide();'; $(this.obj_name).find('.modal-body').append('\
\
\ \
'); } } } return re; }()); var cls=(function(){ this.init=function(){ this.btn_bind(); $(document).ready(function(){ cls.modal_obj = new cls_others.modal_obj('.class-bs-modal-lg','cls.modal_obj'); //如果有指定ID var hash=ANK.fun.get_path(); if(typeof(hash[2])=='string' && hash[2].length>0){ var cid=hash[2]; cls.show_detail(cid); } }); } this.btn_bind=function(){ } this.init(); var re={ 'show_detail':function(obj){ if(typeof(obj)=='string'){ var cid=obj; }else{ var cid=obj.attr('cid'); } cls.modal_obj.show(); cls.modal_obj.loading(); cls.modal_obj.set_title('課程介紹'); var data={ 'ajax_type':'get_unit' } data['cid']=cid; ANK.ajax(['ajax/ajax_cls.php','cls','_main'],data,function(gdata){ var html=Base64.decode(gdata['html']); cls.modal_obj.set_content(html); cls.modal_obj.footer_close_btn(); },'json'); }, //報名送出 'send':function(){ var cfm=confirm('確認是否送出?'); if(!cfm)return false; var data=ANK.get_form_data($('.cls_area')); console.log(data); //防呆處理 if(!this.chk_data(data['price_plan'],'方案尚未選擇'))return false; if(!this.chk_data(data['name'],'姓名尚未填寫'))return false; if(!this.chk_data(data['id_number'],'身份證必須填寫'))return false; if(!this.chk_data(data['email'],'EMAIL必須填寫'))return false; if(!this.chk_data(data['phone'],'電話或聯絡電話必須則一填寫',false)){ if(!this.chk_data(data['phone_2'],'電話或聯絡電話必須則一填寫'))return false; } if(!this.chk_data(data['zip_code'],'郵遞區號必須填寫'))return false; if(!this.chk_data(data['address'],'地址必須填寫'))return false; if(!this.chk_data(data['service_unit'],'服務單位必須填寫'))return false; if(!this.chk_data(data['job_title'],'職稱必須填寫'))return false; //如果方案價錢大於0 var price_selected = parseInt($('.cus_area input[name="price_plan"]:checked').attr('price')); if(price_selected>0){ if(!this.chk_data(data['pay_title'],'繳費抬頭必須填寫'))return false; } //如果有供餐 if(data['meal']!='999'){ if(!this.chk_data(data['meal'],'餐點必須選擇'))return false; } //如果有自定欄位 也必須填寫 if($('input[name="custom1"]').length>0)if(!this.chk_data(data['custom1'],'*必填欄位 必須填寫(a)'))return false; if($('input[name="custom2"]').length>0)if(!this.chk_data(data['custom2'],'*必填欄位 必須填寫(b)'))return false; if($('input[name="custom3"]').length>0)if(!this.chk_data(data['custom3'],'*必填欄位 必須填寫(c)'))return false; if($('input[name="custom4"]').length>0)if(!this.chk_data(data['custom4'],'*必填欄位 必須填寫(d)'))return false; data['ajax_type']='send'; ANK.ajax(['ajax/ajax_cls.php','cls','_main'],data,function(gdata){ alert(gdata['desc_str']); if(gdata['status']){ setTimeout(function(){ location.href='/class/list'; },1500); } },'json'); }, //已報名清單 'show_booked':function(obj){ if(typeof(obj)=='string'){ var cid=obj; }else{ var cid=obj.attr('cid'); } cls.modal_obj.show(); cls.modal_obj.loading(); cls.modal_obj.set_title('已報名列表'); var data={ 'ajax_type':'get_booked_list' } data['cid']=cid; ANK.ajax(['ajax/ajax_cls.php','cls','_main'],data,function(gdata){ var html=Base64.decode(gdata['html']); cls.modal_obj.set_content(html); cls.modal_obj.footer_close_btn(); },'json'); }, //確認訊息 'chk_data':function(data,msg,error_alert){ if(typeof(data)=='undefined'){ if(error_alert!=false)alert(msg); return false; } if(data.length<1){ if(error_alert!=false)alert(msg); return false; } return true; } } return re; }());