function get_company($gc) { /* * 廃棄 * 利用していないこと * */ // 確認ページで業者が表示される仕様の場合はコメントを解除すること // if($_POST["work_company"] == f_bool_edit_db($_POST["relocation_flg"], "0").":".$_POST["input_val"].":".f_num_edit_db($_POST["input_kbn"], "0") ){ // if(count($_POST["arr_company"]) > 0){ // return true; // } // } //----------------------------------------------------- // 条件 // 1.月の有効手数料が限度額の範囲以内 // 2.対応地区 // 3.掲載中 // 4.利用目的により //----------------------------------------------------- $sql = "SELECT"; $sql .= " company_no,"; $sql .= " company_nm,"; $sql .= " company_kbn,"; $sql .= " kakuritsu,"; $sql .= " chintai_flg,"; $sql .= " chintai_ritu,"; $sql .= " relocation_flg,"; $sql .= " relocation_ritu,"; $sql .= " sublease_flg,"; $sql .= " sublease_ritu,"; $sql .= " comment "; $sql .= "FROM"; $sql .= " m_company c "; $sql .= "WHERE"; $sql .= " c.keisai_flg = 1 AND"; $sql .= " c.plan_flg = 2 AND ("; $cnt = 0; if ($_POST["chintai_flg"] == 1) { $sql .= " c.chintai_flg = 1 "; $cnt++; } if ($_POST["relocation_flg"] == 1) { if ($cnt > 0) { $sql .= " OR c.relocation_flg = 1 "; } else { $sql .= " c.relocation_flg = 1 "; } $cnt++; } if ($_POST["sublease_flg"] == 1) { if ($cnt > 0) { $sql .= " OR c.sublease_flg = 1 "; } else { $sql .= " c.sublease_flg = 1 "; } } $sql .= " ) AND "; //if(f_bool_edit_db($_POST["relocation_flg"], "0")=="1"){ // $sql.= " c.relocation_flg = 1 AND"; //}else{ // $sql.= " c.chintai_flg = 1 AND"; //} $sql .= " ("; $sql .= " ("; $sql .= " (c.jyougen - " . $gc->tesuryou . ") >= IFNULL(("; $sql .= " SELECT"; $sql .= " SUM(tesuryou) AS sum_tesuryou "; $sql .= " FROM"; $sql .= " t_item ti "; $sql .= " INNER JOIN"; $sql .= " t_item_company tc "; $sql .= " ON"; $sql .= " ti.item_no = tc.item_no "; $sql .= " WHERE"; $sql .= " ti.mukou_flg = 0 AND"; $sql .= " DATE_FORMAT(ti.moushikomibi,'%Y%m%d') BETWEEN '" . date("Ym01", time()) . "' AND '" . date("Ymt", time()) . "' AND"; $sql .= " tc.company_no = c.company_no"; $sql .= " ), 0)"; $sql .= " ) OR "; $sql .= " c.jyougen = 0"; $sql .= " ) AND"; $sql .= " EXISTS ("; $sql .= " SELECT * FROM"; $sql .= " m_company_area ca"; $sql .= " WHERE"; $sql .= " ca.company_no = c.company_no AND"; $sql .= " ca.shikucyouson_no = " . $gc->shikucyouson_no . ")"; $rs = $gc->db->query($sql); while ($rs->eof == false) { //大手=1 地場=2 $company_kbn = $rs->fields["company_kbn"]; $wk["company_no"] = $rs->fields["company_no"]; //$wk["kakuritsu"] = $rs->fields["kakuritsu"]; $wk["kakuritsu"] = 0; if ($rs->fields["chintai_flg"]) { $wk["kakuritsu"] += $rs->fields["chintai_ritu"]; } if ($rs->fields["relocation_flg"]) { $wk["kakuritsu"] += $rs->fields["relocation_ritu"]; } if ($rs->fields["sublease_flg"]) { $wk["kakuritsu"] += $rs->fields["sublease_ritu"]; } if ($company_kbn == 1) { $oote[] = $wk; } else { $jiba[] = $wk; } $rs->move_next(); } $rs->free_result(); for ($i = 0; $i < count($oote); $i++) { for ($j = 0; $j < $oote[$i]["kakuritsu"]; $j++) { $tbl_oote[] = $oote[$i]["company_no"]; } } for ($i = 0; $i < count($jiba); $i++) { for ($j = 0; $j < $jiba[$i]["kakuritsu"]; $j++) { $tbl_jiba[] = $jiba[$i]["company_no"]; } } $jiba_cnt = 1; if (count($oote) < 2) { //大手が2件以下なら地場を増やす $jiba_cnt = 3 - count($oote); } for ($i = 0; $i < $jiba_cnt; $i++) { if (count($tbl_jiba) > 0) { $id = mt_rand(0, count($tbl_jiba) - 1); $company_no = $tbl_jiba[$id]; $tblwk["company_kbn"] = 2; $tblwk["company_no"] = $company_no; $tbl[] = $tblwk; $tbl_jiba = arr_sakujyo($tbl_jiba, $company_no); } } //残りを大手にする $oote_cnt = 3 - count($tbl); for ($i = 0; $i < $oote_cnt; $i++) { if (count($tbl_oote) > 0) { $id = mt_rand(0, count($tbl_oote) - 1); $company_no = $tbl_oote[$id]; $tblwk["company_kbn"] = 1; $tblwk["company_no"] = $company_no; $tbl[] = $tblwk; $tbl_oote = arr_sakujyo($tbl_oote, $company_no); } } //大手を先にする設定 for ($i = 0; $i < count($tbl); $i++) { if ($tbl[$i]["company_kbn"] == 1) { $arr_company[] = $tbl[$i]["company_no"]; } } for ($i = 0; $i < count($tbl); $i++) { if ($tbl[$i]["company_kbn"] == 2) { $arr_company[] = $tbl[$i]["company_no"]; } } $gc->arr_company = $arr_company; }
function arr_company($gc, $company, $cnt ,$kubuNm){ for ($i = 0; $i < count($company); $i++) { for ($j = 0; $j < $company[$i]["kakuritsu"]; $j++) { $tbl_com[] = $company[$i]["company_no"]; } } $kubu = $gc->arr_company_kbn; $tbl = $gc->arr_company; for ($i = 0; $i < $cnt; $i++) { if(count($tbl_com) > 0){ $id = mt_rand(0, (count($tbl_com) - 1)); $company_no = $tbl_com[$id]; $tbl[] = $company_no; $kubu[$company_no] = $kubuNm; $tbl_com = arr_sakujyo($tbl_com, $company_no); } } $gc->arr_company_kbn = $kubu; $gc->arr_company = $tbl; // print_r($gc->arr_company_kbn); // echo "//"; // print_r($gc->arr_company); // echo "---->"; }
function arr_company($company, $cnt ,$kubuNm){ for ($i = 0; $i < count($company); $i++) { for ($j = 0; $j < $company[$i]["kakuritsu"]; $j++) { $tbl_com[] = $company[$i]["company_no"]; } } $companies = array(); for ($i = 0; $i < $cnt; $i++) { if(count($tbl_com) > 0){ $id = mt_rand(0, (count($tbl_com) - 1)); $company_no = $tbl_com[$id]; $companies[$company_no] = $kubuNm; $tbl_com = arr_sakujyo($tbl_com, $company_no); } } return $companies; }