function get_course_cost($user) { $payment = new Payment(); $late = new Late(); $group_status = $this->is_group_user($user); if ($group_status == 0) { $course_cost_array = $payment->get_personal_course_cost($user->courseid); $course_cost = $course_cost_array['cost']; } else { $participants = $this->get_group_user_num($user); $course_cost_array = $payment->get_course_group_discount($user->courseid, $participants); $course_cost = $course_cost_array['cost']; } $tax_status = $payment->is_course_taxable($user->courseid); if ($tax_status == 1) { $tax = $payment->get_state_taxes($user->state); } else { $tax = 0; } // end else if ($user->slotid > 0) { $apply_delay_fee = $late->is_apply_delay_fee($user->courseid, $user->slotid); $late_fee = $late->get_delay_fee($user->courseid); } $grand_total = $course_cost; if ($tax_status == 1) { $grand_total = $grand_total + round($course_cost * $tax / 100); } if ($apply_delay_fee) { $grand_total = $grand_total + $late_fee; } return $grand_total; }
function get_payment_section($group_data, $users, $participants, $installment = null, $from_email = null, $sum = false, $renew = null) { /* echo "<br/>Users-------------<br/>"; echo "<pre>"; print_r($users); echo "<pre>"; echo "<br/>-------------<br/>"; echo "Group data ----------------<pre>"; print_r($group_data); echo "<pre>"; echo "<br/>-------------<br/>"; */ //echo "Sum inside payment section: ".$sum."<br>"; $list = ""; $cost_block = ""; $card_types = $this->get_card_types_dropbox(); $card_year = $this->get_year_drop_box(); $card_month = $this->get_month_drop_box(); $states = $this->get_states_list(); $late = new Late(); $dashboard = $from_email == null ? 0 : 1; $list .= "<input type='hidden' id='dashboard' value='{$dashboard}'>"; $list .= "<input type='hidden' id='renew' value='{$renew}'>"; if ($from_email != null) { $list .= "<br/><div class='form_div'>"; } $list .= "<div class='panel panel-default' id='payment_detailes'>"; $list .= "<div class='panel-heading'style='text-align:left;'><h5 class='panel-title'>Payment Details</h5></div>"; $list .= "<div class='panel-body'>"; $list .= "<div class='container-fluid' style='text-align:center;'>"; if ($from_email == null) { $list .= "<span class='span8'><input type='checkbox' id='same_address'>Click here if billing Address is same as Contact</span>"; } $list .= "</div>"; $installment = null; // Installment on payment page should always null if ($installment == null) { if ($group_data == '') { $course_name = $this->get_course_name($users->courseid); if ($sum == false) { $course_cost = $this->get_personal_course_cost($users->courseid); } else { $course_cost = array('cost' => $sum, 'discount' => 0); } $list .= "<input type='hidden' value='' id='user_group' name='user_group' />"; $list .= "<input type='hidden' value='{$users->id}' id='userid' name='userid' />"; $list .= "<input type='hidden' value='{$users->courseid}' id='courseid' name='courseid' />"; $tax_status = $this->is_course_taxable($users->courseid); //echo "Tax status: ".$tax_status."<br>"; if ($tax_status == 1) { $tax = $this->get_state_taxes($users->state); } else { $tax = 0; } // end else if ($users->slotid != '' && $sum == false) { $apply_delay_fee = $late->is_apply_delay_fee($users->courseid, $users->slotid); $late_fee = $late->get_delay_fee($users->courseid); } } else { $course_name = $this->get_course_name($group_data->courseid); if ($sum == false) { $course_cost = $this->get_course_group_discount($group_data->courseid, $participants); } else { $course_cost = array('cost' => $sum, 'discount' => 0); } // end else $list .= "<input type='hidden' value='{$group_data->group_name}' id='user_group' name='user_group' />"; $list .= "<input type='hidden' value='{$users->id}' id='userid' name='userid' />"; $list .= "<input type='hidden' value='{$group_data->courseid}' id='courseid' name='courseid' />"; $tax_status = $this->is_course_taxable($group_data->courseid); //echo "Tax status: ".$tax_status."<br>"; if ($tax_status == 1) { $tax = $this->get_state_taxes($group_data->statename); } else { $tax = 0; } // end else if ($group_data->slotid != '' && $sum == false) { $apply_delay_fee = $late->is_apply_delay_fee($group_data->courseid, $group_data->slotid); $late_fee = $late->get_delay_fee($group_data->courseid); } } // end else when group_data are not null // Discount block if ($course_cost['discount'] == 0) { $cost_block .= "\$" . $course_cost['cost']; } else { $cost_block .= "\$" . $course_cost['cost'] . " (discount is " . $course_cost['discount'] . "%)"; } if ($apply_delay_fee) { if ($group_data == '') { $grand_total = $course_cost['cost'] + $late_fee; } else { $grand_total = $course_cost['cost'] + $late_fee * $participants; } // end else } else { $grand_total = $course_cost['cost']; } // end else when no delay fee applied ... //echo "Tax: " . $tax . "<br>"; //echo "Group data: "; //print_r($group_data); //echo "<br>"; //echo "Participants: ".$participants."<br>"; if ($tax == 0) { $list .= "<div class='container-fluid' style='text-align:left;font-weight:bold;'>"; $list .= "<span class='span2'>Selected program</span>"; //$list.="<span class='span2' style='white-space: nowrap;overflow:hidden;'>$course_name</span>"; $list .= "<span class='span2' style=''>{$course_name}</span>"; $list .= "<span class='span2'>Fee</span>"; if ($apply_delay_fee) { if ($group_data == '') { $list .= "<span class='span2'>{$cost_block}+\${$late_fee} (late fee)<br>Total: {$grand_total}</span>"; } else { $list .= "<span class='span2'>{$cost_block}+\$" . $late_fee * $participants . " (late fee)<br>Total: {$grand_total}</span>"; } // end else } else { $list .= "<span class='span2'>{$cost_block}</span>"; } // end else $list .= "<input type='hidden' value='" . $grand_total . "' id='payment_sum' />"; $list .= "</div>"; } else { $tax_sum = round($course_cost['cost'] * $tax / 100, 2); $grand_total = round($course_cost['cost'] + $tax_sum, 2); if ($apply_delay_fee) { if ($group_data == '') { $grand_total2 = $grand_total + $late_fee; } else { $grand_total2 = $grand_total + $late_fee * $participants; } // end else } else { $grand_total2 = $grand_total; } // end else when no delay fee is applied //$grand_total2 = ($apply_delay_fee == true) ? $grand_total + $late_fee : $grand_total; $list .= "<div class='container-fluid' style='text-align:left;font-weight:bold;'>"; $list .= "<span class='span2'>Selected program</span>"; $list .= "<span class='span2'>{$course_name}</span>"; $list .= "<span class='span2'>Subtotal</span>"; if ($apply_delay_fee) { if ($group_data == '') { $list .= "<span class='span2'>{$cost_block}+\${$late_fee} (late fee)</span>"; } else { $list .= "<span class='span2'>{$cost_block}+\$" . $late_fee * $participants . " (late fee)</span>"; } // end else } else { $list .= "<span class='span2'>{$cost_block}</span>"; } $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:left;font-weight:bold;'>"; $list .= "<span class='span2'></span>"; $list .= "<span class='span2'></span>"; $list .= "<span class='span2'>Tax</span>"; $list .= "<span class='span2'>\${$tax_sum}</span>"; $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:left;font-weight:bold;'>"; $list .= "<span class='span2'></span>"; $list .= "<span class='span2'></span>"; $list .= "<span class='span2'>Total</span>"; $list .= "<span class='span2'>\${$grand_total2}</span>"; $list .= "<input type='hidden' value='" . $grand_total2 . "' id='payment_sum' />"; $list .= "</div>"; } // end else when tax is not null } else { $users->slotid = 0; // There is no delay fee for installment users if ($group_data == '') { $course_name = $this->get_course_name($users->courseid); if ($sum == false) { $course_cost = $this->get_personal_course_cost($users->courseid); } else { $course_cost = array('cost' => $sum, 'discount' => 0); } $list .= "<input type='hidden' value='' id='user_group' name='user_group' />"; $list .= "<input type='hidden' value='{$users->id}' id='userid' name='userid' />"; $list .= "<input type='hidden' value='{$users->courseid}' id='courseid' name='courseid' />"; if ($users->slotid != '' && $renew == false) { $apply_delay_fee = $late->is_apply_delay_fee($users->courseid, $users->slotid); $late_fee = $late->get_delay_fee($group_data->courseid); } } else { $group_data->slotid = 0; // There is no delay fee for installment users $course_name = $this->get_course_name($group_data->courseid); if ($sum == false) { $course_cost = $this->get_course_group_discount($group_data->courseid, $participants); } else { $course_cost = array('cost' => $sum, 'discount' => 0); } $list .= "<input type='hidden' value='{$group_data->group_name}' id='user_group' name='user_group' />"; $list .= "<input type='hidden' value='{$users->id}' id='userid' name='userid' />"; $list .= "<input type='hidden' value='{$group_data->courseid}' id='courseid' name='courseid' />"; if ($group_data->slotid != '' && $sum == false) { $apply_delay_fee = $late->is_apply_delay_fee($users->courseid, $group_data->slotid); $apply_delay_fee = $late->is_apply_delay_fee($group_data->courseid, $group_data->slotid); } } // end else when group is not null $first_payment = round($course_cost['cost'] / $installment['num_payments']); $period = $installment['period']; $num_payments = $installment['num_payments']; $grand_total = $apply_delay_fee == true ? $first_payment + $late_fee : $first_payment; $list .= "<div class='container-fluid' style='text-align:left;font-weight:bold;'>"; $list .= "<span class='span2'>Selected program</span>"; $list .= "<span class='span2'>{$course_name}</span>"; $list .= "<span class='span2'>Fee</span>"; if ($apply_delay_fee) { $list .= "<span class='span2'>\${$first_payment} (discount is " . $course_cost['discount'] . "%)+ \${$late_fee} (late fee)</span>"; } else { $list .= "<span class='span2'>\${$first_payment} (discount is " . $course_cost['discount'] . "%)</span>"; } // end else $list .= "<input type='hidden' value='" . $grand_total . "' id='payment_sum' />"; $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:left;'>"; $list .= "<span class='span6'>Note: this is first payment of {$num_payments} payment(s) to be put within {$period} day(s).</span>"; $list .= "</div>"; } // end else when installment is enabled $list .= "<div class='container-fluid' style='text-align:left;'>"; $list .= "<span class='span2'>Card type*</span>"; $list .= "<span class='span2'>{$card_types}</span>"; $list .= "<span class='span2'>Card number*</span>"; $list .= "<span class='span2'><input type='text' id='card_no' name='card_no' ></span>"; $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:left;'>"; $list .= "<span class='span2'>Card Holder Name*</span>"; $list .= "<span class='span2'><input type='text' id='card_holder' name='card_holder' ></span>"; $list .= "<span class='span2'>CVV*</span>"; $list .= "<span class='span2'><input type='text' id='bill_cvv' name='bill_cvv' ></span>"; $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:left;'>"; $list .= "<span class='span2'>Address*</span>"; $list .= "<span class='span2'><input type='text' id='bill_addr' name='bill_addr' ></span>"; $list .= "<span class='span2'>Expiration Date*</span>"; $list .= "<span class='span2'>" . $card_month . " " . $card_year . "</span>"; $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:left;'>"; $list .= "<span class='span2'>State*</span>"; $list .= "<span class='span2'>{$states}</span>"; $list .= "<span class='span2'>City*</span>"; $list .= "<span class='span2'><input type='text' id='bill_city' name='bill_city' ></span>"; $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:left;'>"; $list .= "<span class='span2'>Zip code*</span>"; $list .= "<span class='span2'><input type='text' id='bill_zip' name='bill_zip' ></span>"; $list .= "<span class='span2'>Contact email*</span>"; $list .= "<span class='span2'><input type='text' id='bill_email' name='bill_email' ></span>"; $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:center;'>"; $list .= "<span class='span2'> </span><span class='span4'><a href='#' onClick='return false;' id='policy'>Click Here to View Terms And Conditions</a></span>"; $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:left;'>"; $list .= "<span class='span2'> </span><span class='span4'><input type='checkbox' id='policy_checkbox'> I have read and agree to Terms and Conditions</span>"; $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:left;'>"; $list .= "<span class='span2'><button class='btn btn-primary' id='make_payment_personal'>Submit</button></span>"; $list .= "  <span style='color:red;' id='personal_payment_err'></span>"; $list .= "</div>"; $list .= "<div class='container-fluid' style='text-align:left;'>"; $list .= "<span class='span8' style='text-align:center;display:none;' id='ajax_loading_payment'><img src='https://{$this->host}/assets/img/ajax.gif' /></span>"; $list .= "</div>"; $list .= "</div>"; $list .= "</div>"; if ($from_email != null) { $list .= "</div>"; // form div } return $list; }
function create_user_invoice($user, $group, $participants) { $late = new Late(); $user_installment_status = $this->is_installment_user($user->id, $user->courseid); if ($user_installment_status == 0) { if ($group == null) { $cost = $this->get_personal_course_cost($user->courseid); // cost, discount $item_name = $this->get_course_name($user->courseid); $tax_status = $this->is_course_taxable($user->courseid); // Get invoice user data $user_data = $this->get_invoice_user_data($user->id); if ($tax_status == 1) { $user_state = $this->get_user_state($user->id); $tax = $this->get_state_taxes($user_state); } else { $tax = 0; } // end else if (!property_exists($user, 'slotid')) { $user->slotid = 0; } $apply_delay_fee = $late->is_apply_delay_fee($user->courseid, $user->slotid); $late_fee = $late->get_delay_fee($user->courseid); } else { $group_data = $_SESSION['group_common_section']; $participants = $participants == null ? $_SESSION['tot_participants'] : $participants; $cost = $this->get_course_group_discount($group_data->courseid, $participants); // cost, discount $item_name = $this->get_course_name($group_data->courseid); $tax_status = $this->is_course_taxable($group_data->courseid); if ($tax_status == 1) { $user_state = $group_data->statename; $tax = $this->get_state_taxes($user_state); } else { $tax = 0; } // end else if (!property_exists($group_data, 'slotid')) { $group_data->slotid = 0; } $apply_delay_fee = $late->is_apply_delay_fee($group_data->courseid, $group_data->slotid); $late_fee = $late->get_delay_fee($group_data->courseid); // Get invoice user data $user_data = new stdClass(); $user_data->group_name = $group_data->group_name; $user_data->address = $group_data->addr; $user_data->city = $group_data->city; $user_data->state = $group_data->statename; $user_data->zip = $group_data->zip; } // end else when it is group members } else { $installment = $this->get_user_installment_payments($user->id, $user->courseid); $cost['cost'] = $installment->sum; $cost['discount'] = 0; $item_name = $this->get_course_name($user->courseid); $tax_status = $this->is_course_taxable($user->courseid); if ($tax_status == 1) { $user_state = $this->get_user_state($user->id); $tax = $this->get_state_taxes($user_state); } else { $tax = 0; } // end else $user->slotid = 0; // It is always 0 for installment users $apply_delay_fee = $late->is_apply_delay_fee($user->courseid, $user->slotid); $late_fee = $late->get_delay_fee($user->courseid); // Get invoice user data $user_data = $this->get_invoice_user_data($user->id); } // end else when installment is active if ($cost['discount'] > 0) { $amount = '$' . $cost['cost'] . ' (discount is ' . $cost['discount'] . '%)'; } else { $amount = '$' . $cost['cost']; } $invoice_credentials = $this->get_invoice_credentials(); $invoice_num = $this->get_invoice_num(); $list = ""; $list .= "<html>"; $list .= "<body>"; $list .= "<p></p>"; $list .= "<br/><br/><table border='0' align='center' style='width:100%;table-layout:fixed;'>"; $list .= "<tr>"; $list .= "<td colspan='2' width='55%' style=''><img src='" . $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/5.png' width='350' height=90></td><td style='padding-left:10px;padding-right:10px;border-left:1px solid;' width='45%'>Phone: {$invoice_credentials->phone}<br/>Fax: {$invoice_credentials->fax}</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<td colspan='3' style='border-bottom:1px solid;padding-top:1px;height:10px;'></td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<td style='padding-top:6px;' colspan='2'>No: {$invoice_num}</td><td style='padding-left:10px;'>Date: " . date('Y/m/d', time()) . "</td>"; $list .= "</tr>"; $list .= "<tr style=''>"; $list .= "<td colspan='3' style='padding-top:1px;height:35px;'></td>"; $list .= "</tr>"; $list .= "<tr bgcolor='black'>"; $list .= "<td style='text-align:center;color:black;' width='15' height='15'> </td><td style='padding-left:15px;text-align:left;' width='10%' bgcolor='white'><span style='color:#ff8000;font-weight:bolder;'>INVOICE TO </span></td><td style='text-align:left;color:black;padding-left:15px;'> </td>"; $list .= "</tr>"; // Calculate item block if ($user_data->group_name == '') { // Single registration $item_block = "{$user_data->firstname} {$user_data->lastname}<br/> payment for {$item_name}"; $list .= "<tr>"; $list .= "<td colspan='3'>{$user_data->firstname} {$user_data->lastname}<br/>{$user_data->address}<br/> {$user_data->state}" . "/" . $user_data->city . "<br/>{$user_data->zip}</td>"; $list .= "</tr>"; } else { // Group registration $item_block = "{$user_data->group_name}<br/> payment for {$item_name}"; //$item_block = "$user_data->firstname $user_data->lastname<br/> payment for $item_name"; $list .= "<tr>"; $list .= "<td colspan='3'>{$user_data->group_name}<br/>{$user_data->address}<br/> {$user_data->state}" . "/" . $user_data->city . "<br/>{$user_data->zip}</td>"; $list .= "</tr>"; } // end else $list .= "<tr>"; $list .= "<td colspan='3' style='border-bottom:0px solid;padding-top:1px;height:40px;'></td>"; $list .= "</tr>"; $list .= "<tr bgcolor='black'>"; $list .= "<td style='color:white;text-align:center' width='10%'>No</td><td style='padding-left:15px;text-align:left;color:white' width='60%'>Description</td><td style='text-align:left;color:white;padding-left:15px;' width='5%'>Amount</td>"; $list .= "</tr>"; $list .= "<tr bgcolor='#FAF7F5'>"; $grand_total = $apply_delay_fee == true ? $cost['cost'] + $late_fee : $cost['cost']; if ($apply_delay_fee) { $list .= "<td style='text-align:center;color:black;' width='10%' height='55'>1</td><td style='padding-left:15px;text-align:left;color:black' width='60%'>{$item_block}</td><td style='text-align:left;color:black;padding-left:15px;' width='5%'>\${$grand_total} (late fee of \${$late_fee} is applied)</td>"; } else { $list .= "<td style='text-align:center;color:black;' width='10%' height='55'>1</td><td style='padding-left:15px;text-align:left;color:black' width='60%'>{$item_block}</td><td style='text-align:left;color:black;padding-left:15px;' width='5%'>\${$grand_total} </td>"; } $list .= "</tr>"; $list .= "<tr>"; $list .= "<td></td><td style='padding:10px;' align='right'>Subtotal</td><td bgcolor='black' style='color:white;padding-left:15px;'>\$" . $grand_total . "</td>"; $list .= "</tr>"; if ($tax == 0) { $list .= "<tr>"; $list .= "<td></td><td style='padding:10px;' align='right'>Tax</td><td bgcolor='black' style='padding-left:15px;color:white;'>\$0</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<td></td><td style='padding:10px;' align='right'>Total</td><td bgcolor='black' style='padding-left:15px;color:white;'>\$" . $grand_total . "</td>"; $list .= "</tr>"; } else { $tax_sum = round($cost['cost'] * $tax / 100, 2); $grand_total = round($cost['cost'] + $tax_sum, 2); $grand_total2 = $apply_delay_fee == true ? $grand_total + $late_fee : $grand_total; $list .= "<tr>"; $list .= "<td></td><td style='padding:10px;' align='right'>Tax</td><td bgcolor='black' style='padding-left:15px;color:white;'>\${$tax_sum}</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<td></td><td style='padding:10px;' align='right'>Total</td><td bgcolor='black' style='padding-left:15px;color:white;'>\$" . $grand_total2 . "</td>"; $list .= "</tr>"; } // end else when tax is not null $list .= "<tr>"; $list .= "<td colspan='3' style='border-bottom:0px solid;padding-top:1px;height:55px;'></td>"; $list .= "</tr>"; /* $list.="<tr bgcolor='#ff8000'>"; $list.="<td colspan='3' height='35px' style='color:white;fonr-weight:bold;' align='center'>Mailing Address: Medical2 1830A North Gloster St, Tupelo, MS 38804 </td>"; $list.="</tr>"; */ $list .= "<tr bgcolor='#ff8000'>"; $list .= "<td colspan='3' height='35px' style='color:white;fonr-weight:bold;' align='center'>email: " . $invoice_credentials->email . " " . $invoice_credentials->site . "<br>Mailing Address: Medical2 1830A North Gloster St, Tupelo, MS 38804 </td>"; $list .= "</tr>"; $list .= "</table>"; $list .= "</body>"; $list .= "</html>"; // instantiate and use the dompdf class $dompdf = new Dompdf(); $dompdf->loadHtml($list); // (Optional) Setup the paper size and orientation $dompdf->setPaper('A4', 'portrait'); // Render the HTML as PDF $dompdf->render(); $output = $dompdf->output(); $file_path = $this->invoice_path . "/{$invoice_num}.pdf"; file_put_contents($file_path, $output); return $invoice_num; }
function get_invoice_sum($courseid, $userid, $i_sum) { $late = new Late(); $late_fee = $late->get_delay_fee($courseid); $query = "select * from mdl_scheduler_appointment where studentid={$userid}"; $num = $this->db->numrows($query); if ($num > 0) { $result = $this->db->query($query); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $slotid = $row['slotid']; } } else { $slotid = 0; } // end else if ($slotid > 0) { $is_apply_late_fee = $late->is_apply_delay_fee($courseid, $slotid); } else { $is_apply_late_fee = false; } // end else if ($is_apply_late_fee) { $sum = $i_sum + $late_fee; } else { $sum = $i_sum; } // end else return $sum; }