Jump to content

mythri

Members
  • Posts

    78
  • Joined

  • Last visited

Everything posted by mythri

  1. Thank you @mac_gyver I tried like this and it worked as i wanted. $ven = implode(',', $_POST['vendor']); $vw = $con->prepare("SELECT email FROM ven_contacts WHERE vendor IN ($ven)"); $vw->execute(); while ($email = $vw->fetchAll(PDO::FETCH_COLUMN)) { $output1 = implode(',', $email); $to = '"'.$output1.'"'; $subject = "Email to multiple vendors"; $message = "<p>Hello All</p>"; $message .= "<p>Welcome to our Portal</p>"; $message .= "<p>Thank you</p>"; $headers = ""; $header = "From:info@mydomain.com \r\n"; $headers .= "From: Info <info@mydomain.com> \r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html\r\n"; $retval = mail ($to,$subject,$message,$headers);
  2. I am trying to send email from multiple email addresses using mail() function and it is working fine. But email ids are coming from database as array. Here is my code if(isset($_POST['Submit'])) { foreach($_POST['vendor'] as $k) //$_POST['vendor'] will be having multiple vendor ids { $vw = $con->prepare("SELECT email FROM ven_contacts WHERE vendor=?"); //getting all the email ids of vendors $vw->execute([$k]); foreach($vw as $ems) { $output = $ems; echo implode(', ', $output); } } When i echo $output it shows each email id 2 times for eg: abc@abc.com, abc@abc.comxyz@xyz.com, xyz@xyz.com So my email script doesn't work. if try to get $output outside the loop like this foreach($vw as $ems) { $output = $ems; } echo implode(', ', $output); } still the same problem. I want email ids to be abc@abc.com, xyz@xyz.com Then only my email script $to = $emailids; $subject = "Email to multiple vendors"; $message = "<p>Hello All"; $message .= "Welcome to our Portal"; $message .= "Thank you"; $headers = ""; $header = "From:info@mydomain.com \r\n"; $headers .= "From: Info <info@mydomain.com> \r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html\r\n"; $retval = mail ($to,$subject,$message,$headers); This email script works if i put email ids directly like this mail("abc@abc.com, xyz@xyz.com",$subject, $message, $headers); Can somebody suggest me how to get the array outside the loop
  3. I am uploading json files to my directory called upload/source and the file name in database. When i click on edit, the json file should open in textarea or or in any editor so that i can edit the contents and save. my json file is like this src.json { "sources": [ { "id": "1", "event": "labels", "display": "Label Settings", "resultevent": "printthis" } ] } i got the file contents into textarea to edit something like this <form name="123" action="" method="post"> <table class="table m-0"> <tbody> <?php $l1 = $con->prepare("SELECT sid, src_name FROM sources WHERE sid=?"); $l1->execute([1]); foreach($l1 as $r1) { $file = "uploads/sources/".$r1['src_name']; //Path to your *.txt file $contents = file($file); $string = implode($contents); ?> <tr> <td><?php echo $r1['src_name']; ?></td> <td><textarea name="file"><?php echo $string; ?></textarea></td> <input type="hidden" name="id" value="<?php echo $r1['sid']; ?>" /> </tr> <?php } ?> <tr><td colspan="2"><input type="submit" name="save" class="btn" /></td></tr> </tbody> </table> </form> But i am not getting how to save the edited contents as src.json(same name) . Can somebody suggest me how to do it
  4. I am developing a script in which i will be publishing topics to MQTT server and also when i receive the message , i submit few data to database too. I have copied and the files from MQTT client in E drive as in here , and i have pasted it in my local root directory www/phpmqtt. but i am not getting how run this subscribe.php under examples folder. I tried running it like this - http://phpmqtt/examples/subscribe.php. It shows data from phpMQTT.php messages, but doent shows what is there in subscribe.php. How to run this? Please somebody suggest me. And also where and how do i define topics? Please help me out
  5. Not able to display the result to end-user as requested format in table form. Here are my tables maintab table contains, dataset contains, Now , user needs a display like this Here Result and Method name(m1,m2...) are static. I tried like this $sel = $con->prepare("SELECT m.id, m.edate, m.result, d.nos FROM maintab m INNER JOIN dataset d ON m.id=d.mid"); $sel->execute(); <table class="table"> <tr> <th></th> <th>Result</th> <th>m1</th> <th>m2</th> <th>m3</th> <th>m4</th> <th>m5</th> <th>m6</th> <th>m7</th> <th>m8</th> <th>m9</th> <th>m10</th> </tr> <?php foreach($sel as $r1) { ?> <tr> <td><?php echo date('d-m-Y', strtotime($r1['edate'])); ?></td> <td><?php echo $r1['result']; ?></td> <td><?php echo $r1['nos']; ?></td> </tr> <?php } ?> </table> Couldn't achieve the desired display. I got something like this Not getting where exactly i need to break <td> or i need to change my query. Can somebody please suggest?
  6. No i tried it. With the same code above, i used header("location:".BASE_URL."/".$right_path); But page content wont open. it says even i have used exit(); after header(), but it didn't.
  7. @mac_gyver Now it is happening exactly like this. can you please share any tutorials/examples how i can dynamically produce ?
  8. @requinix Yes, i am stuck here. I am not getting how exactly i can do. i tried using in_array(), but didn't work.
  9. Its not about recreating everything from scratch. If a user having access for page 1, 2, 3, 4 and after few days i want to revoke the permission for page 3 and give access to only 1, 2 and 4 pages, how to do it? As i could not do that, i am deleting everything and inserting from scratch, instead of this is there any way to add/delete only those pages which is been selected. IS there any other way to redirect/hide the page if the user doesn't have access instead of doing if(in_array($right_path, $href1)) { echo "<script type='text/javascript'> document.location = ".BASE_URL."/".$right_path."</script>"; } else { echo "<script type='text/javascript'> document.location = '../no_access.php' </script>"; exit(); }
  10. Below is the screenshots and script for user page level access i have used it for one of my old projects. Code is working as it was intended. But it needs to be improvised. Users table pages table , which has all the pages and links Access level table. which has user id from users table and page id from pages table (for which user has access) Once the user is created, admin gives access to the user on page basis, the permissions.php page looks like this The modules Menus inside the modules Pages in each menu Here is my code for permission.php <div id="demo2-html"> <ul id="demo2" class="mnav"> <li><a href="#">Sales</a> <ul> <li><a href="#">Lead</a> <ul> <table class="table table-bordered table-striped table-hover"> <?php $s1 = mysqli_query($con, "SELECT pages.page_id as pid, pages.code, pages.page, pages.href, access_level.aid, access_level.page_id as pgid, access_level.user_id FROM pages LEFT JOIN access_level ON (pages.page_id=access_level.page_id AND access_level.user_id=".$user." ) WHERE pages.code='led'") or die(mysqli_error($con)); while($s2 = mysqli_fetch_array($s1)) { ?> <tr><li><td><?php echo $s2['page']; ?> </td><td><input type="checkbox" name="sn[]" value="<?php echo $s2['pid']; ?>" <?php if($s2['pgid'] === $s2['pid']) echo 'checked="checked"';?> /> <input type="hidden" value="<?php echo $s2['pid']; ?>" name="page_id[<?php echo $s2['pgid']; ?>]"> </td></li></tr> <?php } ?> </table> </ul> </li> <li><a href="#">Customer</a> <ul> <table class="table table-bordered table-striped table-hover"> <?php $s1 = mysqli_query($con, "SELECT pages.page_id as pid, pages.code, pages.page, pages.href, access_level.aid, access_level.page_id as pgid, access_level.user_id FROM pages LEFT JOIN access_level ON (pages.page_id=access_level.page_id AND access_level.user_id=".$user." ) WHERE pages.code='cst'") or die(mysqli_error($con)); while($s2 = mysqli_fetch_array($s1)) { ?> <tr><li><td><?php echo $s2['page']; ?> </td><td><input type="checkbox" name="sn[]" value="<?php echo $s2['pid']; ?>" <?php if($s2['pgid'] === $s2['pid']) echo 'checked="checked"';?> /> <input type="hidden" value="<?php echo $s2['pid']; ?>" name="page_id[<?php echo $s2['pgid']; ?>]"> </td></li></tr> <?php } ?> </table> </ul> </li> //code goes for all the other modules </ul> </li> </ul> </div> <input type="hidden" name="user" value="<?php echo $user; ?>" /> <div class="row" align="center"> <input type="submit" name="submit" class="btn btn-success" value="Save" /> </form> // form Submission if(isset($_POST['submit'])) { $user = $_POST['user']; $sql = "DELETE FROM access_level WHERE user_id = ".$user.""; $query = mysqli_query($con, $sql) or die (mysqli_error($con)); foreach($_POST['sn'] as $sn) { $sql = "insert into access_level (page_id, user_id) values (".$sn.", ".$user.")"; $query = mysqli_query($con, $sql) or die (mysqli_error($con)); } if($query) { header("location:users.php?access=1"); } } So against each user i am storing all the page ids here. When i edit any of the users, it deletes all the records and again insers new records. Which i feel is not a proper way to do. And also, if i have 10 users and 100 pages, suppose all the users are having access to all the pages, records in user_access table will be 1000. And in codewise also, i am redirecting the user to no_access.php (as below) page if the user do not have access. <?php ob_start(); include("connect.php"); include("admin_auth.php"); $q1 = basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']); $q2 = $_SERVER['REQUEST_URI']; $var1 = "/".$q1; $qa_path=explode('/', $q2); $right_path = $qa_path[2].$var1; $parsedUrl = parse_url($q2); $curdir = dirname($_SERVER['REQUEST_URI'])."/"; $m4 = "select p.page_id, p.code, p.page, p.href, al.aid, al.page_id, al.user_id FROM pages p INNER JOIN access_level al ON p.page_id=al.page_id WHERE al.user_id=".$_SESSION['user_id'].""; $m5 = mysqli_query($con, $m4) or die (mysqli_error($con)); while($nk1 = mysqli_fetch_array($m5)) { $href1[] = ($nk1['href']); } if(in_array($right_path, $href1)) { echo "<script type='text/javascript'> document.location = ".BASE_URL."/".$right_path."</script>"; } else { echo "<script type='text/javascript'> document.location = '../no_access.php' </script>"; exit(); } ?> I need help in improve and better/effective (structural) way to do this both in database and php script.
  11. I am creating a script for creating invoices. Using ajax for populating database data on autosearch. But the products has a field called min_selling_price, user should not be able to put price below min_selling_price. As my entries are dynamic, i am not getting where and how to check it. Here is my form <div class="table-responsive"> <table class="table table-active table-bordered table-sm"> <thead class="thead-active"><tr> <th><input class='check_all' type='checkbox' onclick="select_all()"/></th> <th>Name</th> <th>Description</th> <th>UOM</th> <th>Price</th> <th>Qty</th> <th colspan="2"></th> </tr> </thead> <tr> <td><input type='checkbox' class='case'/></td> <td><input type="text" class="form-control form-control-sm" id="productname_1" name="productname[]" required style="width:120px;"></td> <input type="hidden" class="form-control" id="productcode_1" name="productcode[]"> <td><textarea class="form-control form-control-sm" id="description_1" name="description[]"></textarea></td> <td><select name="uom[]" class="form-control form-control-sm" id="uom_1" style="width:80px;"> <option value="">UOM</option> <?php $su1 = mysqli_query($con, "select * from uom"); while($su2 = mysqli_fetch_array($su1)) { $uoptions .= "<option value='". $su2['uom_name'] . "'>" .$su2['uom_name'] . "</option>"; ?> <option value="<?php echo $su2['uom_name']; ?>"><?php echo $su2['uom_name']; ?></option> <?php } ?> </select> </td> <td><input type="text" class="form-control form-control-sm price" required id="price_1" name="price[]"></td> <td><input type="text" class="form-control form-control-sm quantity" required id="quantity_1" name="quantity[]"></td> <input type="hidden" class="form-control amount" id="amount_1" name="amount[]"> <td><button type="button" class='btn btn-danger delete'>-</button></td> <td><button type="button" class='btn btn-success addmore'>+ </button></td> </tr> </table> </div> <script type="text/javascript"> var options1 = "<?= $uoptions; ?>"; </script> <script type="text/javascript" src="js/auto.js"></script> auto.js $(".delete").on('click', function() { $('.case:checkbox:checked').parents("tr").remove(); $('.check_all').prop("checked", false); check(); }); var i = $('table tr').length - 1; $(".addmore").on('click', function() { count = $('table tr').length - 1; var data = "<tr><td><input type='checkbox' class='case'/></td><td><input class='form-control form-control-sm' type='text' id='productname_" + i + "' name='productname[]' required /></td><input class='form-control' type='hidden' id='productcode_" + i + "' name='productcode[]'/><td> <textarea class='form-control form-control-sm' id='description_"+ i + "' name='description[]'></textarea></td><td><select class='form-control form-control-sm uom' id='uom_" + i + "' name='uom[]'><option value=''>UOM</option>" + options1 + "</select></td><td><input class='form-control form-control-sm price' required type='text' id='price_" + i + "' name='price[]'/></td><td><input class='form-control form-control-sm quantity' required type='text' id='quantity_" + i + "' name='quantity[]'/></td><input class='form-control amount' type='hidden' id='amount_" + i + "' name='amount[]'/></tr>"; $('table').append(data); row = i; $('#productname_' + i).autocomplete({ source: function(request, response) { $.ajax({ url: 'ajax.php', dataType: "json", method: 'post', data: { name_startsWith: request.term, type: 'items_table', row_num: row }, success: function(data) { response($.map(data, function(item) { var code = item.split("|"); return { label: code[0], value: code[0], data: item } })); } }); }, autoFocus: true, minLength: 0, select: function(event, ui) { var names = ui.item.data.split("|"); id_arr = $(this).attr('id'); id = id_arr.split("_"); $('#productcode_' + id[1]).val(names[1]); $('#description_' + id[1]).val(names[2]); $('#uom_' + id[1]).val(names[3]); $('#price_' + id[1]).val(names[4]); //$('#tax_' + id[1]).val(names[5]); } }); i++; }); function select_all() { $('input[class=case]:checkbox').each(function() { if ($('input[class=check_all]:checkbox:checked').length == 0) { $(this).prop("checked", false); } else { $(this).prop("checked", true); } }); } function check() { obj = $('table tr').find('span'); $.each(obj, function(key, value) { id = value.id; $('#' + id).html(key + 1); }); } $('#productname_1').autocomplete({ source: function(request, response) { $.ajax({ url: 'ajax.php', dataType: "json", method: 'post', data: { name_startsWith: request.term, type: 'items_table', row_num: 1 }, success: function(data) { response($.map(data, function(item) { var code = item.split("|"); return { label: code[0], value: code[0], data: item } })); } }); }, autoFocus: true, minLength: 0, select: function(event, ui) { var names = ui.item.data.split("|"); $('#productcode_1').val(names[1]); $('#description_1').val(names[2]); $('#uom_1').val(names[3]); $('#price_1').val(names[4]); } }); in ajax.php if($_POST['type'] == 'items_table'){ $row_num = $_POST['row_num']; $name = $_POST['name_startsWith']; $query = "SELECT * FROM items WHERE status='Active' AND name LIKE '".strtoupper($name)."%'"; $result = mysqli_query($con, $query); $data = array(); while ($row = mysqli_fetch_assoc($result)) { $name = $row['name'].'|'.$row['item_id'].'|'.($row['description']).'|'.$row['uom'].'|'.$row['selling_price'].'|'.$row_num; array_push($data, $name); } header('Content-Type: application/json'); echo json_encode($data); } in items table, i have a filed 'min_selling_price' , i want to check for each line item whether the user entered price is above , if not it should not allow to proceed. Not getting how to do it?
  12. I did like this. function build_toolbar($add_search = false, $add_period = false, $cal_props = false) { // build the main toolbar global $messageStack; $output = ''; if ($add_search) $output .= $this->add_search(); if ($add_period) $output .= $this->add_period(); if ($cal_props) $output .= $this->add_date($cal_props); $output .= '<div id="tb_main_' . $this->id . '" class="ui-state-hover" style="border:0px;">' . "\n"; // Sort the icons by designated order if(isset($this->button[$name])) { } else { $sort_arr = array(); foreach($this->icon_list as $uniqid => $row) foreach($row as $key => $value) $sort_arr[$key][$uniqid] = $value; array_multisort($sort_arr['order'], SORT_ASC, $this->icon_list); foreach ($this->icon_list as $id => $icon) { if ($icon['show']) $output .= html_icon($icon['icon'], $icon['text'], $this->icon_size, 'id ="tb_icon_' . $id . '" style="cursor:pointer;" ' . $icon['params']) . "\n"; } } $output .= '</div>' . "\n"; // end of the right justified icons // display alerts/error messages, if any $output .= $messageStack->output(); return $output; } not getting how to call add_button (my function) here if(isset($this->button[$name])) { } My add_button function function add_button($name, $value, $parameters = '') { // adds some common icons, per request switch ($name) { case 'back': case 'previous': $image = '<a href="#" id="'.$name.'" class="btn btn-blue" '.$parameters.'>BACK</a>'; break; case 'continue': case 'next': $image = '<a href="#" id="'.$name.'" class="btn btn-blue" '.$parameters.'>NEXT</a>'; break; } if ($image) $this->button[$name] = array('show' => true, 'button' => $image, 'params' => $params); } Can you please help me in this?
  13. @mac_gyver Thank you very much. I have added like this function add_help($index = '', $order = 99) { // adds some common icons, per request $this->icon_list['help'] = array( 'show' => true, 'button' =>true, --- ); } and function add_button($name, $value, $parameters = '') { // adds some common icons, per request switch ($name) { case 'back': case 'previous': $image = 'Back'; $text = TEXT_BACK; break; case 'continue': case 'next': $image = 'actions/go-next.png'; $text = TEXT_CONTINUE; break; ----- } if ($image) $this->button[$name] = array('show' => true, 'icon' => $image, 'params' => $params, 'text' => $text, 'order' => $order); } But i am not getting where and how to add if(isset())
  14. In oval shape, those are he icons, instead of that i want to replace text with buttons. in square shape, i removed image and broken link displaying, like this only i want to display
  15. @Jacques1 No, not entire thing and also not submit button. its just a <button> and i should give href link. I am not getting how to change, where to start. I am stuck here. Pls guide me
  16. requinix : no i did not try to change it. But i tried doing like this for add_button function add_button($name, $value, $parameters = '') { // adds some common icons, per request switch ($name) { case 'back': case 'previous': $image = 'Back'; $text = TEXT_BACK; break; case 'continue': case 'next': $image = 'Continue'; $text = TEXT_CONTINUE; break; } if ($image) $this->button[$name] = array('show' => true, 'icon' => $image, 'params' => $params, 'text' => $text, 'order' => $order); }
  17. Hi, I am customising a opensource phreebookerp. I am trying to replace image icons for actions like Save, Edit, Print...etc. Instead of that i want to use buttons. But am not able to do it. Can somebody guide me how exactly i should do it and what is the logic behind it. Here is the code to (Existing to generate image icon) function add_icon($name, $params = '', $order = 98) { // adds some common icons, per request switch ($name) { case 'back': case 'previous': $image = 'actions/go-previous.png'; $text = TEXT_BACK; break; case 'continue': case 'next': $image = 'actions/go-next.png'; $text = TEXT_CONTINUE; break; case 'copy': $image = 'label1 label1-sm label1-info'; $text = TEXT_COPY; break; case 'edit': $image = 'actions/edit-find-replace.png'; $text = TEXT_EDIT; break; case 'email': $image = 'apps/internet-mail.png'; $text = GEN_EMAIL; break; case 'export': $image = 'actions/format-indent-more.png'; $text = TEXT_EXPORT; break; case 'export_csv': $image = 'mimetypes/x-office-spreadsheet.png'; $text = TEXT_EXPORT_CSV; break; case 'finish': $image = 'actions/document-save.png'; $text = TEXT_FINISH; break; case 'import': $image = 'actions/format-indent-less.png'; $text = TEXT_IMPORT; break; case 'new': $image = 'actions/document-new.png'; $text = TEXT_NEW; break; case 'recur': $image = 'actions/go-jump.png'; $text = TEXT_RECUR; break; case 'rename': $image = 'label1 label1-sm label1-info'; $text = TEXT_RENAME; break; case 'payment': $image = 'apps/accessories-calculator.png'; $text = TEXT_PAYMENT; break; case 'ship_all': $image = 'mimetypes/package-x-generic.png'; $text = TEXT_SHIP_ALL; break; case 'search': $image = 'actions/system-search.png'; $text = TEXT_SEARCH; break; case 'update': $image = 'apps/system-software-update.png'; $text = TEXT_UPDATE; break; default: $image = 'emblems/emblem-important.png'; $text = $name . ' ICON NOT FOUND'; } if ($image) $this->icon_list[$name] = array('show' => true, 'icon' => $image, 'params' => $params, 'text' => $text, 'order' => $order); } Can anybody help on this?
  18. . You have giving the link of this post only!
  19. Hi, i want to display consolidated marks sheet of students. Format is same as in the attached image I have saved my data like this exam information will be on exam_time_table like in the image (exam_time_table.jpg), Type of exams will be stored in exam_type (exam_type.jpg), subjects will be in subjects table, exams, subject and marks related to each student will be there in student_exam. I can extract the data, but not able to display in this format. I have made format in html, but not able to fit in my data there. Here is the query i am extracting $sql="SELECT student_exam.id as sid, student_exam.student_id, student_exam.enroll_no, student_exam.exam_id, student_exam.subject_id, student_exam.obtained_marks, exam_time_table.exam_name, exam_time_table.class, exam_time_table.section, exam_time_table.total_marks, subjects.subject, exam_type.exam, student.enroll_no, student.stud_name FROM student_exam INNER JOIN exam_time_table ON student_exam.exam_id=exam_time_table.id INNER JOIN subjects ON student_exam.subject_id=subjects.sub_id INNER JOIN exam_type ON exam_time_table.exam_name=exam_type.eid INNER JOIN student ON student_exam.enroll_no=student.enroll_no WHERE exam_time_table.class='".$class."' AND exam_time_table.section='".$section."' AND student_exam.enroll_no='".$enroll_no."'"; Can somebody please let me know how to do it? Please share if you have any tutorials Tables are like in the attachment
  20. Hello, I am trying to generate pdf dynamically using fpdf. But i am getting it very difficult. Only half of the result i could get. I want to generate my pdf like this And now i am getting like this Here is the code for pdf <?php require('../fpdf/fpdf.php'); error_reporting(-1); $id = $_GET['order_id']; $db = new mysqli('localhost','root','','dbnme'); // use your credentials class INVPDF extends FPDF { var $id; var $today; var $widths; var $heads; var $aligns; var $formats; var $db; var $invTotal = 0; function INVPDF($invno, $db) { parent::fpdf(); $this->id = $invno; $this->db = $db; $this->today = date('jS M Y'); $this->heads = array('Item', 'UOM', 'Price', 'Qty', 'Disc %', 'Tax', 'Frt', 'Total' ); $this->widths = array (45, 15, 35, 15, 15, 20, 25, 30); $this->aligns = array ('L','C','L','C','C','R','C', 'C'); $this->formats = array (0,0,0,0,0,1,0,0); } //Page header function Header() { //Arial bold 15 //Title include("../connect.php"); $ss1 = "select orders.sales_order_id, orders.company_id, lead_address.address, lead_address.address_category, lead_address.country, lead_address.state, lead_address.company_id, lead_address.city,lead_address.pin from orders INNER JOIN lead_address ON orders.company_id=lead_address.company_id where lead_address.address_category='Billing' AND orders.sales_order_id='".$_GET['order_id']."'"; $mq1 = mysql_query($ss1) or die(mysql_error()); $rr1 = mysql_fetch_array($mq1); $billing = $rr1['address']; list($line1, $line2, $line3) = explode(',',$billing); $country = $rr1['country']; $state = $rr1['state']; $city = $rr1['city']; $pin = $rr1['pin']; //list($line1, $line2, $country, $state, $city, $pin) = explode(',',$address); $ss2 = "select orders.sales_order_id, orders.company_id, lead_address.address, lead_address.address_category, lead_address.country, lead_address.state, lead_address.company_id, lead_address.city,lead_address.pin from orders INNER JOIN lead_address ON orders.company_id=lead_address.company_id where lead_address.address_category='Shipping' AND orders.sales_order_id='".$_GET['order_id']."'"; $mq2 = mysql_query($ss2) or die(mysql_error()); $rr2 = mysql_fetch_array($mq2); $shipping = $rr2['address']; $country1 = $rr2['country']; $state1 = $rr2['state']; $city1 = $rr2['city']; $pin1 = $rr2['pin']; $this->setXY(10,20); // $this->Cell(0,10,'Quotation '.$this->id,0,2,'L'); $this->Image('logo.png',20,6,15); $this->setXY(12,20); // $this->SetFont('OpenSans','',7); $this->Cell(0,10,'Company Name. ',0,2,'L'); $this->Cell(0,0,'Address1, address2',0,2,'L'); $this->Cell(0,8,'city, stte',0,2,'L'); $this->Cell(0,2,'sales@company.com',0,2,'L'); //$this->Image('images/logo.png',10,6,60); $this->SetFont('OpenSans','',7); $this->setXY(12,50); $this->Cell(0,-2,'Shipping Address',$this->id,0,2,0,'L'); $this->SetFont('OpenSans','',7); $this->setXY(12,52); $this ->MultiCell(57,22,'', 'LRTB', 'L', 1); //$this->Cell(0,8,$name,$this->id,0,2,0,'L'); $this->setXY(12,55); $this->Cell(0,-1,$shipping,$this->id,0,2,0,'L'); $this->setXY(12,53); $this->Cell(0,10,$country." , ".$state,$this->id,0,2,0,'L'); $this->setXY(12,52); $this->Cell(0,20,$city." , ".$pin,$this->id,0,2,0,'L'); $this->SetFont('OpenSans','',7); $this->setXY(140,52); $this ->MultiCell(57,22,'', 'LRTB', 'L', 1); $this->setXY(140,34); $this->Cell(0,30,'Billing Address',$this->id,0,2,0,'L'); $this->SetFont('OpenSans','',7); $this->setXY(140,35); $this->Cell(0,40,$line1." , ".$line2, $this->id,0,2,0,'L'); $this->setXY(140,35); $this->Cell(0,49,$line3, $this->id,0,2,0,'L'); $this->setXY(140,33); $this->Cell(0,62,$city1." , ".$pin1,$this->id,0,2,0,'L'); $this->setXY(140,33); $this->Cell(0,70,$country1." , ".$state1,$this->id,0,2,0,'L'); $this->SetFont('OpenSans','',7); $this->setXY(10,5); $this->Cell(0,10,'QUOTATION: '.$this->id,0,2,'R'); $this->SetFont('OpenSans','',7); $until = date ('jS F Y', strtotime($this->today)); $this->Cell(0,0,'Date: '.$until,0,2,'R'); $this->SetFont('OpenSans','',7); $this->Cell(0,10,'Due Date: Due on receipt',0,2,'R'); //Line break $this->Ln(60); for ($i=0; $i<9; $i++) { $this->Cell ($this->widths[$i], 8, $this->heads[$i], 1, 0, 'C', 1); } $this->Ln(; } //Page footer function Footer() { # $this->SetY(-50); // Uncomment to position at 5 cm from bottom //Arial italic 8 $this->SetFont('OpenSans','',; $w = array_sum(array_slice($this->widths,0,3)); $this->Cell($w,12,'',1); $this->Cell($this->widths[3],12,'',1,0,'C'); $this->setLeftMargin(45 + array_sum(array_slice($this->widths,0,4))); $this->Cell($this->widths[5],4,'Sub Total',1); $this->Cell($this->widths[6],4,number_format($this->invTotal,2),1,0,'R'); $this->Cell($this->widths[7],4,'USD',1,1,'C'); $this->Cell($this->widths[5],4,'Tax',1); $this->Cell($this->widths[6],4,number_format('Tax amount should come',2),1,0,'R'); $this->Cell($this->widths[7],4,'INR',1,1,'C'); $this->Cell($this->widths[5],4,'Freight',1); $this->Cell($this->widths[6],4,number_format('Freight amount',2),1,0,'R'); $this->Cell($this->widths[7],4,'INR',1,1,'C'); $this->setLeftMargin(10); $this->Cell($this->widths[5],4,'Total',1); $this->Cell($this->widths[6],4,number_format('Overall Toatl',2),1,0,'R'); $this->Cell($this->widths[7],4,'INR',1,1,'C'); $this->SetFont('OpenSans','',6); $this->Cell($w,10,'',0,0,'L'); $this->Cell(30,4,'Private Limited Company - TIN: 345sddd - PAN: sf43534',0,0,'C'); //$this->Cell($w,10,''); $this->Cell(-30,12,'SRVC TAX: gddddddddddd - CIN: sdgdgdgdfgfdgfg',0,0,'C'); $this->Cell(30,20,'This document has been electronically generated and requires no physical signature or stamp.',0,0,'C'); } function makeInvoice() { $sql = "select before_order_line_items.item, before_order_line_items.description, before_order_line_items.uom, before_order_line_items.selling_price, before_order_line_items.quantity, before_order_line_items.discount, before_order_line_items.tax, before_order_line_items.freight, before_order_line_items.tax_amount, before_order_line_items.total, items.name as iname, taxes.tax_id, taxes.name as tname, taxes.rate from before_order_line_items inner join items on before_order_line_items.item=items.item_id inner join taxes on before_order_line_items.tax=taxes.tax_id where before_order_line_items.sales_order_id = '".$_GET['order_id']."' "; //echo $sql; $res = $this->db->query($sql) or die($this->db->error); $this->SetFont('OpenSans','',; if ($res->num_rows > 0) { while ($r = $res->fetch_row()) { $this->invTotal += $r[10]; foreach ($r as $c => $value) { //echo $value; if ($this->formats[$c]) { $value = number_format($value); // echo $value; } $this->Cell($this->widths[$c],10,$value,'LR',0, $this->aligns[$c]); } $this->Ln(); //$amount = number_format($amount+$value); } } } } # invpdf class $invno = $_GET['order_id']; //Instantiation of inherited class $pdf = new INVPDF($invno, $db); $pdf->Open(); $pdf->AliasNbPages(); $pdf->setLeftMargin(10); $pdf->setRightMargin(10); $pdf->AddFont('OpenSans','','Opensans-Regular.php'); $pdf->SetFont('OpenSans','',7); $pdf->SetDrawColor(102); $pdf->SetFillColor(220); $pdf->AddPage(); $pdf->makeInvoice(); $pdf->Output(); ?> Can somebody please help me how to do it? or is there any example code for something similar to this. Thanks
  21. I have more than 1000 records in my database and while displaying i use Pagination with search criteria. Actually When i give search criteria, its displays defined number of records from database, defined in the same file thru pagination. It shows 2,3,4... number with links. But when i click on 2nd page , it goes to 2nd page but again we need to provide search criteria. I wan this to display without search criteria. My code is like this <?php if(isset($_GET['page'])){ $page=$_GET['page']; } else { $page=1; } $start_page=($page-1)*20; if(isset($_POST['search'])) { $stud_id=$_POST['stud_id']; $stud_name=$_POST['stud_name']; $class=$_POST['class']; $section=$_POST['section']; $session=$_POST['session']; if(isset($_POST['search']) && ($_POST['stud_id']!='')) { $sql="select * from student where enroll_no LIKE '".$stud_id."%' "; } elseif(isset($_POST['search']) && ($_POST['stud_name']!='')) { $sql="select * from student where stud_name LIKE '".$stud_name."%' "; } elseif(isset($_POST['search']) && ($_POST['class']!='') && ($_POST['section']!='')) { $sql="select * from student where class LIKE '".$class."%' AND section LIKE '".$section."%' "; } elseif(isset($_POST['search']) && ($_POST['class']!=='')) { echo "Please select section along with class"; } elseif(isset($_POST['search'])) { $sql="select * from student limit $start_page,20"; } } $query=mysql_query($sql); ?> <div class="container"> <div class="row-fluid"> <div class="span12"> <div class="w-box"> <div class="w-box-header"> <h4>Student List</h4> </div> <div class="w-box-content"> <form method="post" action="" > <div class="formSep"><input type="text" name="stud_id" id="stud_id" value="" placeholder="Enroll No" /> <input type="text" name="stud_name" id="stud_name" value="" placeholder="Student Name"/> <select name="class" id="class"> <option value=""> CLASS </option> <option value="Nursery">Nursery</option> <option value="LKG">LKG</option> <option value="UKG">UKG</option> <option value="I">I</option> <option value="II">II</option> <option value="III">III</option> <option value="IV">IV</option> <option value="V">V</option> <option value="VI">VI</option> <option value="VII">VII</option> <option value="VIII">VIII</option> <option value="IX">IX</option> <option value="X">X</option> <option value="XI">XI</option> <option value="XII">XII</option> </select> <select name="section" id="section"><option value=""> SECTION </option> <option value="A">A</option> <option value="B">B</option> <option value="C">C</option> <option value="D">D</option> </select> <input type="submit" name="search" id="search" value="Search" class="btn btn-info" /> </div> </form> </div> </div> <div class="w-box w-box-blue"> <div class="w-box-header"> <h4>Student List</h4> </div> <div class="w-box-content"> <?php $count=mysql_num_rows($query); if($count==0) { echo "<h2>SORRY NONE OF THE RECORD FOUND IN TABLE</h2>"; } else { echo "<table id='dt_hScroll' class='table table-striped'>"; echo "<thead><tr><th>Enroll No</th><th>Student Name</th><th>Photo</th><th>Class</th><th>Class Teacher</th><th>Section</th><th>Emergency Contact</th></tr> </thead>"; $i=0; while($row=mysql_fetch_array($query)) { if($i == 1) { echo '<tr class="EvenTableRows">'; $i=0; } else { echo '<tr class="OddTableRows">'; $i = 1; } ?> <td><?php echo $row['enroll_no']; ?></td> <td><a href="edit_student.php?enroll_no=<?php echo $row['enroll_no']; ?>"><?php echo $row['stud_name']; ?></a></td> <td><img src="<?php echo '../'.$row['stud_photo']; ?>" width="50px" height="50px" /></td> <td><?php echo $row['class']; ?></td> <td> <?php } } ?> </tbody></table> </div> </div> <?php $sql1="select COUNT(id) from student"; $rs_result = mysql_query($sql1); $row1 = mysql_fetch_row($rs_result); $total_records = $row1[0]; $total_pages = ceil($total_records / 20); if ($page > $total_pages) { // set current page to last page $page = $total_pages; } // end if // if current page is less than first page... if ($page < 1) { // set current page to first page $page = 1; } // end if $range=4; echo "<div style='float:left; width:200px;text-align:center; margin-left:40%;'>"; // echo "<a href='view_student.php?page=".$i."'>".$i."</a> "; if ($page > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?page=1'>First</a> "; // get previous page num $prevpage = $page - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?page=$prevpage'>Previous</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($page - $range); $x < (($page + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $total_pages)) { // if we're on current page... if ($x == $page) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?page=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($page != $total_pages) { // get next page $nextpage = $page + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>Next</a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?page=$total_pages'>Last</a> "; } // end if echo "</div>"; ?> how can i make it , please suggest
×
×
  • 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.