function setModuleSeqNumber($mode, $module, $req_str = '', $req_no = '') { global $adb; //when we configure the invoice number in Settings this will be used if ($mode == "configure" && $req_no != '') { //見積モジュールの場合はここはつかってない! $check = $adb->pquery("select cur_id from vtiger_modentity_num where semodule=? and prefix = ?", array($module, $req_str)); if ($adb->num_rows($check) == 0) { $numid = $adb->getUniqueId("vtiger_modentity_num"); $active = $adb->pquery("select num_id from vtiger_modentity_num where semodule=? and active=1", array($module)); $adb->pquery("UPDATE vtiger_modentity_num SET active=0 where num_id=?", array($adb->query_result($active, 0, 'num_id'))); $adb->pquery("INSERT into vtiger_modentity_num values(?,?,?,?,?,?)", array($numid, $module, $req_str, $req_no, $req_no, 1)); return true; } else if ($adb->num_rows($check) != 0) { $num_check = $adb->query_result($check, 0, 'cur_id'); if ($req_no pquery("UPDATE vtiger_modentity_num SET active=0 where active=1 and semodule=?", array($module)); $adb->pquery("UPDATE vtiger_modentity_num SET cur_id=?, active = 1 where prefix=? and semodule=?", array($req_no, $req_str, $module)); return true; } } } else if ($mode == "increment") { //見積もりモジュールの場合はこっちを使ってる。 //when we save new invoice we will increment the invoice id and write $check = $adb->pquery("select cur_id,prefix from vtiger_modentity_num where semodule=? and active = 1", array($module)); $prefix = $adb->query_result($check, 0, 'prefix'); $curid = $adb->query_result($check, 0, 'cur_id'); $prev_inv_no = $prefix . $curid; //←ここで見積もり番号を作ってる! $strip = strlen($curid) - strlen($curid + 1); if ($strip pquery("UPDATE vtiger_modentity_num SET cur_id=? where cur_id=? and active=1 AND semodule=?", array($req_no, $curid, $module)); return decode_html($prev_inv_no); } }
function setModuleSeqNumber($mode, $module, $req_str = '', $req_no = '') { global $adb; if ($mode == "increment") { //見積もりモジュールの場合はこっちを使ってる。 //when we save new invoice we will increment the invoice id and write $check = $adb->pquery("select cur_id,prefix from vtiger_modentity_num where semodule=? and active = 1", array($module)); $prefix = $adb->query_result($check, 0, 'prefix'); $curid = $adb->query_result($check, 0, 'cur_id'); //ここなへんでなんやらする。 $prev_inv_no = $prefix . $curid_str; //←$curidは連番なので、数字以外を入れたい時とか0埋めしたい時とかは$curid_strをつなげるようにする。 //$prev_inv_no = $prefix . $curid; //←もともとの見積もり番号作る。 $strip = strlen($curid) - strlen($curid + 1); if ($strip pquery("UPDATE vtiger_modentity_num SET cur_id=? where cur_id=? and active=1 AND semodule=?", array($req_no, $curid, $module)); return decode_html($prev_inv_no); } }