<?php global $wpdb; global $current_user; // Use global get_currentuserinfo(); // Make sure global is set, if not set it. $company_id = $current_user->company_id; $company_name = $current_user->company_name; //In case of generating application from quotation then show payment tab for showing quotation amount in application tabs $show_payment_tab = isset($_REQUEST['show_payment_tab']) && !empty($_REQUEST['show_payment_tab']) ? $_REQUEST['show_payment_tab'] : 0; $new_application_id = 0; if (isset($_GET['appid'])) { $appid = base64_decode($_GET['appid']); $CrmOperationsobj = new CrmOperations(); $resultsfromcrm = $CrmOperationsobj->getCrmEntityDetails('new_application', array('type' => 'and', 'conditions' => array(array('attribute' => 'new_applicationid', 'operator' => 'eq', 'value' => $appid))), 'list'); //echo "<pre>";print_r($resultsfromcrm);die; } if (!isset($appid) && isset($_GET['id'])) { $appid = base64_decode($_GET['id']); } $status = ''; if (isset($_GET['id']) || isset($_GET['crmid'])) { if (user_can($current_user, "staff") || user_can($current_user, "assessor")) { $sql = 'select * from ' . $wpdb->prefix . 'application_data where id=' . base64_decode($_GET['id']) . " AND status!='Draft'"; } else { if (user_can($current_user, "contact")) { $sql = 'select * from ' . $wpdb->prefix . 'application_data left join ' . $wpdb->prefix . 'application_user_roles on ' . $wpdb->prefix . 'application_user_roles.application_id=' . $wpdb->prefix . 'application_data.id where ' . $wpdb->prefix . 'application_data.id=' . base64_decode($_GET['id']); } else { $sql = 'select * from ' . $wpdb->prefix . 'application_data where id=' . base64_decode($_GET['id']) . " AND user_id=" . get_current_user_id(); }
function renew_application() { global $wpdb; $sql = 'SELECT `status`,`program_id`,`user_id`,`company_id`,`application_data`,`created_by`,`created_on`,`modified_by`,`modified_on`,`deleted_by`,`deleted_on`,`crm_id`,`certificate_crm_id`,`quotation_id`,`application_exp_date`,`certificate_name`,`application_name`, `new_application_id`, `gp_number` FROM ' . $wpdb->prefix . 'application_data WHERE id = ' . base64_decode($_GET['appid']); $new_application_id = base64_decode($_GET['appid']); $result = $wpdb->get_row($sql); if ($wpdb->num_rows > 0) { if ($result->new_application_id != '') { $new_application_id = $result->new_application_id; } else { $crmOperationsObj = new CrmOperations(); $renewed_application_name = $crmOperationsObj->getApplicationName($result->certificate_name, 'renewal'); $wpdb->query("INSERT INTO " . $wpdb->prefix . "application_data (`status`,`program_id`,`user_id`,`company_id`,`application_data`,`created_by`,`created_on`,`modified_by`,`modified_on`,`deleted_by`,`deleted_on`, `certificate_crm_id`,`certificate_name`,`application_name`,`gp_number`) values ('New','" . $result->program_id . "','" . $result->user_id . "','" . $result->company_id . "', '" . $result->application_data . "','" . $result->created_by . "','" . $result->created_on . "','" . $result->modified_by . "', '" . $result->modified_on . "','" . $result->deleted_by . "','" . $result->deleted_on . "','" . $result->certificate_crm_id . "','" . $result->certificate_name . "', '" . $renewed_application_name . "', '" . $result->gp_number . "')"); //In case of renewed application, wipe out old application data and set new(renewed) application id for getting renewed applications. $wpdb->update($wpdb->prefix . "application_data", array('application_data' => NULL, 'new_application_id' => $wpdb->insert_id), array('id' => base64_decode($_GET['appid']))); $wpdb->update($wpdb->prefix . "application_docs", array('application_id' => $wpdb->insert_id), array('application_id' => base64_decode($_GET['appid']))); $new_application_id = $wpdb->insert_id; } wp_redirect(site_url() . '/index.php/listings/?page=create-form-register&id=' . base64_encode($new_application_id)); } else { wp_redirect(site_url() . '/index.php/listings/?page=application-form-register&view=all'); } }
<?php global $wpdb, $per_page, $resulttotal; global $current_user; // Use global get_currentuserinfo(); // Make sure global is set, if not set it. //include(WP_PLUGIN_DIR.'crm-connector/CrmOperations.php'); $CrmOperationsobj = new CrmOperations(); $resultsfromcrm = $CrmOperationsobj->getCrmEntityDetails('new_application', array('type' => 'and', 'conditions' => array(array('entityname' => 'new_certificate', 'operator' => 'null', 'attribute' => "new_certificateid", 'value' => ''))), 'list', '', $page, $per_page, false); //echo "<pre>";print_r($resultsfromcrm); $resulttotal = $resultsfromcrm->TotalRecordCount; $roles = get_user_meta(get_current_user_id(), "wp_capabilities"); $company_admin = is_user_company_admin(); if (user_can($current_user, "customer") && $company_admin == 1) { $sql = "select `id`, `name`, `doc_id` from " . $wpdb->prefix . "applications "; $new_accreditation = $wpdb->get_results($sql); ?> <script> $(document).ready(function() { $('#apply_for_new_accreditation_table').DataTable( { "searching": false, "processing": true, "sDom": '<"head-controls"l<"app-filter">f>t<"foot-controls"ip>', "bPaginate":false, "aoColumnDefs": [ { 'bSortable': false, 'aTargets': [ 1,2 ] } ] } ); jQuery(".colorbox-inline-70").colorbox({ overlayClose: false,
<th>Application ID</th> <th>Status</th> <th>Amount Due</th> <th>Pay</th> </tr> </thead> <tbody> <?php if (isset($_GET['crmid'])) { $crmid = base64_decode($_GET['crmid']); $CrmOperationsobj = new CrmOperations(); $resultsfromcrm = $CrmOperationsobj->getCrmEntityDetails('invoice', array('type' => 'and', 'conditions' => array(array('attribute' => 'customerid', 'operator' => 'eq', 'value' => $crmid))), 'list', '', $page, $per_page); // echo "<pre>";print_r($resultsfromcrm); $resulttotal = $resultsfromcrm->TotalRecordCount; foreach ($resultsfromcrm->Entities as $result) { ?> <tr> <td><?php echo isset($result->new_applicationid->Id) ? $result->new_applicationid->Id : ""; ?> </td> <td><?php echo isset($result->statuscode->FormattedValue) ? $result->statuscode->FormattedValue : ""; ?> </td> <td><?php