function importResource($filePath, $order, $tableName, $tableStructure, $dialListField, $date, $groupid, $resellerid) { global $db, $config; $arrData = getSourceData($filePath); if ($config['synchronize']['id_autocrement_byset']) { $local_lastid = astercrm::getLocalLastId($tableName); if (empty($local_lastid)) { $local_lastid = $config['local_host']['minId']; } } $tableAffectRows = 0; foreach ($arrData as $arrRow) { if ($config['synchronize']['id_autocrement_byset']) { $local_lastid++; array_unshift($arrRow, $local_lastid); } $arrRes = parseRowToSql($arrRow, $order, $dialListField, $tableStructure, $tableName, $date, $groupid, $resellerid); $strSql = $arrRes['strSql']; //得到插入选择表的sql语句 if ($tableName != '' && $strSql != '') { $res = $db->query($strSql); $tableAffectRows += $db->affectedRows(); //得到影响的数据条数 } } return $tableAffectRows; }
function importResource($filePath, $order, $tableName, $tableStructure, $dialListField, $dialListTime, $date, $groupid, $dialTimeInput, $assignNum, $arryAssign, $campaignid) { global $db; $arrData = getSourceData($filePath); $x = 0; $diallistAffectRows = 0; $tableAffectRows = 0; $query = ""; $assgignKey = 0; foreach ($arrData as $arrRow) { if ($tableName == 'diallist') { if (trim($arrRow[$dialListField]) == '') { continue; } if ($assignNum > 0) { while ($arryAssign[$assgignKey] == '') { if ($assgignKey > $assignNum) { $assgignKey = 0; } else { $assgignKey++; } } } } $arrRes = parseRowToSql($arrRow, $order, $dialListField, $dialListTime, $tableStructure, $tableName, $date, $groupid, $assignNum, $arryAssign, $campaignid, $assgignKey); $strSql = $arrRes['strSql']; //得到插入选择表的sql语句 $dialListNum = $arrRes['dialListNum']; //以及要导入diallist的sql语句 $dialListTime = $arrRes['dialListTime']; if ($dialTimeInput != '') { $dialtime = $dialTimeInput; } elseif ($dialListTime != '') { $dialtime = $dialListTime; } else { $dialtime = ''; } if ($tableName != '' && $strSql != '') { $res = @$db->query($strSql); //插入customer或contact表 $tableAffectRows += $db->affectedRows(); //得到影响的数据条数 } if (trim($dialListNum) != "" && $tableName != 'diallist') { if (isset($dialListField) && trim($dialListField) != '' && $assignNum > 0) { //是否存在添加到拨号列表 while ($arryAssign[$x] == '') { if ($x >= $assignNum) { $x = 0; } else { $x++; } } $query = "INSERT INTO diallist SET dialnumber = '{$dialListNum}', dialtime = '{$dialtime}', assign='" . $arryAssign[$x] . "', groupid='{$groupid}',campaignid='{$campaignid}', cretime= now(), creby = '" . $_SESSION['curuser']['username'] . "' "; $x++; } else { if (isset($dialListField) && trim($dialListField) != '' && $assignNum == 0) { $query = "INSERT INTO diallist SET dialnumber = '{$dialListNum}', dialtime = '{$dialtime}', groupid='{$groupid}',campaignid='{$campaignid}', cretime= now(), creby = '" . $_SESSION['curuser']['username'] . "' "; } } if ($query != '') { // 查询该号码是否属于某customer $myquery = "SELECT id FROM customer WHERE phone = '{$dialListNum}' OR fax = '{$dialListNum}' OR mobile ='{$dialListNum}' LIMIT 0,1"; $customerid = $db->getOne($myquery); if ($customerid > 0) { $query = "{$query}, customerid = '{$customerid}' "; } $tmpRs = $db->query($query); // 插入diallist表 $diallistAffectRows += $db->affectedRows(); } } $assgignKey++; } $affectRows['diallist'] = $diallistAffectRows; $affectRows['table'] = $tableAffectRows; return $affectRows; }