function testDate() { $date = new DateTime(); $date->setDate(2016, 31, 1); $ymd = $date->format('Y-m-d'); $ymd = "2016-01-31"; $prev_mon = date('Y-m-d', strtotime($ymd . " +1 month")); $prev_year = date('Y-m-d', strtotime($ymd . " +4 months")); echo " " . $prev_mon . " " . $prev_year; $curMonth = 7; $curYear = 2016; if ($curMonth == 12) { $firstDayNextMonth = mktime(0, 0, 0, 0, 0, $curYear + 1); } else { $firstDayNextMonth = mktime(0, 0, 0, $curMonth + 1, 1); } pr(date("Y-m-d", $firstDayNextMonth)); pr(getFirstDayOfNextMonth($curMonth, $curYear)); pr(getFirstDayOfNext4Month($curMonth, $curYear)); $app = new AppAccount(); $app->getByID(19); $vpt = new VpTransaction(); $vpt->getByID("14720056041915"); $vpt->order_id = 1122; // KomisiModel::log($app,$vpt); $nn = new AppFree(); $nn->printColumlistAsAttributes(); }
function free() { $app = new AppAccount(); $arrApp = $app->getWhere("app_active = 1 AND app_type = 1 ORDER BY app_contract_start ASC"); // pr($arrApp); ?> <h1>Free Approval Queue</h1> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th> App Details </th> <th> Organization Details </th> <th> User & Agent </th> <th> Contract </th> <th> Paket </th> <th> Status </th> </tr> </thead> <tbody> <?php foreach ($arrApp as $app) { $paket = new Paket(); $paket->getByID($app->app_paket_id); $acc = new Account(); $acc->getByID($app->app_client_id); $agent = new Account(); if ($acc->admin_marketer != "") { $agent->getByUsername($acc->admin_marketer); } $vp = new VpTransaction(); $arrT = $vp->getWhere("order_app_id = '{$app->app_id}'"); $free = new AppFree(); $free->getByID($app->app_id); ?> <tr> <td> ID :<?php echo $app->app_id; ?> <br> <?php echo $app->app_name; ?> </td> <td> Apply Date : <?php echo $free->free_date; ?> <br> Org Name : <?php echo $free->free_org_name; ?> <br> Org Type : <?php echo $free->free_org_type; ?> <br> Address : <?php echo $free->free_address; ?> <br> Contact Name : <?php echo $free->free_org_name; ?> <br> Phone : <?php echo $free->free_org_name; ?> <br> Email : <?php echo $free->free_org_name; ?> <br> Docs : <br><?php $exp = explode(",", $free->free_org_docs); foreach ($exp as $x) { ?> <a href="<?php echo _SPPATH . _PHOTOURL . "inputfiles/" . $x; ?> " target="_blank"> <img src="<?php echo _SPPATH . _PHOTOURL . "inputfiles/" . $x; ?> " width="100px"> </a> <?php } ?> </td> <td> <?php echo $acc->admin_username; ?> <?php echo $acc->admin_nama_depan; ?> <br> <?php echo $acc->admin_email; ?> <br> <?php echo $acc->admin_phone; ?> <hr> Agent <br> <?php echo $agent->admin_username; ?> <?php echo $agent->admin_nama_depan; ?> <br> <?php echo $agent->admin_email; ?> <br> <?php echo $agent->admin_phone; ?> </td> <td>Start : <?php echo $app->app_contract_start; ?> <br> End : <?php echo $app->app_contract_end; ?> </td> <td><?php echo $paket->paket_name; ?> </td> <td> <?php echo $app->app_active; ?> <br> <button onclick="accept_free('<?php echo $app->app_id; ?> ');" class="btn btn-default">Accept App</button><br> <button onclick="reject_free('<?php echo $app->app_id; ?> ');" class="btn btn-default">Reject App</button><br> <button onclick="view_free('<?php echo $app->app_id; ?> ');" class="btn btn-default">View App</button> </td> </tr> <?php } ?> </tbody> </table> </div> <script> function accept_free(id){ if(confirm("this will accept the app")) $.post("<?php echo _SPPATH; ?> JobBE/actionfree",{app_id:id,action : "accept"},function(data){ console.log(data); if(data.bool){ alert("Sukses"); lwrefresh('Accept_Free_Apps'); }else{ alert("Gagal"); } },'json'); } function reject_free(id){ if(confirm("this will reject the app")) $.post("<?php echo _SPPATH; ?> JobBE/actionfree",{app_id:id,action : "reject"},function(data){ console.log(data); if(data.bool){ alert("Sukses"); lwrefresh('Accept_Free_Apps'); }else{ alert("Gagal"); } },'json'); } function view_free(id){ } </script> <?php }
public static function processFree() { $json = array(); $json['err'] = ""; $json['bool'] = 0; $rand = $_SESSION['rand']; $token = $_POST['token']; if ($rand != $token) { $json['err'] .= "Wrong Token<br>"; } $id = addslashes($_POST['app_id']); $app = new AppAccount(); $app->getByID($id); AppAccount::checkOwnership($app); if ($app->app_active) { $json['err'] .= "App already active<br>"; } // reason += validateEmpty(theForm.tos); // // reason += validateEmpty(theForm.org_name); // reason += validateEmpty(theForm.org_type); // // reason += validateEmpty(theForm.org_doc); // reason += validateEmpty(theForm.org_addresss); // reason += validateEmpty(theForm.contact_name); // reason += validateEmpty(theForm.contact_phone); // reason += validateEmpty(theForm.contact_email); //check username $tos = addslashes($_POST['tos']); if ($tos == "") { $json['err'] .= "Please accept Terms of Service<br>"; } //check username $org_name = addslashes($_POST['org_name']); if ($org_name == "") { $json['err'] .= "Organization Name cannot be empty<br>"; } //check username $org_type = addslashes($_POST['org_type']); if ($org_type == "") { $json['err'] .= "Organization Type cannot be empty<br>"; } //check username $org_doc = addslashes($_POST['org_doc']); if ($org_doc == "") { $json['err'] .= "Documents cannot be empty<br>"; } //check username $org_addresss = addslashes($_POST['org_addresss']); if ($org_addresss == "") { $json['err'] .= "Adress cannot be empty<br>"; } //check username $contact_name = addslashes($_POST['contact_name']); if ($contact_name == "") { $json['err'] .= "Contact cannot be empty<br>"; } //check username $contact_phone = addslashes($_POST['contact_phone']); if ($contact_phone == "") { $json['err'] .= "Phone cannot be empty<br>"; } //check username $contact_email = addslashes($_POST['contact_email']); if ($contact_email == "") { $json['err'] .= "Email cannot be empty<br>"; } if ($json['err'] == "") { $app->app_type = 1; $app->app_paket_id = 1; //FREE $app->app_active = 1; $succ = $app->save(); //TODO hahah if ($succ) { $free = new AppFree(); $free->free_app_id = $app->app_id; $free->free_address = $org_addresss; $free->free_contact_email = $contact_email; $free->free_org_name = $org_name; $free->free_org_docs = $org_doc; $free->free_org_type = $org_type; $free->free_contact_name = $contact_name; $free->free_contact_phone = $contact_phone; $free->free_date = leap_mysqldate(); $free->save(1); } $json['bool'] = $succ; } // $json['post'] = $_POST; echo json_encode($json); die; }