New Member --> nextBarcode() function

  • Eva01

    Eva01 - 2009-03-16


    I just upgraded from (German) to the latest 0.6.1. I took a while to modify, but I got all working.

    One thing I noticed and that is bugging me is that apparently one function is gone with the new release.
    When adding a new member (cirulation), this function would add an auto-inremental barcode_nmbr to the member fields. Without this function, the staff doesn't know what barcode_nmbrs are already taken.
    The function used to be in the MemberQuery.php file and was called nextBarcode(). I tried to add a modified version of this function to the new MemberQuery file, but since the mbr_fields.php file was completely rewritten in the new release, I could make it work.
    This is the function:

      function nextBarcode() {
        $sql = $this->mkSQL("select max(barcode_nmbr) as lastNmbr from member");
        $array= $this->_conn->fetchRow();
        $nmbr = $array["lastNmbr"];
        return $nmbr+1;

    Could someone please help me make this function work or give me a hint on how to solve this problem otherwise?

    Many thanks in advance!

    • Shane-S

      Shane-S - 2009-03-24

      I got it to work for my install of 0.6.1. Here is what I did, note I used Notepad++ on Windows, so my line numbers might be off. Please be aware this is a HACK!. by no means is this a clean modification, I am very new to the code and usage (just installed it last week on XAMMP).

      Note this code requires you type "auto" [exactly in lowercase] into the Card Number field to work.

      Open classes/MemberQuery.php on the next to last line find the "}" before ?> line 253-254 about.

      Ensure you are between the baces as follows:
      <cursor here>


      Insert the following code:
      function nextBarcode() {
          $sql = $this->mkSQL("select max(barcode_nmbr) as lastNmbr from member");
          $myarray = $this->exec($sql);
          //$array = $this->_conn->fetchRow();
          if ($myarray == false) {
              return false;
          $nmbr = (int)$myarray[0]["lastNmbr"];
          $nmbr +=1;
          //this may NOT be a true number, we needed to convert it, causing issue.
          //Perhaps it can be expanded, for now I just need it working for math.
          return $nmbr;

      Next Open circ/mbr_new.php on Line 82 before the comments added the following code:
        #*    Auto-generate barcode for members
        # value must be "auto"
        if($mbr->getBarcodeNmbr() == "auto"){ //should just be a varible that stays as a string
        //user picked "auto" to have us generate it from MemberQuery.php function
        //use the above object classes
              echo "Auto Code Failed!";

      I hope that works our for you, I would strongly advise you test it first. This was a simple hack I did, because I feel it is useful for my install as well.


    • Shane-S

      Shane-S - 2009-03-24

      Note: Please remove the <pre> </pre> tags from the code inserts when you past, those are not needed, they were to help format, and I missed the HTML will show as code note!



Cancel  Add attachments

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks