Advertisement
Guest User

test bbn

a guest
Mar 26th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. function sp_getLastRefDOC($type_do = "1", $ref = ''){
  2.  
  3.  
  4. if($ref != '') $last_ref = $ref;
  5. else $last_ref = select_unique("SELECT max(do_piece) FROM sir_dv where do_type = ? AND deleted = 0 ", DATA_DB, array($type_do));
  6.  
  7. $prefix = substr($last_ref,0,2);
  8. $n = strlen($last_ref) - 2;
  9.  
  10.  
  11. $cpt = substr($last_ref, -$n);
  12.  
  13. $cpt = intval($cpt);
  14. $cpt++;
  15. $cpt = str_pad($cpt, $n, "0", STR_PAD_LEFT);
  16. $ref = $prefix.$cpt;
  17.  
  18. $exist = select_unique("select do_piece from sir_dv where do_piece = ? ",DATA_DB,array($ref));
  19. if($exist ){
  20. return sp_getLastRefDOC($type_do, $ref);
  21. }
  22. return $ref;
  23.  
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement