Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sp_getLastRefDOC($type_do = "1", $ref = ''){
- if($ref != '') $last_ref = $ref;
- else $last_ref = select_unique("SELECT max(do_piece) FROM sir_dv where do_type = ? AND deleted = 0 ", DATA_DB, array($type_do));
- $prefix = substr($last_ref,0,2);
- $n = strlen($last_ref) - 2;
- $cpt = substr($last_ref, -$n);
- $cpt = intval($cpt);
- $cpt++;
- $cpt = str_pad($cpt, $n, "0", STR_PAD_LEFT);
- $ref = $prefix.$cpt;
- $exist = select_unique("select do_piece from sir_dv where do_piece = ? ",DATA_DB,array($ref));
- if($exist ){
- return sp_getLastRefDOC($type_do, $ref);
- }
- return $ref;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement