<div style="padding: 10px;"></div>

<div class="col-md-2 col-md-offset-1" style="padding-top: 10px; padding-bottom: 10px;">
    <div id="profilepic" onclick="openFileOption()">
    <?php 
$t = time();
$src = _SPPATH . Leap\View\InputFoto::getFoto($roleObj->admin_foto);
$id = "holder_foto_old_" . $t;
?>
        <img src="<?php 
echo $src;
?>
" id="<?php 
echo $id;
?>
" style="width: 100%;" class="img-responsive">
        <input type="file" id="upload" name="upload" style="visibility: hidden; width: 1px; height: 1px"  />
    </div>
<script>
function openFileOption()
{
    document.getElementById('upload').click(); return false;
  
}


            document.querySelector('#profilepic input[type=file]').addEventListener('change', function (event) {
                // Read files
                var files = event.target.files;
                //alert('in');
                //console.log(files);
    function confirmpayment()
    {
        $id = addslashes($_GET['app_id']);
        $acc = new App2Acc();
        $apps = $acc->getWhereFromMultipleTable("ac_admin_id = '" . Account::getMyID() . "' AND ac_app_id = app_id AND ac_app_id = '{$id}' ", array("AppAccount"));
        if (count($apps) < 1) {
            die("hacking attempt");
        } else {
            $app = $apps[0];
        }
        $paket = new Paket();
        $paket->getByID($app->app_paket_id);
        ?>
        <style>
            .helper{
                font-size: 12px;
                padding-top: 5px;
                color:#999999;
            }
            .foto100{
                width: 100px;
                height: 100px;
                overflow: hidden;
            }
            .foto100 img{
                height: 100px;
            }
            .err{
                display: none;
            }
        </style>
<div class="container attop" style="text-align: center;" >
    <div class="col-md-8 col-md-offset-2">
        <h1>Payment Confirmation for <?php 
        echo $app->app_name;
        ?>
</h1>
        <hr>
        <div id="resultajax" style="display: none;"></div>
        <form id="paymentconfirm" class="form-horizontal" role="form">
            <input type="hidden" name="appid" value="<?php 
        echo $app->app_id;
        ?>
">
            <div class="form-group">
                <label class="control-label col-sm-4" for="ttdate">Date :
                    <div class="helper">max 30 chars</div>
                </label>
                <div class="col-sm-8">
                    <input name="ttdate" type="date" class="form-control" id="ttdate" >
                    <div class="err"></div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-4" for="ttname">Sender Name :
                    <div class="helper">max 80 chars</div>
                </label>
                <div class="col-sm-8">
                    <input name="ttname" type="text" class="form-control" id="ttname" >
                    <div class="err"></div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-4" for="ttamount">Amount Transfered :
                    <div class="helper">max 80 chars</div>
                </label>
                <div class="col-sm-8">
                    <input name="ttamount" type="number" class="form-control" id="ttamount" value="<?php 
        echo $paket->paket_price * 12;
        ?>
" >
                    <div class="err"></div>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-sm-4" for="ttto">Payment To :
                    <div class="helper">max 80 chars</div>
                </label>
                <div class="col-sm-8">
                    <select id="ttto" name="ttto" class="form-control">
                        <option value="bca">BCA</option>
                        <option value="permata">Permata</option>
                    </select>
                    <div class="err"></div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-4" for="appicon">Receipt File:
                    <div class="helper">optional</div>
                </label>
                <div class="col-sm-8">
                    <?php 
        $foto = new \Leap\View\InputFoto("ttfile", "ttfile", "");
        $foto->p();
        ?>

                 </div>
            </div>
            <div class="form-group">
                <div class="col-sm-8 col-sm-offset-2">
                    <button type="submit" style="width: 100%;" class="btn btn-lg btn-success">Submit</button>
                    <a href="<?php 
        echo _SPPATH;
        ?>
PaymentWeb/payfor?app_id=<?php 
        echo $app->app_id;
        ?>
" style="width: 100%; margin-top: 10px;" class="btn btn-lg btn-default">Cancel</a>
                </div>
            </div>
        </form>
        </div>
    </div>
        <script>
            $( "#paymentconfirm" ).submit(function( event ) {

                $(".err").hide();

//                        alert("benar semua1");
                var $form = $(this);
                var url = "<?php 
        echo _SPPATH;
        ?>
PaymentWeb/addConfirm";

                $(".err").hide();

                // Send the data using post
                var posting = $.post(url, $form.serialize(), function (data) {
                    console.log(data);
                    if (data.bool) {
                        //kalau success masuk ke check your email....
                        document.location = "<?php 
        echo _SPPATH;
        ?>
myOrders";
                    }
                    else {
                        if(data.all!="") {
                            $("#resultajax").show();
                            $("#resultajax").html(data.all);
                        }
                        var obj = data.err;
                        var tim = data.timeId;
                        //console.log( obj );
                        for (var property in obj) {
                            if (obj.hasOwnProperty(property)) {
                                $( "#"+property ).css( "border-color", "red");
                                $( "#"+property ).next(".err").css( "color", "red").show().empty().append(obj[property]).fadeIn('slow');
                            }
                        }
                    }
                }, 'json');




                event.preventDefault();
            });
        </script>

        <?php 
        /*
                 *
        Transaction Date *
        
        Sender Name *
        
        Amount Transferred *
        
        Payment to *
        
        Email *
        
        Receipt File (optional)
        Choose File
        Fields marked with * are required.
        */
    }
 public function getFoto($src = "")
 {
     if ($src == "") {
         $src = $this->admin_foto;
     }
     return Leap\View\InputFoto::getFoto($src);
 }
    public static function isi_ulangan()
    {
        //$ul = new QuizUlangan();
        //$ul->getByID($id);
        //pr($ul);
        //$lv = new QuizLevel();
        //$lv->getByID($ul->ulangan_level_id);
        $cnt = 1;
        ?>
<style>
    .quest{
        padding: 20px;
        border-bottom: 1px solid #dedede;
    }    
    .answer{
        padding: 20px;
        padding-left: 30px;
    }
    .choice{
        padding: 10px;
    }
    .formulangan{
        padding: 20px;
        margin: 20px;
        background-color: #efefef;
    }
    div.foto100{
        width: 100px;
        height: 100px;
    }
    div.foto100 img{
        height: 100px;
    }
    .file table td{ 
        padding: 5px;
        vertical-align: top;
    }
</style>

<div class="col-md-8 col-md-offset-2">
    <div style="text-align: right; padding: 20px;">
<a href="<?php 
        echo _SPPATH;
        ?>
p/manage_ujian">manajemen ujian</a>
</div>
    <div class="formulangan" >
        <form onsubmit="doSaveUlangan();" id="formulangan" action="<?php 
        echo _SPPATH;
        ?>
p/submit_ul" method="post">
  <div class="form-group">
      <label for="judul_ulangan">Judul <small>*dipakai juga untuk share fb</small></label>
    <input type="text" class="form-control" id="judul_ulangan" placeholder="Judul">
  </div>
  <div class="form-group">
    <label for="deskripsi_ulangan">Deskripsi <small>*hanya dipakai untuk share fb</small></label>
    <input type="text" class="form-control" id="deskripsi_ulangan" placeholder="Deskripsi">
  </div>
  <div class="form-group file">
    <label for="deskripsi_ulangan">Gambar <small>*dipakai juga untuk share fb</small></label>
    <?php 
        $if = new Leap\View\InputFoto("ulangan_file", "ulangan_file", "", "form-control", 1);
        $if->p();
        ?>
  </div>
    <button type="submit" class="btn btn-primary btn-lg" style="width: 100%;">Kirim</button>
</form>
    </div>

             
        
<script>
 function doSaveUlangan(){
            
    event.preventDefault();
    var judul_ulangan = $('#judul_ulangan').val();
    var deskripsi_ulangan = $('#deskripsi_ulangan').val();
    var ulangan_file = $('#ulangan_file').val();
    var err = 0;
    if(judul_ulangan==""||deskripsi_ulangan==""||ulangan_file=="")
    {
        err = 1;
        alert('harap mengisi semua data');
    }

    if(!err)
    $.post('<?php 
        echo _SPPATH;
        ?>
p/submit_ul',
    {
        ulangan_file:ulangan_file,
        deskripsi_ulangan : deskripsi_ulangan,
        judul_ulangan : judul_ulangan,

    }
    ,function(data){
        if(data.bool){
            document.location='<?php 
        echo _SPPATH;
        ?>
p/ul/'+data.ul_id;
        }else{
            alert('Error sewaktu menyimpan');
        }
    },'json');
}    
function doSave(cnt,qid,event){
            
            event.preventDefault();
            var answer_0 = $('#answer_title_'+cnt+'_0').val();
            var answer_0_img = $('#answer_file_'+cnt+'_0').val();
            //alert(answer_1+' '+answer_1_img);
            
            var answer_1 = $('#answer_title_'+cnt+'_1').val();
            var answer_1_img = $('#answer_file_'+cnt+'_1').val();
            //alert(answer_2+' '+answer_2_img);
            
            var answer_2 = $('#answer_title_'+cnt+'_2').val();
            var answer_2_img = $('#answer_file_'+cnt+'_2').val();
            //alert(answer_3+' '+answer_3_img);
            
            var answer_3 = $('#answer_title_'+cnt+'_3').val();
            var answer_3_img = $('#answer_file_'+cnt+'_3').val();
            //alert(answer_4+' '+answer_4_img);
            
            //var qid = <?php 
        echo $q->qid;
        ?>
;
            
            var q_title = $('#question_'+cnt+'_title').val();
            var q_img = $('#question_'+cnt+'_file').val();
            
            var radio = $('input[name=radio_'+cnt+']:checked').val();
            
            var q_aktif = $('#question_'+cnt+'_aktif').val();
            //alert(radio+' '+qid+' '+q_title+' '+q_img+' '+answer_0+' '+answer_0_img+' '+answer_1+' '+answer_1_img+' '+answer_2+' '+answer_2_img+' '+answer_3+' '+answer_3_img);
            
            $.post('<?php 
        echo _SPPATH;
        ?>
UlWeb/saveQ',
            {
                radio:radio,
                qid : qid,
                q_title : q_title,
                q_img : q_img,
                q_aktif: q_aktif,
                answer_0 : answer_0,
                answer_0_img : answer_0_img,
                answer_1 : answer_1,
                answer_1_img : answer_1_img,
                answer_2 : answer_2,
                answer_2_img : answer_2_img,
                answer_3 : answer_3,
                answer_3_img : answer_3_img,
                ul_id : '<?php 
        echo $id;
        ?>
',
            }
            ,function(data){
                alert(data);
                location.reload();
            });
        }
 </script>
<div id="ques" style="display:none;"> 
    <div id="tambahanform"></div>
    <div style="padding: 30px; text-align: center;">
        <button class="btn btn-primary btn-lg" onclick="addform();">Tambah Pertanyaan</button>   
    </div>
</div>
 
</div>
<script>
    var jumlahform = <?php 
        echo $cnt;
        ?>
;
function addform(){
    $('#tambahanform').append('<div id="newform_'+jumlahform+'"></div>');
    
    $('#newform_'+jumlahform).load('<?php 
        echo _SPPATH;
        ?>
UlWeb/newform?jml='+jumlahform);
    jumlahform++;
    
}    
</script>
         <?php 
    }
    <input type="hidden" name="post_date" value="<?php 
echo $obj->post_date;
?>
" id="post_date" class="form-control">   
    <input type="hidden" name="post_modified" value="<?php 
echo $obj->post_modified;
?>
" id="post_modified" class="form-control">  
    <div class="form-group">
       <label for="post_image" class="col-sm-2 control-label"><?php 
echo Lang::t('post_image');
?>
</label>
        <div class="col-sm-10">
    <?php 
$if = new \Leap\View\InputFoto("foto", "post_image", $obj->post_image);
$if->p();
?>
        </div>
       <span class="help-block" id="warning_post_image"></span>  
    </div> 
    <div id="formgroup_post_title" class="form-group">
        <label for="post_title" class="col-sm-2 control-label"><?php 
echo Lang::t('post_title');
?>
</label>
        <div class="col-sm-10">
        <input type="text" name="post_title" value="<?php 
echo $obj->post_title;
?>
" id="post_title" class="form-control">
    function newApp()
    {
        ?>
        <style>
            .helper{
                font-size: 12px;
                padding-top: 5px;
                color:#999999;
            }
            .foto100{
                width: 100px;
                height: 100px;
                overflow: hidden;
            }
            .foto100 img{
                height: 100px;
            }
            .err{
                display: none;
            }
        </style>
        <div class="container attop" >



        <div class="col-md-8 col-md-offset-2">
            <small><a href="<?php 
        echo _SPPATH;
        ?>
mydashboard">back to dashboard</a> </small>
            <div id="resultajax" style="display: none;"></div>
<!--            <h1 class="hype">Form Pendaftaran App</h1>-->
            <form class="form-horizontal" role="form" id="formaddapp">
                <hr>
                <h2 class="hype">Application Descriptions</h2>
                <hr>
                <div class="form-group">
                    <label class="control-label col-sm-4" for="apptitle">Application Title:
                        <div class="helper">max 30 chars</div>
                    </label>
                    <div class="col-sm-8">
                        <input name="apptitle" type="text" class="form-control" id="apptitle" placeholder="Enter Application Title">
                        <div class="err"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4" for="appshort">Short Description:
                        <div class="helper">max 80 chars</div>
                    </label>
                    <div class="col-sm-8">
                        <input type="text" name="appshort" class="form-control" id="appshort" placeholder="Enter Short Description">
                        <div class="err"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4" for="appfull">Full Description:
                        <div class="helper">max 4000 chars</div>
                    </label>
                    <div class="col-sm-8">
                        <textarea name="appfull" class="form-control" id="appfull" rows="5"></textarea>
                        <div class="err"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4" for="appkey">Keywords:
                        <div class="helper">comma separated</div>
                    </label>
                    <div class="col-sm-8">
                        <input type="text" name="appkey" class="form-control" id="appkey" placeholder="Enter Keywords">
                        <div class="err"></div>
                    </div>
                </div>
                <hr>
                <h2 class="hype">Application Icons and Images</h2>
                <hr>
                <div class="form-group">
                    <label class="control-label col-sm-4" for="appicon">Icon:
                        <div class="helper">1024x1024 (32bit PNG)</div>
                    </label>
                    <div class="col-sm-8">
                        <?php 
        $foto = new \Leap\View\InputFoto("appicon", "appicon", "");
        $foto->p();
        ?>

<!--                        <input type="file" name="appicon" class="form-control" id="appicon" placeholder="Enter Keywords">-->
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4" for="appfeat">Feature Graphics:
                        <div class="helper">1024w x 500h (JPG/24bit PNG)</div>
                    </label>
                    <div class="col-sm-8">
                        <?php 
        $foto = new \Leap\View\InputFoto("appfeat", "appfeat", "");
        $foto->p();
        ?>

                    </div>
                </div>
                <hr>
                <h2 class="hype">Pricing</h2>
                <hr>
                <div class="form-group">
                    <label class="control-label col-sm-4" for="appfeat">Package:
                        <div class="helper">learn more about package <a target="_blank" href="<?php 
        echo _SPPATH;
        ?>
pricing">here</a> </div>
                    </label>
                    <div class="col-sm-8">
                        <select name="apppaket" id="apppaket" class="form-control">
                        <?php 
        $paket = new Paket();
        $arrPaket = $paket->getWhere("paket_active = 1 ORDER BY paket_price ASC");
        foreach ($arrPaket as $num => $paket) {
            ?>
                          <option <?php 
            if ($paket->paket_recommended) {
                echo "selected";
            }
            ?>
  value="<?php 
            echo $paket->paket_id;
            ?>
"><?php 
            echo $paket->paket_name;
            ?>
 - Rp.<?php 
            echo idrK($paket->paket_price * 12);
            ?>
/year</option>
                        <?php 
        }
        ?>
                        </select>
                        <div class="err"></div>
                    </div>
                </div>
                <hr>

                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-2">
                        <button type="submit" style="width: 100%;" class="btn btn-lg btn-success">Submit</button>
                        <a href="<?php 
        echo _SPPATH;
        ?>
mydashboard" style="width: 100%; margin-top: 10px;" class="btn btn-lg btn-default">Cancel</a>
                    </div>
                </div>
            </form>

            <script>
                $( "#formaddapp" ).submit(function( event ) {

                    $(".err").hide();

//                        alert("benar semua1");
                        var $form = $(this);
                        var url = "<?php 
        echo _SPPATH;
        ?>
MyApp/appReg";

                        $(".err").hide();

                        // Send the data using post
                        var posting = $.post(url, $form.serialize(), function (data) {
                            console.log(data);
                            if (data.bool) {
                                //kalau success masuk ke check your email....
                                document.location = "<?php 
        echo _SPPATH;
        ?>
PaymentWeb/payfor?app_id="+data.app_id;
                            }
                            else {
                                if(data.all!="") {
                                    $("#resultajax").show();
                                    $("#resultajax").html(data.all);
                                }
                                var obj = data.err;
                                var tim = data.timeId;
                                //console.log( obj );
                                for (var property in obj) {
                                    if (obj.hasOwnProperty(property)) {
                                        $( "#"+property ).css( "border-color", "red");
                                        $( "#"+property ).next(".err").css( "color", "red").show().empty().append(obj[property]).fadeIn('slow');
                                    }
                                }
                            }
                        }, 'json');




                    event.preventDefault();
                });
            </script>

<!--            Application Descriptions-->
<!--            Application Title : 30 chars-->
<!--            Short Desc : 80 chars-->
<!--            Full Desc : 4000 chars-->
<!--            Keywords : comma separated (for more accurate search result)-->
<!--            Contoh : The Body Shop; Body Butter; Soap; Skin;-->
<!---->
<!--            Images-->
<!--            App Icon : 1024x1024 (32bit PNG)-->
<!--            Feature Graphic : 1024w x 500h (JPG/24bit PNG)-->
        </div>
    <?php 
    }
Example #7
0
    function newform()
    {
        $q = new QuizQuestion();
        $cnt = $_GET['jml'];
        ?>

<div class="formulangan" >
<div id="newform_<?php 
        echo $cnt;
        ?>
">
<div class="quest">
    <p style="padding: 10px;">
            *Jawaban yang benar adalah yang tercentang/terpilih<br>
            *Soal bisa terdiri dari text, gambar atau text dan gambar<br>
            *Jawaban hanya terdiri dari text
        </p>
    <form class="form" id="form_q_<?php 
        echo $cnt;
        ?>
" >
        <div class="form-group">
            <div class="col-md-1 col-sm-1 col-xs-1">
            <?php 
        echo $cnt;
        $cnt++;
        ?>
.
            </div>
            <div  class="col-md-11 col-sm-11 col-xs-11">
            <input style="width:100%;" id="question_<?php 
        echo $cnt;
        ?>
_title" class="form-control" type="text" value="">   
            </div>
        </div>
        <input id="question_<?php 
        echo $cnt;
        ?>
_aktif" class="form-control" type="hidden" value="1">   
        
        <div class="form-group file col-md-11 col-md-offset-1" >
            <?php 
        $if = new Leap\View\InputFoto("question_" . $cnt . "_file", "question_" . $cnt . "_file", "", "form-control", 1);
        $if->p();
        ?>
            <?php 
        /*<input id="question_<?=$q->qid;?>_file" class="form-control" type="file" value="<?=$q->q_image;?>">*/
        ?>
        </div>
        <div class="clearfix">
        </div>
    <div class="answer">
        
        <?php 
        $ans = new QuizAnswer();
        $ans = new QuizAnswer();
        // $arrAns = $ans->getWhere("answer_qid = '{$q->qid}'");
        // $arrAns=array_reverse($arrAns);
        for ($x = 0; $x < 4; $x++) {
            //    $ans = array_pop($arrAns);
            //    if(!isset($ans))$ans = new QuizAnswer();
            $checked = "";
            if ($x == 0) {
                $checked = "checked";
            }
            ?>
        <div class="choice">
            
        
           <div class="col-md-1 col-sm-1 col-xs-1">
               <input <?php 
            echo $checked;
            ?>
 type="radio" name="radio_<?php 
            echo $cnt;
            ?>
" value="<?php 
            echo $x;
            ?>
"> 
           </div>
           <div  class="col-md-11 col-sm-11 col-xs-11">
               <input id="answer_title_<?php 
            echo $cnt;
            ?>
_<?php 
            echo $x;
            ?>
" type="text" style="width: 100%;" value="" class="form-control"> 
           </div>
           <!--<div class="form-group">
                <?php 
            $if = new Leap\View\InputFoto("answer_file_{$cnt}_{$x}", "answer_file_{$cnt}_{$x}", "", "form-control", 1);
            $if->p();
            ?>

           </div>-->
       
            
        </div>
                <?php 
        }
        ?>
    </div>
        <div style="text-align: center;">
        <button class="btn btn-primary btn-lg" style="width: 70%; margin-top: 30px;" id="formbutton_q_<?php 
        echo $cnt;
        ?>
" onclick="doSave('<?php 
        echo $cnt;
        ?>
','0',event);">Simpan Soal No <?php 
        echo $cnt - 1;
        ?>
</button>
        </div>
        
    </form>
    
</div>
</div>
</div>

      
            
         <?php 
        die;
    }
    public function pushLocation()
    {
        $identifier = time() . rand(0, 100);
        $l = new LocationModel();
        $arrCities = $l->getWhere("id_location!='0' GROUP BY city ORDER BY city ASC");
        ?>

        <div id="formgroup_city<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="city<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">City</label>

            <div class="col-sm-10">
                <select class="form-control" name="city<?php 
        echo $identifier;
        ?>
" id="city<?php 
        echo $identifier;
        ?>
">
                    <option value="-1" selected="">Select City</option>
                    <option value="0">ALL CITIES</option>
                    <?php 
        foreach ($arrCities as $city) {
            ?>
                        <option value="<?php 
            echo $city->city;
            ?>
"><?php 
            echo $city->city;
            ?>
</option>
                        <?php 
        }
        ?>

                </select>
                <span class="help-block" id="warning_city<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_district<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="district<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">District</label>

            <div class="col-sm-10">
                <select disabled class="form-control" name="district<?php 
        echo $identifier;
        ?>
"
                        id="district<?php 
        echo $identifier;
        ?>
">
                    <option value="-1" selected="">Select District</option>

                </select>
                <span class="help-block" id="warning_district<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_target_device<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="target_device<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">Target User(s)</label>

            <div class="col-sm-10">
                <div class="input-group">
                    <input type="text" name="target_device<?php 
        echo $identifier;
        ?>
" value="0"
                           id="target_device<?php 
        echo $identifier;
        ?>
" class="form-control" disabled readonly>
                    <span class='input-group-addon'>User(s)</span>
                    <span class="help-block" id="warning_target_device<?php 
        echo $identifier;
        ?>
"></span>
                </div>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_user_ids<?php 
        echo $identifier;
        ?>
" class="form-group" hidden>
            <label for="user_ids<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">User Ids</label>

            <div class="col-sm-10">
                <input type="text" name="user_ids<?php 
        echo $identifier;
        ?>
" value=""
                       id="user_ids<?php 
        echo $identifier;
        ?>
" class="form-control">
                <span class="help-block" id="warning_user_ids<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_title<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="title<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">Title</label>

            <div class="col-sm-10">
                <input type="text" name="title<?php 
        echo $identifier;
        ?>
" value=""
                       id="title<?php 
        echo $identifier;
        ?>
" class="form-control">
                <span class="help-block" id="warning_title<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_message<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="message<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">Message</label>

            <div class="col-sm-10">

                <textarea class="form-control" rows="5" id="message<?php 
        echo $identifier;
        ?>
"
                          name="message<?php 
        echo $identifier;
        ?>
"></textarea>
                <span class="help-block" id="warning_message<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div id="formgroup_image<?php 
        echo $identifier;
        ?>
" class="form-group">
            <label for="image<?php 
        echo $identifier;
        ?>
" class=" col-sm-2 control-label">Image</label>

            <div class="col-sm-10">
                <?php 
        $b = new \Leap\View\InputFoto("image{$identifier}", "image{$identifier}", "");
        $b->p();
        ?>
                <span class="help-block" id="warning_message<?php 
        echo $identifier;
        ?>
"></span>
            </div>
            <div class="clearfix"></div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <button type="button" class="btn btn-default" id="button_submit<?php 
        echo $identifier;
        ?>
">submit</button>
            </div>
        </div>

        <script>
            var targetDevice = $('#target_device<?php 
        echo $identifier;
        ?>
');
            var userIds = $('#user_ids<?php 
        echo $identifier;
        ?>
');
            var cities = $('#city<?php 
        echo $identifier;
        ?>
');
            var districts = $('#district<?php 
        echo $identifier;
        ?>
');

            cities.change(function () {
                districts.prop("disabled", false);
                var v = $(this).val();
                if (v == -1) {
                    targetDevice.val(0);
                    userIds.val("");
                    districts.prop("disabled", true);
                    return;
                } else if (v == 0) {
                    targetDevice.val(0);
                    userIds.val("");
                    districts.prop("disabled", true);
                }
                $.ajax({
                    method: "GET",
                    url: _sppath + "PushMR/getDistrictByCity",
                    data: {city: cities.val()}
                })
                    .done(function (msg) {
                        districts.empty();
                        districts.append($("<option></option>")
                            .attr("value", "-1")
                            .text("Select District"));
                        districts.append($("<option></option>")
                            .attr("value", "0")
                            .text("SELECT ALL"));
                        var json_obj = $.parseJSON(msg);
                        var status_code = json_obj.status_code;
                        if (status_code == 0) {
                            alert(json_obj.status_message);
                            return;
                        }
                        var results = json_obj.results;//parse JSON
                        var dist = results.district;
//                        console.log(results);
                        for (var i in dist) {
                            districts.append($("<option></option>")
                                .attr("value", dist[i].value)
                                .text(dist[i].text));
                        }
                        var user_count = json_obj.results.user_count;
                        var user_ids = json_obj.results.user_ids;
                        userIds.val(user_ids);
                        targetDevice.val(user_count);
                        districts.prop("disabled", results.length <= 0);
                    });

            });

            districts.change(function () {

                if (districts.val() == "-1") {
                    return;
                }
                $.ajax({
                    method: "GET",
                    url: _sppath + "PushMR/getUserCountInDistrict",
                    data: {
                        district: districts.val(),
                        city: cities.val()
                    }
                })
                    .done(function (msg) {
                        targetDevice.val(0);
                        var json_obj = $.parseJSON(msg);
                        var status_code = json_obj.status_code;
                        if (status_code == 0) {
                            alert(json_obj.status_message);
                            return;
                        }
                        var results = json_obj.results;//parse JSON

//                        console.log(results);
                        var user_count = json_obj.results.user_count;
                        targetDevice.val(user_count);
                        var user_ids = json_obj.results.user_ids;
                        userIds.val(user_ids);
                    });

            });

            $('#button_submit<?php 
        echo $identifier;
        ?>
').click(function () {
                var v<?php 
        echo $identifier;
        ?>
 = userIds.val();
                var tit<?php 
        echo $identifier;
        ?>
 = $('#title<?php 
        echo $identifier;
        ?>
').val();
                var msg<?php 
        echo $identifier;
        ?>
 = $('#message<?php 
        echo $identifier;
        ?>
').val();
                var img<?php 
        echo $identifier;
        ?>
 = $('#image<?php 
        echo $identifier;
        ?>
').val();
                if (v<?php 
        echo $identifier;
        ?>
 == ',' || v<?php 
        echo $identifier;
        ?>
 == '' || v<?php 
        echo $identifier;
        ?>
 == null) {
                    alert("No Target User");
                    return;
                }

                $.ajax({
                    method: "POST",
                    url: _sppath + "PushMR/pushByLocation",
                    data: {
                        id_users: v<?php 
        echo $identifier;
        ?>
,
                        title: tit<?php 
        echo $identifier;
        ?>
,
                        message: msg<?php 
        echo $identifier;
        ?>
,
                        image: img<?php 
        echo $identifier;
        ?>
                    }
                })
                    .done(function (msg) {
                        console.log(msg);
                        var json_obj = $.parseJSON(msg);//parse JSON

                        if (json_obj.status_code == 0) {
                            alert(json_obj.status_message);
                            return;
                        } else {
                            alert("Success");
                            var psh = json_obj.results.push;
                        }
                        lwrefresh("PushLocation");
                    });
            });
        </script>
        <?php 
    }
    function newform()
    {
        $q = new QuizQuestion();
        $cnt = $_GET['jml'];
        ?>
 <div class="quest">
    <form class="form-inline" id="form_q_<?php 
        echo $cnt;
        ?>
" >
        <div class="form-group">
            <label for="question_<?php 
        echo $q->qid;
        ?>
_title"><?php 
        echo $cnt;
        $cnt++;
        ?>
.</label>
            <input style="min-width: 500px;" id="question_<?php 
        echo $cnt;
        ?>
_title" class="form-control" type="text" value="<?php 
        echo $q->q_title;
        ?>
"><br>
   
        </div>
        <div class="form-group">
            
            Active : <input id="question_<?php 
        echo $cnt;
        ?>
_aktif" class="form-control" type="text" value="1">
   
        </div>
        <div class="form-group">
            <?php 
        $if = new Leap\View\InputFoto("question_" . $cnt . "_file", "question_" . $cnt . "_file", $q->q_image);
        $if->p();
        ?>
            <?php 
        /*<input id="question_<?=$q->qid;?>_file" class="form-control" type="file" value="<?=$q->q_image;?>">*/
        ?>
        </div>
    
    <div class="answer">
        <?php 
        $ans = new QuizAnswer();
        // $arrAns = $ans->getWhere("answer_qid = '{$q->qid}'");
        // $arrAns=array_reverse($arrAns);
        for ($x = 0; $x < 4; $x++) {
            //    $ans = array_pop($arrAns);
            //    if(!isset($ans))$ans = new QuizAnswer();
            $checked = "";
            if ($x == 0) {
                $checked = "checked";
            }
            ?>
        <div class="choice">
            
        
           <div class="form-group">
               <input <?php 
            echo $checked;
            ?>
 type="radio" name="radio_<?php 
            echo $cnt;
            ?>
" value="<?php 
            echo $x;
            ?>
"> 
           </div>
           <div class="form-group">
               <input id="answer_title_<?php 
            echo $cnt;
            ?>
_<?php 
            echo $x;
            ?>
" type="text" style="min-width: 300px;" value="<?php 
            echo $ans->answer_text;
            ?>
" class="form-control"> 
           </div>
           <div class="form-group">
                <?php 
            $if = new Leap\View\InputFoto("answer_file_{$cnt}_{$x}", "answer_file_{$cnt}_{$x}", $ans->answer_image);
            $if->p();
            ?>

           </div>
       
            
        </div>
                <?php 
        }
        ?>
    </div>
        <button class="btn btn-default" onclick="doSave('<?php 
        echo $cnt;
        ?>
','0',event);" id="formbutton_q_<?php 
        echo $cnt;
        ?>
">Save Q and A</button>
    </form>
    
</div>           
            
         <?php 
        die;
    }
    public static function become_agent()
    {
        $rand = time() . rand(0, 100);
        $_SESSION['rand'] = $rand;
        $acc = Account::getAccountObject();
        if ($acc->admin_isAgent == 1) {
            die('Already Agent');
        }
        //        pr($acc);
        ?>
        <style>
            .foto100{
                width: 100px;
                height: 100px;
                overflow: hidden;
                cursor: pointer;
            }
            .foto100 img{
                /*width: 100%;*/
            }
            @media (max-width: 768px) {

                .monly {
                    display: initial;
                }

                .donly {
                    display: none;
                }
                .fotowadah{
                    text-align: center;
                }
                .foto100{
                    margin: 0 auto;
                }

                input[type="file"]{
                    text-align: center;
                    margin: 0 auto;
                }
            }

            @media (min-width: 768px) {
                .monly {
                    display: none;
                }

                .donly {
                    display: initial;
                }


            }
        </style>
        <div class="container attop"  >
            <div class="col-md-8 col-md-offset-2">

                <div class="appear_logo_pages">
                    <a href="<?php 
        echo _SPPATH;
        ?>
">
                        <img src="<?php 
        echo _SPPATH;
        ?>
images/appear-agent.png" >
                    </a>
                </div>

                <div id="waitingApproval" <?php 
        if ($acc->admin_isAgent != -1) {
            ?>
style="display: none;"<?php 
        }
        ?>
>
                    <h3 style="text-align: center;">Your request is being processed. Please wait for our updates.</h3>
                    <div class="back_to_button" style="text-align: center;" >
                        <a href="<?php 
        echo _SPPATH;
        ?>
mydashboard">back to dashboard</a>
                    </div>
                </div>
                <?php 
        if ($acc->admin_isAgent != -1) {
            ?>
                <div id="uploadKTP">
                <div style="text-align: center; padding: 15px;">
                    <p>Please upload your KTP and NPWP, and do not forget to fill your bank credentials to receive payment.</p>
                </div>
                <div class="berpadding" style="text-align: center; margin-bottom: 100px;">
                    <form id="form_agent" class="form-horizontal" role="form" >
                        <input type="hidden" name="token" value="<?php 
            echo $rand;
            ?>
">
                        <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="ktp">KTP : </label>
                            <div class="col-sm-10 fotowadah">
                                <?php 
            $file = new \Leap\View\InputFoto("ktp", "ktp", "");
            $file->p();
            ?>
                                <div id="ktp_err" class="err"></div>
                            </div>
                        </div>
                        </div>
                        <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="npwp">NPWP : </label>
                            <div class="col-sm-10 fotowadah">
                                <?php 
            $file = new \Leap\View\InputFoto("npwp", "npwp", "");
            $file->p();
            ?>
                                <div id="npwp_err" class="err"></div>
                            </div>
                        </div>
                            </div>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="bank_name">Bank Name : </label>
                            <div class="col-sm-10">
                                <input name="bank_name" type="text" class="form-control" id="bank_name" placeholder="Bank Name">
                                <div id="bank_name_err" class="err"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="account_nr">Account Number : </label>
                            <div class="col-sm-10">
                                <input name="account_nr" type="text" class="form-control" id="account_nr" placeholder="Account Number">
                                <div id="account_nr_err" class="err"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="account_name">Account Name : </label>
                            <div class="col-sm-10">
                                <input name="account_name" type="text" class="form-control" id="account_name" placeholder="Account Name">
                                <div id="account_name_err" class="err"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="branch_name">Branch Name (KCU) : </label>
                            <div class="col-sm-10">
                                <input name="branch_name" type="text" class="form-control" id="branch_name" placeholder="Branch Name">
                                <div id="branch_name_err" class="err"></div>
                            </div>
                        </div>
                        <hr>
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="tos">Terms and Conditions: </label>
                            <div class="col-sm-10" style="text-align: left;  ">
                                <input type="checkbox" name="tos" id="tos" value="1"  > I accept the terms and conditions.
                                <div class="read"> <a target="_blank" href="<?php 
            echo _SPPATH;
            ?>
tos/agent">read terms and conditions</a></div>
                                <div id="tos_err" class="err"></div>
                            </div>
                        </div>

                        <hr>

                        <div id="resultajax" style="display: none; text-align: center;" class="alert alert-danger"></div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button style="width: 100%;" type="submit" class="btn btn-primary btn-appeargreen">Verify</button>

                                <div class="back_to_button" >
                                    <a href="<?php 
            echo _SPPATH;
            ?>
mydashboard">back to dashboard</a>
                                </div>
                            </div>
                        </div>
                    </form>


                </div>
                </div>
                <?php 
        }
        ?>
            </div>
        </div>

        <script>
            $( "#form_agent" ).submit(function( event ) {
                if(allowed) {
                    if (validateFormOnSubmit(this)) {
//                        alert("benar semua1");
                        var $form = $(this);
                        var url = "<?php 
        echo _SPPATH;
        ?>
processAgent";

                        $(".err").hide();

                        // Send the data using post
                        var posting = $.post(url, $form.serialize(), function (data) {
                            console.log(data);
                            if (data.bool) {
                                $('#waitingApproval').show();
                                $('#uploadKTP').hide();
                                //kalau success masuk ke check your email....
//                                document.location = "<?php 
        //=_SPPATH;
        ?>
//check_your_email?type=<?php 
        //=$type;
        ?>
//";
                            }
                            else {
                                $("#resultajax").show();
                                $("#resultajax").html(data.err);
                            }
                        }, 'json');

                    } else {

                    }
                }else{
                    alert("Please complete registration");
                }


                event.preventDefault();
            });

            var allowed = 1;

        </script>
        <script>
            function validateFormOnSubmit(theForm) {
                var reason = "";


                reason += validateEmpty(theForm.tos);

                reason += validateEmpty(theForm.ktp);
                reason += validateEmpty(theForm.npwp);

                reason += validateEmpty(theForm.account_nr);
                reason += validateEmpty(theForm.account_name);
                reason += validateEmpty(theForm.bank_name);
                reason += validateEmpty(theForm.branch_name);

                if(!document.getElementById("tos").checked){
                    var texterr = "Please Accept Agreement";
                    reason += texterr;
                    $('#tos_err').css( "color", "red").show().html(texterr);
//                    $('#tos_err').html(texterr);
                }else{
                    $('#tos_err').hide();
                }

                if (reason != "") {
//                        alert("Some fields need correction:\n" + reason);
                    return false;
                }

                return true;
            }

            function validateEmpty(fld) {
                var error = "";

                if (fld.value.length == 0) {
                    error = "The required field has not been filled in.\n"
                    fld.style.background = '#CCCCCC';
                    $( fld ).next().css( "color", "red").show().html(error);

                } else {
                    fld.style.background = 'White';
                    $( fld ).next().hide();
                }
                return error;
            }


            function trim(s)
            {
                return s.replace(/^\s+|\s+$/, '');
            }


        </script>
    <?php 
    }