Jump to content


  • Posts

  • Joined

  • Last visited

About Moorcam

  • Birthday 02/12/1971

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Victoria, Australia
  • Interests
    Coding, driving large heavy vehicles.
  • Age

Recent Profile Visitors

2,374 profile views

Moorcam's Achievements

Advanced Member

Advanced Member (4/5)




Community Answers

  1. Just adding to this. I also wanted this to calculate tax and format with the correct locale, tax name (example: GST for Australia). So, after hours of clowning around, pulling hair out, Googling, and channelling the masters of Code who have long passed away, I finally have it doing what I want. For those of you in the same creek without a paddle, I will share my newfound expertise with you: <?php if($setting['site_currency'] == 'EUR') { $locale = 'en-IE'; } if($setting['site_currency'] == 'GBP') { $locale = 'en-GB'; } if($setting['site_currency'] == 'USD') { $locale = 'en-US'; } if($setting['site_currency'] == 'AUD') { $locale = 'en-AU'; } ?> <script> $(document).ready(function() { $('#numberPerson').on('change',function() { var format = (num) => new Intl.NumberFormat('<?php echo $locale; ?>', { style: 'currency', currency: '<?php echo $setting['site_currency']; ?>' }).format(num); var selectVal = $('#numberPerson').val(); var selectPrice = <?php echo $p_price['p_price_single']; ?>; var taxRate = <?php echo $setting['tax_amount']; ?>; var salesTax = selectPrice * taxRate / 100; var total = selectPrice + salesTax; var totalPrice = selectVal * total; $('#totalPrice').text(format(totalPrice)); }); }); </script> It's probably not what the true experts would do but it works and does what I want it to do and that's what matters. Love you Bye
  2. Scrap my last reply. I am tired and read it wrong. Been driving Interstate last few days. Did it again, looked at it, went, nope, then looked again, did it, and yep. You are a legend. Thank you.
  3. Tried that man. Still no change. Total stays the same.
  4. Hi there, Thanks for the reply. No, only the ID and quantity is being sent forward. I have tried a few different suggestions I have found on Google with this but nothing working. I guess it's not a major issue with "$3000" being displayed rather than "$3,000.00" but I am stubborn lol
  5. Hi guys, I feel this is a Javascript issue so here goes. I am trying to update the total cost of a ticket by selecting the number of passengers from a dropdown. It works. However, not when I format the output within the js by using a number_format() function. Here is the Form: <div class="row book-now"> <div class="col-md-12"> <?php echo form_open(base_url().'payment',array('class' => '')); ?> <input type="hidden" name="p_id" value="<?php echo $id; ?>"> <input type="hidden" name="p_price_single" value="<?php echo number_format($tour['p_price_single'],2); ?>"> <div class="row"> <div class="col-md-12 col-sm-12"> <div class="form-group"> <label>Total Price (per person)</label> <div class="mb_5" style="font-size:32px;"> <?php echo $symbol; ?><?php echo number_format($tour['p_price_single'],2); ?> </div> <div class="sep mb_10"></div> <label>Number of Persons</label> <select id="numberPerson" name="number_of_person" class="custom-select select2 mb_15" style="width: auto;"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> </select> <div class="sep mb_15"></div> <label>Total Price</label> <div class="mb_15" style="font-size:32px;"> <?php echo $symbol; ?><span id="totalPrice"><?php echo number_format($tour['p_price_single'], 2); ?></span> </div> </div> </div> </div> Here is the JS without the function: <script> $(document).ready(function() { $('#numberPerson').on('change',function() { var selectVal = $('#numberPerson').val(); var selectPrice = <?php echo $p_price['p_price_single']; ?>; var totalPrice = selectVal * selectPrice; $('#totalPrice').text(totalPrice); }); }); </script> The above works. However, when the total is calculated from the selection in the dropdown, the total amount loses format. So, for example, if 2 is selected it will show $3000 instead of $3,000.00 Here is the Javascript WITH the number_format function: <script> $(document).ready(function() { $('#numberPerson').on('change',function() { var selectVal = $('#numberPerson').val(); var selectPrice = <?php echo number_format($p_price['p_price_single'], 2); ?>; var totalPrice = selectVal * selectPrice; $('#totalPrice').text(totalPrice); }); }); </script> This just doesn't allow any calculation. The total will stay formatted but just not calculate. Any help would be greatly appreciated. Cheers, Dan
  6. Ignore my impatient and lazy outburst of the "Please rescue me!". I went and put my grown up pants on and figured it out. I was missing some of the Model_FFleet file. Jeesh!
  7. Hi guys, I am using this same code on other sections of the application with no issues but on this particular one I am getting "Undefined Method "Model_fleet::show()" Here is Fleet.php line 16 is the error: <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Fleet extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('admin/Model_common'); $this->load->model('admin/Model_fleet'); } public function index() { $data['setting'] = $this->Model_common->get_setting_data(); $data['fleet'] = $this->Model_fleet->show(); $this->load->view('admin/view_header',$data); $this->load->view('admin/view_fleet',$data); $this->load->view('admin/view_footer'); } public function add() { $data['setting'] = $this->Model_common->get_setting_data(); $error = ''; $success = ''; if(isset($_POST['form1'])) { $valid = 1; $this->form_validation->set_rules('v_number', 'Fleet Number', 'trim|required'); $this->form_validation->set_rules('designation', 'Designated Driver', 'trim|required'); if($this->form_validation->run() == FALSE) { $valid = 0; $error .= validation_errors(); } $path = $_FILES['photo']['name']; $path_tmp = $_FILES['photo']['tmp_name']; if($path!='') { $ext = pathinfo( $path, PATHINFO_EXTENSION ); $file_name = basename( $path, '.' . $ext ); $ext_check = $this->Model_common->extension_check_photo($ext); if($ext_check == FALSE) { $valid = 0; $error .= 'You must have to upload jpg, jpeg, gif or png file for featured photo<br>'; } } else { $valid = 0; $error .= 'You must have to select a photo for featured photo<br>'; } if($valid == 1) { $next_id = $this->Model_fleet->get_auto_increment_id(); foreach ($next_id as $row) { $ai_id = $row['Auto_increment']; } $final_name = 'fleet-'.$ai_id.'.'.$ext; $source_image = $path_tmp; $destination = './public/uploads/'.$final_name; $new_width = 600; $new_height = 600; $quality = 100; $this->Model_common->image_handler($source_image,$destination,$new_width,$new_height,$quality); $final_name_thumb = 'fleet-'.$ai_id.'-thumb'.'.'.$ext; $source_image = $path_tmp; $destination = './public/uploads/'.$final_name_thumb; $new_width = 260; $new_height = 260; $quality = 100; $this->Model_common->image_handler($source_image,$destination,$new_width,$new_height,$quality); $form_data = array( 'v_number' => $_POST['v_number'], 'designation' => $_POST['designation'], 'v_reg' => $_POST['v_reg'], 'v_pax' => $_POST['v_pax'], 'photo' => $final_name ); $this->Model_fleet->add($form_data); $success = 'Fleet is added successfully!'; $this->session->set_flashdata('success',$success); redirect(base_url().'admin/fleet'); } else { $this->session->set_flashdata('error',$error); redirect(base_url().'admin/fleet/add'); } } else { $this->load->view('admin/view_header',$data); $this->load->view('admin/view_fleet_add',$data); $this->load->view('admin/view_footer'); } } public function edit($id) { $tot = $this->Model_fleet->fleet_check($id); if(!$tot) { redirect(base_url().'admin/fleet'); exit; } $data['setting'] = $this->Model_common->get_setting_data(); $error = ''; $success = ''; if(isset($_POST['form1'])) { $valid = 1; $this->form_validation->set_rules('v_number', 'Fleet Number', 'trim|required'); $this->form_validation->set_rules('designation', 'Designation', 'trim|required'); if($this->form_validation->run() == FALSE) { $valid = 0; $error .= validation_errors(); } $path = $_FILES['photo']['name']; $path_tmp = $_FILES['photo']['tmp_name']; if($path!='') { $ext = pathinfo( $path, PATHINFO_EXTENSION ); $file_name = basename( $path, '.' . $ext ); $ext_check = $this->Model_common->extension_check_photo($ext); if($ext_check == FALSE) { $valid = 0; $error .= 'You must have to upload jpg, jpeg, gif or png file for featured photo<br>'; } } if($valid == 1) { $data['fleet'] = $this->Model_fleet->get_fleet($id); if($path == '') { $form_data = array( 'v_number' => $_POST['v_number'], 'designation' => $_POST['designation'], 'v_reg' => $_POST['v_reg'], 'v_pax' => $_POST['v_pax'] ); $this->Model_fleet->update($id,$form_data); } if($path != '') { unlink('./public/uploads/'.$_POST['current_photo']); $final_name = 'fleet-'.$id.'.'.$ext; $temp_arr = explode('.',$_POST['current_photo']); $temp_final = $temp_arr[0].'-thumb'.'.'.$temp_arr[1]; unlink('./public/uploads/'.$temp_final); $final_name = 'fleet-'.$id.'.'.$ext; $source_image = $path_tmp; $destination = './public/uploads/'.$final_name; $new_width = 600; $new_height = 600; $quality = 100; $this->Model_common->image_handler($source_image,$destination,$new_width,$new_height,$quality); $final_name_thumb = 'fleet-'.$id.'-thumb'.'.'.$ext; $source_image = $path_tmp; $destination = './public/uploads/'.$final_name_thumb; $new_width = 260; $new_height = 260; $quality = 100; $this->Model_common->image_handler($source_image,$destination,$new_width,$new_height,$quality); $form_data = array( 'v_number' => $_POST['v_number'], 'designation' => $_POST['designation'], 'v_reg' => $_POST['v_reg'], 'v_pax' => $_POST['v_pax'], 'photo' => $final_name ); $this->Model_fleet->update($id,$form_data); } if($path != '') { unlink('./public/uploads/'.$_POST['current_photo']); $final_name = 'fleet-'.$id.'.'.$ext; $temp_arr = explode('.',$_POST['current_photo']); $temp_final = $temp_arr[0].'-thumb'.'.'.$temp_arr[1]; unlink('./public/uploads/'.$temp_final); $final_name = 'fleet-'.$id.'.'.$ext; $source_image = $path_tmp; $destination = './public/uploads/'.$final_name; $new_width = 600; $new_height = 600; $quality = 100; $this->Model_common->image_handler($source_image,$destination,$new_width,$new_height,$quality); $final_name_thumb = 'fleet-'.$id.'-thumb'.'.'.$ext; $source_image = $path_tmp; $destination = './public/uploads/'.$final_name_thumb; $new_width = 260; $new_height = 260; $quality = 100; $this->Model_common->image_handler($source_image,$destination,$new_width,$new_height,$quality); $form_data = array( 'v_number' => $_POST['v_number'], 'designation' => $_POST['designation'], 'v_reg' => $_POST['v_reg'], 'v_pax' => $_POST['v_pax'], 'photo' => $final_name ); $this->Model_fleet->update($id,$form_data); } $success = 'Fleet is updated successfully'; $this->session->set_flashdata('success',$success); redirect(base_url().'admin/fleet'); } else { $this->session->set_flashdata('error',$error); redirect(base_url().'admin/fleet/edit/'.$id); } } else { $data['fleet'] = $this->Model_fleet->get_fleet($id); $this->load->view('admin/view_header',$data); $this->load->view('admin/view_fleet_edit',$data); $this->load->view('admin/view_footer'); } } public function delete($id) { // If there is no Fleet in this id, then redirect $tot = $this->Model_fleet->fleet_check($id); if(!$tot) { redirect(base_url().'admin/fleet'); exit; } $data['fleet'] = $this->Model_fleet->get_fleet($id); if($data['fleet']) { unlink('./public/uploads/'.$data['fleet']['photo']); $temp_arr = explode('.',$data['fleet']['photo']); $temp_final = $temp_arr[0].'-thumb'.'.'.$temp_arr[1]; unlink('./public/uploads/'.$temp_final); } $this->Model_fleet->delete($id); $success = 'Fleet is deleted successfully'; $this->session->set_flashdata('success',$success); redirect(base_url().'admin/fleet'); } } Here is Model_fleet.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Model_fleet extends CI_Model { function get_auto_increment_id() { $sql = "SHOW TABLE STATUS LIKE 'tbl_fleet'"; $query = $this->db->query($sql); return $query->result_array(); } function get_fleet_number_by_id($id) { $sql = 'SELECT * FROM tbl_fleet WHERE v_id=?'; $query = $this->db->query($sql,array($id)); return $query->first_row('array'); } function show() { $sql = "SELECT * FROM tbl_fleet"; $query = $this->db->query($sql); return $query->result_array(); } function add($data) { $this->db->insert('tbl_fleet',$data); return $this->db->insert_id(); } function update($id,$data) { $this->db->where('v_id',$id); $this->db->update('tbl_fleet',$data); } function delete($id) { $this->db->where('v_id',$id); $this->db->delete('tbl_fleet'); } function getData($id) { $sql = 'SELECT * FROM tbl_fleet WHERE v_id=?'; $query = $this->db->query($sql,array($id)); return $query->first_row('array'); } function fleet_check($id) { $sql = 'SELECT * FROM tbl_fleet WHERE v_id=?'; $query = $this->db->query($sql,array($id)); return $query->first_row('array'); } function get_fleet($id) { $sql = 'SELECT * FROM tbl_fleet WHERE v_id=?'; $query = $this->db->query($sql,array($id)); return $query->first_row('array'); } } And finally view_fleet.php <?php if(!$this->session->userdata('id')) { redirect(base_url().'admin'); } ?> <section class="content-header"> <div class="content-header-left"> <h1>View Fleets</h1> </div> <div class="content-header-right"> <a href="<?php echo base_url(); ?>admin/fleet/add" class="btn btn-primary btn-sm">Add New Fleet</a> </div> </section> <section class="content"> <div class="row"> <div class="col-md-12"> <?php if($this->session->flashdata('error')) { ?> <div class="callout callout-danger"> <p><?php echo $this->session->flashdata('error'); ?></p> </div> <?php } if($this->session->flashdata('success')) { ?> <div class="callout callout-success"> <p><?php echo $this->session->flashdata('success'); ?></p> </div> <?php } ?> <div class="box box-info"> <div class="box-body table-responsive"> <table id="example1" class="table table-bordered table-striped"> <thead> <tr> <th>ID</th> <th>Photo</th> <th>Designation</th> <th>Fleet #</th> <th>Registration</th> <th>Max Pax <th width="140">Action</th> </tr> </thead> <tbody> <?php $i=0; foreach ($fleet as $row) { $i++; ?> <tr> <td><?php echo $i; ?></td> <td style="width:130px;"><img src="<?php echo base_url(); ?>public/uploads/<?php echo $row['photo']; ?>" alt="<?php echo $row['v_number']; ?>" style="width:120px;"></td> <td><?php echo $row['designation']; ?></td> <td><?php echo $row['v_number']; ?></td> <td><?php echo $row['v_reg']; ?></td> <td><?php echo $row['v_pax']; ?></td> <td> <a href="<?php echo base_url(); ?>admin/fleet/edit/<?php echo $row['v_id']; ?>" class="btn btn-primary btn-xs">Edit</a> <a href="<?php echo base_url(); ?>admin/fleet/delete/<?php echo $row['v_id']; ?>" class="btn btn-danger btn-xs" onClick="return confirm('Are you sure?');">Delete</a> </td> </tr> <?php } ?> </tbody> </table> </div> </div> </div> </div> </section> I can't work out why this is happening as all other sections, use the same code concept and layout with no issue. Any guidance would be appreciated. Cheers Dan
  8. By using <button onclick="myFunction('<?php echo $target;?>')">go to url</button> And from looking at the code: $target="target"; You are asking the myfunction to look for 'target' That's all it will look for is 'target'. Change it to $target=$row['target']; I could be wrong though. But that's how I am seeing it.
  9. Thank you so much mate. That resolved it.
  10. Howdy folks, Been a while. Hope all is well. Anyway, I have run into a pickle and can't for the life of me get out of it. I am trying to calculate the total amount of money in a database table. Table is called tbl_payment. The information is displayed in the admin dashboard. Here is the section from view_Dashboard file: <div class="col-md-4 col-sm-6 col-xs-12"> <div class="info-box"> <span class="info-box-icon bg-green"><i class="fa fa-map-signs"></i></span> <div class="info-box-content"> <span class="info-box-text">Total Income</span> <span class="info-box-number"><?php echo $paid_amount; ?></span> </div> </div> </div> Here is the Controller file - Dashboard.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Dashboard extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('admin/Model_common'); $this->load->model('admin/Model_dashboard'); } public function index() { $data['setting'] = $this->Model_common->get_setting_data(); $data['total_category'] = $this->Model_dashboard->show_total_category(); $data['total_news'] = $this->Model_dashboard->show_total_news(); $data['total_destination'] = $this->Model_dashboard->show_total_destination(); $data['total_tour'] = $this->Model_dashboard->show_total_tour(); $data['total_team_member'] = $this->Model_dashboard->show_total_team_member(); $data['total_client'] = $this->Model_dashboard->show_total_client(); $data['total_service'] = $this->Model_dashboard->show_total_service(); $data['total_testimonial'] = $this->Model_dashboard->show_total_testimonial(); $data['total_traveller'] = $this->Model_dashboard->show_total_traveller(); $data['total_vehicle'] = $this->Model_dashboard->show_total_vehicle(); $data['paid_amount'] = $this->Model_dashboard->show_total_paid_amount(); $this->load->view('admin/view_header',$data); $this->load->view('admin/view_dashboard',$data); $this->load->view('admin/view_footer'); } } And finally, the Model file - Model_dashboard.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Model_dashboard extends CI_Model { public function show_total_category() { $sql = 'SELECT * from tbl_category'; $query = $this->db->query($sql); return $query->num_rows(); } public function show_total_news() { $sql = 'SELECT * FROM tbl_news'; $query = $this->db->query($sql); return $query->num_rows(); } public function show_total_destination() { $sql = 'SELECT * from tbl_destination'; $query = $this->db->query($sql); return $query->num_rows(); } public function show_total_tour() { $sql = 'SELECT * from tbl_tour'; $query = $this->db->query($sql); return $query->num_rows(); } public function show_total_team_member() { $sql = 'SELECT * from tbl_team_member'; $query = $this->db->query($sql); return $query->num_rows(); } public function show_total_client() { $sql = 'SELECT * from tbl_client'; $query = $this->db->query($sql); return $query->num_rows(); } public function show_total_service() { $sql = 'SELECT * from tbl_service'; $query = $this->db->query($sql); return $query->num_rows(); } public function show_total_testimonial() { $sql = 'SELECT * from tbl_testimonial'; $query = $this->db->query($sql); return $query->num_rows(); } public function show_total_traveller() { $sql = 'SELECT * from tbl_traveller'; $query = $this->db->query($sql); return $query->num_rows(); } public function show_total_vehicle() { $sql = 'SELECT * from tbl_vehicle'; $query = $this->db->query($sql); return $query->num_rows(); } public function show_total_paid_amount() { $sql = 'SELECT `p_id`, SUM(`paid_amount`) AS `total_paid_amount` FROM `tbl_payment` GROUP BY `p_id`'; $query = $this->db->query($sql); return $query->num_rows(); } } I have tried all I can find. I have 1 record in the Database that shows an amount of $360.00. However, the result in Dashboard is just displaying the number 1. Hope you guys can help. Cheers, Dan
  11. Been here a while and can't remember posting anything in here so thought I had better. Anyways, I am Dan. 50 years old. Anyone who says that life begins at 40 and 50 is the new 21 has no idea. I am Irish. Grew up in a lovely market town in the South East called Dungarvan. Loved it there. I now live in Central Victoria, Australia and have done for almost 14 years. I guess my coding and dev days started many centuries ago. My first taste of any type of development was in school on an old Apple computer where the class created a messaging type thing that only sent messages from one computer to the other. It was absolute shite but at 14 years of age we thought it was amazing. From there I took an interest in website design and hosting and ran a successful VPS Hosting service in Ireland for a number of years while designing websites on the side for clients. I sold that business in 2005 and drank more Guinness than the Brewery could brew and gave up on the whole shebang until about 2+ years ago. Wow, how the coding standards have changed. I am now back to Square One, learning about PHP, JavaScript and this PDO and Bootstrap carry on. 🤔 At the moment I drive Interstate on a regular basis, mostly in Road Coaches and Semi Trucks on an odd occasion. Love it, but want to settle at home. So, myself and an ex- employer of mine are currently working on an application that we hope will allow me to do just that as there is a huge opening in the Market for an app like it here in Australia. Enough said Anyways, pleasure to make your acquaintance.
  12. Is it worth the price though? What does it offer that say, Sublime Text or Visual Studio Code doesn't? Asking for a friend I used Notepad++ for years and recently started to use Sublime Text.
  13. Thought I would add to the list. Been using VentraIP Australia with years. Also used to work for them and still great friends with the owners. Top quality services. http://www.ventraip.com.au
  14. Howdy, Just started to use PDO and loving it so far. Much better than MySQLi. Anyway, would like to know the best reference books available for PHP. If you use reference books, what do you use? Had a google today and found one "The Complete Reference to PHP". Sounded promising but was published in 2007 so not sure if it would be a good buy. Thoughts?
  15. Moorcam

    Video script

    As requinix said, you will need to learn about the workings of CSS and HTML and how they both work together. My advice is to make use of the website w3schools.com and learn these two vital languages. For this to do what you want, wouldn't be surprised if you needed some Javascript too. Post up your HTML with the video in a simple iFrame and playable. Maybe someone here can point you in the right direction.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.