New Member --> nextBarcode() function

Help
Eva01
2009-03-16
2013-05-30
  • Eva01

    Eva01 - 2009-03-16

    Hi,

    I just upgraded from 0.5.1.6 (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");
        $this->exec($sql);
       
        $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:
      <pre>
      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;
          }
      </pre>

      Next Open circ/mbr_new.php on Line 82 before the comments added the following code:
      <pre>
      #******************************************
        #*    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
          if($mbrQ->nextBarcode()){
              $mbr->setBarcodeNmbr($mbrQ->nextBarcode());
          }else{
              echo "Auto Code Failed!";
              exit();
          }
        }
      </pre>

      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.

      Thanks!
      Shane

       
    • 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!

       


Anonymous

Cancel  Add attachments





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

Sign up for the SourceForge newsletter:





No, thanks